Listener Cleanup

This commit is contained in:
KHobbits 2012-04-02 02:22:07 +01:00
parent d72f831519
commit 0e0a96b6d8
5 changed files with 27 additions and 21 deletions

View file

@ -20,14 +20,14 @@ public class EssentialsBlockListener implements Listener
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
final User user = ess.getUser(event.getPlayer());
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
// http://leaky.bukkit.org/issues/663
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
if (is == null)
{
return;
}
final User user = ess.getUser(event.getPlayer());
final boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{

View file

@ -383,6 +383,7 @@ public class Settings implements ISettings
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = _getEnabledSigns();
teleportInvulnerability = _isTeleportInvulnerability();
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
itemSpawnBl = _getItemSpawnBlacklist();
kits = _getKits();
chatFormats.clear();
@ -695,9 +696,15 @@ public class Settings implements ISettings
{
return config.getBoolean("register-back-in-listener", false);
}
private boolean disableItemPickupWhileAfk;
@Override
public boolean getDisableItemPickupWhileAfk()
{
return disableItemPickupWhileAfk;
}
private boolean _getDisableItemPickupWhileAfk()
{
return config.getBoolean("disable-item-pickup-while-afk", true);
}
@ -746,7 +753,6 @@ public class Settings implements ISettings
{
this.metricsEnabled = metricsEnabled;
}
private boolean teleportInvulnerability;
@Override
@ -754,12 +760,12 @@ public class Settings implements ISettings
{
return config.getLong("teleport-invulnerability", 0) * 1000;
}
private boolean _isTeleportInvulnerability()
{
return (config.getLong("teleport-invulnerability", 0) > 0);
}
@Override
public boolean isTeleportInvulnerability()
{

View file

@ -25,10 +25,10 @@ public class SignBlockListener implements Listener
this.ess = ess;
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}
@ -76,10 +76,10 @@ public class SignBlockListener implements Listener
return false;
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSignChange(final SignChangeEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}
@ -107,10 +107,10 @@ public class SignBlockListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}
@ -141,10 +141,10 @@ public class SignBlockListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBurn(final BlockBurnEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}
@ -169,10 +169,10 @@ public class SignBlockListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockIgnite(final BlockIgniteEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}

View file

@ -43,10 +43,10 @@ public class SignEntityListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}

View file

@ -20,10 +20,10 @@ public class SignPlayerListener implements Listener
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
if (ess.getSettings().areSignsDisabled())
{
return;
}
@ -33,8 +33,8 @@ public class SignPlayerListener implements Listener
{
return;
}
final int mat = block.getTypeId();
if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId())
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
{
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{