EventManager
Link to eventmanager
Manages the registration and handling of custom handlers for the various events of the game.
You can register event handlers for pretty much everything, but make sure that the class you are referencing is documented as an event, otherwise you're in for a nasty surprise.
Importing the class
Link to importing-the-class
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
ZenScript Copyimport crafttweaker.api.events.EventManager;
Methods
Link to methods
Name: register
Registers a new event listener.
ZenScript CopyEventManager.register<T : Object>(consumer as Consumer<T>)
Parameter | Type | Description |
---|---|---|
Parameter consumer | Type Consumer<T> | Description The event handler. |
Parameter T | Type Object | Description The type of the event. |
Name: register
Registers a new event listener that can listen to cancelled events.
ZenScript CopyEventManager.register<T : Object>(listenToCanceled as boolean, consumer as Consumer<T>)
Parameter | Type | Description |
---|---|---|
Parameter listenToCanceled | Type boolean | Description Whether cancelled events should also be listened to or not. |
Parameter consumer | Type Consumer<T> | Description The event handler. |
Parameter T | Type Object | Description The type of the event. |
Name: register
Registers a new event listener for the specified EventPhase.
ZenScript CopyEventManager.register<T : Object>(phase as EventPhase, consumer as Consumer<T>)
Parameter | Type | Description |
---|---|---|
Parameter phase | Type EventPhase | Description The phase on which the event should be registered. |
Parameter consumer | Type Consumer<T> | Description The event handler. |
Parameter T | Type Object | Description The type of the event. |
Name: register
Registers a new event listener for the specified EventPhase that can listen to cancelled events.
ZenScript CopyEventManager.register<T : Object>(phase as EventPhase, listenToCanceled as boolean, consumer as Consumer<T>)
Parameter | Type | Description |
---|---|---|
Parameter phase | Type EventPhase | Description The phase on which the event should be registered. |
Parameter listenToCanceled | Type boolean | Description Whether cancelled events should also be listened to or not. |
Parameter consumer | Type Consumer<T> | Description The event handler. |
Parameter T | Type Object | Description The type of the event. |