summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandban.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandban.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandban.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
index 01e8ab5b3..d9d080441 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
@@ -2,31 +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.api.IUser;
import org.bukkit.Server;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.user.Ban;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandban extends EssentialsCommand
{
- public Commandban()
- {
- super("ban");
- }
-
@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 < 1)
{
throw new NotEnoughArgumentsException();
}
- final User user = getPlayer(server, args, 0, true);
+ @Cleanup
+ final IUser user = getPlayer(args, 0, true);
if (!user.isOnline())
{
- if (sender instanceof Player
- && !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
+ if (Permissions.BAN_EXEMPT.isAuthorized(user))
{
sender.sendMessage(_("banExempt"));
return;
@@ -34,32 +32,35 @@ public class Commandban extends EssentialsCommand
}
else
{
- if (user.isAuthorized("essentials.ban.exempt"))
+ if (Permissions.BAN_OFFLINE.isAuthorized(sender))
{
sender.sendMessage(_("banExempt"));
return;
}
}
-
- final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
+
+ user.acquireWriteLock();
String banReason;
+ user.getData().setBan(new Ban());
if (args.length > 1)
{
- banReason = _("banFormat", getFinalArg(args, 1), senderName);
+ banReason = getFinalArg(args, 1);
+ user.getData().getBan().setReason(banReason);
}
else
{
- banReason = _("banFormat", _("defaultBanReason"), senderName);
+ banReason = _("defaultBanReason");
+ user.getData().getBan().setReason("");
}
- user.setBanReason(banReason);
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));
}