mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-08 00:38:27 +01:00
Add delayable command "ncp delay", for arbitrary commands.
This commit is contained in:
parent
a4780bf079
commit
77802bd3e5
@ -14,12 +14,13 @@ commands:
|
|||||||
description: NoCheatPlus command(s).
|
description: NoCheatPlus command(s).
|
||||||
# permission: nocheatplus.admin.reload
|
# permission: nocheatplus.admin.reload
|
||||||
usage: |
|
usage: |
|
||||||
/<command> info <player>: Display the violations of a player
|
/<command> info (player): Display the violations of a player
|
||||||
/<command> reload: reload NoCheatPlus configuration
|
/<command> reload: reload NoCheatPlus configuration
|
||||||
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> 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
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
nocheatplus:
|
nocheatplus:
|
||||||
|
@ -81,7 +81,8 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
new InfoCommand(plugin),
|
new InfoCommand(plugin),
|
||||||
new KickCommand(plugin),
|
new KickCommand(plugin),
|
||||||
new ReloadCommand(plugin),
|
new ReloadCommand(plugin),
|
||||||
new TellCommand(plugin)
|
new TellCommand(plugin),
|
||||||
|
new DelayCommand(plugin),
|
||||||
}){
|
}){
|
||||||
commands.put(cmd.label, cmd);
|
commands.put(cmd.label, cmd);
|
||||||
}
|
}
|
||||||
|
32
src/fr/neatmonster/nocheatplus/command/DelayCommand.java
Normal file
32
src/fr/neatmonster/nocheatplus/command/DelayCommand.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.command;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
|
import fr.neatmonster.nocheatplus.players.Permissions;
|
||||||
|
|
||||||
|
public class DelayCommand extends DelayableCommand {
|
||||||
|
|
||||||
|
public DelayCommand(NoCheatPlus plugin){
|
||||||
|
super(plugin, "delay", Permissions.ADMINISTRATION_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, Command command, String label,
|
||||||
|
String[] alteredArgs, long delay) {
|
||||||
|
if (alteredArgs.length < 2) return false;
|
||||||
|
final String cmd = join(alteredArgs, 1);
|
||||||
|
schedule(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Server server = Bukkit.getServer();
|
||||||
|
server.dispatchCommand(server.getConsoleSender(), cmd);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,7 +24,8 @@ public class Permissions {
|
|||||||
*/
|
*/
|
||||||
private static final String ADMINISTRATION = NOCHEATPLUS + ".admin";
|
private static final String ADMINISTRATION = NOCHEATPLUS + ".admin";
|
||||||
|
|
||||||
public static final String ADMINISTRATION_BAN = ADMINISTRATION + ".ban";
|
public static final String ADMINISTRATION_BAN = ADMINISTRATION + ".ban";
|
||||||
|
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_NOTIFY = ADMINISTRATION + ".notify";
|
public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify";
|
||||||
@ -176,5 +177,4 @@ public class Permissions {
|
|||||||
public static final String ZOMBE_FLY = ZOMBE + ".fly";
|
public static final String ZOMBE_FLY = ZOMBE + ".fly";
|
||||||
public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip";
|
public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip";
|
||||||
public static final String ZOMBE_CHEAT = ZOMBE + ".cheat";
|
public static final String ZOMBE_CHEAT = ZOMBE + ".cheat";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user