mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 09:08:03 +01:00
Merge pull request #2559 from BentoBoxWorld/multi_island_aware_admin_team_commands
Admin kick to kick from all teams
This commit is contained in:
commit
2fedb88b2f
@ -59,35 +59,28 @@ public class AdminTeamKickCommand extends CompositeCommand {
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user