From ce90ea25027276b0dc4f45679f032eb7e43cbb2d Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Wed, 12 Oct 2011 15:03:34 -0400 Subject: [PATCH] Added ipbanlist --- .../TotalFreedomMod/TFM_Cmds_General.java | 47 +++++++++++++++++++ .../TotalFreedomMod/TotalFreedomMod.java | 1 + src/plugin.yml | 3 ++ 3 files changed, 51 insertions(+) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java index 44c88481..79744ae1 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java @@ -293,6 +293,53 @@ public class TFM_Cmds_General implements CommandExecutor sender.sendMessage(ChatColor.GRAY + banned_players.toString()); + return true; + } + else if (cmd.getName().equalsIgnoreCase("ipbanlist")) + { + if (args.length > 0) + { + if (args[0].equalsIgnoreCase("purge")) + { + if (senderIsConsole || plugin.isUserSuperadmin(sender)) + { + for (String ip : Bukkit.getIPBans()) + { + Bukkit.unbanIP(ip); + } + + sender.sendMessage(ChatColor.GRAY + "IP Ban list has been purged."); + + return true; + } + else + { + sender.sendMessage(ChatColor.YELLOW + "You do not have permission to purge the IP ban list, you may only view it."); + } + } + } + + List ip_bans = Arrays.asList(Bukkit.getIPBans().toArray(new String[0])); + Collections.sort(ip_bans); + + StringBuilder banned_ips = new StringBuilder(); + banned_ips.append("Banned IPs: "); + boolean first = true; + for (String ip : ip_bans) + { + if (!first) + { + banned_ips.append(", "); + } + if (ip.matches("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")) + { + first = false; + banned_ips.append(ip.trim()); + } + } + + sender.sendMessage(ChatColor.GRAY + banned_ips.toString()); + return true; } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 2be247c3..b353260e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -300,6 +300,7 @@ public class TotalFreedomMod extends JavaPlugin this.getCommand("skylands").setExecutor(GeneralCommands); this.getCommand("nether").setExecutor(GeneralCommands); this.getCommand("banlist").setExecutor(GeneralCommands); + this.getCommand("ipbanlist").setExecutor(GeneralCommands); this.getCommand("fr").setExecutor(AdminCommands); this.getCommand("gtfo").setExecutor(AdminCommands); diff --git a/src/plugin.yml b/src/plugin.yml index 778ac850..2b974221 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -46,6 +46,9 @@ commands: gtfo: description: Superadmin command - Makes someone GTFO (deop and ip ban by username). usage: / + ipbanlist: + description: Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list. + usage: / [purge] lavadmg: description: Superadmin command - Enable/disable lava damage. usage: /