Jump to content

Extending method provider and nullpointerexception


Theorems

Recommended Posts

13 hours ago, progamerz said:

There is no other way lol

You have access to the bot context.

 

14 hours ago, dreameo said:

When you're extending MethodProvider, some inherited fields must be initialized. That is the only reason why you're getting null. 

What those fields are, i'm not sure (take a look in Script class and see how it handles it). There are different ways on dealing this situation. @Alek Can tell you the preferred way. I think he mentioned it before in the forums. 

By design scripters shouldn't use anything that's marked for internal use only. They should pass bot which derives everything for that instance. I don't even extend MethodProvider in our API, it just doesn't make sense from a design perspective - we pass MethodProvider or Bot. I'd encourage other scripters to do the same, but it's your code so do whatever you guys like! :)  
 

  • Like 2
Link to comment
Share on other sites

45 minutes ago, Alek said:

By design scripters shouldn't use anything that's marked for internal use only. They should pass bot which derives everything for that instance. I don't even extend MethodProvider in our API, it just doesn't make sense from a design perspective - we pass MethodProvider or Bot. I'd encourage other scripters to do the same, but it's your code so do whatever you guys like! :)  
 

 

Aye, passing MethodProvider or Bot as a parameter is certainly "better", I just hate having every API call prefixed with some variable like methods.myPlayer() or whatever, and every class having MethodProvider as a constructor parameter. It just makes me feel a little sad when I look at it :feels:

If I was writing a small script for sure I would just pass the context as a parameter, but for large scripts it starts getting ugly.

I guess an alternative would be to have a static MethodProvider variable in your main class, and access the API via that, but again... *shudder* not gucci

Edited by Explv
  • Like 1
  • Boge 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...