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

@@ -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, "");