Fully remove scarpet commands when apps are unloaded (#1452)
Using new Loader 0.14+ features
This commit is contained in:
1 parent
e9f1509a1d
commit
f63c6acb05
7 files changed
+69
-3
No files matched your search
@@ -192,7 +192,7 @@ public class CarpetScriptHost extends ScriptHost
|
||||
String hostName = main.name();
|
||||
Predicate<CommandSourceStack> configValidator = getCommandConfigPermissions();
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal(hostName).
|
||||
requires((player) -> CarpetServer.scriptServer.modules.containsKey(hostName) && useValidator.test(player) && configValidator.test(player));
|
||||
requires((player) -> useValidator.test(player) && configValidator.test(player));
|
||||
for (Pair<List<CommandToken>,FunctionArgument> commandData : entries)
|
||||
{
|
||||
command = this.addPathToCommand(command, commandData.getKey(), commandData.getValue());
|
||||
@@ -472,7 +472,7 @@ public class CarpetScriptHost extends ScriptHost
|
||||
}
|
||||
String hostName = getName();
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal(hostName).
|
||||
requires((player) -> scriptServer().modules.containsKey(hostName) && commandValidator.test(player) && configValidator.test(player)).
|
||||
requires((player) -> commandValidator.test(player) && configValidator.test(player)).
|
||||
executes( (c) ->
|
||||
{
|
||||
CarpetScriptHost targetHost = scriptServer().modules.get(hostName).retrieveOwnForExecution(c.getSource());
|
||||
@@ -505,7 +505,7 @@ public class CarpetScriptHost extends ScriptHost
|
||||
{
|
||||
command = command.
|
||||
then(literal(function).
|
||||
requires((player) -> scriptServer().modules.containsKey(hostName) && scriptServer().modules.get(hostName).getFunction(function) != null).
|
||||
requires((player) -> scriptServer().modules.get(hostName).getFunction(function) != null).
|
||||
executes((c) -> {
|
||||
CarpetScriptHost targetHost = scriptServer().modules.get(hostName).retrieveOwnForExecution(c.getSource());
|
||||
Value response = targetHost.handleCommandLegacy(c.getSource(),function, null, "");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user