mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
Added ban/unban cooldown
This commit is contained in:
parent
1256b0ee22
commit
492a0b9105
@ -162,6 +162,10 @@ public class Settings implements DataObject {
|
||||
@ConfigEntry(path = "island.name.max-length")
|
||||
private int nameMaxLength = 20;
|
||||
|
||||
@ConfigComment("How long a player must wait until they can ban a player")
|
||||
@ConfigComment("after unbanning them. In minutes.")
|
||||
@ConfigEntry(path = "island.ban-wait")
|
||||
private int banWait = 10;
|
||||
|
||||
// Ranks
|
||||
@ConfigEntry(path = "island.customranks")
|
||||
@ -607,4 +611,19 @@ public class Settings implements DataObject {
|
||||
public void setNameMaxLength(int nameMaxLength) {
|
||||
this.nameMaxLength = nameMaxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the banWait
|
||||
*/
|
||||
public int getBanWait() {
|
||||
return banWait;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param banWait the banWait to set
|
||||
*/
|
||||
public void setBanWait(int banWait) {
|
||||
this.banWait = banWait;
|
||||
}
|
||||
|
||||
}
|
@ -59,17 +59,20 @@ public class IslandBanCommand extends CompositeCommand {
|
||||
}
|
||||
if (getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||
user.sendMessage("commands.island.ban.cannot-ban-member");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
if (getIslands().getIsland(getWorld(), playerUUID).isBanned(targetUUID)) {
|
||||
user.sendMessage("commands.island.ban.player-already-banned");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (getSettings().getBanWait() > 0 && !checkCooldown(user, targetUUID)) {
|
||||
return false;
|
||||
}
|
||||
User target = User.getInstance(targetUUID);
|
||||
// Cannot ban ops
|
||||
if (target.isOp()) {
|
||||
user.sendMessage("commands.island.ban.cannot-ban");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
// Finished error checking - start the banning
|
||||
return ban(user, target);
|
||||
@ -84,7 +87,7 @@ public class IslandBanCommand extends CompositeCommand {
|
||||
if (targetUser.isOnline() && getIslands().hasIsland(getWorld(), targetUser.getUniqueId()) && island.onIsland(targetUser.getLocation())) {
|
||||
getIslands().homeTeleport(getWorld(), targetUser.getPlayer());
|
||||
island.getWorld().playSound(targetUser.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Banning was blocked, maybe due to an event cancellation. Fail silently.
|
||||
|
@ -31,7 +31,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
||||
// Show help
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
UUID playerUUID = user.getUniqueId();
|
||||
// Player issuing the command must have an island
|
||||
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||
@ -55,7 +55,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
||||
}
|
||||
if (!getIslands().getIsland(getWorld(), playerUUID).isBanned(targetUUID)) {
|
||||
user.sendMessage("commands.island.unban.player-not-banned");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
// Finished error checking - start the unbanning
|
||||
User targetUser = User.getInstance(targetUUID);
|
||||
@ -66,6 +66,11 @@ public class IslandUnbanCommand extends CompositeCommand {
|
||||
if (getIslands().getIsland(getWorld(), user.getUniqueId()).removeFromBanList(targetUser.getUniqueId())) {
|
||||
user.sendMessage("general.success");
|
||||
targetUser.sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName());
|
||||
// Set cooldown
|
||||
if (getSettings().getBanWait() > 0 && getParent() != null) {
|
||||
getParent().getSubCommand("ban").ifPresent(subCommand ->
|
||||
subCommand.setCooldown(user.getUniqueId(), targetUser.getUniqueId(), getSettings().getBanWait() * 60));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Unbanning was blocked, maybe due to an event cancellation. Fail silently.
|
||||
@ -73,7 +78,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||
List<String> options = island.getBanned().stream().map(getPlayers()::getName).collect(Collectors.toList());
|
||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||
|
@ -83,6 +83,9 @@ island:
|
||||
# These set the minimum and maximum size of a name.
|
||||
min-length: 4
|
||||
max-length: 20
|
||||
# How long a player must wait until they can ban a player
|
||||
# after unbanning them. In minutes.
|
||||
ban-wait: 10
|
||||
customranks: {}
|
||||
# These settings should not be edited
|
||||
uniqueId: config
|
||||
|
Loading…
Reference in New Issue
Block a user