MilkBowl / VaultAPI

API Component of Vault
GNU Lesser General Public License v3.0
273 stars 109 forks source link

getting null on RegisteredServiceProvider<Economy> #137

Closed Jens-Co closed 2 years ago

Jens-Co commented 2 years ago

Hello there, a few weeks ago my plugin was working just fine. The only thing that ive changed where bukkit runnables on join/quit events which isn't causing the issue.

Ive tested both Paper and spigot both on latest mc versions with no other plugins then Vault and my plugin. no errors are being thrown except that the line in perma link is returning null and i got no clue why.

https://github.com/ProjectG-Plugins/EcoDatabase/blob/87ebdcbd269af361af79c477c3a0a5a0c6447454/spigot/src/main/java/dev/projectg/ecodatabase/api/VaultApi.java#L23

Geolykt commented 2 years ago

as a gernal critique of your code, you should cache https://github.com/ProjectG-Plugins/EcoDatabase/blob/87ebdcbd269af361af79c477c3a0a5a0c6447454/spigot/src/main/java/dev/projectg/ecodatabase/api/VaultApi.java#L54 and only invalidate the cache when the ServiceEvent is called.

That being said, the fact that you are caching your instance is not at fault for you issue and thus invalidates the most common reason of there being a null value (the economy is obtained too early). So I assume that it returns null because you fell for the second most common trap - not installing an economy plugin (or just not registering it at all)

In other words: user issue, unlikely to be a vault bug.

Also I generally recommend going to a support discord (the spigot discord is full of kind people) and if discord isn't for you and if you have plenty of patience #spigot@irc.spi.gt and #paper-dev@irc.esper.net will always be there for you. Github issues isn't really meant for getting support

Jens-Co commented 2 years ago

Thanks for getting back to me that fast. Not having installed an eco plugin was indeed the cause of my issue, ( was using a debug server ) Thanks for the tip on caching that one!