Execute commands delayed synchronous

This commit is contained in:
Evenprime 2012-01-04 14:25:44 +01:00
parent 655dae0d85
commit 83789e27c0

View File

@ -2,6 +2,7 @@ package cc.co.evenprime.bukkit.nocheat.checks;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandException; import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -72,15 +73,19 @@ public abstract class Check {
} }
private final void executeConsoleCommand(ConsolecommandAction action, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) { private final void executeConsoleCommand(ConsolecommandAction action, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) {
String command = ""; final String command = action.getCommand(player, check);
try { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
command = action.getCommand(player, check);
System.out.println("Going to execute command "+command); @Override
plugin.getServer().dispatchCommand(noCheatCommandSender, command); public void run() {
} catch(CommandException e) { try {
System.out.println("[NoCheat] failed to execute the command '" + command + "': " + e.getMessage() + ", please check if everything is setup correct. "); plugin.getServer().dispatchCommand(noCheatCommandSender, command);
} } catch(CommandException e) {
System.out.println("[NoCheat] failed to execute the command '" + command + "': " + e.getMessage() + ", please check if everything is setup correct.");
}
}
});
} }
public String getParameter(ParameterName wildcard, NoCheatPlayer player) { public String getParameter(ParameterName wildcard, NoCheatPlayer player) {