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> event, Class<T> type, Getter<T,E> getter, int time)
      Registers an event value.
      Parameters:
      event - the event type class.
      type - the return type of the getter for the event value.
      getter - the getter to get the value with the provided event.
      time - value of TIME_PAST if this is the value before the event, 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> event, Class<T> type, Getter<T,E> getter, 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:
      event - the event type class.
      type - the return type of the getter for the event value.
      getter - the getter to get the value with the provided event.
      time - value of TIME_PAST if this is the value before the event, 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 event for which this event value should not be registered for
    • getEventValue

      @Nullable public static <T, E extends org.bukkit.event.Event> 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

      @Nullable 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:
    • hasMultipleGetters

      public static <T, E extends org.bukkit.event.Event> Kleenean hasMultipleGetters(Class<E> event, Class<T> type, int time)
      Checks if an event has multiple getters, including default ones.
      Parameters:
      event - the event class the getter will be getting from.
      type - type of getter.
      time - the event-value's time.
      Returns:
      true or false if the event and type have multiple getters.
    • getEventValueGetter

      @Nullable public static <T, E extends org.bukkit.event.Event> @Nullable Getter<? extends T,? super E> getEventValueGetter(Class<E> event, Class<T> type, 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.
      type - 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)