Search the Community
Showing results for tags 'listener'.
-
I'm relatively new to scripting in DreamBot and Java and have been working on a simple Firemaking script, but seem to be getting a lot of false negatives for Players.getLocal().isAnimating(), leading to lots of dropped logs and missed XP. To counteract this I'm trying to implement the ExperienceListener, so that after using the tinderbox on the logs the script sleeps until the player receives and XP drop. However, I can't for the life of me figure out how to properly implement this in my script and know I'm making some silly mistakes but can't find a proper tutorial anywhere at my level. Here is what I have so far: // Start ExperienceListener.java // import org.dreambot.api.script.event.impl.ExperienceEvent; interface ExperienceListener extends java.util.EventListener { public boolean onGained(ExperienceEvent event); } // End ExperienceListener.java // // Start XpDrop.java // import org.dreambot.api.script.event.impl.ExperienceEvent; public class XpDrop implements ExperienceListener { @Override public boolean onGained(ExperienceEvent event) { return true; } } // End XpDrop.java // The part of the script I'm trying to implement this into: public int execute() { // Construct FireMaker to access getLogs method FireMaker fireMaker = new FireMaker(); // Get logs String logs = fireMaker.getLogs(); // Use tinderbox Inventory.interact("Tinderbox"); sleep(Calculations.random(250, 500)); // On logs Inventory.interact(logs); // Construct XpDrop Class XpDrop xpDrop = new XpDrop(); // Sleep until XP drop while (!xpDrop.onGained(ExperienceEvent event)) { // This is where I'm having problems - I don't know what to pass into onGained() sleep(Calculations.random(300,700) } return 300; } Very grateful for any help or links to resources!