diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-09-15 20:57:44 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-09-15 20:57:44 +0100 |
commit | cdf2c8beed14b647f1232eb466f7773d7a56aadf (patch) | |
tree | 17d9b6bb0d0fec197255da1c5a7f8c184db22d67 | |
parent | 3e06c068279d4bcf3efe00d13317207c91a8e12b (diff) | |
download | Essentials-cdf2c8beed14b647f1232eb466f7773d7a56aadf.tar Essentials-cdf2c8beed14b647f1232eb466f7773d7a56aadf.tar.gz Essentials-cdf2c8beed14b647f1232eb466f7773d7a56aadf.tar.lz Essentials-cdf2c8beed14b647f1232eb466f7773d7a56aadf.tar.xz Essentials-cdf2c8beed14b647f1232eb466f7773d7a56aadf.zip |
Allow bans on players who have never connected.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandban.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index f98cce98a..5f70df273 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.User; import java.util.logging.Level; import org.bukkit.Server; @@ -23,7 +24,15 @@ public class Commandban extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - final User user = getPlayer(server, args, 0, true); + User user; + try + { + user = getPlayer(server, args, 0, true); + } + catch (NoSuchFieldException e) + { + user = ess.getUser(new OfflinePlayer(args[0], ess)); + } if (!user.isOnline()) { if (sender instanceof Player @@ -41,7 +50,7 @@ public class Commandban extends EssentialsCommand return; } } - + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; String banReason; if (args.length > 1) @@ -52,11 +61,11 @@ public class Commandban extends EssentialsCommand { banReason = _("banFormat", _("defaultBanReason"), senderName); } - + user.setBanReason(banReason); user.setBanned(true); user.kickPlayer(banReason); - + server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason)); for (Player onlinePlayer : server.getOnlinePlayers()) |