Skip to content

Commit

Permalink
Fix admin commands to avoid removing players from more than one island
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Feb 24, 2024
1 parent 631a155 commit 0a9da71
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ private void setSpawn(User user, Island i) {
.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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean execute(User user, String label, @NonNull List<String> args) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void acceptTeamInvite(User user, Invite invite) {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void testExecute() {
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());
Expand Down

0 comments on commit 0a9da71

Please sign in to comment.