3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-27 03:12:37 +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; package com.sk89q.worldedit.command.util;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -35,6 +36,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.sk89q.worldedit.util.command.CommandUtil.byCleanName; 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 final int perPage = actor instanceof Player ? 8 : 20; // More pages for console
if (commandPath.isEmpty()) { if (commandPath.isEmpty()) {
printAllCommands(page, perPage, manager.getAllCommands(), actor, true); printAllCommands(page, perPage, manager.getAllCommands(), actor, ImmutableList.of());
return; return;
} }
@ -117,11 +119,12 @@ public class PrintCommandHelp {
CommandUsageBox box = new CommandUsageBox(currentCommand, String.join(" ", visited)); CommandUsageBox box = new CommandUsageBox(currentCommand, String.join(" ", visited));
actor.print(box.create()); actor.print(box.create());
} else { } 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 // Get a list of aliases
List<Command> commands = commandStream List<Command> commands = commandStream
.sorted(byCleanName()) .sorted(byCleanName())
@ -147,7 +150,10 @@ public class PrintCommandHelp {
// Add each command // Add each command
for (Command mapping : list) { 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); TextComponent commandName = TextComponent.of(alias, TextColor.GOLD);
if (insertion != null) { if (insertion != null) {
commandName = commandName 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"))); .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")));
} }
getContents().append(commandName.append(TextComponent.of(": "))); getContents().append(commandName.append(TextComponent.of(": ")));