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]
.
Additionally, Vanilla will ignore position data unless one of the following arguments is present:
Allresolve
methods have a look-alike named resolveForce
which always uses the given position data.
Modifier and Type | Method and Description |
---|---|
SelectorBuilder |
builder()
Returns a new
SelectorBuilder with the content of this selector. |
<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 . |
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)
|
Set<Entity> |
resolveForce(Collection<? extends Extent> extent)
|
Set<Entity> |
resolveForce(CommandSource origin)
Resolves this
Selector to a list of entities around the origin. |
Set<Entity> |
resolveForce(Extent... extent)
|
Set<Entity> |
resolveForce(Location<World> location)
|
String |
toPlain()
Converts this
Selector to a valid selector string. |
SelectorType 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
.Selector
boolean has(ArgumentType<?> type)
type
in this Selector
.type
- - The ArgumentType
to check fortrue
if the given type is present in this
Selector
, otherwise false
boolean 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 false
Set<Entity> resolve(CommandSource origin)
Selector
to a list of entities around the origin.origin
- The source that should be considered the origin of this
selectorSet<Entity> resolve(Extent... extent)
extent
- The extents to search for targetsSet<Entity> resolve(Collection<? extends Extent> extent)
extent
- The extents to search for targetsSet<Entity> resolve(Location<World> location)
location
- The location to resolve the selector aroundSet<Entity> resolveForce(CommandSource origin)
Selector
to a list of entities around the origin.origin
- The source that should be considered the origin of this
selectorSet<Entity> resolveForce(Extent... extent)
extent
- The extents to search for targetsSet<Entity> resolveForce(Collection<? extends Extent> extent)
extent
- The extents to search for targetsSet<Entity> resolveForce(Location<World> location)
location
- The location to resolve the selector aroundString toPlain()
Selector
to a valid selector string.Selector
string that can be inserted into a
commandSelectorBuilder builder()
SelectorBuilder
with the content of this selector.
This can be used to edit an immutable Selector
instance.