Add kicklist and unkick commands.

This commit is contained in:
asofold 2012-09-15 18:16:32 +02:00
parent 8aa31ff8a9
commit af51326125
6 changed files with 85 additions and 2 deletions

View File

@ -21,7 +21,9 @@ commands:
/:Auxiliary: /:Auxiliary:
/<command> ban [delay=(ticks)] (player) [(reason)...]: ban player /<command> ban [delay=(ticks)] (player) [(reason)...]: ban player
/<command> kick [delay=(ticks)] (player) [(reason)...]: kick player /<command> kick [delay=(ticks)] (player) [(reason)...]: kick player
/<command> kicklist: Show temporarily kicked players.
/<command> tempkick [delay=(ticks)] (player) (minutes) [(reason)...] /<command> tempkick [delay=(ticks)] (player) (minutes) [(reason)...]
/<command> unkick (player): Allow a player to login again.
/<command> tell [delay=(ticks)] (player) (message)...: tell a message /<command> tell [delay=(ticks)] (player) (message)...: tell a message
/<command> delay [delay=(ticks)] (command)...: delay a command /<command> delay [delay=(ticks)] (command)...: delay a command
@ -44,12 +46,16 @@ permissions:
description: Allow use of the ncp ban command. description: Allow use of the ncp ban command.
nocheatplus.admin.kick: nocheatplus.admin.kick:
description: Allow use of the ncp kick command. description: Allow use of the ncp kick command.
nocheatplus.admin.kicklist:
description: Allow use of the ncp kicklist command.
nocheatplus.admin.tell: nocheatplus.admin.tell:
description: Allow use of the ncp tell command. description: Allow use of the ncp tell command.
nocheatplus.admin.delay: nocheatplus.admin.delay:
description: Allow use of the ncp delay command. description: Allow use of the ncp delay command.
nocheatplus.admin.tempkick: nocheatplus.admin.tempkick:
description: Allow use of the ncp tempkick command. description: Allow use of the ncp tempkick command.
nocheatplus.admin.unkick:
description: Allow use of the ncp unkick command.
nocheatplus.admin.removeplayer: nocheatplus.admin.removeplayer:
description: Allow use of the ncp removeplayer command. description: Allow use of the ncp removeplayer command.
nocheatplus.bypass: nocheatplus.bypass:

View File

