Jump to content

Difference between getGrandExchange and GrandExchange?


Recommended Posts

Posted

Noob question incoming

When programming my bot to interact with the grand Exchange, I noticed that some snippets use the getGrandExchange() method in the MethodProvider, for example: 

getGrandExchange().isOpen()

And sometimes people don't use the MethodProvider, so they use GrandExchange class directly, like so:

if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_BUY) {
   status = "Pending offer";
}else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) {
   status = "Offer completed - Collecting";
}

What is the difference between the two? The same applies with Inventory class & getInventory(), Bank class & getBank() etc....  

I guess this question could be phrased more generally: What is the difference between using methodProvider get-functions or interacting with the classes directly? 

Posted (edited)

Generally, you should always use getters/setters for variables contained in other classes, if one is provided as they may be doing more than just returning the variable. In example, calling getInventory() instead of just calling the variable could actually be verifying that it is returning the most up-to-date  Inventory state, instead of the one that is currently cached.

Edited by BravoTaco
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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