Add the command "ncp unkick *".

This commit is contained in:
asofold 2013-03-13 05:41:17 +01:00
parent 0d2862c21b
commit 976cd59b7c
2 changed files with 24 additions and 2 deletions

View File

@ -145,6 +145,21 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
return System.currentTimeMillis() <= time;
}
/**
* Remove all players from the allow login set.
* @return Number of players that had actually been denied to login.
*/
public static int allowLoginAll(){
int denied = 0;
final long now = System.currentTimeMillis();
for (final String playerName : denyLoginNames.keySet()){
final Long time = denyLoginNames.get(playerName);
if (time != null && time > now) denied ++;
}
denyLoginNames.clear();
return denied;
}
/**
* Deny the player to login. This will also remove expired entries.
* @param playerName

View File

@ -17,8 +17,15 @@ public class UnKickCommand extends NCPCommand {
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if (args.length != 2) return false;
if (NoCheatPlus.allowLogin(args[1])) sender.sendMessage(TAG + "Allow to login again: " + args[1].trim());
else sender.sendMessage(TAG + "Was not denied to login: " + args[1].trim());
if (args[1].trim().equals("*")){
sender.sendMessage(TAG + "Removed " + NoCheatPlus.allowLoginAll() + " players from the 'deny-login' list.");
}
else if (NoCheatPlus.allowLogin(args[1])){
sender.sendMessage(TAG + "Allow to login again: " + args[1].trim());
}
else{
sender.sendMessage(TAG + "Was not denied to login: " + args[1].trim());
}
return true;
}