JustADumbass 1 Share Posted April 12, 2022 New to scripting, I've been following a video guide while trying to make a goblin killing script. I get the error "Cannot resolve symbol 'AdvancedMessageListener'. How to fix? import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.tabs.Tab; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.NPC; @ScriptManifest(author = "me", description = "Kills goblins", name = "Goblin Slayer", category = Category.COMBAT, version = 1) public class GoblinSlayer extends AbstractScript implements AdvancedMessageListener { State state; NPC npc; NPC grave; boolean isDead = false; Area Spawn = new Area(new Tile(3217,3225), new Tile(3226,3216)); Area Goblins = new Area(new Tile(3239,3253), new Tile(3267, 3213)); Area House = new Area(new Tile(3245,3248), new Tile(3248, 3244)); float KillTotal = 0; float KillsSinceWait = 0; @Override //Infinite loop public int onLoop() { //Determined by which state gets returned by getState() then do that case. switch(getState()) { case WALKING2GOBLINS: log("walking :D"); if (!getLocalPlayer().isMoving()) { getWalking().walk(3260, 3233); sleep(randomNum(2054, 2304)); } break; case SEARCHING4GOBLINS: log("ON THE HUNTer"); npc = getNpcs().closest(GoblinE -> GoblinE != null && GoblinE.getName().contentEquals("Goblin") && !GoblinE.isInCombat() && Goblins.contains(GoblinE)); if (npc != null) { if (npc.isOnScreen()) { getCamera().keyboardRotateToEntity(npc); sleep(randomNum(483, 999)); } npc.interact("Attack"); sleep(randomNum(1500, 2500)); } break; case FIGHTING: if (npc != null) { if (npc.exists() || npc.getHealthPercent() == 0) { KillsSinceWait++; KillTotal++; npc = null; } } if (getLocalPlayer().getHealthPercent() == 0) { isDead = true; } break; case DIED: if (!getLocalPlayer().isMoving()) { getWalking().walk(3260,3233); if(Goblins.contains(getLocalPlayer())){ grave = getNpcs().closest(GraveE -> GraveE != null && GraveE.getName().contentEquals("Grave")); if (grave != null) { if (grave.isOnScreen()) { getCamera().keyboardRotateToEntity(grave); sleep(randomNum(483, 999)); } grave.interact("Loot"); sleep(randomNum(1000, 1500)); if (!getTabs().isOpen(Tab.INVENTORY)) { getTabs().open(Tab.INVENTORY); } if(getTabs().isOpen(Tab.INVENTORY)) { getInventory().contains("Wooden shield", "Wield"); sleep(250, 500); getInventory().contains("Steel med helm", "Wear"); sleep(250, 500); getInventory().contains("Leather boots", "Wear"); sleep(250, 500); getInventory().contains("Leather gloves", "Wear"); sleep(250, 500); getInventory().contains("Black Platebody", "Wear"); sleep(250, 500); if(getInventory().contains("Black longsword")) { getInventory().contains("Black longsword", "Wield"); } else if(getInventory().contains("Steel longsword")){ getInventory().contains("Steel longsword", "Wield"); } else if(getInventory().contains("Bronze sword")){ getInventory().contains("Bronze sword", "Wield"); } sleep(250, 500); } isDead = false; state = State.SEARCHING4GOBLINS; log(state); log(getState()); } } } break; } return 0; } //State names private enum State{ FIGHTING, WALKING2GOBLINS, BREAK, SEARCHING4GOBLINS, DIED } public int randomNum(int i, int k){ int num = (int)(Math.random() * (k - i + 1)) + 1; return num; } //Checks if a certain condition is met, then return that state. private State getState() { if(Spawn.contains(getLocalPlayer())) { state = State.WALKING2GOBLINS; } else if(Goblins.contains(getLocalPlayer()) && !getLocalPlayer().isInCombat() && !isDead){ state = State.SEARCHING4GOBLINS; } else if(Goblins.contains(getLocalPlayer()) && getLocalPlayer().isInCombat()){ state = State.FIGHTING; log("ATTACKING!"); } else if(isDead == true) { state = State.DIED; } else{ stop(); } return state; } //When script start load this. public void onStart() { log("Bot Started"); } //When script ends do this. public void onExit() { log("Bot Ended"); } } Link to comment Share on other sites More sharing options...
Hans Zimmer 18 Share Posted April 12, 2022 (edited) Your problem is here: public class GoblinSlayer extends AbstractScript implements AdvancedMessageListener { Your IDE is telling you that it doesnt know what AdvancedMessageListener is. The keyword "implements" means you are implementing an interface, in this case AdvancedMessageListener. If you're following a guide, there must be that interface somewhere (an interface is another class). If you can't find it in the guide, there is no point implementing an interface. Taking a very quick look at the code, doesn't look like you're using anything from the interface anyways so changing the class declaration to the following one should fix your issue: public class GoblinSlayer extends AbstractScript I strongly suggest learning more about Java in general before diving into scripting, will save you A LOT of time. Edited April 12, 2022 by Hans Zimmer Link to comment Share on other sites More sharing options...
JustADumbass 1 Author Share Posted April 12, 2022 46 minutes ago, Hans Zimmer said: Your problem is here: public class GoblinSlayer extends AbstractScript implements AdvancedMessageListener { Your IDE is telling you that it doesnt know what AdvancedMessageListener is. The keyword "implements" means you are implementing an interface, in this case AdvancedMessageListener. If you're following a guide, there must be that interface somewhere (an interface is another class). If you can't find it in the guide, there is no point implementing an interface. Taking a very quick look at the code, doesn't look like you're using anything from the interface anyways so changing the class declaration to the following one should fix your issue: public class GoblinSlayer extends AbstractScript Yeah, I didn't have anything using the interface because it was giving me an error while trying to implement it. I figured out the problem was that dreambot renamed "AdvancedMessageListener" to "ChatListener" and that my guide was just old. Quote I strongly suggest learning more about Java in general before diving into scripting, will save you A LOT of time. Nah, coding is always a cycle of pain, bugs and errors Pandemic 1 Link to comment Share on other sites More sharing options...
Articron 738 Share Posted April 13, 2022 11 hours ago, JustADumbass said: Nah, coding is always a cycle of pain, bugs and errors This quote is so true I took it personal Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now