Interface EventValueRegistry

All Superinterfaces:
Iterable<EventValue<?,?>>, Registry<EventValue<?,?>>, ViewProvider<EventValueRegistry>

public interface EventValueRegistry extends Registry<EventValue<?,?>>, ViewProvider<EventValueRegistry>
Registry and resolver for EventValue definitions.

Use this registry to register, unregister and resolve event values by identifier text or by desired value type. Resolution prefers the closest matching event type and, optionally, can fall back to default time state and/or allow value-type conversion.

Obtain an instance using SkriptAddon#registry(EventValueRegistry.class).
Or an unmodifiable view using Skript.instance().registry(EventValueRegistry.class).

  • Method Details

    • empty

      static EventValueRegistry empty(Skript skript)
      Creates an empty event value registry.
      Parameters:
      skript - the Skript instance
      Returns:
      a new empty event value registry
    • register

      <E extends org.bukkit.event.Event> void register(EventValue<E,?> eventValue)
      Registers a new EventValue.
      Type Parameters:
      E - the event type
      Parameters:
      eventValue - the event value to register
      Throws:
      SkriptAPIException - if another value with the same event class, value class, time, and identifier patterns already exists
    • unregister

      boolean unregister(EventValue<?,?> eventValue)
      Unregisters the given event value.
      Parameters:
      eventValue - the event value to unregister
      Returns:
      true if the value was removed
    • isRegistered

      boolean isRegistered(EventValue<?,?> eventValue)
      Checks whether an equivalent event value is already registered.
      Parameters:
      eventValue - the event value to check for
      Returns:
      true if an equivalent event value is registered
    • isRegistered

      boolean isRegistered(Class<? extends org.bukkit.event.Event> eventClass, Class<?> valueClass, EventValue.Time time)
      Checks whether a value for the exact event/value class and time is registered.
      Parameters:
      eventClass - the event class to check for
      valueClass - the value class to check for
      time - the time state to check for
      Returns:
      true if a value is registered for the given parameters
    • resolve

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> resolve(Class<E> eventClass, String identifier)
      Type Parameters:
      E - the event type
      V - the expected value type
      Parameters:
      eventClass - the event type to resolve for
      identifier - user input that identifies the value
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
      See Also:
    • resolve

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> resolve(Class<E> eventClass, String identifier, EventValue.Time time)
      Resolve an EventValue by identifier for a specific time using EventValueRegistry.Flags.DEFAULT.
      Type Parameters:
      E - the event type
      V - the expected value type
      Parameters:
      eventClass - the event type to resolve for
      identifier - user input that identifies the value
      time - the time state
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
      See Also:
    • resolve

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> resolve(Class<E> eventClass, String identifier, EventValue.Time time, EventValueRegistry.Flags flags)
      Resolve an EventValue by identifier with explicit time and flags.
      Type Parameters:
      E - the event type
      V - the expected value type
      Parameters:
      eventClass - the event type to resolve for
      identifier - user input that identifies the value
      time - the time state
      flags - the resolver flags
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
    • resolve

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,? extends V> resolve(Class<E> eventClass, Class<V> valueClass)
      Resolves by desired value class using EventValue.Time.NOW and EventValueRegistry.Flags.DEFAULT.
      Type Parameters:
      E - the event type
      V - the desired value type
      Parameters:
      eventClass - the event type to resolve for
      valueClass - the desired value type
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
    • resolve

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,? extends V> resolve(Class<E> eventClass, Class<V> valueClass, EventValue.Time time)
      Resolves by desired value class for a specific time using EventValueRegistry.Flags.DEFAULT.
      Type Parameters:
      E - the event type
      V - the desired value type
      Parameters:
      eventClass - the event type to resolve for
      valueClass - the desired value type
      time - the time state
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
    • resolve

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,? extends V> resolve(Class<E> eventClass, Class<V> valueClass, EventValue.Time time, EventValueRegistry.Flags flags)
      Resolves by desired value class with explicit time and flags.
      Type Parameters:
      E - the event type
      V - the desired value type
      Parameters:
      eventClass - the event type to resolve for
      valueClass - the desired value type
      time - the time state
      flags - the resolver flags
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
    • resolveExact

      <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> resolveExact(Class<E> eventClass, Class<V> valueClass, EventValue.Time time)
      Resolves only exact value-class matches, choosing the nearest compatible event class.
      Type Parameters:
      E - the event type
      V - the value type
      Parameters:
      eventClass - the event type to resolve for
      valueClass - the exact value type to match
      time - the time state
      Returns:
      a EventValueRegistry.Resolution describing candidates or empty/error state
    • elements

      @Unmodifiable List<EventValue<?,?>> elements()
      Returns all registered event values at all time states.
      Specified by:
      elements in interface Registry<EventValue<?,?>>
      Returns:
      an unmodifiable list of all registered event values
    • elements

      @Unmodifiable List<EventValue<?,?>> elements(EventValue.Time time)
      Returns a snapshot of event values for the given time state.
      Parameters:
      time - the time state
      Returns:
      an unmodifiable list of event values for the given time state
    • elements

      <E extends org.bukkit.event.Event> @Unmodifiable List<EventValue<? extends E,?>> elements(Class<E> event)
      Returns a snapshot of the direct (subevents only) event values for the given event.
      For example, getting the event values of EntityDeathEvent will return the event values registered under EntityDeathEvent and PlayerDeathEvent, but not EntityEvent.
      Parameters:
      event - the event
      Returns:
      an unmodifiable list of event values for the given event
    • unmodifiableView

      default EventValueRegistry unmodifiableView()
      Description copied from interface: ViewProvider
      Constructs an unmodifiable view of this.
      Specified by:
      unmodifiableView in interface ViewProvider<EventValueRegistry>
      Returns:
      an unmodifiable view of this registry