mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 19:07:45 +01:00
[COMMAND CHANGE] Remove delay feature from ncp ban/kick/tell/tempkick.
"ncp delay..." still is available.
This commit is contained in:
parent
8ea5eccaa0
commit
4811fefb05
@ -1,5 +1,7 @@
|
|||||||
package fr.neatmonster.nocheatplus.command.actions;
|
package fr.neatmonster.nocheatplus.command.actions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -8,42 +10,46 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
||||||
import fr.neatmonster.nocheatplus.command.actions.delay.DelayableCommand;
|
import fr.neatmonster.nocheatplus.command.BaseCommand;
|
||||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||||
|
|
||||||
public class BanCommand extends DelayableCommand {
|
public class BanCommand extends BaseCommand {
|
||||||
|
|
||||||
public BanCommand(JavaPlugin plugin) {
|
public BanCommand(JavaPlugin plugin) {
|
||||||
super(plugin, "ban", Permissions.ADMINISTRATION_BAN);
|
super(plugin, "ban", Permissions.ADMINISTRATION_BAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final CommandSender sender, Command command, String label,
|
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
|
||||||
String[] alteredArgs, long delay) {
|
|
||||||
// Args contains "ban" as first arg.
|
// Args contains "ban" as first arg.
|
||||||
if (alteredArgs.length < 2) return false;
|
if (args.length < 2) return false;
|
||||||
final String name = alteredArgs[1];
|
final String name = args[1];
|
||||||
final String reason;
|
final String reason;
|
||||||
if (alteredArgs.length > 2) reason = AbstractCommand.join(alteredArgs, 2);
|
if (args.length > 2) reason = AbstractCommand.join(args, 2);
|
||||||
else reason = "";
|
else reason = "";
|
||||||
schedule(new Runnable() {
|
ban(sender, name, reason);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
ban(sender, name, reason);
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ban(CommandSender sender, String name, String reason) {
|
void ban(CommandSender sender, String name, String reason) {
|
||||||
Player player = DataManager.getPlayer(name);
|
Player player = DataManager.getPlayer(name);
|
||||||
if (player != null)
|
if (player != null){
|
||||||
player.kickPlayer(reason);
|
player.kickPlayer(reason);
|
||||||
|
}
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(name);
|
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(name);
|
||||||
offlinePlayer.setBanned(true);
|
offlinePlayer.setBanned(true);
|
||||||
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Banned " + offlinePlayer.getName() + " : " + reason);
|
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Banned " + offlinePlayer.getName() + " : " + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#onTabComplete(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command,
|
||||||
|
String alias, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,33 @@
|
|||||||
package fr.neatmonster.nocheatplus.command.actions;
|
package fr.neatmonster.nocheatplus.command.actions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
||||||
import fr.neatmonster.nocheatplus.command.actions.delay.DelayableCommand;
|
import fr.neatmonster.nocheatplus.command.BaseCommand;
|
||||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||||
|
|
||||||
public class KickCommand extends DelayableCommand {
|
public class KickCommand extends BaseCommand {
|
||||||
|
|
||||||
public KickCommand(JavaPlugin plugin) {
|
public KickCommand(JavaPlugin plugin) {
|
||||||
super(plugin, "kick", Permissions.ADMINISTRATION_KICK);
|
super(plugin, "kick", Permissions.ADMINISTRATION_KICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final CommandSender sender, Command command, String label,
|
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
|
||||||
String[] alteredArgs, long delay) {
|
|
||||||
// Args contains "kick" as first arg.
|
// Args contains "kick" as first arg.
|
||||||
if (alteredArgs.length < 2) return false;
|
if (args.length < 2) return false;
|
||||||
final String name = alteredArgs[1];
|
final String name = args[1];
|
||||||
final String reason;
|
final String reason;
|
||||||
if (alteredArgs.length > 2) reason = AbstractCommand.join(alteredArgs, 2);
|
if (args.length > 2) reason = AbstractCommand.join(args, 2);
|
||||||
else reason = "";
|
else reason = "";
|
||||||
schedule(new Runnable() {
|
kick(sender, name, reason);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
kick(sender, name, reason);
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,4 +38,13 @@ public class KickCommand extends DelayableCommand {
|
|||||||
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
|
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#onTabComplete(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command,
|
||||||
|
String alias, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package fr.neatmonster.nocheatplus.command.actions;
|
package fr.neatmonster.nocheatplus.command.actions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
||||||
import fr.neatmonster.nocheatplus.command.actions.delay.DelayableCommand;
|
import fr.neatmonster.nocheatplus.command.BaseCommand;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||||
@ -16,24 +18,18 @@ import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
|||||||
* @author mc_dev
|
* @author mc_dev
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TellCommand extends DelayableCommand {
|
public class TellCommand extends BaseCommand {
|
||||||
|
|
||||||
public TellCommand(JavaPlugin plugin) {
|
public TellCommand(JavaPlugin plugin) {
|
||||||
super(plugin, "tell", Permissions.ADMINISTRATION_TELL);
|
super(plugin, "tell", Permissions.ADMINISTRATION_TELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, Command command, String label,
|
public boolean onCommand(CommandSender sender, Command command, String label, final String[] args) {
|
||||||
final String[] alteredArgs, long delay) {
|
if (args.length < 3) return false;
|
||||||
if (alteredArgs.length < 3) return false;
|
final String name = args[1].trim();
|
||||||
final String name = alteredArgs[1].trim();
|
final String message = AbstractCommand.join(args, 2);
|
||||||
final String message = AbstractCommand.join(alteredArgs, 2);
|
tell(name, message);
|
||||||
schedule(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
tell(name, message);
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,4 +38,13 @@ public class TellCommand extends DelayableCommand {
|
|||||||
if (player != null) player.sendMessage(ColorUtil.replaceColors(message));
|
if (player != null) player.sendMessage(ColorUtil.replaceColors(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.command.actions.delay.DelayableCommand#onTabComplete(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command,
|
||||||
|
String alias, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package fr.neatmonster.nocheatplus.command.actions;
|
package fr.neatmonster.nocheatplus.command.actions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -7,43 +9,36 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||||
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
import fr.neatmonster.nocheatplus.command.AbstractCommand;
|
||||||
import fr.neatmonster.nocheatplus.command.actions.delay.DelayableCommand;
|
import fr.neatmonster.nocheatplus.command.BaseCommand;
|
||||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||||
|
|
||||||
public class TempKickCommand extends DelayableCommand {
|
public class TempKickCommand extends BaseCommand {
|
||||||
|
|
||||||
public TempKickCommand(JavaPlugin plugin) {
|
public TempKickCommand(JavaPlugin plugin) {
|
||||||
super(plugin, "tempkick", Permissions.ADMINISTRATION_TEMPKICK, new String[]{
|
super(plugin, "tempkick", Permissions.ADMINISTRATION_TEMPKICK,
|
||||||
"tkick", "tempban", "tban",
|
new String[]{"tkick", "tempban", "tban",});
|
||||||
}, 1, -1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final CommandSender sender, Command command, String label,
|
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
|
||||||
String[] alteredArgs, long delay) {
|
|
||||||
// Args contains sub command label as first arg.
|
// Args contains sub command label as first arg.
|
||||||
if (alteredArgs.length < 3) return false;
|
if (args.length < 3) return false;
|
||||||
long base = 60000; // minutes (!)
|
long base = 60000; // minutes (!)
|
||||||
final String name = alteredArgs[1];
|
final String name = args[1];
|
||||||
long duration = -1;
|
long duration = -1;
|
||||||
try{
|
try{
|
||||||
// TODO: parse for abbreviations like 30s 30m 30h 30d, and set base...
|
// TODO: parse for abbreviations like 30s 30m 30h 30d, and set base...
|
||||||
duration = Integer.parseInt(alteredArgs[2]);
|
duration = Integer.parseInt(args[2]);
|
||||||
}
|
}
|
||||||
catch( NumberFormatException e){};
|
catch( NumberFormatException e){};
|
||||||
if (duration <= 0) return false;
|
if (duration <= 0) return false;
|
||||||
final long finalDuration = duration * base;
|
final long finalDuration = duration * base;
|
||||||
final String reason;
|
final String reason;
|
||||||
if (alteredArgs.length > 3) reason = AbstractCommand.join(alteredArgs, 3);
|
if (args.length > 3) reason = AbstractCommand.join(args, 3);
|
||||||
else reason = "";
|
else reason = "";
|
||||||
schedule(new Runnable() {
|
tempKick(sender, name, finalDuration, reason);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
tempKick(sender, name, finalDuration, reason);
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,4 +50,14 @@ public class TempKickCommand extends DelayableCommand {
|
|||||||
player.kickPlayer(reason);
|
player.kickPlayer(reason);
|
||||||
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " for " + duration/60000 +" minutes: " + reason);
|
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " for " + duration/60000 +" minutes: " + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#onTabComplete(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command,
|
||||||
|
String alias, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package fr.neatmonster.nocheatplus.command.actions;
|
package fr.neatmonster.nocheatplus.command.actions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -30,4 +32,13 @@ public class UnKickCommand extends BaseCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#onTabComplete(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command,
|
||||||
|
String alias, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user