Fix TNTListener tests

This commit is contained in:
tastybento 2022-01-22 11:57:11 -08:00
parent 823bc5ceed
commit 5573e9f329

View File

@ -43,10 +43,13 @@ public class TNTListener extends FlagListener {
* @param e - event * @param e - event
*/ */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTNTDamage(EntityChangeBlockEvent e) { public void onTNTDamageEvent(EntityChangeBlockEvent e) {
onTNTDamage(e);
}
boolean onTNTDamage(EntityChangeBlockEvent e) {
// Check world // Check world
if (!e.getBlock().getType().equals(Material.TNT) || !getIWM().inWorld(e.getBlock().getLocation())) { if (!e.getBlock().getType().equals(Material.TNT) || !getIWM().inWorld(e.getBlock().getLocation())) {
return; return false;
} }
// Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow // Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow
if (e.getEntity() instanceof Projectile projectile) { if (e.getEntity() instanceof Projectile projectile) {
@ -56,9 +59,10 @@ public class TNTListener extends FlagListener {
// Remove the arrow // Remove the arrow
projectile.remove(); projectile.remove();
e.setCancelled(true); e.setCancelled(true);
return; return true;
} }
} }
return false;
} }
/** /**