Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • DB 2.x vs 3.0.0 API depreciations


    Realistic
     Share

    Recommended Posts

    Hi all,

    I am a relatively experienced Python developer learning Java and building my first DreamBot script! I have been looking at a bunch of example scripts and have notices that when building vs the DB3.0.0 JAR a lot of the DB API used in the scripts is considered deprecated. For example:

    • getNpcs()
    • getWidgets()

    For widgets I am using

    Widgets.getWidget(123)

    instead. Is this the correct way to do it? I am still struggling to find the best way to interact with NPCs not using the getNpcs() method.

     

    Can anyone point me to the new best practices? Is there any documentation about the 3.0.0 API deprecations?

     

    Thanks all,

    Realistic

    Link to comment
    Share on other sites

    That's correct, we plan on adding a more detailed post later with future deprecation info and dates of removal.

    Our API is now static, so instead of using getNpcs() you can access the methods through the NPCs class directly:

    // DB2:
    getNpcs().closest("Man").interact("Attack");
    
    // DB3:
    NPCs.closest("Man").interact("Attack");

    This allows you to more easily use the API in other classes without needing to pass around our MethodContext.

    Hope that helps!

    Link to comment
    Share on other sites

    Perfect! Thank you Pandemic.

    While work my way through building a bot I am writing some "Docs for Noobs like me" that answer some questions I have had. I am using DB3 (TaskScript), and I am planning on releasing the source code. I chose a tutorial island bot (There is already 1 open source tut bot, but it is 2.x based and not a TaskScript) as it uses most major features. Walking (no web), NPC interaction, combat, cooking, item interaction, dialog traversing, widget interaction, etc...

    What would the best way to release the source code be? I have it in a private Github repo right now.

    Is it considered ok to release the source code of an entire script like this?

    Would anyone be willing to do a small Code Review on it before I make a post that could include some not so best practices?

    Thank you,

    Realistic

     

    P.S. Is it possible to edit posts? I can't find a way to do it...

    Link to comment
    Share on other sites

    I'm also dabbling in Java right now. I'm not experiences enough to clean-up code or give advice.
    Speaking of API deprecations, does anyone know why it telling me that getWalking is deprecated?
    Does anyone have an example on how to get around that, I searched the forums a bit but couldn't find a post other than this one.
    I can post on a separate topic if need be.

    Link to comment
    Share on other sites

    2 hours ago, RipperX said:

    I'm also dabbling in Java right now. I'm not experiences enough to clean-up code or give advice.
    Speaking of API deprecations, does anyone know why it telling me that getWalking is deprecated?
    Does anyone have an example on how to get around that, I searched the forums a bit but couldn't find a post other than this one.
    I can post on a separate topic if need be.

    From what Pandemic said all the getX methods that used to be inherited from MethodContext are now classes. So for walking it would be:

    import org.dreambot.api.methods.map.Tile; 
    
    Walking.walkOnScreen(new Tile(3092,3103,0));

    to walk to a tile on your screen.

    Link to comment
    Share on other sites

    • 2 weeks later...
    • 1 year later...
    On 8/29/2020 at 12:41 PM, Pandemic said:

    That's correct, we plan on adding a more detailed post later with future deprecation info and dates of removal.

    Our API is now static, so instead of using getNpcs() you can access the methods through the NPCs class directly:

    // DB2:
    getNpcs().closest("Man").interact("Attack");
    
    // DB3:
    NPCs.closest("Man").interact("Attack");

    This allows you to more easily use the API in other classes without needing to pass around our MethodContext.

    Hope that helps!

    Did this post ever happen, I am guess tabs is one of these and I just sent a few hours screaming at my computer using gettabs vs tabs... :)

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.