From 3dd9e973fb91fe75162eb0ef235ffdb1d3ed9768 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 11 Sep 2021 16:50:43 -0700 Subject: [PATCH] Island range perms could be 2x island distance This could allow protection ranges to be much greater than the island range and therefore overflow into adjacent islands. https://github.com/BentoBoxWorld/BentoBox/issues/1851 --- .../world/bentobox/bentobox/listeners/JoinLeaveListener.java | 4 ++-- .../bentobox/bentobox/listeners/JoinLeaveListenerTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index e1f28b671..a716ef566 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -220,8 +220,8 @@ public class JoinLeaveListener implements Listener { 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()).map(GameModeAddon::getPermissionPrefix).orElse("") + "island.range", island.getProtectionRange()); - // Range cannot be greater than the island distance * 2 - range = Math.min(range, 2 * plugin.getIWM().getIslandDistance(island.getWorld())); + // Range cannot be greater than the island distance + range = Math.min(range, plugin.getIWM().getIslandDistance(island.getWorld())); // Range can go up or down if (range != island.getProtectionRange()) { user.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range)); diff --git a/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java index 6a1bc21d7..3edd9bfdb 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java @@ -246,9 +246,9 @@ public class JoinLeaveListenerTest { // Verify verify(player).sendMessage(eq("commands.admin.setrange.range-updated")); // Verify island setting - verify(island).setProtectionRange(eq(200)); + verify(island).setProtectionRange(eq(100)); // Verify log - verify(plugin).log("Island protection range changed from 50 to 200 for tastybento due to permission."); + verify(plugin).log("Island protection range changed from 50 to 100 for tastybento due to permission."); } /**