Package ch.njol.skript.lang
Class SkriptEvent
java.lang.Object
org.skriptlang.skript.lang.structure.Structure
ch.njol.skript.lang.SkriptEvent
- All Implemented Interfaces:
Debuggable
,SyntaxElement
- Direct Known Subclasses:
SectionSkriptEvent
,SelfRegisteringSkriptEvent
,SimpleEvent
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
It is also needed if the event has parameters.
EvtClick
checks whether it was a rightclick or
not).It is also needed if the event has parameters.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The listening behavior of a Skript event.Nested classes/interfaces inherited from class org.skriptlang.skript.lang.structure.Structure
Structure.Priority, Structure.StructureData
-
Field Summary
Modifier and TypeFieldDescriptionprotected @Nullable org.bukkit.event.EventPriority
protected @Nullable SkriptEvent.ListeningBehavior
static final Structure.Priority
protected boolean
protected Trigger
The Trigger containing this SkriptEvent's code.Fields inherited from class org.skriptlang.skript.lang.structure.Structure
DEFAULT_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Override this method to allow Skript to not force synchronization.abstract boolean
check
(org.bukkit.event.Event event) Checks whether the given Event applies, e.g.static String
fixPattern
(String pattern) Fixes patterns in event by modifying everyTypePatternElement
to be nullable.Class<? extends org.bukkit.event.Event>[]
org.bukkit.event.EventPriority
The priority of a Structure determines the order in which it should be loaded.abstract boolean
init
(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult) Called just after the constructorfinal boolean
init
(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult, @Nullable EntryContainer entryContainer) The initialization phase of a Structure.boolean
boolean
boolean
load()
This method handles the loading of the Structure's syntax elements.static @Nullable SkriptEvent
parse
(String expr, SectionNode sectionNode, @Nullable String defaultError) boolean
postLoad()
This method handles the registration of this event with Skript and Bukkit.void
This method handles the unregistration of this event with Skript and Bukkit.boolean
preLoad()
This method handles the loading of the Structure's syntax elements.boolean
Script loader checks this before loading items in event.void
unload()
This method handles the unregistration of this event with Skript and Bukkit.Methods inherited from class org.skriptlang.skript.lang.structure.Structure
getEntryContainer, init, parse, parse, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.Debuggable
toString
Methods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser
-
Field Details
-
PRIORITY
-
eventPriority
@Nullable protected @Nullable org.bukkit.event.EventPriority eventPriority -
listeningBehavior
-
supportsListeningBehavior
protected boolean supportsListeningBehavior -
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()
). -
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! -
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! -
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! -
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! -
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 classStructure
-
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 ofStructure.Priority
.- Overrides:
getPriority
in classStructure
- 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
- 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
- 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
Fixes patterns in event by modifying everyTypePatternElement
to be nullable. -
parse
@Nullable public static @Nullable SkriptEvent parse(String expr, SectionNode sectionNode, @Nullable @Nullable String defaultError)
-