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

Don't use a no-op suggester

Dieser Commit ist enthalten in:
Matthew Miller 2019-05-19 13:49:37 +10:00
Ursprung a3ffb91917
Commit 4804fe64e3
12 geänderte Dateien mit 16 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -97,7 +97,7 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
@Override @Override
public List<String> getSuggestions(String input) { public List<String> getSuggestions(String input) {
return limitByPrefix(factoryExtractor.apply(worldEdit).getSuggestions(), input); return factoryExtractor.apply(worldEdit).getSuggestions(input);
} }
@Override @Override

Datei anzeigen

@ -201,7 +201,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
// TODO Include states // TODO Include states
return BlockType.REGISTRY.keySet().stream(); return BlockType.REGISTRY.keySet().stream();
} }

Datei anzeigen

@ -41,7 +41,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return ItemType.REGISTRY.keySet().stream(); return ItemType.REGISTRY.keySet().stream();
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class BiomeMaskParser extends InputParser<Mask> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return BiomeType.REGISTRY.keySet().stream().map(biomeType -> "$" + biomeType); return BiomeType.REGISTRY.keySet().stream().map(biomeType -> "$" + biomeType);
} }

Datei anzeigen

@ -38,7 +38,7 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str); return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str);
} }

Datei anzeigen

@ -43,8 +43,8 @@ public class BlocksMaskParser extends InputParser<Mask> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return worldEdit.getBlockFactory().getSuggestions(); return worldEdit.getBlockFactory().getSuggestions(input).stream();
} }
@Override @Override

Datei anzeigen

@ -40,7 +40,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str); return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str);
} }

Datei anzeigen

@ -40,7 +40,7 @@ public class ClipboardPatternParser extends InputParser<Pattern> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return Stream.of("#clipboard", "#copy"); return Stream.of("#clipboard", "#copy");
} }

Datei anzeigen

@ -36,8 +36,8 @@ public class SingleBlockPatternParser extends InputParser<Pattern> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return worldEdit.getBlockFactory().getSuggestions(); return worldEdit.getBlockFactory().getSuggestions(input).stream();
} }
@Override @Override

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.internal.registry; package com.sk89q.worldedit.internal.registry;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
@ -79,8 +80,8 @@ public abstract class AbstractFactory<E> {
throw new NoMatchException("No match for '" + input + "'"); throw new NoMatchException("No match for '" + input + "'");
} }
public Stream<String> getSuggestions() { public List<String> getSuggestions(String input) {
return parsers.stream().flatMap(InputParser::getSuggestions); return limitByPrefix(parsers.stream().flatMap(parser -> parser.getSuggestions(input)), input);
} }
/** /**

Datei anzeigen

@ -48,7 +48,7 @@ public abstract class InputParser<E> {
* *
* @return a stream of suggestions * @return a stream of suggestions
*/ */
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return Stream.empty(); return Stream.empty();
} }
} }

Datei anzeigen

@ -66,7 +66,7 @@ public abstract class SimpleInputParser<E> extends InputParser<E> {
} }
@Override @Override
public Stream<String> getSuggestions() { public Stream<String> getSuggestions(String input) {
return Stream.of(getPrimaryMatcher()); return Stream.of(getPrimaryMatcher());
} }
} }