Package ch.njol.skript.registrations
Class EventValues
java.lang.Object
ch.njol.skript.registrations.EventValues
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
The future time of an event value.static int
The current time of an event value.static int
The past time of an event value. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
doesEventValueHaveTimeStates(Class<? extends org.bukkit.event.Event> e, Class<?> c)
static <T, E extends org.bukkit.event.Event>
@Nullable TgetEventValue(E e, Class<T> c, int time)
Gets a specific value from an event.static <T, E extends org.bukkit.event.Event>
@Nullable Getter<? extends T,? super E>getEventValueGetter(Class<E> e, Class<T> c, int time)
Returns a getter to get a value from in an event.static List<ch.njol.skript.registrations.EventValues.EventValueInfo<?,?>>
getEventValuesListForTime(int time)
Get Event Values list for the specified timestatic <T, E extends org.bukkit.event.Event>
voidregisterEventValue(Class<E> e, Class<T> c, Getter<T,E> g, int time)
Registers an event value.static <T, E extends org.bukkit.event.Event>
void
-
Field Details
-
TIME_PAST
public static final int TIME_PASTThe past time of an event value. Represented by "past" or "former".- See Also:
- Constant Field Values
-
TIME_NOW
public static final int TIME_NOWThe current time of an event value.- See Also:
- Constant Field Values
-
TIME_FUTURE
public static final int TIME_FUTUREThe future time of an event value.- See Also:
- Constant Field Values
-
-
Method Details
-
getEventValuesListForTime
public static List<ch.njol.skript.registrations.EventValues.EventValueInfo<?,?>> getEventValuesListForTime(int time)Get Event Values list for the specified time- Parameters:
time
- The time of the event values. One ofTIME_PAST
,TIME_NOW
orTIME_FUTURE
.- Returns:
- An immutable copy of the event values list for the specified time
-
registerEventValue
public static <T, E extends org.bukkit.event.Event> void registerEventValue(Class<E> e, Class<T> c, Getter<T,E> g, int time)Registers an event value.- Parameters:
e
- the event typec
- the type of the default valueg
- the getter to get the valuetime
- -1 if this is the value before the event, 1 if after, and 0 if it's the default or this value doesn't have distinct states. Always register a default state! You can leave out one of the other states instead, e.g. only register a default and a past state. The future state will default to the default state in this case.
-
registerEventValue
@SafeVarargs public static <T, E extends org.bukkit.event.Event> void registerEventValue(Class<E> e, Class<T> c, Getter<T,E> g, int time, @Nullable String excludeErrorMessage, @Nullable Class<? extends E>... excludes)- Parameters:
e
-c
-g
-time
- -1 if this is the value before the event, 1 if after, and 0 if it's the default or this value doesn't have distinct states. Always register a default state! You can leave out one of the other states instead, e.g. only register a default and a past state. The future state will default to the default state in this case.excludes
- Subclasses of the event for which this event value should not be registered for
-
getEventValue
public static <T, E extends org.bukkit.event.Event> @Nullable T getEventValue(E e, Class<T> c, int time)Gets a specific value from an event. Returns null if the event doesn't have such a value (conversions are done to try and get the desired value).It is recommended to use
getEventValueGetter(Class, Class, int)
orEventValueExpression(Class)
instead of invoking this method repeatedly.- Parameters:
e
- eventc
- return type of gettertime
- -1 if this is the value before the event, 1 if after, and 0 if it's the default or this value doesn't have distinct states. Always register a default state! You can leave out one of the other states instead, e.g. only register a default and a past state. The future state will default to the default state in this case.- Returns:
- The event's value
- See Also:
registerEventValue(Class, Class, Getter, int)
-
getEventValueGetter
public static <T, E extends org.bukkit.event.Event> @Nullable Getter<? extends T,? super E> getEventValueGetter(Class<E> e, Class<T> c, int time)Returns a getter to get a value from in an event.Can print an error if the event value is blocked for the given event.
- Parameters:
e
- the event class the getter will be getting fromc
- type of gettertime
- the event-value's time- Returns:
- A getter to get values for a given type of events
- See Also:
registerEventValue(Class, Class, Getter, int)
,EventValueExpression(Class)
-
doesEventValueHaveTimeStates
-