GaetanoH Posted March 15, 2016 Share Posted March 15, 2016 Hello, so I'm busy making a trout/salmon fishing script I know it's far from finished but somehow the bot always seems to get a nullpointer exception and I can't seem to find the problem... Can somebody please help me out? Thanks in advance GaetanoH import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; /** * Created by Gaetano on 15/03/16. */ @ScriptManifest(name = "Salmon/Trout Fisher", author = "GaetanoH", version = 1.0, info = "", logo = "") public class Fisher extends Script { public enum State { FISHING, DROPPING; } public State getState(){ if(!inventory.contains("Raw trout") && !inventory.contains("Raw salmon")){ log("fishing"); return State.FISHING; } if(inventory.isFull() && inventory.contains("Raw trout") && inventory.contains("Raw salmon")){ log("dropping"); return State.DROPPING; } return null; } @Override public void onStart() throws InterruptedException { log("Welcome to my Barbarian Village Fisher/Cooker, start with a fly fishing rod with enough feathers, a tinderbox and a axe equipped."); } @Override public void onExit() throws InterruptedException { log("Thanks for using my script"); } @Override public int onLoop() throws InterruptedException { switch (getState()) { case FISHING: if(!myPlayer().isAnimating()){ getNpcs().closest("Fishing spot").interact("Lure"); } break; case DROPPING: getInventory().dropAllExcept("Fly fishing rod", "Feather"); break; } return random(500, 800); } @Override public void onPaint(Graphics2D g) { } } Quote Link to comment Share on other sites More sharing options...
Fruity Posted March 15, 2016 Share Posted March 15, 2016 getNpcs().closest("Fishing spot").interact("Lure"); Possibly there. could be that the fishing spot is null Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted March 15, 2016 Author Share Posted March 15, 2016 Oh yeah..., knew it was something small, thank you man! It was the fact that I checked if you had salmon/trout before fishing which ended up not working and just standing still Quote Link to comment Share on other sites More sharing options...
Vilius Posted March 15, 2016 Share Posted March 15, 2016 Oh, and you should always look at the logger and see what line the error occurs one ;) Quote Link to comment Share on other sites More sharing options...
The Hero of Time Posted March 15, 2016 Share Posted March 15, 2016 Oh, and you should always look at the logger and see what line the error occurs one Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted March 15, 2016 Author Share Posted March 15, 2016 Yeah i saw what line it was but didn't see my mistake Quote Link to comment Share on other sites More sharing options...
Acerd Posted March 15, 2016 Share Posted March 15, 2016 Yeah i saw what line it was but didn't see my mistake tip: NullPointerException usually happens when you didnt check if something was null or not. Quote Link to comment Share on other sites More sharing options...