From 2b0a4bab27c1d11493e17e52b007f48711a2b37b Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 28 Jun 2019 15:28:24 -0400 Subject: [PATCH] Change unknown selector to list to enable suggestions. --- .../sk89q/worldedit/command/SelectionCommands.java | 2 +- .../worldedit/command/argument/EnumConverter.java | 11 ++++++----- .../worldedit/command/argument/SelectorChoice.java | 2 +- 3 files changed, 8 insertions(+), 7 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 31aba51e9..da4e75681 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 @@ -582,7 +582,7 @@ public class SelectionCommands { limit.ifPresent(integer -> player.print(integer + " points maximum.")); break; } - case UNKNOWN: + case LIST: default: CommandListBox box = new CommandListBox("Selection modes", null); box.setHidingHelp(true); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java index 14a49b38c..41f8bae07 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java @@ -29,14 +29,15 @@ import org.enginehub.piston.inject.Key; import javax.annotation.Nullable; import java.util.EnumSet; +import java.util.Locale; import java.util.Set; import java.util.function.Function; -public class EnumConverter { +public final class EnumConverter { public static void register(CommandManager commandManager) { commandManager.registerConverter(Key.of(SelectorChoice.class), - basic(SelectorChoice.class, SelectorChoice.UNKNOWN)); + basic(SelectorChoice.class)); commandManager.registerConverter(Key.of(TreeGenerator.TreeType.class), full(TreeGenerator.TreeType.class, t -> ImmutableSet.copyOf(t.lookupKeys), @@ -48,11 +49,11 @@ public class EnumConverter { } private static > ArgumentConverter basic(Class enumClass) { - return full(enumClass, e -> ImmutableSet.of(e.name()), null); + return full(enumClass, e -> ImmutableSet.of(e.name().toLowerCase(Locale.ROOT)), null); } - private static > ArgumentConverter basic(Class enumClass, E unknownValue) { - return full(enumClass, e -> ImmutableSet.of(e.name()), unknownValue); + private static > ArgumentConverter basic(Class enumClass, @Nullable E unknownValue) { + return full(enumClass, e -> ImmutableSet.of(e.name().toLowerCase(Locale.ROOT)), unknownValue); } private static > ArgumentConverter full(Class enumClass, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SelectorChoice.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SelectorChoice.java index c17c71601..6a4b4b9ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SelectorChoice.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SelectorChoice.java @@ -29,5 +29,5 @@ public enum SelectorChoice { CONVEX, HULL, POLYHEDRON, - UNKNOWN + LIST }