public interface Selector
In Vanilla, selectors are mostly represented as plain text, starting with an
@ symbol and followed by a single character signifying the type, and
finally the (optional) arguments in brackets.
As an example, the all player selector is @a, and with a radius of
20 it would be @a[r=20].
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Selector.Builder |
| Modifier and Type | Method and Description |
|---|---|
static Selector.Builder |
builder()
Creates a
Selector.Builder. |
static List<String> |
complete(String selector)
Fetch completions for a selector command argument.
|
<T> Optional<T> |
get(ArgumentType<T> type)
Returns the argument value for the specified
ArgumentType in this
Selector. |
<T> Optional<Argument.Invertible<T>> |
getArgument(ArgumentType.Invertible<T> type)
|
<T> Optional<Argument<T>> |
getArgument(ArgumentType<T> type)
|
List<Argument<?>> |
getArguments()
Returns the arguments for this
Selector. |
SelectorType |
getType()
Returns the type of this
Selector. |
boolean |
has(ArgumentType<?> type)
Checks for the presence of
type in this Selector. |
boolean |
isInverted(ArgumentType.Invertible<?> type)
Checks for the inversion state of
type in this Selector. |
static Selector |
parse(String selector)
Parses a
Selector from the given selector string. |
Set<Entity> |
resolve(Collection<? extends Extent> extent)
|
Set<Entity> |
resolve(CommandSource origin)
Resolves this
Selector to a list of entities around the origin. |
Set<Entity> |
resolve(Extent... extent)
|
Set<Entity> |
resolve(Location<World> location)
|
default Set<Entity> |
resolveForce(Collection<? extends Extent> extent)
Deprecated.
|
default Set<Entity> |
resolveForce(CommandSource origin)
Deprecated.
|
default Set<Entity> |
resolveForce(Extent... extent)
Deprecated.
|
default Set<Entity> |
resolveForce(Location<World> location)
Deprecated.
|
Selector.Builder |
toBuilder()
Returns a new
Selector.Builder
with the content of this selector. |
String |
toPlain()
Converts this
Selector to a valid selector string. |
static Selector.Builder builder()
Selector.Builder.static Selector parse(String selector)
Selector from the given selector string.selector - The raw selector stringstatic List<String> complete(String selector)
selector - The partial selectorSelectorType getType()
Selector.<T> Optional<T> get(ArgumentType<T> type)
ArgumentType in this
Selector. May be used for ArgumentType.Invertible, but
the inverted state must be checked with
isInverted(ArgumentType.Invertible).T - The type of the valuetype - The argument type<T> Optional<Argument<T>> getArgument(ArgumentType<T> type)
T - The type of the argument valuetype - The argument type<T> Optional<Argument.Invertible<T>> getArgument(ArgumentType.Invertible<T> type)
T - The type of the argument valuetype - The argument typeList<Argument<?>> getArguments()
Selector.Selectorboolean has(ArgumentType<?> type)
type in this Selector.type - - The ArgumentType to check fortrue if the given type is present in this
Selector, otherwise falseboolean isInverted(ArgumentType.Invertible<?> type)
type in this Selector.type - - The invertible ArgumentType to check inversion
status ontrue if the given type is inverted in this
Selector, otherwise falseSet<Entity> resolve(CommandSource origin)
Selector to a list of entities around the origin.
The returned set may be ordered based on distance from the origin (with the nearest first).
origin - The source that should be considered the origin of this
selectorSet<Entity> resolve(Extent... extent)
Selector to a list of entities around (0|0|0) in
the given Extent(s).
The returned set may be ordered based on distance from the origin (with the nearest first).
extent - The extents to search for targetsSet<Entity> resolve(Collection<? extends Extent> extent)
Selector to a list of entities around (0|0|0) in
the given Extent(s).
The returned set may be ordered based on distance from the origin (with the nearest first).
extent - The extents to search for targetsSet<Entity> resolve(Location<World> location)
Selector to a list of entities around the given
Location.
The returned set may be ordered based on distance from the origin (with the nearest first).
location - The location to resolve the selector around@Deprecated default Set<Entity> resolveForce(CommandSource origin)
resolve(CommandSource)Selector to a list of entities around the origin.origin - The source that should be considered the origin of this
selector@Deprecated default Set<Entity> resolveForce(Extent... extent)
resolve(Extent[])extent - The extents to search for targets@Deprecated default Set<Entity> resolveForce(Collection<? extends Extent> extent)
resolve(Collection)extent - The extents to search for targets@Deprecated default Set<Entity> resolveForce(Location<World> location)
resolve(Location)location - The location to resolve the selector aroundString toPlain()
Selector to a valid selector string.Selector string that can be inserted into a
commandSelector.Builder toBuilder()
Selector.Builder
with the content of this selector. This can be used to edit an immutable
Selector instance.