summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-12-18 02:24:45 -0800
committerKHobbits <rob@khobbits.co.uk>2012-12-18 02:24:45 -0800
commit258fbdb0e87aed7a97b2ccf84a0d23305bd4298c (patch)
treeaeac4213b20edd6f1e3649911fb740292cf329d2
parentbd4a48c441092b41b2d604cbd370f4da14279250 (diff)
parentecf5d47e97adb2d7bda0ed269f64aff86320fc39 (diff)
downloadEssentials-258fbdb0e87aed7a97b2ccf84a0d23305bd4298c.tar
Essentials-258fbdb0e87aed7a97b2ccf84a0d23305bd4298c.tar.gz
Essentials-258fbdb0e87aed7a97b2ccf84a0d23305bd4298c.tar.lz
Essentials-258fbdb0e87aed7a97b2ccf84a0d23305bd4298c.tar.xz
Essentials-258fbdb0e87aed7a97b2ccf84a0d23305bd4298c.zip
Merge pull request #216 from chrisgward/patch-1
Add tempban limit (with override node)
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtempban.java11
-rw-r--r--Essentials/src/config.yml4
-rw-r--r--Essentials/src/messages.properties1
-rw-r--r--Essentials/src/messages_cs.properties1
-rw-r--r--Essentials/src/messages_da.properties1
-rw-r--r--Essentials/src/messages_de.properties1
-rw-r--r--Essentials/src/messages_en.properties1
-rw-r--r--Essentials/src/messages_es.properties1
-rw-r--r--Essentials/src/messages_fi.properties1
-rw-r--r--Essentials/src/messages_fr.properties1
-rw-r--r--Essentials/src/messages_it.properties1
-rw-r--r--Essentials/src/messages_nl.properties1
-rw-r--r--Essentials/src/messages_pl.properties1
-rw-r--r--Essentials/src/messages_pt.properties1
-rw-r--r--Essentials/src/messages_se.properties1
17 files changed, 35 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index fb0073c8a..1ad9b0207 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -183,4 +183,6 @@ public interface ISettings extends IConf
public int getMailsPerMinute();
public void setEssentialsChatActive(boolean b);
+
+ long getMaxTempban();
}
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index a8ef1a344..43b7dea30 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -986,4 +986,10 @@ public class Settings implements ISettings
{
return mailsPerMinute;
}
+
+ @Override
+ public long getMaxTempban()
+ {
+ return config.getLong("max-tempban-time", -1);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
index 0549e9c0d..4ac2db89c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
@@ -4,6 +4,8 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -35,7 +37,7 @@ public class Commandtempban extends EssentialsCommand
}
else
{
- if (user.isAuthorized("essentials.tempban.exempt"))
+ if (user.isAuthorized("essentials.tempban.exempt") && sender instanceof Player)
{
sender.sendMessage(_("tempbanExempt"));
return;
@@ -44,6 +46,13 @@ public class Commandtempban extends EssentialsCommand
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
+ final long max = ess.getSettings().getMaxTempban();
+ if(max != 0 && banTimestamp - GregorianCalendar.getInstance().getTimeInMillis() > max * 1000 && ess.getUser(sender).isAuthorized("essentials.tempban.unlimited"))
+ {
+ sender.sendMessage(_("oversizedTempban"));
+ throw new NoChargeException();
+ }
+
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName);
user.setBanReason(banReason);
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index a766e0549..e428354a8 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -351,6 +351,10 @@ sethome-multiple:
# Set to 0 for no timeout
tpa-accept-cancellation: 0
+# Set the maximum time /tempban can be used for in seconds.
+# Set to -1 to disable, and essentials.tempban.unlimited can be used to override.
+max-tempban-time: -1
+
############################################################
# +------------------------------------------------------+ #
# | EssentialsEco | #
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 8a17513cf..a84e9cdab 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties
index 5cc095f15..dca74c0e0 100644
--- a/Essentials/src/messages_cs.properties
+++ b/Essentials/src/messages_cs.properties
@@ -469,3 +469,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 6beff781a..e9099f3cf 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 4db624c6a..35f584f52 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 8a17513cf..a84e9cdab 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties
index 8d0ad7892..c3bbfb80c 100644
--- a/Essentials/src/messages_es.properties
+++ b/Essentials/src/messages_es.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties
index fef0aeb78..ceb44335e 100644
--- a/Essentials/src/messages_fi.properties
+++ b/Essentials/src/messages_fi.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index e5cfd4975..bed11e666 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties
index f24899599..9afb93c4d 100644
--- a/Essentials/src/messages_it.properties
+++ b/Essentials/src/messages_it.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index 0c4fd2cd0..5ec926da5 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties
index 804784f19..a3c27652c 100644
--- a/Essentials/src/messages_pl.properties
+++ b/Essentials/src/messages_pl.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties
index 4c039bc1c..5aa293a73 100644
--- a/Essentials/src/messages_pt.properties
+++ b/Essentials/src/messages_pt.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.
diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties
index b6017786b..3a184f675 100644
--- a/Essentials/src/messages_se.properties
+++ b/Essentials/src/messages_se.properties
@@ -466,3 +466,4 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.
fullStack=\u00a74You already have a full stack
+oversizedTempban=\u00a74You may not ban a player for this period of time.