mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-26 19:17:40 +01:00
Fixed code smells
This commit is contained in:
parent
6b0b0237cd
commit
1a3049b3b9
@ -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
|
||||
e.setTarget(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,11 @@ 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)) {
|
||||
// Remove the arrow
|
||||
projectile.remove();
|
||||
e.setCancelled(true);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user