Class EventValues

java.lang.Object
ch.njol.skript.registrations.EventValues

public class EventValues extends Object
  • Field Details

    • TIME_PAST

      public static final int TIME_PAST
      The past time of an event value. Represented by "past" or "former".
      See Also:
    • TIME_NOW

      public static final int TIME_NOW
      The current time of an event value.
      See Also:
    • TIME_FUTURE

      public static final int TIME_FUTURE
      The future time of an event value.
      See Also:
  • 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 of TIME_PAST, TIME_NOW or TIME_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 type
      c - the type of the default value
      g - the getter to get the value
      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.
    • 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) or EventValueExpression(Class) instead of invoking this method repeatedly.

      Parameters:
      e - event
      c - return type of getter
      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.
      Returns:
      The event's value
      See Also:
    • getExactEventValueGetter

      public static <T, E extends org.bukkit.event.Event> @Nullable Getter<? extends T,? super E> getExactEventValueGetter(Class<E> event, Class<T> c, int time)
      Checks that a getter exists for the exact type. No converting or subclass checking.
      Parameters:
      event - the event class the getter will be getting from
      c - type of getter
      time - the event-value's time
      Returns:
      A getter to get values for a given type of events
      See Also:
    • getEventValueGetter

      public static <T, E extends org.bukkit.event.Event> @Nullable Getter<? extends T,? super E> getEventValueGetter(Class<E> event, 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:
      event - the event class the getter will be getting from
      c - type of getter
      time - the event-value's time
      Returns:
      A getter to get values for a given type of events
      See Also:
    • doesExactEventValueHaveTimeStates

      public static boolean doesExactEventValueHaveTimeStates(Class<? extends org.bukkit.event.Event> event, Class<?> c)
    • doesEventValueHaveTimeStates

      public static boolean doesEventValueHaveTimeStates(Class<? extends org.bukkit.event.Event> event, Class<?> c)