regularshiz Posted June 17, 2020 Posted June 17, 2020 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?
ExtraBotz Posted June 17, 2020 Posted June 17, 2020 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 } } } 1