diff --git a/src/main/java/world/bentobox/bentobox/api/addons/GameModeAddon.java b/src/main/java/world/bentobox/bentobox/api/addons/GameModeAddon.java index af8c03d7e..fd891d261 100644 --- a/src/main/java/world/bentobox/bentobox/api/addons/GameModeAddon.java +++ b/src/main/java/world/bentobox/bentobox/api/addons/GameModeAddon.java @@ -190,4 +190,13 @@ public boolean isFixIslandCenter() { return true; } + /** + * Indicates whether BentoBox should fail to run if island ranges in a Game Mode are different. + * For some Game Modes, this is not an issue. Also disables console errors if islands cannot be made. + * @return default is true + * @since 3.8.2 + */ + public boolean isEnforceEqualRanges() { + return true; + } } diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 0405734f5..e31edca2c 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -1302,6 +1302,7 @@ public void load() throws IOException { } // Check island distance and if incorrect stop BentoBox else if (!plugin.getSettings().isOverrideSafetyCheck() + && plugin.getIWM().getAddon(island.getWorld()).map(GameModeAddon::isEnforceEqualRanges).orElse(true) && island.getWorld() != null && plugin.getIWM().inWorld(island.getWorld()) && island.getRange() != plugin.getIWM().getIslandDistance(island.getWorld())) { diff --git a/src/main/java/world/bentobox/bentobox/managers/island/NewIsland.java b/src/main/java/world/bentobox/bentobox/managers/island/NewIsland.java index 6adf59f37..a6204584f 100644 --- a/src/main/java/world/bentobox/bentobox/managers/island/NewIsland.java +++ b/src/main/java/world/bentobox/bentobox/managers/island/NewIsland.java @@ -298,7 +298,7 @@ private void cleanUpUser(Location loc) { // Set protection range based on user's permission, if different from default island.setProtectionRange(user.getPermissionValue( plugin.getIWM().getAddon(island.getWorld()).map(GameModeAddon::getPermissionPrefix).orElse("") - + "island.range", + + "island.range", island.getProtectionRange())); } @@ -312,14 +312,18 @@ private Location makeNextIsland() throws IOException { // Use location strategy to find next available spot Location next = this.locationStrategy.getNextLocation(world, user); if (next == null) { - plugin.logError("Failed to make island - no unoccupied spot found."); - plugin.logError("If the world was imported, try multiple times until all unowned islands are known."); + if (plugin.getIWM().getAddon(world).map(GameModeAddon::isEnforceEqualRanges).orElse(true)) { + plugin.logError("Failed to make island - no unoccupied spot found."); + plugin.logError("If the world was imported, try multiple times until all unowned islands are known."); + } throw new IOException("commands.island.create.cannot-create-island"); } // Add island to grid island = plugin.getIslands().createIsland(next, user.getUniqueId()); if (island == null) { - plugin.logError("Failed to make island! Island could not be added to the grid."); + if (plugin.getIWM().getAddon(world).map(GameModeAddon::isEnforceEqualRanges).orElse(true)) { + plugin.logError("Failed to make island! Island could not be added to the grid."); + } throw new IOException("commands.island.create.unable-create-island"); } return next; @@ -359,8 +363,8 @@ private void tidyUp(Island oldIsland) { // Fire exit event for plugins/addons IslandEvent.builder().involvedPlayer(user.getUniqueId()) - .reason(reason == Reason.RESET ? Reason.RESETTED : Reason.CREATED).island(island) - .location(island.getCenter()).oldIsland(oldIsland).build(); + .reason(reason == Reason.RESET ? Reason.RESETTED : Reason.CREATED).island(island) + .location(island.getCenter()).oldIsland(oldIsland).build(); } } \ No newline at end of file