3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Don't suggest default namespaces.

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

(cherry picked from commit d2601851835201d11e5805250ecffc703d0b0cd6)
Dieser Commit ist enthalten in:
wizjany 2020-04-10 12:20:43 -04:00 committet von MattBDev
Ursprung 396b03edf7
Commit ee3a30d582

Datei anzeigen

@ -149,7 +149,8 @@ public final class SuggestionHelper {
if (input.isEmpty() || input.equals(":")) { if (input.isEmpty() || input.equals(":")) {
final Set<String> namespaces = registry.getKnownNamespaces(); final Set<String> namespaces = registry.getKnownNamespaces();
if (namespaces.size() == 1) { 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 { } else {
return namespaces.stream().map(s -> s + ":"); return namespaces.stream().map(s -> s + ":");
} }
@ -164,7 +165,8 @@ public final class SuggestionHelper {
// don't yet have namespace - search namespaces + default // don't yet have namespace - search namespaces + default
final String lowerSearch = input.toLowerCase(Locale.ROOT); final String lowerSearch = input.toLowerCase(Locale.ROOT);
String defKey = registry.getDefaultNamespace() + ":" + lowerSearch; 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 + ":")); registry.getKnownNamespaces().stream().filter(n -> n.startsWith(lowerSearch)).map(n -> n + ":"));
} }
// have a namespace - search that // have a namespace - search that