MilkBowl / VaultAPI

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

getRegistration returns null #134

Closed zxcqirara closed 2 years ago

zxcqirara commented 2 years ago

My code:

getServer().getServicesManager().getRegistration(Economy.class);

Why it returns null & how to fix it? I need to check player's balance

PaperMC 1.18.1-132, localhost, no plugins except mine and Vault 1.7.3-b131

Geolykt commented 2 years ago

You need a plugin that registers the economy otherwise this is intended behaviour

zxcqirara commented 2 years ago

You need a plugin that registers the economy otherwise this is intended behaviour

How can I register it?

Geolykt commented 2 years ago

Read the documentation, it's straightforward enough that most people should be able to do it. If you do not intend to create an economy, use an economy plugin

zxcqirara commented 2 years ago

Documentation? Where is documentation? I found only example & javadocs. Example class returns null at this line too.

Geolykt commented 2 years ago

Okay, yeah you are right, not sure where I found this documentation I used ages back ... Anyways, found a snippet on the internet that does what you might need

Bukkit.getServicesManager().register(Economy.class, myEconomyInstance, plugin,  ServicePriority.Normal);

That being said, ONLY use this if you actually want to register an economy (as only one plugin should register it), if you do not have an economy, use a dedicated economy plugin

zxcqirara commented 2 years ago

Ok, thx, I'll try this later

Sleaker commented 2 years ago

@ChA0S-f4me Vault doesn't provide an economy implementation, if you are developing a plugin to use economy features you'll need to install an economy plugin that works with vault when you go to test things.