Class SkriptEvent

All Implemented Interfaces:
Debuggable, SyntaxElement
Direct Known Subclasses:
SectionSkriptEvent, SelfRegisteringSkriptEvent, SimpleEvent

public abstract class SkriptEvent extends Structure
A SkriptEvent is like a condition. It is called when any of the registered events occurs. An instance of this class should then check whether the event applies (e.g. the rightclick event is included in the PlayerInteractEvent which also includes lefclicks, thus the SkriptEvent EvtClick checks whether it was a rightclick or not).
It is also needed if the event has parameters.
See Also:
  • Field Details

    • PRIORITY

      public static final Structure.Priority PRIORITY
    • eventPriority

      @Nullable protected @Nullable org.bukkit.event.EventPriority eventPriority
    • listeningBehavior

      @Nullable protected @Nullable SkriptEvent.ListeningBehavior listeningBehavior
    • supportsListeningBehavior

      protected boolean supportsListeningBehavior
    • trigger

      protected Trigger trigger
      The Trigger containing this SkriptEvent's code.
  • Constructor Details

    • SkriptEvent

      public SkriptEvent()
  • Method Details

    • init

      public final boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult, @Nullable @Nullable EntryContainer entryContainer)
      Description copied from class: Structure
      The initialization phase of a Structure. Typically, this should be used for preparing fields (e.g. handling arguments, parse tags) Logic such as trigger loading should be saved for a loading phase (e.g. Structure.load()).
      Specified by:
      init in class Structure
      Returns:
      Whether initialization was successful.
    • init

      public abstract boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult)
      Called just after the constructor
    • preLoad

      public boolean preLoad()
      This method handles the loading of the Structure's syntax elements. Only override this method if you know what you are doing!
      Overrides:
      preLoad in class Structure
      Returns:
      Whether preloading was successful. An error should be printed prior to returning false to specify the cause.
    • load

      public boolean load()
      This method handles the loading of the Structure's syntax elements. Only override this method if you know what you are doing!
      Specified by:
      load in class Structure
      Returns:
      Whether loading was successful. An error should be printed prior to returning false to specify the cause.
    • postLoad

      public boolean postLoad()
      This method handles the registration of this event with Skript and Bukkit. Only override this method if you know what you are doing!
      Overrides:
      postLoad in class Structure
      Returns:
      Whether postLoading was successful. An error should be printed prior to returning false to specify the cause.
    • unload

      public void unload()
      This method handles the unregistration of this event with Skript and Bukkit. Only override this method if you know what you are doing!
      Overrides:
      unload in class Structure
    • postUnload

      public void postUnload()
      This method handles the unregistration of this event with Skript and Bukkit. Only override this method if you know what you are doing!
      Overrides:
      postUnload in class Structure
    • getPriority

      public Structure.Priority getPriority()
      Description copied from class: Structure
      The priority of a Structure determines the order in which it should be loaded. For more information, see the javadoc of Structure.Priority.
      Overrides:
      getPriority in class Structure
      Returns:
      The priority of this Structure. By default, this is Structure.DEFAULT_PRIORITY.
    • check

      public abstract boolean check(org.bukkit.event.Event event)
      Checks whether the given Event applies, e.g. the left-click event is only part of the PlayerInteractEvent, and this checks whether the player left-clicked or not. This method will only be called for events this SkriptEvent is registered for.
      Returns:
      true if this is SkriptEvent is represented by the Bukkit Event or false if not
    • shouldLoadEvent

      public boolean shouldLoadEvent()
      Script loader checks this before loading items in event. If false is returned, they are not parsed and the event is not registered.
      Returns:
      If this event should be loaded.
    • getEventClasses

      public Class<? extends org.bukkit.event.Event>[] getEventClasses()
      Returns:
      the Event classes to use in ParserInstance.
    • getEventPriority

      public org.bukkit.event.EventPriority getEventPriority()
      Returns:
      the EventPriority to be used for this event. Defined by the user-specified priority, or otherwise the default event priority.
    • isEventPrioritySupported

      public boolean isEventPrioritySupported()
      Returns:
      whether this SkriptEvent supports event priorities
    • getListeningBehavior

      public SkriptEvent.ListeningBehavior getListeningBehavior()
      Returns:
      the SkriptEvent.ListeningBehavior to be used for this event. Defaults to the default listening behavior of the SkriptEventInfo for this SkriptEvent.
    • isListeningBehaviorSupported

      public boolean isListeningBehaviorSupported()
      Returns:
      whether this SkriptEvent supports listening behaviors
    • canExecuteAsynchronously

      public boolean canExecuteAsynchronously()
      Override this method to allow Skript to not force synchronization.
    • fixPattern

      public static String fixPattern(String pattern)
      Fixes patterns in event by modifying every TypePatternElement to be nullable.
    • parse

      @Nullable public static @Nullable SkriptEvent parse(String expr, SectionNode sectionNode, @Nullable @Nullable String defaultError)