Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.
/ ChimeraEventBus Public archive

EventSystem for registering events, with a priority system, caching and ease of use.

Notifications You must be signed in to change notification settings

FelixH2012/ChimeraEventBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

EventSystem

A simple event system, with priorities and caching

Usage/Examples

Registering an event

import com.felix.chimera.base.implementation.event.Event;

public class ExampleEvent extends Event {

}

Initialisation in the main class of your client

public class ClientMain {

    private static ClientMain instance;

    public EventManager eventManager;

    public ClientMain() {
       this.eventManager = new EventManager();
    }

    public static ClientMain instance() {
        if (instance == null) {
            instance = new ClientMain();
        }
        return instance;
    } 
}

Triggering an event, for example a tick event in the Minecraft - Main klass

   public void runTick() throws IOException {
      ClientMain.instance().eventManager().triggerEvent(new ExampleEvent());
   }
}

Registering the events in the module class

     public void callModule(boolean state) {
        this.moduleToggleState = state;
        if (state) {
             ClientMain.instance().eventManager().subscribe(this);
            enable();
        } else {
             ClientMain.instance().eventManager().unsubscribe(this);
            disable();
        }
    }
}

Use of the event in a module

        private final EventManager.EventListener<ExampleEvent> exampleEventEventListener = e -> {

    };
}

About

EventSystem for registering events, with a priority system, caching and ease of use.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages