Add main listener and move the first listener content into it.
This commit is contained in:
parent
fc64136380
commit
75ec92fb7d
@ -20,7 +20,6 @@ import com.massivecraft.factions.listeners.FactionsBlockListener;
|
|||||||
import com.massivecraft.factions.listeners.FactionsChatListener;
|
import com.massivecraft.factions.listeners.FactionsChatListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsEntityListener;
|
import com.massivecraft.factions.listeners.FactionsEntityListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsExploitListener;
|
import com.massivecraft.factions.listeners.FactionsExploitListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsAppearanceListener;
|
|
||||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsServerListener;
|
import com.massivecraft.factions.listeners.FactionsServerListener;
|
||||||
import com.massivecraft.factions.util.AutoLeaveTask;
|
import com.massivecraft.factions.util.AutoLeaveTask;
|
||||||
@ -55,7 +54,6 @@ public class Factions extends MPlugin
|
|||||||
public FactionsExploitListener exploitListener;
|
public FactionsExploitListener exploitListener;
|
||||||
public FactionsBlockListener blockListener;
|
public FactionsBlockListener blockListener;
|
||||||
public FactionsServerListener serverListener;
|
public FactionsServerListener serverListener;
|
||||||
public FactionsAppearanceListener appearanceListener;
|
|
||||||
|
|
||||||
// Persistance related
|
// Persistance related
|
||||||
private boolean locked = false;
|
private boolean locked = false;
|
||||||
@ -109,6 +107,8 @@ public class Factions extends MPlugin
|
|||||||
startEconLandRewardTask(false);
|
startEconLandRewardTask(false);
|
||||||
|
|
||||||
// Register Event Handlers
|
// Register Event Handlers
|
||||||
|
MainListener.get().setup();
|
||||||
|
|
||||||
this.playerListener = new FactionsPlayerListener(this);
|
this.playerListener = new FactionsPlayerListener(this);
|
||||||
getServer().getPluginManager().registerEvents(this.playerListener, this);
|
getServer().getPluginManager().registerEvents(this.playerListener, this);
|
||||||
|
|
||||||
@ -127,9 +127,6 @@ public class Factions extends MPlugin
|
|||||||
this.serverListener = new FactionsServerListener(this);
|
this.serverListener = new FactionsServerListener(this);
|
||||||
getServer().getPluginManager().registerEvents(this.serverListener, this);
|
getServer().getPluginManager().registerEvents(this.serverListener, this);
|
||||||
|
|
||||||
this.appearanceListener = new FactionsAppearanceListener(this);
|
|
||||||
getServer().getPluginManager().registerEvents(this.appearanceListener, this);
|
|
||||||
|
|
||||||
postEnable();
|
postEnable();
|
||||||
this.loadSuccessful = true;
|
this.loadSuccessful = true;
|
||||||
}
|
}
|
||||||
|
@ -1,88 +1,97 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import com.massivecraft.factions.ConfServer;
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
|
public class MainListener implements Listener
|
||||||
|
{
|
||||||
public class FactionsAppearanceListener implements Listener
|
// -------------------------------------------- //
|
||||||
{
|
// INSTANCE & CONSTRUCT
|
||||||
public Factions p;
|
// -------------------------------------------- //
|
||||||
public FactionsAppearanceListener(Factions p)
|
|
||||||
{
|
private static MainListener i = new MainListener();
|
||||||
this.p = p;
|
public static MainListener get() { return i; }
|
||||||
}
|
public MainListener() {}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// FULL TWO-WAYS
|
// SETUP
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void fullTwoWay(Player player)
|
public void setup()
|
||||||
{
|
{
|
||||||
SpoutFeatures.updateTitleShortly(player, null);
|
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
||||||
SpoutFeatures.updateTitleShortly(null, player);
|
}
|
||||||
SpoutFeatures.updateCapeShortly(player, null);
|
|
||||||
SpoutFeatures.updateCapeShortly(null, player);
|
// -------------------------------------------- //
|
||||||
}
|
// SPOUT
|
||||||
|
// -------------------------------------------- //
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
// Standard
|
||||||
{
|
|
||||||
fullTwoWay(event.getPlayer());
|
public static void spoutStandard(Player player)
|
||||||
}
|
{
|
||||||
|
SpoutFeatures.updateTitleShortly(player, null);
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
SpoutFeatures.updateTitleShortly(null, player);
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
SpoutFeatures.updateCapeShortly(player, null);
|
||||||
{
|
SpoutFeatures.updateCapeShortly(null, player);
|
||||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) return;
|
}
|
||||||
fullTwoWay(event.getPlayer());
|
|
||||||
}
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void spoutStandard(PlayerJoinEvent event)
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
{
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
spoutStandard(event.getPlayer());
|
||||||
{
|
}
|
||||||
fullTwoWay(event.getPlayer());
|
|
||||||
}
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void spoutStandard(PlayerTeleportEvent event)
|
||||||
// -------------------------------------------- //
|
{
|
||||||
// HEALTH BAR
|
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) return;
|
||||||
// -------------------------------------------- //
|
spoutStandard(event.getPlayer());
|
||||||
|
}
|
||||||
public static void possiblyUpdateHealthBar(Entity entity)
|
|
||||||
{
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
if ( ! ConfServer.spoutHealthBarUnderNames) return;
|
public void spoutStandard(PlayerRespawnEvent event)
|
||||||
if ( ! (entity instanceof Player)) return;
|
{
|
||||||
Player player = (Player)entity;
|
spoutStandard(event.getPlayer());
|
||||||
SpoutFeatures.updateTitle(player, null);
|
}
|
||||||
}
|
|
||||||
|
// Health Bar
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void monitorEntityDamageEvent(EntityDamageEvent event)
|
public static void spoutHealthBar(Entity entity)
|
||||||
{
|
{
|
||||||
possiblyUpdateHealthBar(event.getEntity());
|
if ( ! ConfServer.spoutHealthBarUnderNames) return;
|
||||||
}
|
if ( ! (entity instanceof Player)) return;
|
||||||
|
Player player = (Player)entity;
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
SpoutFeatures.updateTitle(player, null);
|
||||||
public void monitorEntityRegainHealthEvent(EntityRegainHealthEvent event)
|
}
|
||||||
{
|
|
||||||
possiblyUpdateHealthBar(event.getEntity());
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
}
|
public void spoutHealthBar(EntityDamageEvent event)
|
||||||
|
{
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
spoutHealthBar(event.getEntity());
|
||||||
public void monitorPlayerRespawnEvent(PlayerRespawnEvent event)
|
}
|
||||||
{
|
|
||||||
possiblyUpdateHealthBar(event.getPlayer());
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
}
|
public void spoutHealthBar(EntityRegainHealthEvent event)
|
||||||
|
{
|
||||||
}
|
spoutHealthBar(event.getEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void spoutHealthBar(PlayerRespawnEvent event)
|
||||||
|
{
|
||||||
|
spoutHealthBar(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -89,10 +89,11 @@ public class FactionsEntityListener implements Listener
|
|||||||
Bukkit.getPluginManager().callEvent(powerLossEvent);
|
Bukkit.getPluginManager().callEvent(powerLossEvent);
|
||||||
|
|
||||||
// Call player onDeath if the event is not cancelled
|
// Call player onDeath if the event is not cancelled
|
||||||
if(!powerLossEvent.isCancelled())
|
if ( ! powerLossEvent.isCancelled())
|
||||||
{
|
{
|
||||||
fplayer.onDeath();
|
fplayer.onDeath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the message from the powerLossEvent
|
// Send the message from the powerLossEvent
|
||||||
final String msg = powerLossEvent.getMessage();
|
final String msg = powerLossEvent.getMessage();
|
||||||
if (msg != null && !msg.isEmpty())
|
if (msg != null && !msg.isEmpty())
|
||||||
|
Loading…
Reference in New Issue
Block a user