Package ch.njol.skript.lang
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
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.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
check(org.bukkit.event.Event e)
Checks whether the given Event applies, e.g.Class<? extends org.bukkit.event.Event> @Nullable []
org.bukkit.event.EventPriority
boolean
init(Expression<?>[] vars, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
Called just after the constructor.abstract boolean
init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult)
called just after the constructorboolean
boolean
Script loader checks this before loading items in event.toString()
Should returntoString
(null, false)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
-
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 interfaceSyntaxElement
- 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 matchedisDelayed
- 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
- Returns:
- the Event classes to use in
ParserInstance
, ornull
if the Event classes this SkriptEvent was registered with should be used.
-
toString
Description copied from interface:Debuggable
Should returntoString
(null, false)- Specified by:
toString
in interfaceDebuggable
- Overrides:
toString
in classObject
-
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
-