pharaoh 130 Share Posted October 3, 2020 Not sure why I am having such an issue porting my script over from another client. I have tried defining the Widgets in different parts of my class but they still continue to produce a NullPointer. I am defining some of them as: Then like this in my execute method: Now I am using switch cases in my task and this is what the first step looks like and it produces a NP on the first sleepUntil line. My loop return is 800, is this too short? I don't have any errors in the code and I have also tried defining the Widget in this switch case as well. case GRAB_BOWL: Settings.state = getState().name(); Settings.action = "Searching the cupboard"; if (Constants.UTENSIL_CUPBOARD != null && Constants.UTENSIL_CUPBOARD.interact("Search")) { sleepUntil(() -> Widgets.getWidget(242).isVisible(), 1200); } if (bowlWidget != null && bowlWidget.interact("Take-X")) { Settings.action = "Taking some bowls"; sleepUntil(enterAmountWidget::isVisible, 2000); if (enterAmountWidget.isVisible()) { Keyboard.type("14", true); sleep(300, 500); sleepUntil(() -> Inventory.contains("Bowl"), 2000); closeButton.interact("Close"); sleepUntil(() -> !utensilWidget.isVisible(), 800); } } break; Link to comment Share on other sites More sharing options...
LostVirt 106 Share Posted October 3, 2020 null check enterAmountWidget Link to comment Share on other sites More sharing options...
pharaoh 130 Author Share Posted October 3, 2020 1 hour ago, LostVirt said: null check enterAmountWidget Thanks, I'll try that but the issue is on the line below sleepUntil(() -> Widgets.getWidget(242).isVisible(), 1200); Link to comment Share on other sites More sharing options...
LostVirt 106 Share Posted October 3, 2020 22 minutes ago, pharaoh said: Thanks, I'll try that but the issue is on the line below sleepUntil(() -> Widgets.getWidget(242).isVisible(), 1200); you should be able to do this, for example: sleepUntil(() -> Widgets.getWidget(242) != null, 1200); But not 100% sure, give it a try Link to comment Share on other sites More sharing options...
Nuclear Nezz 2040 Share Posted October 4, 2020 5 hours ago, pharaoh said: Thanks, I'll try that but the issue is on the line below sleepUntil(() -> Widgets.getWidget(242).isVisible(), 1200); You need to null check that widget. So you'll do: Widgets.getWidget(242) != null && Widgets.getWidget(242).isVisible() Link to comment Share on other sites More sharing options...
LordJashin32 54 Share Posted October 4, 2020 Java and all the null checks drives me crazy. And optionals would just drive me more crazy. I think maybe I'll just wrap the classes with some null handlers and throw them in a dark corner of my project source window. Then have the log hiccup if there actually is a null. which i don't plan for to be lol. Just a tip for you. WATCH out for OnStart. I did something in there. and found out all my problems were solved by moving the code to the OnLoop. Took me 3-4 days to figure out why my onLoop was firing only some of the time. Link to comment Share on other sites More sharing options...
pharaoh 130 Author Share Posted October 5, 2020 On 10/3/2020 at 7:50 PM, Nuclear Nezz said: You need to null check that widget. So you'll do: Widgets.getWidget(242) != null && Widgets.getWidget(242).isVisible() Thanks, I'll do that. member that music fest in like 2015 or something we met up at? cuz i member On 10/4/2020 at 3:30 AM, LordJashin32 said: Java and all the null checks drives me crazy. And optionals would just drive me more crazy. I think maybe I'll just wrap the classes with some null handlers and throw them in a dark corner of my project source window. Then have the log hiccup if there actually is a null. which i don't plan for to be lol. Just a tip for you. WATCH out for OnStart. I did something in there. and found out all my problems were solved by moving the code to the OnLoop. Took me 3-4 days to figure out why my onLoop was firing only some of the time. thanks bro ill be on the lookout haha Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.