June 17, 20205 yr case TRADE: Player muler = getPlayers().closest(player -> player != null && player.getName().equals(mule)); if (!trade.isCurrentlyTrading()) { state = "Trading with mule."; muler.interact("Trade with"); new org.osbot.rs07.utility.ConditionalSleep(20000) { @Override public boolean condition() throws InterruptedException { return trade.isCurrentlyTrading(); } }.sleep(); } why getting null pointer exception for this?
June 17, 20205 yr You should still do a null check for the muler object. if(muler != null) { // then we can access the muler object } Also when you use an Interactable the method returns a boolean so you should check if your .interact() interaction returns true. Player muler = getPlayers().closest(player -> player != null && player.getName().equals(mule)); if(muler != null) { if(!trade.isCurrentlyTrading()) { if(muler.interact("Trade with")) { state = "Trading with mule."; // sleep condition } } }
Create an account or sign in to comment