Open Huh-DIETHGOD opened 11 months ago
ALWAYS get the service provider lazily - that is as late as possible, but preferably via https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/server/ServiceRegisterEvent.html.
If it is done eagerly you risk that the economy plugin hasn't been initialized yet which would necessarily blow up your plugin.
However this approach doesn't guard against the event where there is no economy plugin - at which point you just have to roll the dice and decide what you do from there (either do nothing and crash with a NPE, disable plugin when no eco plugin is active or disable certain functionalities of your plugin if the eco plugin is absent)
But there is XConomy plugin
This is an issue tracker, not a help forum. This is not an issue with Vault.
I already said that the fix is to obtain services lazily as you can never be certain when the plugins register their economies. The most basic solution is to register stuff on the 1st tick. BUT NEVER EVER OBTAIN THE SERVICE PROVIDER IN YOUR ONENABLE() OR CONSTURCTOR
ok ty
depend: [PlaceholderAPI, Vault, XConomy] api-version: 1.16
Error occurred while enabling UltimateRPGPlugin v0.0.1 ALPHA (Is it up to date?) java.lang.NullPointerException: null at Ultimate.huh.core.UltimateRPGPlugin.setupChat(UltimateRPGPlugin.java:150) ~[?:?] at Ultimate.huh.core.UltimateRPGPlugin.onEnable(UltimateRPGPlugin.java:53) ~[?:?]
IDE: Method invocation 'getProvider' may produce 'NullPointerException'
How to solve this?