mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-25 15:03:48 +00:00
Add tempban limit (with override node) and console override to exempt node.
This commit is contained in:
parent
77df82eaff
commit
ecf5d47e97
17 changed files with 35 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue