Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!
RuneMate will permanently shut down on August 7, 2026
due to events outside our control. You can continue using RuneMate until this date after which it will no longer be available. Thank you to everyone that contributed to RuneMate's success and to the community for the opportunity to serve you all these years.

  • Learn about RuneMate Vault and how its zero knowledge local encryption already protects your sensitive information.
  • Edit or delete your RuneMate account from your Account Settings.
  • All account upgrade subscriptions have been cancelled. No action required.

Resolved Custom event

Joined
Mar 29, 2016
Messages
54
I'm trying to use the EventDispatcher (com.runemate.game.api.script.framework.core.EventDispatcher) to fire a custom event I created.

It's not working (its not dispaching) and I can't figure it out why.

Custom Event:
Code:
package com.TheVTM.bots.BonePrayer.Events;

import com.TheVTM.bots.BonePrayer.UserConfiguration;

import java.util.EventObject;

public class ConfigurationEvent extends EventObject {
    public UserConfiguration userConfiguration;

    public ConfigurationEvent(Object source, UserConfiguration userConfiguration) {
        super(source);
        this.userConfiguration = userConfiguration;
    }
}

Event Listener Interface:
Code:
package com.TheVTM.bots.BonePrayer.Events.Listeners;

import com.TheVTM.bots.BonePrayer.Events.ConfigurationEvent;

import java.util.EventListener;

public interface ConfigurationListener extends EventListener {
    public void onConfiguration(ConfigurationEvent event);
}

Usage:
Code:
public class Statistics implements ConfigurationListener {
public Statistics() {
  // Register Listeners
  Environment.getScript().getEventDispatcher().addListener(this);
}

@Override
public void onConfiguration(ConfigurationEvent event) {
  LOGGER.log(Level.CONFIG, "Configuring Statistics...");
  // Initialize variables
  initialLevel = Skill.PRAYER.getBaseLevel();
  initialExperiece = Skill.PRAYER.getExperience();
  bonesCounter = 0;
  startTime = System.currentTimeMillis();
}
}

Fire Event:
Code:
public class BonePrayer extends TaskScript {

@Override
public void onStart(String...a) {
  super.onStart(a);

  ConfigurationEvent configurationEvent = new ConfigurationEvent(this,
   new UserConfiguration(Players.getLocal().getPosition(), 7));
  getEventDispatcher().process(configurationEvent);
}

}
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,121
Are you adding whatever class implements ConfigurationListener as an event dispatcher?
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,121
No, just as a listener.
How do I do that?
Looking at the source code, the event dispatcher is not intended to be extended with custom listeners and events. You could always build your own async engine to achieve this result.
 
Joined
Mar 29, 2016
Messages
54
Looking at the source code, the event dispatcher is not intended to be extended with custom listeners and events. You could always build your own async engine to achieve this result.

Ok, thank you!!
 
Top