-
Notifications
You must be signed in to change notification settings - Fork 0
Event policy
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:
- knowing that something happened (Listener as monitor)
- changing the behaviour of XialotEcon (Listener as modifier)
- adding new things into XialotEcon (Listener as extension)
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.
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.
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).
Some events are fired asynchronously (with PluginManager::callAsyncEvent()
), and listeners can therefore call Event->pause()
to execute async operations before returning a value.