Update Upstream

b1c230d Add conditional checking in help command (1888)
b4fbbc9 Move clearable checks for Bukkit to adapters (1887)
This commit is contained in:
NotMyFault
2021-09-04 10:31:31 +02:00
parent cdc3abbc43
commit d236470df8
4 changed files with 29 additions and 33 deletions

View File

@ -30,6 +30,9 @@ import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.inject.MapBackedValueStore;
import java.util.ArrayList;
import java.util.List;
@ -48,6 +51,9 @@ import static java.util.stream.Collectors.toList;
// Stored in a separate class to prevent import conflicts, and because it's aliased via /we help.
public class PrintCommandHelp {
private PrintCommandHelp() {
}
private static Command detectCommand(CommandManager manager, String command) {
Optional<Command> mapping;
@ -140,8 +146,12 @@ public class PrintCommandHelp {
int page, Stream<Command> commandStream, Actor actor,
List<Command> commandList, String helpRootCommand
) throws InvalidComponentException {
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context ->
Optional.of(actor));
// Get a list of aliases
List<Command> commands = commandStream
.filter(command -> command.getCondition().satisfied(store))
.sorted(byCleanName())
.collect(toList());
@ -166,7 +176,4 @@ public class PrintCommandHelp {
actor.print(box.create(page));
}
private PrintCommandHelp() {
}
}