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:
EvtBreed,EvtBrewingComplete,EvtBrewingFuel,EvtBrewingStart,EvtBucketEntity,EvtFish,EvtFurnace,EvtPlayerInput,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
Nested ClassesModifier and TypeClassDescriptionstatic enumThe listening behavior of a Skript event.Nested classes/interfaces inherited from class org.skriptlang.skript.lang.structure.Structure
Structure.Priority, Structure.StructureData -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable org.bukkit.event.EventPriorityprotected @Nullable SkriptEvent.ListeningBehaviorstatic final Structure.Priorityprotected booleanprotected TriggerThe Trigger containing this SkriptEvent's code.Fields inherited from class org.skriptlang.skript.lang.structure.Structure
DEFAULT_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanOverride this method to allow Skript to not force synchronization.abstract booleancheck(org.bukkit.event.Event event) Checks whether the given Event applies, e.g.static StringfixPattern(String pattern) Fixes patterns in event by modifying everyTypePatternElementto be nullable.Class<? extends org.bukkit.event.Event>[]org.bukkit.event.EventPriorityThe priority of a Structure determines the order in which it should be loaded.abstract booleaninit(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult) Called just after the constructorfinal booleaninit(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult, @Nullable EntryContainer entryContainer) The initialization phase of a Structure.booleanbooleanbooleanload()This method handles the loading of the Structure's syntax elements.static @Nullable SkriptEventparse(String expr, SectionNode sectionNode, @Nullable String defaultError) booleanpostLoad()This method handles the registration of this event with Skript and Bukkit.voidThis method handles the unregistration of this event with Skript and Bukkit.booleanpreLoad()This method handles the loading of the Structure's syntax elements.booleanScript loader checks this before loading items in event.voidunload()This method handles the unregistration of this event with Skript and Bukkit.Methods inherited from class org.skriptlang.skript.lang.structure.Structure
getEntryContainer, getSyntaxTypeName, init, parse, parse, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.njol.skript.lang.Debuggable
toStringMethods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser, preInit
-
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:StructureThe 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:
initin classStructure- Parameters:
args- The arguments of the Structure.matchedPattern- The matched pattern of the Structure.parseResult- The parse result of the Structure.entryContainer- The EntryContainer of the Structure. Will not be null if the Structure provides aEntryValidator.- 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! -
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:
postUnloadin classStructure
-
getPriority
Description copied from class:StructureThe priority of a Structure determines the order in which it should be loaded. For more information, see the javadoc ofStructure.Priority.- Overrides:
getPriorityin 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
EventPriorityto 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.ListeningBehaviorto 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 everyTypePatternElementto be nullable. -
parse
@Nullable public static @Nullable SkriptEvent parse(String expr, SectionNode sectionNode, @Nullable @Nullable String defaultError)
-