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
This commit is contained in:
tastybento 2021-09-11 16:50:43 -07:00
parent 2b452cddbd
commit 3dd9e973fb
2 changed files with 4 additions and 4 deletions

View File

@ -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));

View File

@ -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.");
}
/**