From 45f2dca414e7314699fb4e3ad08d7dfb112bfc6d Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 12 Feb 2023 12:08:38 -0800 Subject: [PATCH] Fixes max team size checks. Fixes #2034 --- .../island/team/IslandTeamInviteAcceptCommand.java | 2 +- .../api/commands/island/team/IslandTeamInviteCommand.java | 8 ++++---- .../world/bentobox/bentobox/managers/IslandsManager.java | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java index 8144ed765..5f17a3ab2 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java @@ -157,7 +157,7 @@ private void acceptTeamInvite(User user, Invite invite) { user.sendMessage(INVALID_INVITE); return; } - if (teamIsland.getMemberSet(RanksManager.MEMBER_RANK, true).size() > getIslands().getMaxMembers(teamIsland, RanksManager.MEMBER_RANK)) { + if (teamIsland.getMemberSet(RanksManager.MEMBER_RANK, true).size() >= getIslands().getMaxMembers(teamIsland, RanksManager.MEMBER_RANK)) { user.sendMessage("commands.island.team.invite.errors.island-is-full"); return; } diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java index 2785fb95c..a36584f14 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java @@ -51,9 +51,9 @@ public boolean canExecute(User user, String label, List args) { Invite invite = itc.getInvite(playerUUID); String name = getPlayers().getName(playerUUID); switch (invite.getType()) { - case COOP -> user.sendMessage("commands.island.team.invite.name-has-invited-you.coop", TextVariables.NAME, name); - case TRUST -> user.sendMessage("commands.island.team.invite.name-has-invited-you.trust", TextVariables.NAME, name); - default -> user.sendMessage("commands.island.team.invite.name-has-invited-you", TextVariables.NAME, name); + case COOP -> user.sendMessage("commands.island.team.invite.name-has-invited-you.coop", TextVariables.NAME, name); + case TRUST -> user.sendMessage("commands.island.team.invite.name-has-invited-you.trust", TextVariables.NAME, name); + default -> user.sendMessage("commands.island.team.invite.name-has-invited-you", TextVariables.NAME, name); } return true; } @@ -69,7 +69,7 @@ public boolean canExecute(User user, String label, List args) { return false; } // Check for space on team - if (island.getMemberSet().size() > getIslands().getMaxMembers(island, RanksManager.MEMBER_RANK)) { + if (island.getMemberSet().size() >= getIslands().getMaxMembers(island, RanksManager.MEMBER_RANK)) { user.sendMessage("commands.island.team.invite.errors.island-is-full"); return false; } diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index a49b3f14b..ce585a6cb 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -490,6 +490,8 @@ public Set getMembers(@NonNull World world, @NonNull UUID playerUUID) { * Gets the maximum number of island members allowed on this island. * Will update the value based on world settings or island owner permissions (if online). * If the island is unowned, then this value will be 0. + * The number given for MEMBER_RANK is meant to include this rank and higher, e.g. {@link RanksManager#SUB_OWNER_RANK} + * and {@link RanksManager#OWNER_RANK} * @param island - island * @param rank {@link RanksManager#MEMBER_RANK}, {@link RanksManager#COOP_RANK}, or {@link RanksManager#TRUSTED_RANK} * @return max number of members. If negative, then this means unlimited.