mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 04:26:42 +00:00
Added suggestions to a lot of factory-related commands
This commit is contained in:
@ -27,8 +27,11 @@ import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* An abstract implementation of a factory for internal usage.
|
||||
@ -76,6 +79,10 @@ public abstract class AbstractFactory<E> {
|
||||
throw new NoMatchException("No match for '" + input + "'");
|
||||
}
|
||||
|
||||
public Stream<String> getSuggestions() {
|
||||
return parsers.stream().flatMap(InputParser::getSuggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an InputParser to this factory
|
||||
*
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Input parser interface for {@link AbstractFactory}.
|
||||
@ -43,11 +44,11 @@ public abstract class InputParser<E> {
|
||||
public abstract E parseFromInput(String input, ParserContext context) throws InputParseException;
|
||||
|
||||
/**
|
||||
* Gets a list of suggestions of input to this parser.
|
||||
* Gets a stream of suggestions of input to this parser.
|
||||
*
|
||||
* @return a list of suggestions
|
||||
* @return a stream of suggestions
|
||||
*/
|
||||
public List<String> getSuggestions() {
|
||||
return Collections.emptyList();
|
||||
public Stream<String> getSuggestions() {
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* An input parser that only performs a single function from aliases.
|
||||
@ -65,7 +66,7 @@ public abstract class SimpleInputParser<E> extends InputParser<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions() {
|
||||
return Lists.newArrayList(getPrimaryMatcher());
|
||||
public Stream<String> getSuggestions() {
|
||||
return Stream.of(getPrimaryMatcher());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user