From 7816916a8e88e25af146f107c0253f143debb62d Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Sat, 2 Feb 2013 18:45:32 +1100 Subject: Add tempban limit config option with matching exempt node. Console override to tempban.exempt --- Essentials/src/messages.properties | 1 + Essentials/src/net/ess3/commands/Commandtempban.java | 11 ++++++++++- Essentials/src/net/ess3/permissions/Permissions.java | 1 + Essentials/src/net/ess3/settings/Commands.java | 1 + Essentials/src/net/ess3/settings/commands/Tempban.java | 17 +++++++++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Essentials/src/net/ess3/settings/commands/Tempban.java diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 29095b7c1..dd0b99e8a 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -367,6 +367,7 @@ teleporting=\u00a76Teleporting... teleportingPortal=\u00a76Teleporting via portal. tempBanned=Temporarily banned from server for {0} tempbanExempt=\u00a74You may not tempban that player. +tempbanOversized=\u00a74You may not ban a player for this period of time. thunder= \u00a76You\u00a7c {0} \u00a76thunder in your world. thunderDuration=\u00a76You\u00a7c {0} \u00a76thunder in your world for\u00a7c {1} \u00a76seconds. timeBeforeHeal=\u00a76Time before next heal:\u00a7c {0} diff --git a/Essentials/src/net/ess3/commands/Commandtempban.java b/Essentials/src/net/ess3/commands/Commandtempban.java index 3bd267095..13b72f92c 100644 --- a/Essentials/src/net/ess3/commands/Commandtempban.java +++ b/Essentials/src/net/ess3/commands/Commandtempban.java @@ -10,6 +10,8 @@ import net.ess3.utils.DateUtil; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Calendar; + public class Commandtempban extends EssentialsCommand { @@ -31,7 +33,7 @@ public class Commandtempban extends EssentialsCommand } else { - if (Permissions.TEMPBAN_EXEMPT.isAuthorized(user)) + if (Permissions.TEMPBAN_EXEMPT.isAuthorized(user) && sender instanceof Player) { sender.sendMessage(_("tempbanExempt")); return; @@ -40,6 +42,13 @@ public class Commandtempban extends EssentialsCommand final String time = getFinalArg(args, 1); final long banTimestamp = DateUtil.parseDateDiff(time, true); + final long max = ess.getSettings().getData().getCommands().getTempban().getMaxTempbanTime(); + if(max != -1 && banTimestamp - Calendar.getInstance().getTimeInMillis() > max && !Permissions.TEMPBAN_UNLIMITED.isAuthorized(sender)) + { + sender.sendMessage(_("tempbanOversized")); + return; + } + final String banReason = _("tempBanned", DateUtil.formatDateDiff(banTimestamp)); final Ban ban = new Ban(); final UserData userData = user.getData(); diff --git a/Essentials/src/net/ess3/permissions/Permissions.java b/Essentials/src/net/ess3/permissions/Permissions.java index 6783da8b1..60eb45b6a 100644 --- a/Essentials/src/net/ess3/permissions/Permissions.java +++ b/Essentials/src/net/ess3/permissions/Permissions.java @@ -100,6 +100,7 @@ public enum Permissions implements IPermission TELEPORT_TIMER_BYPASS, TELEPORT_TIMER_MOVE, TEMPBAN_EXEMPT, + TEMPBAN_UNLIMITED, TEMPBAN_OFFLINE, TIME_SET, TOGGLEJAIL_OFFLINE, diff --git a/Essentials/src/net/ess3/settings/Commands.java b/Essentials/src/net/ess3/settings/Commands.java index fc525f81b..8ca36bfab 100644 --- a/Essentials/src/net/ess3/settings/Commands.java +++ b/Essentials/src/net/ess3/settings/Commands.java @@ -23,6 +23,7 @@ public class Commands implements StorageObject private SocialSpy socialspy = new SocialSpy(); private Spawnmob spawnmob = new Spawnmob(); private Teleport teleport = new Teleport(); + private Tempban tempban = new Tempban(); private Speed speed = new Speed(); @ListType @Comment( diff --git a/Essentials/src/net/ess3/settings/commands/Tempban.java b/Essentials/src/net/ess3/settings/commands/Tempban.java new file mode 100644 index 000000000..283e2ebbf --- /dev/null +++ b/Essentials/src/net/ess3/settings/commands/Tempban.java @@ -0,0 +1,17 @@ +package net.ess3.settings.commands; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.ess3.storage.Comment; +import net.ess3.storage.StorageObject; + +@Data +@EqualsAndHashCode(callSuper = false) +public class Tempban implements StorageObject +{ + @Comment({ + "Set to the maximum time in seconds a player can be tempbanned for.", + "Set to -1 to disable, and override with essentials.tempban.unlimited" + }) + private long maxTempbanTime = -1; +} -- cgit v1.2.3