Skip to content

Commit

Permalink
Initial work on supporting multiple islands per player
Browse files Browse the repository at this point in the history
The default allowed number is 5 for now, but will be set to 1 by
default.

Lots more work to do on this!
  • Loading branch information
tastybento committed Aug 17, 2023
1 parent 37258c4 commit 3fdbb01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public boolean canExecute(User user, String label, List<String> args) {
if (island.isReserved()) {
return true;
}
// Get how many islands this player has
int num = this.getIslands().getNumberOfConcurrentIslands(user.getUniqueId(), getWorld());
if (num < this.getIWM().getWorldSettings(getWorld()).getConcurrentIslands()) {
return true;
}
// You cannot make an island
user.sendMessage("general.errors.already-have-island");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,13 @@ default boolean isMakeEndPortals() {
default boolean isCheckForBlocks() {
return true;
}

/**
* Get the number of concurrent islands a player can have in the world
* @return 1 by default
* @since 1.24.2
*/
default int getConcurrentIslands() {
return 5;
}
}
10 changes: 10 additions & 0 deletions src/main/java/world/bentobox/bentobox/managers/IslandsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1891,4 +1891,14 @@ public boolean isGoingHome(User user) {
return goingHome.contains(user.getUniqueId());
}

/**
* Get the number of concurrent islands for this player
* @param uuid UUID of player
* @param world world to check
* @return number of islands this player owns in this game world
*/
public int getNumberOfConcurrentIslands(UUID uuid, World world) {
return islandCache.getAllIslands(world, uuid).size();
}

}

0 comments on commit 3fdbb01

Please sign in to comment.