Interface EventValue<E extends org.bukkit.event.Event,V>
public sealed interface EventValue<E extends org.bukkit.event.Event,V>
Describes a single "event value" available in a specific
Event context.
An event value provides a typed value (e.g. the player, entity, location) for a given event and
can optionally support changing that value via Skript's Changer API.
Each event value is identified by one or more textual identifier patterns that are matched against
user input (e.g. "player", "entity"). Resolution and lookup are handled by
EventValueRegistry.
Instances should be created using builder(Class, Class) and registered via
EventValueRegistry.register(EventValue).
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceEventValue.Builder<E extends org.bukkit.event.Event,V> A builder for creatingEventValueinstances.static interfaceEventValue.Changer<E extends org.bukkit.event.Event,V> A changer for applying modifications to the value for a given event instance.static interfaceEventValue.NoValueChanger<E extends org.bukkit.event.Event,V> A changer that does not require a value to be passed (e.g.static enumRepresents the time state an event value is registered for.static enumRepresents the validation status of an event value against an event context. -
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends org.bukkit.event.Event,V>
EventValue.Builder<E, V> Creates a new builder for anEventValue.changer(Changer.ChangeMode mode) Returns the changer for the specifiedChanger.ChangeMode, if present.The converter used to obtain the value from the event.The event class this value applies to.@Nullable StringAn optional error message shown when this value is excluded for a matching event.Event types explicitly excluded from using this event value.Obtains the value from the given event instance.<ConvertedEvent extends org.bukkit.event.Event,ConvertedValue>
@Nullable EventValue<ConvertedEvent, ConvertedValue> getConverted(Class<ConvertedEvent> newEventClass, Class<ConvertedValue> newValueClass) Returns a new event value that converts this value to a different value class, or uses a different event class.default <NewEvent extends org.bukkit.event.Event,NewValue>
@Nullable EventValue<NewEvent, NewValue> getConverted(Class<NewEvent> newEventClass, Class<NewValue> newValueClass, Converter<V, NewValue> converter) Returns a new event value that converts this value to a different value class using the provided converter.<NewEvent extends org.bukkit.event.Event,NewValue>
EventValue<NewEvent, NewValue> getConverted(Class<NewEvent> newEventClass, Class<NewValue> newValueClass, Converter<V, NewValue> converter, @Nullable Converter<NewValue, V> reverseConverter) Returns a new event value that converts this value to a different value class using the provided converter and reverse converter.booleanhasChanger(Changer.ChangeMode mode) Checks whether a changer is supported for the specifiedChanger.ChangeMode.default booleanChecks whether this event value matches the provided event class and value class.default booleanChecks whether this event value matches the provided event class, value class, and identifier patterns.default booleanmatches(EventValue<?, ?> eventValue) Checks whether this event value matches the provided event value in terms of event class, value class, and identifier patterns.booleanmatchesInput(String input) Checks whether the provided input matches one ofpatterns()and satisfies any additional input validation.String @Nullable []patterns()Patterns used to identify this event value from user input.static <E extends org.bukkit.event.Event,V>
EventValue<E, V> Creates a newEventValueusing a gettertime()The time state this event value is registered for.Validates that this event value can be used in the provided event context.The type of the value produced by this event value.
-
Method Details
-
builder
static <E extends org.bukkit.event.Event,V> EventValue.Builder<E,V> builder(Class<E> eventClass, Class<V> valueClass) Creates a new builder for anEventValue.- Parameters:
eventClass- the event type this value applies tovalueClass- the value type to produce- Returns:
- a builder to configure and build the event value
- See Also:
-
simple
static <E extends org.bukkit.event.Event,V> EventValue<E,V> simple(Class<E> eventClass, Class<V> valueClass, Converter<E, V> converter) Creates a newEventValueusing a getter- Parameters:
eventClass- the event type this value applied tovalueClass- the value type to produceconverter- the getter- Returns:
- the constructed event value
- See Also:
-
eventClass
The event class this value applies to.- Returns:
- the event type this event value is defined for
-
valueClass
The type of the value produced by this event value.- Returns:
- the value type
-
patterns
String @Nullable [] patterns()Patterns used to identify this event value from user input.- Returns:
- the patterns
-
validate
Validates that this event value can be used in the provided event context.- Parameters:
event- the concrete event class to validate against- Returns:
- the validation status
-
matchesInput
Checks whether the provided input matches one ofpatterns()and satisfies any additional input validation.- Parameters:
input- the identifier provided by the user- Returns:
trueif the validation succeeds
-
get
Obtains the value from the given event instance.- Parameters:
event- the event instance- Returns:
- the value obtained from the event, which may be
null
-
converter
The converter used to obtain the value from the event.- Returns:
- the converter
-
hasChanger
Checks whether a changer is supported for the specifiedChanger.ChangeMode.- Parameters:
mode- the change mode- Returns:
trueif a changer is supported
-
changer
Returns the changer for the specifiedChanger.ChangeMode, if present.- Parameters:
mode- the change mode- Returns:
- an
Optionalcontaining the changer if available
-
time
EventValue.Time time()The time state this event value is registered for.- Returns:
- the time state
-
excludedEvents
Event types explicitly excluded from using this event value.- Returns:
- an array of excluded event classes or
nullif none
-
excludedErrorMessage
An optional error message shown when this value is excluded for a matching event.- Returns:
- the exclusion error message or
null
-
matches
Checks whether this event value matches the provided event value in terms of event class, value class, and identifier patterns.- Parameters:
eventValue- the event value to compare against- Returns:
trueif they match
-
matches
default boolean matches(Class<? extends org.bukkit.event.Event> eventClass, Class<?> valueClass, String[] patterns) Checks whether this event value matches the provided event class, value class, and identifier patterns.- Parameters:
eventClass- the event class to compare againstvalueClass- the value class to compare againstpatterns- the patterns to compare against- Returns:
trueif they match
-
matches
Checks whether this event value matches the provided event class and value class.- Parameters:
eventClass- the event class to compare againstvalueClass- the value class to compare against- Returns:
trueif they match
-
getConverted
@Nullable <ConvertedEvent extends org.bukkit.event.Event,ConvertedValue> @Nullable EventValue<ConvertedEvent,ConvertedValue> getConverted(Class<ConvertedEvent> newEventClass, Class<ConvertedValue> newValueClass) Returns a new event value that converts this value to a different value class, or uses a different event class.This method attempts to find a suitable converter for the value classes automatically.
- Type Parameters:
ConvertedEvent- the new event typeConvertedValue- the new value type- Parameters:
newEventClass- the new event classnewValueClass- the new value class- Returns:
- a new converted event value, or
nullif no converter was found
-
getConverted
@Nullable default <NewEvent extends org.bukkit.event.Event,NewValue> @Nullable EventValue<NewEvent,NewValue> getConverted(Class<NewEvent> newEventClass, Class<NewValue> newValueClass, Converter<V, NewValue> converter) Returns a new event value that converts this value to a different value class using the provided converter.- Type Parameters:
NewEvent- the new event typeNewValue- the new value type- Parameters:
newEventClass- the new event classnewValueClass- the new value classconverter- the converter to use- Returns:
- a new converted event value
- See Also:
-
getConverted
<NewEvent extends org.bukkit.event.Event,NewValue> EventValue<NewEvent,NewValue> getConverted(Class<NewEvent> newEventClass, Class<NewValue> newValueClass, Converter<V, NewValue> converter, @Nullable @Nullable Converter<NewValue, V> reverseConverter) Returns a new event value that converts this value to a different value class using the provided converter and reverse converter.- Type Parameters:
NewEvent- the new event typeNewValue- the new value type- Parameters:
newEventClass- the new event classnewValueClass- the new value classconverter- the converter to use to obtain the new value typereverseConverter- the reverse converter to use for changing the value, if available- Returns:
- a new converted event value
-