Hi, I am just starting to code with Sponge and I am loving it so far. I recently have been trying to make my plugin interface with another economy plugin. So far, I have tried narrowing down the issue and have found that the event for Loading the EconomyService is not run, which might be causing the error.
Here is my error that occurs when I place a block. No other errors related to this plugin show up on startup:
(RIP, new users can only put 2 links, I put the error I get when placing the block at the end of my BlockPlaceListener class for you to get to it if you need)
Any help is greatly appreciated, thank you for reading
Edit: I have the plugin TotalEconomy for Sponge installed, it works fine and all of it’s commands function in game.
Edit 2: Better formatting
Edit 3: It seems that the plugin is not registering the onChangeServiceProvider Event or it doesn’t exist. It is never run and does not set the private EconomyService variable which line 32 uses, so I think my issue is that that @Listener is not being called at all. Also I am using the most recent Bleeding Edge version of Sponge to develop on and run sponge on.
I put it at the end of my second link in the original post, but here it is. I only get the error on block place, as if the ChangeServiceProviderEvent is never run.
Well, it’s more of when you register the listener. You’re registering it after TotalEconomy has changed the service, so the event was posted, you just weren’t listening for it at the time.
Consider using Sponge.getServiceManager().provide(EconomyService.class); to get the economy service instead the first time you fire the BlockPlaceListener, and store it then. I’d keep the other listener just in case it changes for some reason.
Sorry for flagging your posts as Spam, sometimes the forums software produces false positives (it automatically blocks posts by new users with many links in it)
Hope it didn’t cause you any trouble.
This is what I have tried and I still get the same error at Sponge.getServiceManager().provide(EconomyService.class); instead of at economyService.getOrCreateAccount(ply.getUniqueId());
Edit 1: This seems to have replied to the wrong person, sorry lol
What dualspiral was saying is if economyService is null (the first time you use it it will be null, since your economy listener doesn’t fire) use Sponge.getServiceManager().provide(EconomyService.class) to set it.