ignoreCancelled events.

This commit is contained in:
KHobbits 2012-09-19 21:07:50 +01:00
parent 2a8e44dda8
commit 44d8c85450
4 changed files with 25 additions and 69 deletions

View File

@ -235,7 +235,7 @@ public class EssentialsAntiBuildListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onCraftItemEvent(final CraftItemEvent event) public void onCraftItemEvent(final CraftItemEvent event)
{ {
HumanEntity entity = event.getWhoClicked(); HumanEntity entity = event.getWhoClicked();
@ -256,14 +256,14 @@ public class EssentialsAntiBuildListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) public void onPlayerPickupItem(PlayerPickupItemEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
final ItemStack item = event.getItem().getItemStack(); final ItemStack item = event.getItem().getItemStack();
if (!metaPermCheck(user, "craft", item.getTypeId(), item.getData().getData())) if (!metaPermCheck(user, "pickup", item.getTypeId(), item.getData().getData()))
{ {
event.setCancelled(true); event.setCancelled(true);
event.getItem().setPickupDelay(50); event.getItem().setPickupDelay(50);
@ -271,7 +271,7 @@ public class EssentialsAntiBuildListener implements Listener
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event)
{ {

View File

@ -25,14 +25,9 @@ public class EssentialsProtectBlockListener implements Listener
this.ess = prot.getEssentialsConnect().getEssentials(); this.ess = prot.getEssentialsConnect().getEssentials();
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event) public void onBlockPlace(final BlockPlaceEvent event)
{ {
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
final Block blockPlaced = event.getBlockPlaced(); final Block blockPlaced = event.getBlockPlaced();
@ -79,13 +74,9 @@ public class EssentialsProtectBlockListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) public void onBlockIgnite(BlockIgniteEvent event)
{ {
if (event.isCancelled())
{
return;
}
final Block block = event.getBlock(); final Block block = event.getBlock();
if ((block.getType() == Material.RAILS || block.getType() == Material.POWERED_RAIL || block.getType() == Material.DETECTOR_RAIL) if ((block.getType() == Material.RAILS || block.getType() == Material.POWERED_RAIL || block.getType() == Material.DETECTOR_RAIL)
&& prot.getSettingBool(ProtectConfig.protect_rails)) && prot.getSettingBool(ProtectConfig.protect_rails))
@ -130,13 +121,9 @@ public class EssentialsProtectBlockListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockFromTo(final BlockFromToEvent event) public void onBlockFromTo(final BlockFromToEvent event)
{ {
if (event.isCancelled())
{
return;
}
final Block toBlock = event.getToBlock(); final Block toBlock = event.getToBlock();
if ((toBlock.getType() == Material.RAILS || toBlock.getType() == Material.POWERED_RAIL || toBlock.getType() == Material.DETECTOR_RAIL) if ((toBlock.getType() == Material.RAILS || toBlock.getType() == Material.POWERED_RAIL || toBlock.getType() == Material.DETECTOR_RAIL)
&& prot.getSettingBool(ProtectConfig.protect_rails)) && prot.getSettingBool(ProtectConfig.protect_rails))
@ -171,13 +158,9 @@ public class EssentialsProtectBlockListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(final BlockBurnEvent event) public void onBlockBurn(final BlockBurnEvent event)
{ {
if (event.isCancelled())
{
return;
}
final Block block = event.getBlock(); final Block block = event.getBlock();
if ((block.getType() == Material.RAILS || block.getType() == Material.POWERED_RAIL || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails)) if ((block.getType() == Material.RAILS || block.getType() == Material.POWERED_RAIL || block.getType() == Material.DETECTOR_RAIL) && prot.getSettingBool(ProtectConfig.protect_rails))
{ {
@ -207,13 +190,9 @@ public class EssentialsProtectBlockListener implements Listener
BlockFace.SELF BlockFace.SELF
}; };
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event) public void onBlockBreak(final BlockBreakEvent event)
{ {
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
final Block block = event.getBlock(); final Block block = event.getBlock();
@ -290,13 +269,9 @@ public class EssentialsProtectBlockListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) public void onBlockPistonExtend(BlockPistonExtendEvent event)
{ {
if (event.isCancelled())
{
return;
}
for (Block block : event.getBlocks()) for (Block block : event.getBlocks())
{ {
if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS
@ -338,10 +313,10 @@ public class EssentialsProtectBlockListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) public void onBlockPistonRetract(BlockPistonRetractEvent event)
{ {
if (event.isCancelled() || !event.isSticky()) if (!event.isSticky())
{ {
return; return;
} }

View File

@ -26,13 +26,9 @@ public class EssentialsProtectEntityListener implements Listener
this.ess = prot.getEssentialsConnect().getEssentials(); this.ess = prot.getEssentialsConnect().getEssentials();
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) public void onEntityDamage(final EntityDamageEvent event)
{ {
if (event.isCancelled())
{
return;
}
final Entity target = event.getEntity(); final Entity target = event.getEntity();
if (target instanceof Villager && prot.getSettingBool(ProtectConfig.prevent_villager_death)) if (target instanceof Villager && prot.getSettingBool(ProtectConfig.prevent_villager_death))
@ -191,10 +187,10 @@ public class EssentialsProtectEntityListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityExplode(final EntityExplodeEvent event) public void onEntityExplode(final EntityExplodeEvent event)
{ {
if (event.isCancelled() || event.getEntity() == null) if (event.getEntity() == null)
{ {
return; return;
} }
@ -263,17 +259,13 @@ public class EssentialsProtectEntityListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCreatureSpawn(final CreatureSpawnEvent event) public void onCreatureSpawn(final CreatureSpawnEvent event)
{ {
if (event.getEntity() instanceof Player) if (event.getEntity() instanceof Player)
{ {
return; return;
} }
if (event.isCancelled())
{
return;
}
final EntityType creature = event.getEntityType(); final EntityType creature = event.getEntityType();
if (creature == null) if (creature == null)
{ {
@ -290,13 +282,9 @@ public class EssentialsProtectEntityListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(final EntityTargetEvent event) public void onEntityTarget(final EntityTargetEvent event)
{ {
if (event.isCancelled())
{
return;
}
if (!(event.getTarget() instanceof Player)) if (!(event.getTarget() instanceof Player))
{ {
return; return;
@ -316,7 +304,7 @@ public class EssentialsProtectEntityListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) public void onExplosionPrime(ExplosionPrimeEvent event)
{ {
if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball) if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
@ -326,13 +314,9 @@ public class EssentialsProtectEntityListener implements Listener
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) public void onEntityChangeBlock(EntityChangeBlockEvent event)
{ {
if (event.isCancelled())
{
return;
}
if (event.getEntityType() == EntityType.ENDERMAN && prot.getSettingBool(ProtectConfig.prevent_enderman_pickup)) if (event.getEntityType() == EntityType.ENDERMAN && prot.getSettingBool(ProtectConfig.prevent_enderman_pickup))
{ {
event.setCancelled(true); event.setCancelled(true);

View File

@ -17,11 +17,10 @@ public class EssentialsProtectWeatherListener implements Listener
this.prot = prot; this.prot = prot;
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWeatherChange(final WeatherChangeEvent event) public void onWeatherChange(final WeatherChangeEvent event)
{ {
if (!event.isCancelled() if (prot.getSettingBool(ProtectConfig.disable_weather_storm)
&& prot.getSettingBool(ProtectConfig.disable_weather_storm)
&& event.toWeatherState()) && event.toWeatherState())
{ {
event.setCancelled(true); event.setCancelled(true);
@ -29,21 +28,19 @@ public class EssentialsProtectWeatherListener implements Listener
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onLightningStrike(final LightningStrikeEvent event) public void onLightningStrike(final LightningStrikeEvent event)
{ {
if (!event.isCancelled() if (prot.getSettingBool(ProtectConfig.disable_weather_lightning))
&& prot.getSettingBool(ProtectConfig.disable_weather_lightning))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onThunderChange(final ThunderChangeEvent event) public void onThunderChange(final ThunderChangeEvent event)
{ {
if (!event.isCancelled() if (prot.getSettingBool(ProtectConfig.disable_weather_thunder)
&& prot.getSettingBool(ProtectConfig.disable_weather_thunder)
&& event.toThunderState()) && event.toThunderState())
{ {
event.setCancelled(true); event.setCancelled(true);