Fix unchecked removal of commands by app name
This commit is contained in:
1 parent
c9c1e5a4dc
commit
fb7b1f79a5
2 files changed
+13
-5
No files matched your search
@@ -83,6 +83,7 @@ public class CarpetScriptHost extends ScriptHost
|
||||
Predicate<CommandSourceStack> commandValidator;
|
||||
boolean isRuleApp;
|
||||
public AppStoreManager.StoreNode storeSource;
|
||||
boolean hasCommand;
|
||||
|
||||
private CarpetScriptHost(CarpetScriptServer server, Module code, boolean perUser, ScriptHost parent, Map<Value, Value> config, Map<String, CommandArgument> argTypes, Predicate<CommandSourceStack> commandValidator, boolean isRuleApp)
|
||||
{
|
||||
@@ -358,6 +359,12 @@ public class CarpetScriptHost extends ScriptHost
|
||||
}
|
||||
}
|
||||
|
||||
// Used to ensure app gets marked as holding command from a central place
|
||||
private void registerCommand(LiteralArgumentBuilder<CommandSourceStack> command) {
|
||||
scriptServer().server.getCommands().getDispatcher().register(command);
|
||||
hasCommand = true;
|
||||
}
|
||||
|
||||
public void readCustomArgumentTypes() throws CommandSyntaxException
|
||||
{
|
||||
// read custom arguments
|
||||
@@ -401,7 +408,7 @@ public class CarpetScriptHost extends ScriptHost
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = readCommands(commandValidator);
|
||||
if (command != null)
|
||||
{
|
||||
scriptServer().server.getCommands().getDispatcher().register(command);
|
||||
registerCommand(command);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -523,7 +530,7 @@ public class CarpetScriptHost extends ScriptHost
|
||||
})));
|
||||
}
|
||||
}
|
||||
scriptServer().server.getCommands().getDispatcher().register(command);
|
||||
registerCommand(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,9 +341,10 @@ public class CarpetScriptServer extends ScriptServer
|
||||
return false;
|
||||
}
|
||||
// stop all events associated with name
|
||||
events.removeAllHostEvents(modules.get(name));
|
||||
modules.get(name).onClose();
|
||||
modules.remove(name);
|
||||
CarpetScriptHost host = modules.remove(name);
|
||||
events.removeAllHostEvents(host);
|
||||
host.onClose();
|
||||
if (host.hasCommand)
|
||||
((CommandDispatcherInterface)server.getCommands().getDispatcher()).carpet$unregister(name);
|
||||
if (!isRuleApp) unloadableModules.remove(name);
|
||||
CommandHelper.notifyPlayersCommandsChanged(server);
|
||||
|
||||
Reference in new issue
Block a user