Added ban/unban cooldown

This commit is contained in:
tastybento 2018-08-04 21:10:51 -07:00
parent 1256b0ee22
commit 492a0b9105
4 changed files with 38 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -65,6 +65,9 @@ public class IslandBanCommand extends CompositeCommand {
user.sendMessage("commands.island.ban.player-already-banned");
return false;
}
if (getSettings().getBanWait() > 0 && !checkCooldown(user, targetUUID)) {
return false;
}
User target = User.getInstance(targetUUID);
// Cannot ban ops
if (target.isOp()) {

View File

@ -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.

View File

@ -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