Update jails to new event system.

This commit is contained in:
KHobbits 2012-01-31 08:06:50 +00:00
parent 8500542e93
commit 2942ef40f3

View File

@ -1,18 +1,24 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.*;
import org.bukkit.event.player.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.plugin.PluginManager;
@ -33,13 +39,8 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener();
pluginManager.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.High, ess);
pluginManager.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, ess);
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.High, ess);
pluginManager.registerEvents(blockListener, ess);
pluginManager.registerEvents(playerListener, ess);
}
@Override
@ -146,9 +147,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
private class JailBlockListener extends BlockListener
private class JailBlockListener implements Listener
{
@Override
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(final BlockBreakEvent event)
{
final User user = ess.getUser(event.getPlayer());
@ -158,7 +159,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(final BlockPlaceEvent event)
{
final User user = ess.getUser(event.getPlayer());
@ -168,7 +169,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.LOW)
public void onBlockDamage(final BlockDamageEvent event)
{
final User user = ess.getUser(event.getPlayer());
@ -180,9 +181,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
private class JailPlayerListener extends PlayerListener
private class JailPlayerListener implements Listener
{
@Override
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(final PlayerInteractEvent event)
{
final User user = ess.getUser(event.getPlayer());
@ -192,7 +193,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
@ -211,7 +212,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
final User user = ess.getUser(event.getPlayer());
@ -231,7 +232,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
user.sendMessage(_("jailMessage"));
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(final PlayerJoinEvent event)
{
final User user = ess.getUser(event.getPlayer());