[COMMAND CHANGE] Remove delay feature from ncp ban/kick/tell/tempkick.

"ncp delay..." still is available.
This commit is contained in:
asofold 2013-06-11 21:33:33 +02:00
parent 8ea5eccaa0
commit 4811fefb05
5 changed files with 89 additions and 57 deletions

View File

@ -1,5 +1,7 @@
package fr.neatmonster.nocheatplus.command.actions;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -8,42 +10,46 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
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.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
public class BanCommand extends DelayableCommand {
public class BanCommand extends BaseCommand {
public BanCommand(JavaPlugin plugin) {
super(plugin, "ban", Permissions.ADMINISTRATION_BAN);
}
@Override
public boolean execute(final CommandSender sender, Command command, String label,
String[] alteredArgs, long delay) {
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
// Args contains "ban" as first arg.
if (alteredArgs.length < 2) return false;
final String name = alteredArgs[1];
if (args.length < 2) return false;
final String name = args[1];
final String reason;
if (alteredArgs.length > 2) reason = AbstractCommand.join(alteredArgs, 2);
if (args.length > 2) reason = AbstractCommand.join(args, 2);
else reason = "";
schedule(new Runnable() {
@Override
public void run() {
ban(sender, name, reason);
}
}, delay);
ban(sender, name, reason);
return true;
}
void ban(CommandSender sender, String name, String reason) {
Player player = DataManager.getPlayer(name);
if (player != null)
if (player != null){
player.kickPlayer(reason);
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(name);
offlinePlayer.setBanned(true);
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;
}
}

View File

@ -1,37 +1,33 @@
package fr.neatmonster.nocheatplus.command.actions;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
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.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
public class KickCommand extends DelayableCommand {
public class KickCommand extends BaseCommand {
public KickCommand(JavaPlugin plugin) {
super(plugin, "kick", Permissions.ADMINISTRATION_KICK);
}
@Override
public boolean execute(final CommandSender sender, Command command, String label,
String[] alteredArgs, long delay) {
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
// Args contains "kick" as first arg.
if (alteredArgs.length < 2) return false;
final String name = alteredArgs[1];
if (args.length < 2) return false;
final String name = args[1];
final String reason;
if (alteredArgs.length > 2) reason = AbstractCommand.join(alteredArgs, 2);
if (args.length > 2) reason = AbstractCommand.join(args, 2);
else reason = "";
schedule(new Runnable() {
@Override
public void run() {
kick(sender, name, reason);
}
}, delay);
kick(sender, name, reason);
return true;
}
@ -42,4 +38,13 @@ public class KickCommand extends DelayableCommand {
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;
}
}

View File

@ -1,12 +1,14 @@
package fr.neatmonster.nocheatplus.command.actions;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
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.players.DataManager;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
@ -16,24 +18,18 @@ import fr.neatmonster.nocheatplus.utilities.ColorUtil;
* @author mc_dev
*
*/
public class TellCommand extends DelayableCommand {
public class TellCommand extends BaseCommand {
public TellCommand(JavaPlugin plugin) {
super(plugin, "tell", Permissions.ADMINISTRATION_TELL);
}
@Override
public boolean execute(CommandSender sender, Command command, String label,
final String[] alteredArgs, long delay) {
if (alteredArgs.length < 3) return false;
final String name = alteredArgs[1].trim();
final String message = AbstractCommand.join(alteredArgs, 2);
schedule(new Runnable() {
@Override
public void run() {
tell(name, message);
}
}, delay);
public boolean onCommand(CommandSender sender, Command command, String label, final String[] args) {
if (args.length < 3) return false;
final String name = args[1].trim();
final String message = AbstractCommand.join(args, 2);
tell(name, message);
return true;
}
@ -42,4 +38,13 @@ public class TellCommand extends DelayableCommand {
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;
}
}

View File

@ -1,5 +1,7 @@
package fr.neatmonster.nocheatplus.command.actions;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -7,43 +9,36 @@ import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
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.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
public class TempKickCommand extends DelayableCommand {
public class TempKickCommand extends BaseCommand {
public TempKickCommand(JavaPlugin plugin) {
super(plugin, "tempkick", Permissions.ADMINISTRATION_TEMPKICK, new String[]{
"tkick", "tempban", "tban",
}, 1, -1, false);
super(plugin, "tempkick", Permissions.ADMINISTRATION_TEMPKICK,
new String[]{"tkick", "tempban", "tban",});
}
@Override
public boolean execute(final CommandSender sender, Command command, String label,
String[] alteredArgs, long delay) {
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
// Args contains sub command label as first arg.
if (alteredArgs.length < 3) return false;
if (args.length < 3) return false;
long base = 60000; // minutes (!)
final String name = alteredArgs[1];
final String name = args[1];
long duration = -1;
try{
// 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){};
if (duration <= 0) return false;
final long finalDuration = duration * base;
final String reason;
if (alteredArgs.length > 3) reason = AbstractCommand.join(alteredArgs, 3);
if (args.length > 3) reason = AbstractCommand.join(args, 3);
else reason = "";
schedule(new Runnable() {
@Override
public void run() {
tempKick(sender, name, finalDuration, reason);
}
}, delay);
tempKick(sender, name, finalDuration, reason);
return true;
}
@ -55,4 +50,14 @@ public class TempKickCommand extends DelayableCommand {
player.kickPlayer(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;
}
}

View File

@ -1,5 +1,7 @@
package fr.neatmonster.nocheatplus.command.actions;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
@ -30,4 +32,13 @@ public class UnKickCommand extends BaseCommand {
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;
}
}