Merge pull request #216 from chrisgward/patch-1

Add tempban limit (with override node)
This commit is contained in:
KHobbits 2012-12-18 02:24:45 -08:00
commit 258fbdb0e8
17 changed files with 35 additions and 1 deletions

View file

@ -183,4 +183,6 @@ public interface ISettings extends IConf
public int getMailsPerMinute();
public void setEssentialsChatActive(boolean b);
long getMaxTempban();
}

View file

@ -986,4 +986,10 @@ public class Settings implements ISettings
{
return mailsPerMinute;
}
@Override
public long getMaxTempban()
{
return config.getLong("max-tempban-time", -1);
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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