Fix admin commands to avoid removing players from more than one island

This commit is contained in:
tastybento 2024-02-24 15:51:24 -08:00
parent 631a15563d
commit 0a9da71c65
5 changed files with 7 additions and 7 deletions

View File

@ -65,8 +65,8 @@ public class AdminSetspawnCommand extends ConfirmableCommand {
.build();
}
// If island is owned, then unregister the owner and any members
new ImmutableSet.Builder<UUID>().addAll(i.getMembers().keySet()).build().forEach(m ->
getIslands().removePlayer(getWorld(), m));
new ImmutableSet.Builder<UUID>().addAll(i.getMembers().keySet()).build()
.forEach(m -> getIslands().removePlayer(i, m));
}
getIslands().setSpawn(i);
i.setSpawnPoint(World.Environment.NORMAL, user.getLocation());

View File

@ -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

View File

@ -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);

View File

@ -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.'

View File

@ -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());