diff options
4 files changed, 34 insertions, 16 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 69b4b0d48..30a073dde 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import org.bukkit.ChatColor; -import org.bukkit.event.Event.Priority; +import org.bukkit.event.EventPriority; public interface ISettings extends IConf @@ -151,7 +151,7 @@ public interface ISettings extends IConf boolean getDisableItemPickupWhileAfk(); - Priority getRespawnPriority(); + EventPriority getRespawnPriority(); long getTpaAcceptCancellation(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index e25683e32..070743bbc 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -8,7 +8,7 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.ChatColor; -import org.bukkit.event.Event.Priority; +import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; @@ -599,30 +599,30 @@ public class Settings implements ISettings } @Override - public Priority getRespawnPriority() + public EventPriority getRespawnPriority() { String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH); if ("lowest".equals(priority)) { - return Priority.Lowest; + return EventPriority.LOWEST; } if ("low".equals(priority)) { - return Priority.Low; + return EventPriority.LOW; } if ("normal".equals(priority)) { - return Priority.Normal; + return EventPriority.NORMAL; } if ("high".equals(priority)) { - return Priority.High; + return EventPriority.HIGH; } if ("highest".equals(priority)) { - return Priority.Highest; + return EventPriority.HIGHEST; } - return Priority.Normal; + return EventPriority.NORMAL; } @Override diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java index 813220a16..565764aa6 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java @@ -8,8 +8,14 @@ import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Type; +import org.bukkit.event.EventException; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -38,8 +44,22 @@ public class EssentialsSpawn extends JavaPlugin ess.addReloadListener(spawns); final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns); - pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, ess.getSettings().getRespawnPriority(), this); - pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, ess.getSettings().getRespawnPriority(), this); + pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() + { + @Override + public void execute(final Listener ll, final Event event) throws EventException + { + ((EssentialsSpawnPlayerListener)ll).onPlayerRespawn((PlayerRespawnEvent)event); + } + }, this); + pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() + { + @Override + public void execute(final Listener ll, final Event event) throws EventException + { + ((EssentialsSpawnPlayerListener)ll).onPlayerJoin((PlayerJoinEvent)event); + } + }, this); LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); } diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 81e8f6e9e..2814714a2 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -7,13 +7,13 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -public class EssentialsSpawnPlayerListener extends PlayerListener +public class EssentialsSpawnPlayerListener implements Listener { private final transient IEssentials ess; private final transient SpawnStorage spawns; @@ -26,7 +26,6 @@ public class EssentialsSpawnPlayerListener extends PlayerListener this.spawns = spawns; } - @Override public void onPlayerRespawn(final PlayerRespawnEvent event) { final User user = ess.getUser(event.getPlayer()); @@ -51,7 +50,6 @@ public class EssentialsSpawnPlayerListener extends PlayerListener } } - @Override public void onPlayerJoin(final PlayerJoinEvent event) { final User user = ess.getUser(event.getPlayer()); |