Jump to content

Why getting NPE for this trading :(((


regularshiz

Recommended Posts

            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? :(

Link to comment
Share on other sites

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
        }
    }
}

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...