Fix unchecked removal of commands by app name
This commit is contained in:
1 parent
c9c1e5a4dc
commit
fb7b1f79a5
2 files changed
+14
-6
No files matched your search
@@ -83,6 +83,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
Predicate<CommandSourceStack> commandValidator;
|
Predicate<CommandSourceStack> commandValidator;
|
||||||
boolean isRuleApp;
|
boolean isRuleApp;
|
||||||
public AppStoreManager.StoreNode storeSource;
|
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)
|
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
|
public void readCustomArgumentTypes() throws CommandSyntaxException
|
||||||
{
|
{
|
||||||
// read custom arguments
|
// read custom arguments
|
||||||
@@ -401,7 +408,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
LiteralArgumentBuilder<CommandSourceStack> command = readCommands(commandValidator);
|
LiteralArgumentBuilder<CommandSourceStack> command = readCommands(commandValidator);
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
scriptServer().server.getCommands().getDispatcher().register(command);
|
registerCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -523,7 +530,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scriptServer().server.getCommands().getDispatcher().register(command);
|
registerCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -341,10 +341,11 @@ public class CarpetScriptServer extends ScriptServer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// stop all events associated with name
|
// stop all events associated with name
|
||||||
events.removeAllHostEvents(modules.get(name));
|
CarpetScriptHost host = modules.remove(name);
|
||||||
modules.get(name).onClose();
|
events.removeAllHostEvents(host);
|
||||||
modules.remove(name);
|
host.onClose();
|
||||||
((CommandDispatcherInterface)server.getCommands().getDispatcher()).carpet$unregister(name);
|
if (host.hasCommand)
|
||||||
|
((CommandDispatcherInterface)server.getCommands().getDispatcher()).carpet$unregister(name);
|
||||||
if (!isRuleApp) unloadableModules.remove(name);
|
if (!isRuleApp) unloadableModules.remove(name);
|
||||||
CommandHelper.notifyPlayersCommandsChanged(server);
|
CommandHelper.notifyPlayersCommandsChanged(server);
|
||||||
if (notifySource) Messenger.m(source, "gi Removed "+name+" app");
|
if (notifySource) Messenger.m(source, "gi Removed "+name+" app");
|
||||||
|
|||||||
Reference in new issue
Block a user