Cleanup unnecessary in-house Cancellable#isCancelled checks.
Use the ignoreCancelled EventHandler annotation parameter instead.
This commit is contained in:
parent
1daf79c6c3
commit
c7d9e6b92c
@ -22,11 +22,8 @@ public class FactionsBlockListener implements Listener {
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (!event.canBuild()) {
|
||||
return;
|
||||
}
|
||||
@ -41,33 +38,22 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (!Conf.pistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
@ -90,10 +76,10 @@ public class FactionsBlockListener implements Listener {
|
||||
*/
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
// if not a sticky piston, retraction should be fine
|
||||
if (event.isCancelled() || !event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) {
|
||||
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,8 @@ public class FactionsChatListener implements Listener {
|
||||
}
|
||||
|
||||
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player talkingPlayer = event.getPlayer();
|
||||
String msg = event.getMessage();
|
||||
FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer);
|
||||
@ -101,12 +97,8 @@ public class FactionsChatListener implements Listener {
|
||||
}
|
||||
|
||||
// this is for handling insertion of the player's faction tag, set at highest priority to give other plugins a chance to modify chat first
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Are we to insert the Faction tag into the format?
|
||||
// If we are not to insert it - we are done.
|
||||
if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) {
|
||||
|
@ -89,12 +89,8 @@ public class FactionsEntityListener implements Listener {
|
||||
* Who can I hurt? I can never hurt members or allies. I can always hurt enemies. I can hurt neutrals as long as
|
||||
* they are outside their own territory.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||
@ -106,12 +102,8 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = event.getLocation();
|
||||
Entity boomer = event.getEntity();
|
||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(loc));
|
||||
@ -171,12 +163,8 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
// mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0);
|
||||
if (!this.canDamagerHurtDamagee(sub, false)) {
|
||||
event.setCancelled(true);
|
||||
@ -186,12 +174,8 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<PotionEffectType>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER));
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPotionSplashEvent(PotionSplashEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// see if the potion has a harmful effect
|
||||
boolean badjuju = false;
|
||||
for (PotionEffect effect : event.getPotion().getEffects()) {
|
||||
@ -411,9 +395,9 @@ public class FactionsEntityListener implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (event.isCancelled() || event.getLocation() == null) {
|
||||
if (event.getLocation() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -422,12 +406,8 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if there is a target
|
||||
Entity target = event.getTarget();
|
||||
if (target == null) {
|
||||
@ -445,11 +425,8 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPaintingBreak(HangingBreakEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() == RemoveCause.EXPLOSION) {
|
||||
Location loc = event.getEntity().getLocation();
|
||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(loc));
|
||||
@ -484,23 +461,15 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPaintingPlace(HangingPlaceEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
// for now, only interested in Enderman and Wither boss tomfoolery
|
||||
|
@ -13,9 +13,9 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
public class FactionsExploitListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void obsidianGenerator(BlockFromToEvent event) {
|
||||
if (event.isCancelled() || !Conf.handleExploitObsidianGenerators) {
|
||||
if (!Conf.handleExploitObsidianGenerators) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -29,9 +29,9 @@ public class FactionsExploitListener implements Listener {
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void enderPearlTeleport(PlayerTeleportEvent event) {
|
||||
if (event.isCancelled() || !Conf.handleExploitEnderPearlClipping) {
|
||||
if (!Conf.handleExploitEnderPearlClipping) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
|
||||
|
@ -113,12 +113,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
// Holds the next time a player can have a map shown.
|
||||
private HashMap<UUID, Long> showTimes = new HashMap<UUID, Long>();
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// clear visualization
|
||||
if (event.getFrom().getBlockX() != event.getTo().getBlockX() || event.getFrom().getBlockY() != event.getTo().getBlockY() || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
||||
VisualizeUtil.clear(event.getPlayer());
|
||||
@ -202,11 +198,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// only need to check right-clicks and physical as of MC 1.4+; good performance boost
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
|
||||
return;
|
||||
@ -442,12 +435,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
// For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected),
|
||||
// but these separate bucket events below always fire without fail
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlockClicked();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -457,12 +446,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlockClicked();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -542,12 +527,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FPlayer badGuy = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (badGuy == null) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user