From 8baf221c954534b04934f3ad531cb439937b8894 Mon Sep 17 00:00:00 2001 From: wizjany Date: Mon, 29 Apr 2019 17:38:26 -0400 Subject: [PATCH] Hide help buttons in //sel selector box. --- .../worldedit/command/SelectionCommands.java | 1 + .../formatting/component/CommandListBox.java | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index 8a62dc529..bac02819a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -619,6 +619,7 @@ public class SelectionCommands { case UNKNOWN: default: CommandListBox box = new CommandListBox("Selection modes", null); + box.setHidingHelp(true); TextComponentProducer contents = box.getContents(); contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java index 4c08f6863..e1b889059 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java @@ -31,6 +31,7 @@ import java.util.List; public class CommandListBox extends PaginationBox { private List commands = Lists.newArrayList(); + private boolean hideHelp; /** * Create a new box. @@ -43,7 +44,7 @@ public class CommandListBox extends PaginationBox { @Override public Component getComponent(int number) { - return commands.get(number).createComponent(); + return commands.get(number).createComponent(hideHelp); } @Override @@ -63,6 +64,14 @@ public class CommandListBox extends PaginationBox { commands.add(new CommandEntry(alias, description, insertion)); } + public boolean isHidingHelp() { + return hideHelp; + } + + public void setHidingHelp(boolean hideHelp) { + this.hideHelp = hideHelp; + } + private static class CommandEntry { private final String alias; private final Component description; @@ -74,11 +83,13 @@ public class CommandListBox extends PaginationBox { this.insertion = insertion; } - Component createComponent() { + Component createComponent(boolean hideHelp) { TextComponentProducer line = new TextComponentProducer(); - line.append(SubtleFormat.wrap("? ") - .clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "//help " + insertion)) - .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Additional Help")))); + if (!hideHelp) { + line.append(SubtleFormat.wrap("? ") + .clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "//help " + insertion)) + .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Additional Help")))); + } TextComponent command = TextComponent.of(alias, TextColor.GOLD); if (insertion == null) { line.append(command);