Package ch.njol.skript.lang.util
Class ConvertedKeyProviderExpression<F,T>
java.lang.Object
ch.njol.skript.lang.util.ConvertedExpression<F,T>
ch.njol.skript.lang.util.ConvertedKeyProviderExpression<F,T>
- All Implemented Interfaces:
Debuggable
,Expression<T>
,KeyProviderExpression<T>
,KeyReceiverExpression<T>
,Loopable<T>
,Simplifiable<Expression<? extends T>>
,SyntaxElement
public class ConvertedKeyProviderExpression<F,T>
extends ConvertedExpression<F,T>
implements KeyProviderExpression<T>, KeyReceiverExpression<T>
A
ConvertedExpression
that converts a keyed expression to another type with consideration of keys.
This expression is used when the source expression is a KeyProviderExpression
- See Also:
-
Field Summary
Fields inherited from class ch.njol.skript.lang.util.ConvertedExpression
source, to, toExact
-
Constructor Summary
ConstructorsConstructorDescriptionConvertedKeyProviderExpression
(KeyProviderExpression<? extends F> source, Class<T>[] toExact, Collection<ConverterInfo<? super F, ? extends T>> converterInfos, boolean performFromCheck) ConvertedKeyProviderExpression
(KeyProviderExpression<? extends F> source, Class<T> to, ConverterInfo<? super F, ? extends T> info) -
Method Summary
Modifier and TypeMethodDescriptionboolean
While all keyed expressions may offer their keys, some may prefer that they are not used unless strictly required (e.g.boolean
Returns whether this expression can return keys.void
change
(org.bukkit.event.Event event, Object @NotNull [] delta, Changer.ChangeMode mode, @NotNull String @NotNull [] keys) An alternative changer method that provides a set of keys as well as a set of values.T[]
getAll
(org.bukkit.event.Event event) Gets all possible return values of this expression, i.e.@NotNull String @NotNull []
getAllKeys
(org.bukkit.event.Event event) A set of keys, matching the length and order of the immediately-previousExpression.getAll(Event)
values array.T[]
getArray
(org.bukkit.event.Event event) Get all the values of this expression.@NotNull String @NotNull []
getArrayKeys
(org.bukkit.event.Event event) A set of keys, matching the length and order of the immediately-previousExpression.getArray(Event)
values array.KeyProviderExpression
<? extends F> Returns the original expression that was parsed, i.e.boolean
Checks whether the given 'loop-...' expression should match this loop, e.g.Methods inherited from class ch.njol.skript.lang.util.ConvertedExpression
acceptChange, beforeChange, change, check, check, getAnd, getConvertedExpression, getReturnType, getSingle, getTime, init, isDefault, isSingle, iterator, newInstance, possibleReturnTypes, setTime, simplify, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.Debuggable
toString, toString
Methods inherited from interface ch.njol.skript.lang.Expression
acceptChange, beforeChange, canBeSingle, canReturn, change, changeInPlace, changeInPlace, check, check, getAcceptedChangeModes, getAnd, getConvertedExpression, getOptionalSingle, getReturnType, getSingle, getSyntaxTypeName, getTime, isDefault, possibleReturnTypes, setTime, stream, streamAll
Methods inherited from interface ch.njol.skript.lang.KeyProviderExpression
isIndexLoop, isSingle, keyedIterator
Methods inherited from interface ch.njol.skript.lang.Loopable
iterator, supportsLoopPeeking
Methods inherited from interface ch.njol.skript.lang.simplification.Simplifiable
simplify
Methods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser, init, preInit
-
Constructor Details
-
ConvertedKeyProviderExpression
public ConvertedKeyProviderExpression(KeyProviderExpression<? extends F> source, Class<T> to, ConverterInfo<? super F, ? extends T> info) -
ConvertedKeyProviderExpression
public ConvertedKeyProviderExpression(KeyProviderExpression<? extends F> source, Class<T>[] toExact, Collection<ConverterInfo<? super F, ? extends T>> converterInfos, boolean performFromCheck)
-
-
Method Details
-
getArray
Description copied from interface:Expression
Get all the values of this expression. The returned array is empty if this expression doesn't have any values for the given event.The returned array must not contain any null values.
Do not use this in conditions, use
Expression.check(Event, Predicate, boolean)
instead.- Specified by:
getArray
in interfaceExpression<F>
- Overrides:
getArray
in classConvertedExpression<F,
T> - Parameters:
event
- The event- Returns:
- An array of values of this expression which must neither be null nor contain nulls, and which must not be an internal array.
-
getAll
Description copied from interface:Expression
Gets all possible return values of this expression, i.e. it returns the same asExpression.getArray(Event)
ifExpression.getAnd()
is true, otherwise all possible values forExpression.getSingle(Event)
.- Specified by:
getAll
in interfaceExpression<F>
- Overrides:
getAll
in classConvertedExpression<F,
T> - Parameters:
event
- The event- Returns:
- An array of all possible values of this expression for the given event which must neither be null nor contain nulls, and which must not be an internal array.
-
getSource
Description copied from interface:Expression
Returns the original expression that was parsed, i.e. without any conversions done.- Specified by:
getSource
in interfaceExpression<F>
- Overrides:
getSource
in classConvertedExpression<F,
T> - Returns:
- The unconverted source expression of this expression or this expression itself if it was never converted.
-
getArrayKeys
@NotNull public @NotNull String @NotNull [] getArrayKeys(org.bukkit.event.Event event) throws IllegalStateException Description copied from interface:KeyProviderExpression
A set of keys, matching the length and order of the immediately-previousExpression.getArray(Event)
values array.
This should only be called immediately after aExpression.getArray(Event)
invocation, and iffKeyProviderExpression.canReturnKeys()
returnstrue
. If it is called without a matching values request (or after a delay) then the behaviour is undefined, in which case:- the method may throw an error,
- the method may return keys not matching any previous values,
- or the method may return nothing at all.
- Specified by:
getArrayKeys
in interfaceKeyProviderExpression<F>
- Parameters:
event
- The event context- Returns:
- A set of keys, of the same length as
Expression.getArray(Event)
- Throws:
IllegalStateException
- If this was not called directly after aExpression.getArray(Event)
call or ifKeyProviderExpression.canReturnKeys()
returnsfalse
-
getAllKeys
Description copied from interface:KeyProviderExpression
A set of keys, matching the length and order of the immediately-previousExpression.getAll(Event)
values array.
This should only be called immediately after aExpression.getAll(Event)
invocation, and iffKeyProviderExpression.canReturnKeys()
returnstrue
. If it is called without a matching values request (or after a delay) then the behaviour is undefined, in which case:- the method may throw an error,
- the method may return keys not matching any previous values,
- or the method may return nothing at all.
- Specified by:
getAllKeys
in interfaceKeyProviderExpression<F>
- Parameters:
event
- The event context- Returns:
- A set of keys, of the same length as
Expression.getAll(Event)
-
canReturnKeys
public boolean canReturnKeys()Description copied from interface:KeyProviderExpression
Returns whether this expression can return keys.
If this returns false, thenKeyProviderExpression.getArrayKeys(Event)
andKeyProviderExpression.getAllKeys(Event)
should never be called.- Specified by:
canReturnKeys
in interfaceKeyProviderExpression<F>
- Returns:
- Whether this expression can return keys
-
areKeysRecommended
public boolean areKeysRecommended()Description copied from interface:KeyProviderExpression
While all keyed expressions may offer their keys, some may prefer that they are not used unless strictly required (e.g. variables).- Specified by:
areKeysRecommended
in interfaceKeyProviderExpression<F>
- Returns:
- Whether the caller is recommended to ask for keys after asking for values
-
change
public void change(org.bukkit.event.Event event, Object @NotNull [] delta, Changer.ChangeMode mode, @NotNull @NotNull String @NotNull [] keys) Description copied from interface:KeyReceiverExpression
An alternative changer method that provides a set of keys as well as a set of values. This is only ever called forChanger.ChangeMode.supportsKeyedChange()
safe change modes, where a set of values is provided. (This will never be called for valuelessChanger.ChangeMode.DELETE
orChanger.ChangeMode.RESET
changers, for example.)- Specified by:
change
in interfaceKeyReceiverExpression<F>
- Parameters:
event
- The current event contextdelta
- The change valuesmode
- The key-safe change modeChanger.ChangeMode.SET
keys
- The keys, matching the length and order of the values array
-
isLoopOf
Description copied from interface:Loopable
Checks whether the given 'loop-...' expression should match this loop, e.g. loop-block matches any loops that loop through blocks and loop-argument matches an argument loop.You should usually just return false as e.g. loop-block will automatically match the expression if its returnType is Block or a subtype of it.
- Specified by:
isLoopOf
in interfaceKeyProviderExpression<F>
- Specified by:
isLoopOf
in interfaceLoopable<F>
- Overrides:
isLoopOf
in classConvertedExpression<F,
T> - Parameters:
input
- The entered input string (the blank in loop-___)- Returns:
- Whether this loop matches the given string
-