New Event Listener system

Deazer

Head Developer
Staff member
Implemented a new, more flexible event listener system, allowing for the elimination of excessive hardcoding.
This is the mechanics of arbitrary event listeners. In order for third-party developers to add their own implementations of reactions to game and other events, a mechanism for arbitrary listeners is introduced.

Example Implementation:
Let's say an action occurs in your handler, such as issuing an augmentation, granting hero status, or any other action you have implemented.
The fireEvent method is responsible for generating an event and passing it to all registered listeners.
  • Parameters:
    • eventType - the type of event that occurred.
    • args - any number of arguments that will be passed to the event listeners.
In this example:

Example: GameServer.getInstance().getListeners().fireEvent("activateHero", player, player.getActiveClassId());
Here, we pass 2 arguments as objects: player and player.getActiveClassId(). The number of arguments is not limited.

Thus, this code provides a flexible and extendable event management system, allowing for the dynamic addition and invocation of listeners for various event types.

Visualization of listener registration usage:
b9e4f409e7b46ace9899f8576f9dc744.png


How to use the registered listener:
 
Back
Top