3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Fix help command suggestion

Dieser Commit ist enthalten in:
Kenzie Togami 2019-04-25 23:02:23 -07:00
Ursprung 8348ffa7cf
Commit 2486388e18
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 5D200B325E157A81
2 geänderte Dateien mit 11 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.util;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
@ -35,6 +36,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.sk89q.worldedit.util.command.CommandUtil.byCleanName;
@ -77,7 +79,7 @@ public class PrintCommandHelp {
final int perPage = actor instanceof Player ? 8 : 20; // More pages for console
if (commandPath.isEmpty()) {
printAllCommands(page, perPage, manager.getAllCommands(), actor, true);
printAllCommands(page, perPage, manager.getAllCommands(), actor, ImmutableList.of());
return;
}
@ -117,11 +119,12 @@ public class PrintCommandHelp {
CommandUsageBox box = new CommandUsageBox(currentCommand, String.join(" ", visited));
actor.print(box.create());
} else {
printAllCommands(page, perPage, subCommands.values().stream(), actor, false);
printAllCommands(page, perPage, subCommands.values().stream(), actor, visited);
}
}
private static void printAllCommands(int page, int perPage, Stream<Command> commandStream, Actor actor, boolean isRootLevel) {
private static void printAllCommands(int page, int perPage, Stream<Command> commandStream, Actor actor,
List<String> commandList) {
// Get a list of aliases
List<Command> commands = commandStream
.sorted(byCleanName())
@ -147,7 +150,10 @@ public class PrintCommandHelp {
// Add each command
for (Command mapping : list) {
box.appendCommand((isRootLevel ? "/" : "") + mapping.getName(), mapping.getDescription());
String alias = (commandList.isEmpty() ? "/" : "") + mapping.getName();
String command = Stream.concat(commandList.stream(), Stream.of(mapping.getName()))
.collect(Collectors.joining(" ", "/", ""));
box.appendCommand(alias, mapping.getDescription(), command);
}
}

Datei anzeigen

@ -53,7 +53,7 @@ public class CommandListBox extends MessageBox {
TextComponent commandName = TextComponent.of(alias, TextColor.GOLD);
if (insertion != null) {
commandName = commandName
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, insertion))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, insertion))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")));
}
getContents().append(commandName.append(TextComponent.of(": ")));