From 15f97927ded588979e81663b654235e4dd525547 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 3 Mar 2019 19:23:15 -0800 Subject: [PATCH] Fixes range resetting if player does not have a range permission. If a player's island range is set using the range set admin command, the range was being reset when the player logged in if they had no range permission. https://github.com/BentoBoxWorld/BentoBox/issues/484 --- .../bentobox/listeners/JoinLeaveListener.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index e388db3da..c7d2585b2 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -154,18 +154,18 @@ public class JoinLeaveListener implements Listener { .filter(world -> plugin.getIslands().isOwner(world, user.getUniqueId())) .forEach(world -> { Island island = plugin.getIslands().getIsland(world, user); + if (island != null) { + // Check if new owner has a different range permission than the island size + int range = user.getPermissionValue(plugin.getIWM().getAddon(island.getWorld()).get().getPermissionPrefix() + "island.range", island.getProtectionRange()); - // Check if new owner has a different range permission than the island size - int range = user.getPermissionValue(plugin.getIWM().getAddon(island.getWorld()).get().getPermissionPrefix() + "island.range", plugin.getIWM().getIslandProtectionRange(Util.getWorld(island.getWorld()))); - - // Range can go up or down - if (range != island.getProtectionRange()) { - user.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range)); - plugin.log("Island protection range changed from " + island.getProtectionRange() + " to " - + range + " for " + user.getName() + " due to permission."); + // Range can go up or down + if (range != island.getProtectionRange()) { + user.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range)); + plugin.log("Island protection range changed from " + island.getProtectionRange() + " to " + + range + " for " + user.getName() + " due to permission."); + } + island.setProtectionRange(range); } - - island.setProtectionRange(range); }); }