Fully remove scarpet commands when apps are unloaded (#1452)

Using new Loader 0.14+ features
This commit is contained in:
altrisi authored and GitHub committed 2022-10-02 13:32:27 +02:00
1 parent e9f1509a1d
commit f63c6acb05
7 files changed
+69 -3

No files matched your search

@@ -1,6 +1,7 @@
package carpet.script;
import carpet.CarpetSettings;
import carpet.fakes.CommandDispatcherInterface;
import carpet.script.annotation.AnnotationParser;
import carpet.script.api.Auxiliary;
import carpet.script.api.BlockIterators;
@@ -343,6 +344,7 @@ public class CarpetScriptServer extends ScriptServer
events.removeAllHostEvents(modules.get(name));
modules.get(name).onClose();
modules.remove(name);
((CommandDispatcherInterface)server.getCommands().getDispatcher()).carpet$unregister(name);
if (!isRuleApp) unloadableModules.remove(name);
CommandHelper.notifyPlayersCommandsChanged(server);
if (notifySource) Messenger.m(source, "gi Removed "+name+" app");