Package ch.njol.skript.registrations
Class EventValues
java.lang.Object
ch.njol.skript.registrations.EventValues
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordEventValues.EventValueInfo<E extends org.bukkit.event.Event,T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe future time of an event value.static final intThe current time of an event value.static final intThe past value of an event value. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandoesEventValueHaveTimeStates(Class<? extends org.bukkit.event.Event> eventClass, Class<?> valueClass) static booleandoesExactEventValueHaveTimeStates(Class<? extends org.bukkit.event.Event> eventClass, Class<?> valueClass) static <T,E extends org.bukkit.event.Event>
TgetEventValue(E event, Class<T> valueClass, int time) Gets a specific value from an eventClass.static <T,E extends org.bukkit.event.Event>
@Nullable Converter<? super E, ? extends T> getEventValueConverter(Class<E> eventClass, Class<T> valueClass, int time) Returns aConverterto get a value from in an event.static <T,E extends org.bukkit.event.Event>
@Nullable Getter<? extends T, ? super E> getEventValueGetter(Class<E> eventClass, Class<T> valueClass, int time) Deprecated, for removal: This API element is subject to removal in a future version.static List<EventValues.EventValueInfo<?, ?>> getEventValuesListForTime(int time) Get Event Values list for the specified timestatic <E extends org.bukkit.event.Event,T>
@Nullable Converter<? super E, ? extends T> getExactEventValueConverter(Class<E> eventClass, Class<T> valueClass, int time) Checks that aConverterexists for the exact type.static <T,E extends org.bukkit.event.Event>
@Nullable Getter<? extends T, ? super E> getExactEventValueGetter(Class<E> eventClass, Class<T> valueClass, int time) Deprecated, for removal: This API element is subject to removal in a future version.UsegetExactEventValueConverter(Class, Class, int)instead.static com.google.common.collect.Multimap<Class<? extends org.bukkit.event.Event>, EventValues.EventValueInfo<?, ?>> static int[]All supported time states for an event value.static <T,E extends org.bukkit.event.Event>
KleeneanhasMultipleConverters(Class<E> eventClass, Class<T> valueClass, int time) Checks if an event has multipleConverters, including default ones.static <T,E extends org.bukkit.event.Event>
KleeneanhasMultipleGetters(Class<E> eventClass, Class<T> valueClass, int time) Deprecated, for removal: This API element is subject to removal in a future version.UsehasMultipleConverters(Class, Class, int)instead.static <T,E extends org.bukkit.event.Event>
voidregisterEventValue(Class<E> eventClass, Class<T> valueClass, Getter<T, E> getter, int time) Deprecated, for removal: This API element is subject to removal in a future version.UseregisterEventValue(Class, Class, Converter, int)instead.static <T,E extends org.bukkit.event.Event>
voidregisterEventValue(Class<E> eventClass, Class<T> valueClass, Getter<T, E> getter, int time, @Nullable String excludeErrorMessage, @Nullable Class<? extends E>... excludes) Deprecated, for removal: This API element is subject to removal in a future version.static <T,E extends org.bukkit.event.Event>
voidregisterEventValue(Class<E> eventClass, Class<T> valueClass, Converter<E, T> converter) Registers an event value, specified by the providedConverter, with excluded events.static <T,E extends org.bukkit.event.Event>
voidregisterEventValue(Class<E> eventClass, Class<T> valueClass, Converter<E, T> converter, int time) Registers an event value.static <T,E extends org.bukkit.event.Event>
voidregisterEventValue(Class<E> eventClass, Class<T> valueClass, Converter<E, T> converter, int time, @Nullable String excludeErrorMessage, @Nullable Class<? extends E>... excludes) Registers an event value and with excluded events.
-
Field Details
-
TIME_PAST
public static final int TIME_PASTThe past value of an event value. Represented by "past" or "former".- See Also:
-
TIME_NOW
public static final int TIME_NOWThe current time of an event value.- See Also:
-
TIME_FUTURE
public static final int TIME_FUTUREThe future time of an event value.- See Also:
-
-
Method Details
-
getEventValuesListForTime
Get Event Values list for the specified time- Parameters:
time- The time of the event values. One ofTIME_PAST,TIME_NOWorTIME_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> eventClass, Class<T> valueClass, Converter<E, T> converter) Registers an event value, specified by the providedConverter, with excluded events. Uses the default time,TIME_NOW.- See Also:
-
registerEventValue
public static <T,E extends org.bukkit.event.Event> void registerEventValue(Class<E> eventClass, Class<T> valueClass, Converter<E, T> converter, int time) Registers an event value.- Parameters:
eventClass- the event class.valueClass- the return type of the converter for the event value.converter- the converter to get the value with the provided eventClass.time- value of TIME_PAST if this is the value before the eventClass, TIME_FUTURE if after, and TIME_NOW 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> eventClass, Class<T> valueClass, Converter<E, T> converter, int time, @Nullable @Nullable String excludeErrorMessage, @Nullable @Nullable Class<? extends E>... excludes) Registers an event value and with excluded events. Excluded events are events that this event value can't operate in.- Parameters:
eventClass- the event class.valueClass- the return type of the converter for the event value.converter- the converter to get the value with the provided eventClass.time- value of TIME_PAST if this is the value before the eventClass, TIME_FUTURE if after, and TIME_NOW 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.excludeErrorMessage- The error message to display when used in the excluded events.excludes- subclasses of the eventClass for which this event value should not be registered for
-
registerEventValue
@Deprecated(since="2.10.0", forRemoval=true) @SafeVarargs public static <T,E extends org.bukkit.event.Event> void registerEventValue(Class<E> eventClass, Class<T> valueClass, Getter<T, E> getter, int time, @Nullable @Nullable String excludeErrorMessage, @Nullable @Nullable Class<? extends E>... excludes) Deprecated, for removal: This API element is subject to removal in a future version. -
registerEventValue
@Deprecated(since="2.10.0", forRemoval=true) public static <T,E extends org.bukkit.event.Event> void registerEventValue(Class<E> eventClass, Class<T> valueClass, Getter<T, E> getter, int time) Deprecated, for removal: This API element is subject to removal in a future version.UseregisterEventValue(Class, Class, Converter, int)instead. -
getEventValue
@Nullable public static <T,E extends org.bukkit.event.Event> T getEventValue(E event, Class<T> valueClass, int time) Gets a specific value from an eventClass. Returns null if the eventClass 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:
event- eventClassvalueClass- return type of gettertime- -1 if this is the value before the eventClass, 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:
-
getExactEventValueGetter
@Nullable @Deprecated(since="2.10.0", forRemoval=true) public static <T,E extends org.bukkit.event.Event> @Nullable Getter<? extends T,? super E> getExactEventValueGetter(Class<E> eventClass, Class<T> valueClass, int time) Deprecated, for removal: This API element is subject to removal in a future version.UsegetExactEventValueConverter(Class, Class, int)instead. -
getExactEventValueConverter
@Nullable public static <E extends org.bukkit.event.Event,T> @Nullable Converter<? super E,? extends T> getExactEventValueConverter(Class<E> eventClass, Class<T> valueClass, int time) Checks that aConverterexists for the exact type. No converting or subclass checking.- Parameters:
eventClass- the event class the getter will be getting fromvalueClass- type ofConvertertime- the event-value's time- Returns:
- A getter to get values for a given type of events
- See Also:
-
hasMultipleGetters
@Deprecated(since="2.10.0", forRemoval=true) public static <T,E extends org.bukkit.event.Event> Kleenean hasMultipleGetters(Class<E> eventClass, Class<T> valueClass, int time) Deprecated, for removal: This API element is subject to removal in a future version.UsehasMultipleConverters(Class, Class, int)instead. -
hasMultipleConverters
public static <T,E extends org.bukkit.event.Event> Kleenean hasMultipleConverters(Class<E> eventClass, Class<T> valueClass, int time) Checks if an event has multipleConverters, including default ones. -
getEventValueGetter
@Nullable @Deprecated(since="2.10.0", forRemoval=true) public static <T,E extends org.bukkit.event.Event> @Nullable Getter<? extends T,? super E> getEventValueGetter(Class<E> eventClass, Class<T> valueClass, int time) Deprecated, for removal: This API element is subject to removal in a future version.UsegetEventValueConverter(Class, Class, int)instead. -
getEventValueConverter
@Nullable public static <T,E extends org.bukkit.event.Event> @Nullable Converter<? super E,? extends T> getEventValueConverter(Class<E> eventClass, Class<T> valueClass, int time) Returns aConverterto get a value from in an event.Can print an error if the event value is blocked for the given event.
-
doesExactEventValueHaveTimeStates
-
doesEventValueHaveTimeStates
-
getTimeStates
public static int[] getTimeStates()All supported time states for an event value.- Returns:
- An array of all the time states.
-
getPerEventEventValues
public static com.google.common.collect.Multimap<Class<? extends org.bukkit.event.Event>,EventValues.EventValueInfo<?, getPerEventEventValues()?>> - Returns:
- All the event values for each registered event's class.
-
getEventValueConverter(Class, Class, int)instead.