Skip to content

Commit

Permalink
Merge pull request #2559 from BentoBoxWorld/multi_island_aware_admin_…
Browse files Browse the repository at this point in the history
…team_commands

Admin kick to kick from all teams
  • Loading branch information
tastybento authored Nov 26, 2024
2 parents 74312b2 + aac7963 commit 2fedb88
Showing 1 changed file with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,28 @@ public boolean canExecute(User user, String label, List<String> args) {

@Override
public boolean execute(User user, String label, @NonNull List<String> args) {
Island island = getIslands().getIsland(getWorld(), targetUUID);
if (island == null) {
List<Island> 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;
}
}

0 comments on commit 2fedb88

Please sign in to comment.