From 4125616af6dc8181b2cd864f7118994921ef05d5 Mon Sep 17 00:00:00 2001 From: Nick Perkins Date: Thu, 31 Oct 2013 13:54:26 +1000 Subject: [PATCH] Adjust command usage and description information. --- .../lethargiclion/informaban/InformaBan.java | 4 ++-- .../informaban/InformaBanCommandExecutor.java | 1 + .../informaban/events/IPBan.java | 2 +- .../informaban/events/Unban.java | 19 ++++++++++++------- src/main/resources/Messages.properties | 14 ++++++++------ 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/lethargiclion/informaban/InformaBan.java b/src/main/java/net/lethargiclion/informaban/InformaBan.java index bf6db72..6738c09 100644 --- a/src/main/java/net/lethargiclion/informaban/InformaBan.java +++ b/src/main/java/net/lethargiclion/informaban/InformaBan.java @@ -147,8 +147,8 @@ public void onEnable() { PluginCommand ipban = getCommand("ipban"); if (ipban != null) { ipban.setExecutor(commandExecutor); - ipban.setDescription(messages.getString("command.ban.description")); - ipban.setUsage(messages.getString("command.ban.usage")); + ipban.setDescription(messages.getString("command.ipban.description")); + ipban.setUsage(messages.getString("command.ipban.usage")); } else log.warning(msgFailed.format(new Object[] { "/ban" })); diff --git a/src/main/java/net/lethargiclion/informaban/InformaBanCommandExecutor.java b/src/main/java/net/lethargiclion/informaban/InformaBanCommandExecutor.java index 05910ad..570d458 100644 --- a/src/main/java/net/lethargiclion/informaban/InformaBanCommandExecutor.java +++ b/src/main/java/net/lethargiclion/informaban/InformaBanCommandExecutor.java @@ -264,6 +264,7 @@ private boolean commandRap(CommandSender sender, String[] args) { if (ipaddress != null) { List ipevents = plugin.getDatabase().find(Event.class).where() .disjunction() + .eq("subject", ipaddress) .eq("subjectIP", ipaddress) .findList(); diff --git a/src/main/java/net/lethargiclion/informaban/events/IPBan.java b/src/main/java/net/lethargiclion/informaban/events/IPBan.java index 17bb145..9cab10c 100644 --- a/src/main/java/net/lethargiclion/informaban/events/IPBan.java +++ b/src/main/java/net/lethargiclion/informaban/events/IPBan.java @@ -111,7 +111,7 @@ public boolean apply(ResourceBundle messages, String subject, Player[] players = Bukkit.getOnlinePlayers(); for (Player p: players) { - if (p.getAddress().getHostString().equals(subject)) { + if (p.getAddress().getAddress().getHostAddress().equals(subject)) { p.kickPlayer(StringUtils.join(message, '\n')); } } diff --git a/src/main/java/net/lethargiclion/informaban/events/Unban.java b/src/main/java/net/lethargiclion/informaban/events/Unban.java index e07ccd9..05b3e84 100644 --- a/src/main/java/net/lethargiclion/informaban/events/Unban.java +++ b/src/main/java/net/lethargiclion/informaban/events/Unban.java @@ -8,13 +8,14 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import com.google.common.net.InetAddresses; + @Entity() @DiscriminatorValue("UNBAN") public class Unban extends Event { - - public Unban() { - } - + + public Unban() {} + public boolean apply(ActiveBan ban, CommandSender enforcer, String reason) { @@ -25,11 +26,15 @@ public boolean apply(ActiveBan ban, // Record details super.apply(ban.subject, enforcer, reason); - // Record as unbanned - since banned player must be offline - Bukkit.getOfflinePlayer(ban.subject).setBanned(false); + if (InetAddresses.isInetAddress(ban.subject)) { + Bukkit.unbanIP(ban.subject); + } else { + // Record as unbanned - since banned player must be offline + Bukkit.getOfflinePlayer(ban.subject).setBanned(false); + } return true; } - + @Override public String toString() { return String.format("%s: %s unbanned %s: %s", diff --git a/src/main/resources/Messages.properties b/src/main/resources/Messages.properties index 11faab4..ddfc402 100644 --- a/src/main/resources/Messages.properties +++ b/src/main/resources/Messages.properties @@ -10,11 +10,13 @@ command.ib.usage = Usage: /ib reload command.kick.description = Kicks a player from the server. command.kick.usage = Usage: /kick command.ban.description = Bans a player from the server. -command.ban.usage = Usage: /ban