Fixed code smells

This commit is contained in:
Florian CUNY 2019-02-14 10:41:39 +01:00
parent 6b0b0237cd
commit 1a3049b3b9
2 changed files with 9 additions and 12 deletions

View File

@ -19,11 +19,10 @@ public class ExperiencePickupListener extends FlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onExperienceOrbTargetPlayer(EntityTargetLivingEntityEvent e) {
// Make sure the target is a Player and the entity is an experience orb
if (e.getTarget() instanceof Player && e.getEntity() instanceof ExperienceOrb) {
if (!checkIsland(e, (Player) e.getTarget(), e.getEntity().getLocation(), Flags.EXPERIENCE_PICKUP)) {
// Canceling the event won't be enough, we need to explicitly set the target to null
if (e.getTarget() instanceof Player && e.getEntity() instanceof ExperienceOrb
&& !checkIsland(e, (Player) e.getTarget(), e.getEntity().getLocation(), Flags.EXPERIENCE_PICKUP)) {
// Cancelling the event won't work, we need to explicitly set the target to null
e.setTarget(null);
}
}
}
}

View File

@ -35,15 +35,14 @@ public class TNTListener extends FlagListener {
if (e.getEntity() instanceof Projectile) {
Projectile projectile = (Projectile) e.getEntity();
// Find out who fired it
if (projectile.getShooter() instanceof Player && projectile.getFireTicks() > 0) {
if (!checkIsland(e, (Player)projectile.getShooter(), e.getBlock().getLocation(), Flags.BREAK_BLOCKS)) {
if (projectile.getShooter() instanceof Player && projectile.getFireTicks() > 0
&& !checkIsland(e, (Player)projectile.getShooter(), e.getBlock().getLocation(), Flags.BREAK_BLOCKS)) {
// Remove the arrow
projectile.remove();
e.setCancelled(true);
}
}
}
}
/**
@ -73,5 +72,4 @@ public class TNTListener extends FlagListener {
e.setCancelled(true);
}
}
}