Skip to content

Event policy

SOFe edited this page Apr 9, 2018 · 1 revision

Warning: This is a nerdy article, written for developers who want to write plugins related to XialotEcon or participate in XialotEcon development.

XialotEcon uses the events API extensively. Listening to XialotEcon events opens the door to a lot of things, including:

Listener as monitor

If you listen to an event to monitor XialotEcon activity, the listener should be declared at the @priority MONITOR priority. If the event is cancellable, you should declare the @ignoreCancelled true tag too. Such listeners should not modify the event data by any means.

Listener as modifier

If you listen to an event to modify XialotEcon activity, the listener should be declared in the @priority range LOWEST to HIGHEST. Modifiers only need to modify the data they are concerned, and may neglect other data in the event.

Listener as extension

XialotEcon fires some events as extension points (instead of notifying that something happened). For example, AccountDescriptionEvent is fired so that implementations can inject the appropriate account description for accounts they declared.

Extension listeners should fully handle the event, providing all the data that the event requires. There may be modifiers before or after the extension, but the extension itself must fill all the data required (contrary to modifiers, which do not need to complete the whole event alone).

Async listeners

Some events are fired asynchronously (with PluginManager::callAsyncEvent()), and listeners can therefore call Event->pause() to execute async operations before returning a value.

Clone this wiki locally