Don't suggest default namespaces.

This just ends adding a lot of `minecraft:` to otherwise short commands.

(cherry picked from commit d2601851835201d11e5805250ecffc703d0b0cd6)
This commit is contained in:
wizjany 2020-04-10 12:20:43 -04:00 committed by MattBDev
parent 396b03edf7
commit ee3a30d582

View File

@ -149,7 +149,8 @@ public final class SuggestionHelper {
if (input.isEmpty() || input.equals(":")) {
final Set<String> 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