From 0a9da71c65ee6e7dad04fb5ca81ef8a9510aff66 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 24 Feb 2024 15:51:24 -0800 Subject: [PATCH] Fix admin commands to avoid removing players from more than one island --- .../bentobox/api/commands/admin/AdminSetspawnCommand.java | 4 ++-- .../api/commands/admin/team/AdminTeamKickCommand.java | 2 +- .../commands/island/team/IslandTeamInviteAcceptCommand.java | 2 +- src/main/resources/locales/en-US.yml | 4 ++-- .../api/commands/admin/team/AdminTeamKickCommandTest.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSetspawnCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSetspawnCommand.java index ef7476e4f..2372ed76a 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSetspawnCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminSetspawnCommand.java @@ -65,8 +65,8 @@ public class AdminSetspawnCommand extends ConfirmableCommand { .build(); } // If island is owned, then unregister the owner and any members - new ImmutableSet.Builder().addAll(i.getMembers().keySet()).build().forEach(m -> - getIslands().removePlayer(getWorld(), m)); + new ImmutableSet.Builder().addAll(i.getMembers().keySet()).build() + .forEach(m -> getIslands().removePlayer(i, m)); } getIslands().setSpawn(i); i.setSpawnPoint(World.Environment.NORMAL, user.getLocation()); diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java index efce9f268..3b069c3f6 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java @@ -71,7 +71,7 @@ public class AdminTeamKickCommand extends CompositeCommand { User target = User.getInstance(targetUUID); target.sendMessage("commands.admin.team.kick.admin-kicked"); - getIslands().removePlayer(getWorld(), targetUUID); + getIslands().removePlayer(island, targetUUID); user.sendMessage("commands.admin.team.kick.success", TextVariables.NAME, target.getName(), "[owner]", getPlayers().getName(island.getOwner())); // Fire event so add-ons know 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 0d86ec37f..db2a23be0 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 @@ -156,7 +156,7 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand { user.sendMessage("commands.island.team.invite.errors.island-is-full"); return; } - // Remove player as owner of the old island + // Remove the player's other islands getIslands().removePlayer(getWorld(), user.getUniqueId()); // Remove money inventory etc. for leaving cleanPlayer(user); diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 8eee324cc..ac0a963ab 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -714,7 +714,7 @@ commands: name-has-invited-you: '&a [name] has invited you to join their island.' to-accept-or-reject: '&a Do /[label] team accept to accept, or /[label] team reject to reject' - you-will-lose-your-island: '&c WARNING! You will lose your island if you accept!' + you-will-lose-your-island: '&c WARNING! You will lose all your islands if you accept!' gui: titles: team-invite-panel: "Invite Players" @@ -757,7 +757,7 @@ commands: name-joined-your-island: '&a [name] joined your island!' confirmation: |- &c Are you sure you want to accept this invite? - &c&l You will &n LOSE &r&c&l your current island! + &c&l You will &n LOSE ALL &r&c&l your islands! reject: description: reject an invitation you-rejected-invite: '&a You rejected the invitation to join an island.' diff --git a/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java index bd3a214d3..422e6166f 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java @@ -210,7 +210,7 @@ public class AdminTeamKickCommandTest { AdminTeamKickCommand itl = new AdminTeamKickCommand(ac); assertTrue(itl.canExecute(user, itl.getLabel(), Collections.singletonList(name))); assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList(name))); - verify(im).removePlayer(eq(world), eq(notUUID)); + verify(im).removePlayer(is, notUUID); verify(user).sendMessage(eq("commands.admin.team.kick.success"), eq(TextVariables.NAME), eq(name), eq("[owner]"), anyString()); // Offline so event will be called 4 times verify(pim, times(4)).callEvent(any());