RuneMate Documentation
  • 👋Welcome to RuneMate
  • 🌟Getting Started
    • Project Setup
    • Gradle Plugin
      • Configuration
      • Manifests
      • Publishing
      • Advanced Builds
  • 🖥️API
    • Querying
    • Delays
    • Game World
      • Instances
      • Navigation
      • Global Pathfinding
    • Default User Interface
      • Settings
    • Varps, Varbits and Varcs
    • Events
  • ❔Support
    • Frequently Asked Questions
      • Billing FAQ
      • Client FAQ
    • Using RuneLite
      • Linux
    • Using OSRS
Powered by GitBook
On this page
  • Listeners
  • Event Dispatcher
  1. API

Events

Reacting to changes in the game.

PreviousVarps, Varbits and VarcsNextFrequently Asked Questions

Last updated 9 months ago

Events are a highly efficient way of reacting to changes in the game engine, such as Npcs spawning and despawning, Skill level-ups, or Varps changing. RuneMate offers a variety of listeners that can be leveraged to this end.

Listeners

The interfaces can be implemented in order to react to various events in-game. For example, we can use the to run some code every tick:

MyEngineListener.java
public class MyEngineListener implements EngineListener {

    private int tick;

    @Override
    public void onEngineEvent(EngineEvent event) {
        if (event.getType() == EngineEvent.Type.SERVER_TICK) {
            tick++;
        }
    }

}

Event Dispatcher

The EventDispatcher is the core of the event framework, and all listeners must be registered with it. An instance of the EventDispatcher is provided by your bot instance:

MyBot.java
public class MyBot extends LoopingBot {

    private MyEngineListener listener;
    
    @Override
    public void onStart(String... args) {
        getEventDispatcher().addListener(listener);
    }
}
🖥️
EventListener
EngineListener