mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-30 22:53:39 +01:00
Improve team kick command (#1957)
The kick command has an unnecessary owner check. As command should be configurable by island owners, then limiting it to an owner is wrong. Add a code that allows kicking only lower-ranked players. Add message that shows who kicked from the island. Add message that shows that rank does not allow to kick.
This commit is contained in:
parent
6796fceee8
commit
9f21314818
@ -42,10 +42,6 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
|||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!user.getUniqueId().equals(getOwner(getWorld(), user))) {
|
|
||||||
user.sendMessage("general.errors.not-owner");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Check rank to use command
|
// Check rank to use command
|
||||||
Island island = getIslands().getIsland(getWorld(), user);
|
Island island = getIslands().getIsland(getWorld(), user);
|
||||||
int rank = Objects.requireNonNull(island).getRank(user);
|
int rank = Objects.requireNonNull(island).getRank(user);
|
||||||
@ -72,6 +68,14 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
|||||||
user.sendMessage("general.errors.not-in-team");
|
user.sendMessage("general.errors.not-in-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int targetRank = Objects.requireNonNull(island).getRank(user);
|
||||||
|
if (rank <= targetRank) {
|
||||||
|
user.sendMessage("commands.island.team.kick.cannot-kick-rank",
|
||||||
|
TextVariables.NAME, getPlayers().getName(targetUUID));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getSettings().isKickConfirmation()) {
|
if (!getSettings().isKickConfirmation()) {
|
||||||
kick(user, targetUUID);
|
kick(user, targetUUID);
|
||||||
return true;
|
return true;
|
||||||
@ -93,7 +97,9 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
target.sendMessage("commands.island.team.kick.owner-kicked", TextVariables.GAMEMODE, getAddon().getDescription().getName());
|
target.sendMessage("commands.island.team.kick.player-kicked",
|
||||||
|
TextVariables.GAMEMODE, getAddon().getDescription().getName(),
|
||||||
|
TextVariables.NAME, user.getName());
|
||||||
|
|
||||||
getIslands().removePlayer(getWorld(), targetUUID);
|
getIslands().removePlayer(getWorld(), targetUUID);
|
||||||
// Clean the target player
|
// Clean the target player
|
||||||
|
@ -652,8 +652,9 @@ commands:
|
|||||||
kick:
|
kick:
|
||||||
description: "remove a member from your island"
|
description: "remove a member from your island"
|
||||||
parameters: "<player>"
|
parameters: "<player>"
|
||||||
owner-kicked: "&c The owner kicked you from the island in [gamemode]!"
|
player-kicked: "&c The [name] kicked you from the island in [gamemode]!"
|
||||||
cannot-kick: "&c You cannot kick yourself!"
|
cannot-kick: "&c You cannot kick yourself!"
|
||||||
|
cannot-kick-rank: "&c Your rank does not allow to kick [name]!"
|
||||||
success: "&b [name] &a has been kicked from your island."
|
success: "&b [name] &a has been kicked from your island."
|
||||||
demote:
|
demote:
|
||||||
description: "demote a player on your island down a rank"
|
description: "demote a player on your island down a rank"
|
||||||
|
Loading…
Reference in New Issue
Block a user