Permalink
Browse files

Update list of commands for players and commandblocks upon register_c…

…ommand()
  • Loading branch information...
PseudoKnight committed Aug 23, 2018
1 parent a42c09c commit 36ee1339a1d700094acf9916ce6c8474ef2dde50
@@ -6,6 +6,10 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.laytonsmith.commandhelper.CommandHelperPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
@@ -52,12 +56,22 @@ public MCCommand getCommand(String name) {
@Override
public boolean register(String fallback, MCCommand cmd) {
return scm.register(fallback, ((BukkitMCCommand) cmd).cmd);
boolean success = scm.register(fallback, ((BukkitMCCommand) cmd).cmd);
if(!CommandHelperPlugin.self.isFirstLoad()) {
Server s = Bukkit.getServer();
ReflectionUtils.invokeMethod(s.getClass(), s, "syncCommands");
}
return success;
}
@Override
public boolean register(String label, String fallback, MCCommand cmd) {
return scm.register(label, fallback, ((BukkitMCCommand) cmd).cmd);
boolean success = scm.register(label, fallback, ((BukkitMCCommand) cmd).cmd);
if(!CommandHelperPlugin.self.isFirstLoad()) {
Server s = Bukkit.getServer();
ReflectionUtils.invokeMethod(s.getClass(), s, "syncCommands");
}
return success;
}
@SuppressWarnings("unchecked")
@@ -110,7 +110,7 @@
public final ExecutionQueue executionQueue = new MethodScriptExecutionQueue("CommandHelperExecutionQueue", "default");
public PersistenceNetwork persistenceNetwork;
public Profiles profiles;
//public boolean firstLoad = true;
private boolean firstLoad = true;
public long interpreterUnlockedUntil = 0;
private Thread loadingThread;
/**
@@ -364,7 +364,7 @@ public Integer call() throws Exception {
CommandHelperFileLocations.getDefault().getLocalPackagesDirectory(),
CommandHelperFileLocations.getDefault().getPreferencesFile(),
new File(CommandHelperFileLocations.getDefault().getConfigDirectory(), mainFile), this);
ac.reload(null, null, true);
ac.reload(null, null, this.firstLoad);
//Clear out our hostname cache
hostnameLookupCache = new ConcurrentHashMap<>();
@@ -396,9 +396,15 @@ public Thread newThread(Runnable r) {
playerListener.loadGlobalAliases();
interpreterListener.reload();
firstLoad = false;
Static.getLogger().log(Level.INFO, "[CommandHelper] CommandHelper {0} enabled", getDescription().getVersion());
}
public boolean isFirstLoad() {
return this.firstLoad;
}
public static AliasCore getCore() {
return ac;
}

0 comments on commit 36ee133

Please sign in to comment.