Return void for event listeners

https://github.com/BentoBoxWorld/BentoBox/issues/1918
This commit is contained in:
tastybento 2022-01-21 18:47:31 -08:00
parent 5ab89ac63d
commit f25e54f3c8
4 changed files with 21 additions and 18 deletions

View File

@ -48,8 +48,8 @@ public class FireListener extends FlagListener {
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public boolean onBlockBurn(BlockBurnEvent e) {
return checkFire(e, e.getBlock().getLocation(), Flags.FIRE_BURNING);
public void onBlockBurn(BlockBurnEvent e) {
checkFire(e, e.getBlock().getLocation(), Flags.FIRE_BURNING);
}
/**
@ -57,8 +57,10 @@ public class FireListener extends FlagListener {
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public boolean onBlockSpread(BlockSpreadEvent e) {
return e.getSource().getType().equals(Material.FIRE) && checkFire(e, e.getBlock().getLocation(), Flags.FIRE_SPREAD);
public void onBlockSpread(BlockSpreadEvent e) {
if (e.getSource().getType().equals(Material.FIRE)) {
checkFire(e, e.getBlock().getLocation(), Flags.FIRE_SPREAD);
}
}
/**
@ -66,9 +68,11 @@ public class FireListener extends FlagListener {
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public boolean onBlockIgnite(BlockIgniteEvent e) {
public void onBlockIgnite(BlockIgniteEvent e) {
// Check if this is a portal lighting - that is allowed any time
return !e.getBlock().getType().equals(Material.OBSIDIAN) && checkFire(e, e.getBlock().getLocation(), Flags.FIRE_IGNITE);
if (!e.getBlock().getType().equals(Material.OBSIDIAN)) {
checkFire(e, e.getBlock().getLocation(), Flags.FIRE_IGNITE);
}
}
/**

View File

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

View File

@ -28,10 +28,10 @@ public class MobSpawnListener extends FlagListener {
* @return true if cancelled
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public boolean onMobSpawn(CreatureSpawnEvent e) {
public void onMobSpawn(CreatureSpawnEvent e) {
// If not in the right world, or spawning is not natural return
if (!getIWM().inWorld(e.getEntity().getLocation())) {
return false;
return;
}
switch (e.getSpawnReason()) {
// Natural
@ -53,14 +53,14 @@ public class MobSpawnListener extends FlagListener {
case VILLAGE_INVASION:
boolean cancelNatural = shouldCancel(e.getEntity(), e.getLocation(), Flags.ANIMAL_NATURAL_SPAWN, Flags.MONSTER_NATURAL_SPAWN);
e.setCancelled(cancelNatural);
return cancelNatural;
return;
// Spawners
case SPAWNER:
boolean cancelSpawners = shouldCancel(e.getEntity(), e.getLocation(), Flags.ANIMAL_SPAWNERS_SPAWN, Flags.MONSTER_SPAWNERS_SPAWN);
e.setCancelled(cancelSpawners);
return cancelSpawners;
return;
default:
return false;
return;
}
}

View File

@ -36,7 +36,7 @@ public class ObsidianScoopingListener extends FlagListener {
* @return false if obsidian not scooped, true if scooped
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public boolean onPlayerInteract(final PlayerInteractEvent e) {
public void onPlayerInteract(final PlayerInteractEvent e) {
if (!getIWM().inWorld(e.getPlayer().getLocation())
|| !Flags.OBSIDIAN_SCOOPING.isSetForWorld(e.getPlayer().getWorld())
|| !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)
@ -44,9 +44,9 @@ public class ObsidianScoopingListener extends FlagListener {
|| !(e.getItem() != null && e.getItem().getType().equals(Material.BUCKET))
|| !(e.getClickedBlock() != null && e.getClickedBlock().getType().equals(Material.OBSIDIAN))
|| e.getClickedBlock().getRelative(e.getBlockFace()).getType().equals(Material.WATER)) {
return false;
return;
}
return lookForLava(e);
lookForLava(e);
}
private boolean lookForLava(PlayerInteractEvent e) {