Skip to content

Commit

Permalink
Admin kick to kick from all teams
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 17, 2024
1 parent 01eaea9 commit 50b5118
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 50b5118

Please sign in to comment.