From 83789e27c08e70419d4fe7b715cd52a0f64f9809 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Wed, 4 Jan 2012 14:25:44 +0100 Subject: [PATCH] Execute commands delayed synchronous --- .../bukkit/nocheat/checks/Check.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java b/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java index 5af3e6a8..2fe8d864 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java @@ -2,6 +2,7 @@ package cc.co.evenprime.bukkit.nocheat.checks; import java.util.Locale; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.CommandException; 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) { - String command = ""; + final String command = action.getCommand(player, check); - try { - command = action.getCommand(player, check); - System.out.println("Going to execute command "+command); - 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. "); - } + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + + @Override + public void run() { + try { + 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) {