Fixed bugs with /saconfig clear. Resolves #167

Admins can now use /saconfig clear [ip] to remove the designated IP (only their own IPs can be removed. They can also simply use /saconfig clear to remove all IPs but the current one. /saconfig clear is safe, meaning you can't remove your current IP or an IP that doesn't belong to you.
This commit is contained in:
unknown 2014-05-05 14:27:33 +02:00
parent 68d83fa397
commit ad06bea3ae
2 changed files with 9 additions and 9 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Mon May 05 14:10:07 CEST 2014 #Mon May 05 14:23:17 CEST 2014
build.number=818 build.number=820

View File

@ -67,21 +67,21 @@ public class Command_saconfig extends TFM_Command
final TFM_Admin admin = TFM_AdminList.getEntry(sender_p); final TFM_Admin admin = TFM_AdminList.getEntry(sender_p);
TFM_Util.adminAction(sender.getName(), "Cleaning my supered IPs", true);
final String ip = TFM_Util.getIp(sender_p); final String ip = TFM_Util.getIp(sender_p);
if (args.length == 1) if (args.length == 1)
{ {
TFM_Util.adminAction(sender.getName(), "Cleaning my supered IPs", true);
int counter = 0; int counter = 0;
for (String adminIp : (String[]) admin.getIps().toArray()) for (int i = 0; i < admin.getIps().size(); i++)
{ {
if (adminIp.equals(ip)) if (admin.getIps().get(i).equals(ip))
{ {
continue; continue;
} }
admin.removeIp(ip); admin.removeIp(admin.getIps().get(i));
counter++; counter++;
} }
@ -89,7 +89,6 @@ public class Command_saconfig extends TFM_Command
playerMsg(counter + " IPs removed."); playerMsg(counter + " IPs removed.");
playerMsg(admin.getIps().get(0) + " is now your only IP address"); playerMsg(admin.getIps().get(0) + " is now your only IP address");
return true; return true;
} }
@ -106,12 +105,13 @@ public class Command_saconfig extends TFM_Command
return true; return true;
} }
TFM_Util.adminAction(sender.getName(), "Removing a supered IP", true);
admin.removeIp(args[1]); admin.removeIp(args[1]);
TFM_AdminList.save(); TFM_AdminList.save();
playerMsg("Removed IP " + args[1]); playerMsg("Removed IP " + args[1]);
playerMsg("Current IPs: " + StringUtils.join(admin.getIps(), ", ")); playerMsg("Current IPs: " + StringUtils.join(admin.getIps(), ", "));
return true; return true;
} }