How to give a Player money using Economy API

Ok, and do you ever actually assign anything to instance? Because if you don’t, then it just remains null.

…no I don’t know what to assign to it.

That’s what I was hoping someone would explain. Because I’m trying to pay people for killing entities. And as this is the first time i’ve tried using the new Economy API, i need help.

But this isn’t related to the Economy API. This is just a matter of getting an instance of your plugin. First of all, the type of instance and getInstance should be HOB, not Plugin. Plugin is an annotation. Then, during a GamePreInitializationEvent, assign this to instance.

1 Like

And how would you you do this in the GamePreInitializationEvent? I’m drawing a blank today.
Edit: Wait…how isn’t this related to the Economy API? All i’m trying to do is when they kill something it pays them?

It went from ‘how do you use the Economy API’ to ‘how do you make a Cause’ to ‘how do you make a static instance of a class’. And what do you mean how would you do this? Just say instance=this.

3 Likes

wow My mind is really gone. Thanks

Ok now the final piece! haha.

since the above is fixed now. Why is this line null?

in EcoRewards Line 38

this.economyService.getOrCreateAccount(player2).get().deposit(economyService.getDefaultCurrency(), bd, cause);

Well, if that’s the top frame, then economyService would most likely be null.

OK sorry it’s been a while… I now understand casting a bit better now. Thank you for the recommendation, so now I’m curious. What would I set the the economyService to?
Here’s what I hAve
private EconomyService economyService;
@Listener
public void onChangeServiceProvider(ChangeServiceProviderEvent event){
if(event.getService().equals(EconomyService.class)){
economyService = (EconomyService) event.getNewProviderRegistration().getProvider()

Please? can someone help me figure how to set the Economy Service up?

Here’s the Link