summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandtempban.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtempban.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
index 25c457a20..4068f8d18 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
@@ -2,32 +2,29 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
-import org.bukkit.Server;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.user.Ban;
+import com.earth2me.essentials.utils.DateUtil;
+import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandtempban extends EssentialsCommand
{
- public Commandtempban()
- {
- super("tempban");
- }
-
@Override
- public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
- final User user = getPlayer(server, args, 0, true);
+ final IUser user = getPlayer(args, 0, true);
if (!user.isOnline())
{
- if (sender instanceof Player
- && !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
+ if (Permissions.TEMPBAN_OFFLINE.isAuthorized(sender))
{
sender.sendMessage(_("tempbanExempt"));
return;
@@ -35,26 +32,28 @@ public class Commandtempban extends EssentialsCommand
}
else
{
- if (user.isAuthorized("essentials.tempban.exempt"))
+ if (Permissions.TEMPBAN_EXEMPT.isAuthorized(user))
{
sender.sendMessage(_("tempbanExempt"));
return;
}
}
final String time = getFinalArg(args, 1);
- final long banTimestamp = Util.parseDateDiff(time, true);
+ final long banTimestamp = DateUtil.parseDateDiff(time, true);
- final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp));
- user.setBanReason(banReason);
- user.setBanTimeout(banTimestamp);
+ final String banReason = _("tempBanned", DateUtil.formatDateDiff(banTimestamp));
+ user.acquireWriteLock();
+ user.getData().setBan(new Ban());
+ user.getData().getBan().setReason(banReason);
+ user.getData().getBan().setTimeout(banTimestamp);
user.setBanned(true);
user.kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(onlinePlayer);
- if (player.isAuthorized("essentials.ban.notify"))
+ final IUser player = ess.getUser(onlinePlayer);
+ if (Permissions.BAN_NOTIFY.isAuthorized(player))
{
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
}