@ -83,6 +83,18 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
} }
} }
/**
* Allow login (remove from deny login map).
* @param playerName
* @return If player was denied to login.
*/
public static boolean allowLogin(String playerName){
playerName = playerName.trim().toLowerCase();
final Long time = denyLoginNames.remove(playerName);
if (time == null) return false;
return System.currentTimeMillis() <= time;
}
/** /**
* Deny the player to login. This will also remove expired entries. * Deny the player to login. This will also remove expired entries.
* @param playerName * @param playerName
@ -108,6 +120,13 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
public static boolean isLoginDenied(String playerName){ public static boolean isLoginDenied(String playerName){
return isLoginDenied(playerName, System.currentTimeMillis()); return isLoginDenied(playerName, System.currentTimeMillis());
} }
public String[] getLoginDeniedPlayers() {
checkDenyLoginsNames();
String[] kicked = new String[denyLoginNames.size()];
denyLoginNames.keySet().toArray(kicked);
return kicked;
}
/** /**
* Check if a player is denied to login at a certain point of time. * Check if a player is denied to login at a certain point of time.

View File

@ -19,7 +19,9 @@ import fr.neatmonster.nocheatplus.command.actions.DelayCommand;
import fr.neatmonster.nocheatplus.command.actions.KickCommand; import fr.neatmonster.nocheatplus.command.actions.KickCommand;
import fr.neatmonster.nocheatplus.command.actions.TellCommand; import fr.neatmonster.nocheatplus.command.actions.TellCommand;
import fr.neatmonster.nocheatplus.command.actions.TempKickCommand; import fr.neatmonster.nocheatplus.command.actions.TempKickCommand;
import fr.neatmonster.nocheatplus.command.actions.UnKickCommand;
import fr.neatmonster.nocheatplus.command.admin.InfoCommand; import fr.neatmonster.nocheatplus.command.admin.InfoCommand;
import fr.neatmonster.nocheatplus.command.admin.KickListCommand;
import fr.neatmonster.nocheatplus.command.admin.ReloadCommand; import fr.neatmonster.nocheatplus.command.admin.ReloadCommand;
import fr.neatmonster.nocheatplus.command.admin.RemovePlayerCommand; import fr.neatmonster.nocheatplus.command.admin.RemovePlayerCommand;
import fr.neatmonster.nocheatplus.config.ConfPaths; import fr.neatmonster.nocheatplus.config.ConfPaths;
@ -96,7 +98,8 @@ public class CommandHandler implements CommandExecutor {
new TellCommand(plugin), new TellCommand(plugin),
new TempKickCommand(plugin), new TempKickCommand(plugin),
new RemovePlayerCommand(plugin), new RemovePlayerCommand(plugin),
new KickListCommand(plugin),
new UnKickCommand(plugin),
}){ }){
addCommand(cmd); addCommand(cmd);
} }

View File

@ -0,0 +1,25 @@
package fr.neatmonster.nocheatplus.command.actions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.command.NCPCommand;
import fr.neatmonster.nocheatplus.players.Permissions;
public class UnKickCommand extends NCPCommand {
public UnKickCommand(NoCheatPlus plugin) {
super(plugin, "unkick", Permissions.ADMINISTRATION_UNKICK);
}
@Override
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());
return true;
}
}

View File

@ -0,0 +1,28 @@
package fr.neatmonster.nocheatplus.command.admin;
import java.util.Arrays;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.command.NCPCommand;
import fr.neatmonster.nocheatplus.players.Permissions;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
public class KickListCommand extends NCPCommand {
public KickListCommand(NoCheatPlus plugin) {
super(plugin, "kicklist", Permissions.ADMINISTRATION_KICKLIST);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
final String[] kicked = plugin.getLoginDeniedPlayers();
if (kicked.length < 100) Arrays.sort(kicked);
sender.sendMessage(TAG + "Temporarily kicked players:");
sender.sendMessage(CheckUtils.join(Arrays.asList(kicked), " "));
return true;
}
}

View File

@ -28,14 +28,16 @@ public class Permissions {
public static final String ADMINISTRATION_DELAY = ADMINISTRATION + ".delay"; public static final String ADMINISTRATION_DELAY = ADMINISTRATION + ".delay";
public static final String ADMINISTRATION_INFO = ADMINISTRATION + ".info"; public static final String ADMINISTRATION_INFO = ADMINISTRATION + ".info";
public static final String ADMINISTRATION_KICK = ADMINISTRATION + ".kick"; public static final String ADMINISTRATION_KICK = ADMINISTRATION + ".kick";
public static final String ADMINISTRATION_KICKLIST = ADMINISTRATION + ".kicklist";
public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify"; public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify";
public static final String ADMINISTRATION_PLUGINS = ADMINISTRATION + ".plugins"; public static final String ADMINISTRATION_PLUGINS = ADMINISTRATION + ".plugins";
public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload"; public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload";
public static final String ADMINISTRATION_REMOVEPLAYER = ADMINISTRATION + ".removeplayer"; public static final String ADMINISTRATION_REMOVEPLAYER = ADMINISTRATION + ".removeplayer";
public static final String ADMINISTRATION_TELL = ADMINISTRATION + ".tell"; public static final String ADMINISTRATION_TELL = ADMINISTRATION + ".tell";
public static final String ADMINISTRATION_TEMPKICK = ADMINISTRATION + ".tempkick"; public static final String ADMINISTRATION_TEMPKICK = ADMINISTRATION + ".tempkick";
public static final String ADMINISTRATION_UNKICK = ADMINISTRATION + ".unkick";
// Debug permission, for player spam (not in plugin.yml, currently). // Debug permission, for player spam (not in plugin.yml, currently).
public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug"; public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug";
// Bypasses held extra from command permissions. // Bypasses held extra from command permissions.