Merge pull request #2312 from BentoBoxWorld/2311_team_kick_gui_fix

Fix for Island team kick requires confirmation when using GUI #2311
This commit is contained in:
tastybento 2024-03-03 14:32:23 -08:00 committed by GitHub
commit bbafa6d340
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -557,7 +557,7 @@ public class IslandTeamCommand extends CompositeCommand {
case RanksManager.TRUSTED_RANK -> this.unTrustCommand.unTrustCmd(user, member.getUniqueId());
default -> {
if (kickCommand.canExecute(user, kickCommand.getLabel(), List.of(member.getName()))) {
yield kickCommand.execute(user, kickCommand.getLabel(), List.of(member.getName()));
yield kickCommand.kick(clicker, member.getUniqueId());
} else {
yield false;
}

View File

@ -90,7 +90,10 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
}
}
protected void kick(User user, UUID targetUUID) {
protected boolean kick(User user, UUID targetUUID) {
if (targetUUID == null) {
return false;
}
User target = User.getInstance(targetUUID);
Island oldIsland = Objects.requireNonNull(getIslands().getIsland(getWorld(), targetUUID)); // Should never be
// null because of
@ -99,7 +102,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
IslandBaseEvent event = TeamEvent.builder().island(oldIsland).reason(TeamEvent.Reason.KICK)
.involvedPlayer(targetUUID).build();
if (event.isCancelled()) {
return;
return false;
}
target.sendMessage("commands.island.team.kick.player-kicked", TextVariables.GAMEMODE,
getAddon().getDescription().getName(), TextVariables.NAME, user.getName(), TextVariables.DISPLAY_NAME,
@ -121,6 +124,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
getParent().getSubCommand("invite").ifPresent(c -> c.setCooldown(oldIsland.getUniqueId(),
targetUUID.toString(), getSettings().getInviteCooldown() * 60));
}
return true;
}
@Override