mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Fixed bugs with NPEs in non-island worlds.
This commit is contained in:
parent
10d5c262ca
commit
aa7fbabf82
@ -8,6 +8,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.configuration.WorldSettings;
|
||||
import us.tastybento.bskyblock.api.localization.TextVariables;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
|
||||
@ -61,10 +62,12 @@ public class Flag implements Comparable<Flag> {
|
||||
/**
|
||||
* Check if a setting is set in this world
|
||||
* @param world - world
|
||||
* @return world setting, or default flag setting if a specific world setting is not set
|
||||
* @return world setting or default flag setting if a specific world setting is not set.
|
||||
* If world is not a game world, then the result will always be false!
|
||||
*/
|
||||
public boolean isSetForWorld(World world) {
|
||||
return BSkyBlock.getInstance().getIWM().getWorldSettings(world).getWorldFlags().getOrDefault(getID(), setting);
|
||||
WorldSettings ws = BSkyBlock.getInstance().getIWM().getWorldSettings(world);
|
||||
return ws != null ? ws.getWorldFlags().getOrDefault(getID(), setting) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ public class JoinLeaveListener implements Listener {
|
||||
} else {
|
||||
plugin.logWarning("Player that just logged in has no name! " + playerUUID.toString());
|
||||
}
|
||||
if (Flags.REMOVE_MOBS.isSetForWorld(user.getWorld())) {
|
||||
if (plugin.getIWM().inWorld(user.getLocation()) && Flags.REMOVE_MOBS.isSetForWorld(user.getWorld())) {
|
||||
RemoveMobsListener.clearArea(user.getLocation());
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ public class EnterExitListener extends AbstractFlagListener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
// Only process if Enter Exit flags are active, we are in the right world and there is a change in X or Z coords
|
||||
if (!Flags.ENTER_EXIT_MESSAGES.isSetForWorld(e.getFrom().getWorld())
|
||||
if (!getIslandWorldManager().inWorld(e.getFrom())
|
||||
|| e.getFrom().toVector().multiply(XZ).equals(e.getTo().toVector().multiply(XZ))
|
||||
|| !getIslandWorldManager().inWorld(e.getFrom())) {
|
||||
|| !Flags.ENTER_EXIT_MESSAGES.isSetForWorld(e.getFrom().getWorld())) {
|
||||
return;
|
||||
}
|
||||
Optional<Island> from = this.getIslands().getProtectedIslandAt(e.getFrom());
|
||||
|
@ -35,7 +35,7 @@ public class RemoveMobsListener extends AbstractFlagListener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onUserTeleport(PlayerTeleportEvent e) {
|
||||
// Only process if flag is active
|
||||
if (Flags.REMOVE_MOBS.isSetForWorld(e.getTo().getWorld()) && getIslands().locationIsOnIsland(e.getPlayer(), e.getTo())) {
|
||||
if (getIslands().locationIsOnIsland(e.getPlayer(), e.getTo()) && Flags.REMOVE_MOBS.isSetForWorld(e.getTo().getWorld())) {
|
||||
clearArea(e.getTo());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user