Class SkriptEvent

java.lang.Object
ch.njol.skript.lang.SkriptEvent
All Implemented Interfaces:
Debuggable, SyntaxElement
Direct Known Subclasses:
EvtBlock, EvtBlockLegacy, EvtBookEdit, EvtBookSign, EvtClick, EvtCommand, EvtDamage, EvtEntity, EvtEntityBlockChange, EvtEntityTarget, EvtFirework, EvtFirstJoin, EvtGameMode, EvtGrow, EvtItem, EvtLevel, EvtMove, EvtPlantGrowth, EvtPressurePlate, EvtResourcePackResponse, EvtTestCase, EvtWeatherChange, SectionSkriptEvent, SelfRegisteringSkriptEvent, SimpleEvent

public abstract class SkriptEvent extends Object implements SyntaxElement, Debuggable
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:
Skript.registerEvent(String, Class, Class, String...), Skript.registerEvent(String, Class, Class[], String...)
  • Constructor Details

    • SkriptEvent

      public SkriptEvent()
  • Method Details

    • init

      public final boolean init(Expression<?>[] vars, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
      Description copied from interface: SyntaxElement
      Called just after the constructor.
      Specified by:
      init in interface SyntaxElement
      Parameters:
      vars - all %expr%s included in the matching pattern in the order they appear in the pattern. If an optional value was left out it will still be included in this list holding the default value of the desired type which usually depends on the event.
      matchedPattern - The index of the pattern which matched
      isDelayed - Whether this expression is used after a delay or not (i.e. if the event has already passed when this expression will be called)
      parseResult - Additional information about the match.
      Returns:
      Whether this expression was initialised successfully. An error should be printed prior to returning false to specify the cause.
      See Also:
      ParserInstance.isCurrentEvent(Class...)
    • init

      public abstract boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult)
      called just after the constructor
      Parameters:
      args -
    • check

      public abstract boolean check(org.bukkit.event.Event e)
      Checks whether the given Event applies, e.g. the leftclick event is only part of the PlayerInteractEvent, and this checks whether the player leftclicked or not. This method will only be called for events this SkriptEvent is registered for.
      Parameters:
      e -
      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> @Nullable [] getEventClasses()
      Returns:
      the Event classes to use in ParserInstance, or null if the Event classes this SkriptEvent was registered with should be used.
    • toString

      public String toString()
      Description copied from interface: Debuggable
      Should return toString(null, false)
      Specified by:
      toString in interface Debuggable
      Overrides:
      toString in class Object
    • 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