Added ipbanlist

This commit is contained in:
Steven Lawson 2011-10-12 15:03:34 -04:00
parent 112382893d
commit ce90ea2502
3 changed files with 51 additions and 0 deletions

View File

@ -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<String> 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;
}
}

View File

@ -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);

View File

@ -46,6 +46,9 @@ commands:
gtfo:
description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
usage: /<command> <partialname>
ipbanlist:
description: Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list.
usage: /<command> [purge]
lavadmg:
description: Superadmin command - Enable/disable lava damage.
usage: /<command> <on|off>