Few misc command fixes.

This commit is contained in:
wizjany
2019-06-01 07:41:19 -04:00
parent 9099a17fe5
commit 1e7c074217
7 changed files with 44 additions and 28 deletions

View File

@ -80,10 +80,7 @@ class BukkitCommandInspector implements CommandInspector {
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context ->
Optional.of(plugin.wrapCommandSender(sender)));
CommandParameters parameters = NoInputCommandParameters.builder()
.injectedValues(MemoizingValueAccess.wrap(store))
.build();
return mapping.get().getCondition().satisfied(parameters);
return mapping.get().getCondition().satisfied(store);
} else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return false;

View File

@ -77,14 +77,11 @@ public class WorldEditListener implements Listener {
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context ->
Optional.of(plugin.wrapCommandSender(event.getPlayer())));
CommandParameters parameters = NoInputCommandParameters.builder()
.injectedValues(MemoizingValueAccess.wrap(store))
.build();
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager();
event.getCommands().removeIf(name ->
// remove if in the manager and not satisfied
commandManager.getCommand(name)
.filter(command -> !command.getCondition().satisfied(parameters))
.filter(command -> !command.getCondition().satisfied(store))
.isPresent()
);
}