Open samldm 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)
The most basic solution is to register stuff on the 1st tick. BUT NEVER EVER OBTAIN THE SERVICE PROVIDER IN YOUR ONENABLE() OR CONSTURCTOR
Make sure you have Vault declared as a dependency in your plugin.yml
The above stacktrace is likely induced by ServerCore.getInstance().getServer().getPluginManager().disablePlugin(ServerCore.getInstance());
and further things in your code attempting to load additional classes. However once you invoke disablePlugin, the classloader is closed and you MUST NOT (as per RFC 2119) load any classes - be it classes of your plugin or classes of other plugins (in your case Vault's Chat
interface). A disabled plugin ought normally perform no actions.
Hello there, i have an error while trying to get the chat provider
spigot version: 1.20.1
plugins:
there is the error:
There is my code:
JavaPlugin:
VaultHook class: