From ee3a30d582dd29811765ee0417425d41284878ca Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 10 Apr 2020 12:20:43 -0400 Subject: [PATCH] Don't suggest default namespaces. This just ends adding a lot of `minecraft:` to otherwise short commands. (cherry picked from commit d2601851835201d11e5805250ecffc703d0b0cd6) --- .../com/sk89q/worldedit/command/util/SuggestionHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java index ed5e3aacb..cd6181a1f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java @@ -149,7 +149,8 @@ public final class SuggestionHelper { if (input.isEmpty() || input.equals(":")) { final Set namespaces = registry.getKnownNamespaces(); if (namespaces.size() == 1) { - return registry.keySet().stream(); + int def = namespaces.iterator().next().length() + 1; // default namespace length + ':' + return registry.keySet().stream().map(s -> s.substring(def)); } else { return namespaces.stream().map(s -> s + ":"); } @@ -164,7 +165,8 @@ public final class SuggestionHelper { // don't yet have namespace - search namespaces + default final String lowerSearch = input.toLowerCase(Locale.ROOT); String defKey = registry.getDefaultNamespace() + ":" + lowerSearch; - return Stream.concat(registry.keySet().stream().filter(s -> s.startsWith(defKey)), + int defLength = registry.getDefaultNamespace().length() + 1; + return Stream.concat(registry.keySet().stream().filter(s -> s.startsWith(defKey)).map(s -> s.substring(defLength)), registry.getKnownNamespaces().stream().filter(n -> n.startsWith(lowerSearch)).map(n -> n + ":")); } // have a namespace - search that