Initial work on supporting multiple islands per player

The default allowed number is 5 for now, but will be set to 1 by
default.

Lots more work to do on this!
This commit is contained in:
tastybento 2023-08-16 20:30:06 -07:00
parent 37258c4394
commit 3fdbb014c7
3 changed files with 24 additions and 0 deletions

View File

@ -48,6 +48,11 @@ public class IslandCreateCommand extends CompositeCommand {
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;

View File

@ -634,4 +634,13 @@ public interface WorldSettings extends ConfigObject {
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;
}
}

View File

@ -1891,4 +1891,14 @@ public class IslandsManager {
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();
}
}