Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

Expand All @@ -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;
Expand Down Expand Up @@ -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();

}
}
Loading