Minor cleanup of the economy helper class

This commit is contained in:
Kristian Knarvik 2021-09-02 01:34:06 +02:00
parent 3717e4d3b6
commit d624bb5103

View File

@ -6,11 +6,19 @@ import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicesManager;
public class EconomyHelper { /**
* Helper class for economy related functions
*/
public final class EconomyHelper {
private static Economy economy; private static Economy economy;
private EconomyHelper() {
}
/** /**
* Gets an economy instance for making transactions * Gets an economy instance for making transactions
* @return <p>An economy instance, or null if it's not initialized</p> * @return <p>An economy instance, or null if it's not initialized</p>
@ -30,9 +38,10 @@ public class EconomyHelper {
Server server = BooksWithoutBorders.getInstance().getServer(); Server server = BooksWithoutBorders.getInstance().getServer();
Plugin plugin = server.getPluginManager().getPlugin("Vault"); Plugin plugin = server.getPluginManager().getPlugin("Vault");
ServicesManager servicesManager = server.getServicesManager();
if (plugin != null) { if (plugin != null) {
RegisteredServiceProvider<Economy> economyProvider = server.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class);
if (economyProvider != null) { if (economyProvider != null) {
economy = economyProvider.getProvider(); economy = economyProvider.getProvider();
} }