From 50b5118a72499a5acaa53fbff3705c711cb9a437 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 17 Nov 2024 09:28:31 -0800 Subject: [PATCH] Admin kick to kick from all teams https://github.com/BentoBoxWorld/AOneBlock/issues/406 --- .../admin/team/AdminTeamKickCommand.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) 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 3b069c3f6..a9f76c2e1 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 @@ -59,35 +59,28 @@ public class AdminTeamKickCommand extends CompositeCommand { @Override public boolean execute(User user, String label, @NonNull List args) { - Island island = getIslands().getIsland(getWorld(), targetUUID); - if (island == null) { + List islands = getIslands().getIslands(getWorld(), targetUUID); + if (islands.isEmpty()) { return false; } - if (targetUUID.equals(island.getOwner())) { - user.sendMessage("commands.admin.team.kick.cannot-kick-owner"); - new IslandInfo(island).showMembers(user); - return false; - } - User target = User.getInstance(targetUUID); - target.sendMessage("commands.admin.team.kick.admin-kicked"); + islands.forEach(island -> { + if (!user.getUniqueId().equals(island.getOwner())) { + User target = User.getInstance(targetUUID); + target.sendMessage("commands.admin.team.kick.admin-kicked"); - getIslands().removePlayer(island, targetUUID); - user.sendMessage("commands.admin.team.kick.success", TextVariables.NAME, target.getName(), "[owner]", getPlayers().getName(island.getOwner())); + 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 + TeamEvent.builder().island(island).reason(TeamEvent.Reason.KICK).involvedPlayer(targetUUID).admin(true) + .build(); + IslandEvent.builder().island(island).involvedPlayer(targetUUID).admin(true) + .reason(IslandEvent.Reason.RANK_CHANGE) + .rankChange(island.getRank(target), RanksManager.VISITOR_RANK).build(); + } + }); + user.sendRawMessage("Player removed from all teams in this world"); - // Fire event so add-ons know - TeamEvent.builder() - .island(island) - .reason(TeamEvent.Reason.KICK) - .involvedPlayer(targetUUID) - .admin(true) - .build(); - IslandEvent.builder() - .island(island) - .involvedPlayer(targetUUID) - .admin(true) - .reason(IslandEvent.Reason.RANK_CHANGE) - .rankChange(island.getRank(target), RanksManager.VISITOR_RANK) - .build(); return true; } }