Jack Posted July 3, 2014 Share Posted July 3, 2014 (edited) [ERROR][Bot #1][07/02 07:31:01 PM]: Error in script executor! java.lang.NullPointerException at org.osbot.utility.Logger.log(f:243) at org.osbot.utility.Logger.log(f:189) at org.osbot.utility.Logger.log(f:25) at org.osbot.utility.Logger.info(f:4) at org.osbot.rs07.script.MethodProvider.log(MethodProvider.java:721) at net.jack.scripts.Core.onLoop(Core.java:111) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ScriptExecutor.java:99) at java.lang.Thread.run(Unknown Source) was there an error on line 111? This is line 111: catch(Exception e){ ---> log(e.getMessage()); } So what was the original error? Did it throw an exception while trying to tell me what the previous exception was? Im so confused Edited July 3, 2014 by Jack Link to comment Share on other sites More sharing options...
adc Posted July 3, 2014 Share Posted July 3, 2014 Since the top of the stack points to an error within Logger's log method, I would guess that the logger is unable to change that message to a string? Try logging a test string instead of e.getMessage(). Link to comment Share on other sites More sharing options...
Mysteryy Posted July 3, 2014 Share Posted July 3, 2014 [ERROR][Bot #1][07/02 07:31:01 PM]: Error in script executor! java.lang.NullPointerException at org.osbot.utility.Logger.log(f:243) at org.osbot.utility.Logger.log(f:189) at org.osbot.utility.Logger.log(f:25) at org.osbot.utility.Logger.info(f:4) at org.osbot.rs07.script.MethodProvider.log(MethodProvider.java:721) at net.jack.scripts.Core.onLoop(Core.java:111) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ScriptExecutor.java:99) at java.lang.Thread.run(Unknown Source) was there an error on line 111? This is line 111: catch(Exception e){ ---> log(e.getMessage()); } So what was the original error? Did it throw an exception while trying to tell me what the previous exception was? Im so confused Its possible that something is crapping out and killing or messing up the script executor. If this happens then the client would throw an NPE because there would be no script to log to, because log is actually in Script#log(). If script doesnt exist, then you cant log. Thus the NPE on the log method. Just delete that log and do e.printStackTrace() instead. ^_^ What is inside of your try{} that could throw an exception? Link to comment Share on other sites More sharing options...
Ericthecmh Posted July 3, 2014 Share Posted July 3, 2014 Is Core your main script, or is another class your main script and you're passing the script reference to Core? Because if you are then it should be script.log, if your reference is called script. 1 Link to comment Share on other sites More sharing options...
Jack Posted July 3, 2014 Author Share Posted July 3, 2014 Its possible that something is crapping out and killing or messing up the script executor. If this happens then the client would throw an NPE because there would be no script to log to, because log is actually in Script#log(). If script doesnt exist, then you cant log. Thus the NPE on the log method. Just delete that log and do e.printStackTrace() instead. What is inside of your try{} that could throw an exception? Mostly sleeps and a few npc interactions I think it was client error though, not script error. Link to comment Share on other sites More sharing options...
Mysteryy Posted July 3, 2014 Share Posted July 3, 2014 Mostly sleeps and a few npc interactions I think it was client error though, not script error. Ok. Also, look what eric said. Are you passing script to this class? Because if so it needs to be script.log() not log. ^_^ 1 Link to comment Share on other sites More sharing options...
Jack Posted July 3, 2014 Author Share Posted July 3, 2014 Is Core your main script, or is another class your main script and you're passing the script reference to Core? Because if you are then it should be script.log, if your reference is called script. Core is my main class that extends script It seems to now be working when I added a null check here: (food is an ArrayList<String> of food names) for(int i = 0; i < inventory.getItems().length; i++){ if(inventory.getItems()[i]!=null&&food.contains(inventory.getItems()[i].getName())){ inventory.getItems()[i].interact("Eat"); return random(650, 900); } } Is there a better way to write this? Link to comment Share on other sites More sharing options...
Mysteryy Posted July 3, 2014 Share Posted July 3, 2014 (edited) Core is my main class that extends script It seems to now be working when I added a null check here: (food is an ArrayList<String> of food names) for(int i = 0; i < inventory.getItems().length; i++){ if(inventory.getItems()[i]!=null&&food.contains(inventory.getItems()[i].getName())){ inventory.getItems()[i].interact("Eat"); return random(650, 900); } } Is there a better way to write this? This is my method for eating food, it might need a small change or two, but I have not yet had an issues with it, nor an exception thrown from it. It seems that you forgot to make sure the inventory tab is open. You cant interact with the food if your inventory tab isn't open. public boolean eatFood(String foodName){ Item food = script.inventory.getItem(foodName); if(food != null && script.inventory.contains(foodName)){ if(script.tabs.getOpen().equals(Tab.INVENTORY)) return food.interact("Eat"); else script.tabs.open(Tab.INVENTORY); } return false; } Edited July 3, 2014 by Mysteryy Link to comment Share on other sites More sharing options...
Joseph Posted July 3, 2014 Share Posted July 3, 2014 Core is my main class that extends script It seems to now be working when I added a null check here: (food is an ArrayList<String> of food names) for(int i = 0; i < inventory.getItems().length; i++){ if(inventory.getItems()[i]!=null&&food.contains(inventory.getItems()[i].getName())){ inventory.getItems()[i].interact("Eat"); return random(650, 900); } } Is there a better way to write this? you could always use a enhanced for loop for (Item item: script.inventory.getItems()) { if (item != null && item.getName().equalsIgnoreCase(argument)) { blah blah } } Link to comment Share on other sites More sharing options...