Class CustomEvent
java.lang.Object
org.bukkit.event.Event
dev.magicmq.pyspigot.bukkit.event.ScriptEvent
dev.magicmq.pyspigot.bukkit.event.custom.CustomEvent
- All Implemented Interfaces:
Cancellable
A custom event that scripts may instantiate and call for other plugins/scripts to listen to.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionCustomEvent(String name, PyObject data) Note: This class should be instantiated from scripts only!CustomEvent(String name, PyObject data, boolean async) Note: This class should be instantiated from scripts only! -
Method Summary
Modifier and TypeMethodDescriptiongetData()Get the data attached to this event.<T> TgetDataAsType(Class<T> clazz) Attempt to convert the data attached to this event to a provided type.getDataAsType(String clazz) Attempt to convert the data attached to this event to a provided type.static HandlerListgetName()Get the name of this event.booleanvoidsetCancelled(boolean cancelled) Methods inherited from class dev.magicmq.pyspigot.bukkit.event.ScriptEvent
getScriptMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
CustomEvent
Note: This class should be instantiated from scripts only!
- Parameters:
name- The name of the event being created. Can be used to create subtypes of the generic custom eventdata- The data to attach to the event
-
CustomEvent
Note: This class should be instantiated from scripts only!
- Parameters:
name- The name of the event being created. Can be used to create subtypes of the generic custom eventdata- The data to attach to the eventasync- Whether the event is being called from an asynchronous context
-
-
Method Details
-
getName
Get the name of this event.- Returns:
- The name of this event
-
getData
Get the data attached to this event.- Returns:
- The data attached to this event
-
getDataAsType
Attempt to convert the data attached to this event to a provided type.- Parameters:
clazz- The type that the data should be converted to- Returns:
- An object of the specified type representing the converted data
- Throws:
PyException- If the data could not be converted to the provided type
-
getDataAsType
Attempt to convert the data attached to this event to a provided type.- Type Parameters:
T- The type to which the data should be converted- Parameters:
clazz- The type that the data should be converted to- Returns:
- An object of the specified type representing the converted data
- Throws:
PyException- If the data could not be converted to the provided type
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceCancellable
-
setCancelled
public void setCancelled(boolean cancelled) - Specified by:
setCancelledin interfaceCancellable
-
getHandlers
- Overrides:
getHandlersin classScriptEvent
-
getHandlerList
-