diff --git a/pom.xml b/pom.xml index 717cbf7e..cca19564 100644 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,6 @@ vault 1.7.1 - - net.nifheim.beelzebu - Coins - 2.3.2 - me.robin leaderheads diff --git a/src/main/java/me/goodandevil/skyblock/economy/EconomyManager.java b/src/main/java/me/goodandevil/skyblock/economy/EconomyManager.java index ba07ae8f..3527b3cb 100644 --- a/src/main/java/me/goodandevil/skyblock/economy/EconomyManager.java +++ b/src/main/java/me/goodandevil/skyblock/economy/EconomyManager.java @@ -1,16 +1,13 @@ package me.goodandevil.skyblock.economy; +import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent; +import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.RegisteredServiceProvider; -import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent; -import net.milkbowl.vault.economy.Economy; -import net.nifheim.beelzebu.coins.CoinsAPI; - public class EconomyManager { - private EconomyPlugin economyPlugin; private Economy economy; public EconomyManager() { @@ -19,43 +16,24 @@ public class EconomyManager { public void setup() { if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) { - RegisteredServiceProvider registeredServiceProvider = Bukkit.getServer().getServicesManager() - .getRegistration(Economy.class); + RegisteredServiceProvider registeredServiceProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); - if (registeredServiceProvider != null) { + if (registeredServiceProvider != null) economy = registeredServiceProvider.getProvider(); - } - - economyPlugin = EconomyPlugin.Vault; - } else if (Bukkit.getServer().getPluginManager().getPlugin("Coins") != null) { - economyPlugin = EconomyPlugin.Coins; } } public double getBalance(Player player) { - if (economy != null) { - return economy.getBalance(player); - } else if (economyPlugin == EconomyPlugin.Coins) { - return CoinsAPI.getCoins(player.getUniqueId()); - } - - return 0.0D; + return economy == null ? 0.0D : economy.getBalance(player); } public boolean hasBalance(Player player, double money) { - if (getBalance(player) >= money) { - return true; - } - - return false; + return getBalance(player) >= money; } public void withdraw(Player player, double money) { - if (economy != null) { + if (economy != null) economy.withdrawPlayer(player, money); - } else if (economyPlugin == EconomyPlugin.Coins) { - CoinsAPI.takeCoins(player.getUniqueId(), money); - } Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money)); } @@ -63,25 +41,12 @@ public class EconomyManager { public void deposit(Player player, double money) { if (economy != null) { economy.depositPlayer(player, money); - } else if (economyPlugin == EconomyPlugin.Coins) { - CoinsAPI.addCoins(player.getUniqueId(), money); } Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money)); } public boolean isEconomy() { - if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null - && Bukkit.getServer().getPluginManager().getPlugin("Coins") == null) { - return false; - } - - return true; - } - - public enum EconomyPlugin { - - Vault, Coins; - + return Bukkit.getServer().getPluginManager().getPlugin("Vault") != null; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0dd7f295..03b5f733 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ version: maven-version-number api-version: 1.13 description: A unique SkyBlock plugin author: Songoda -softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, Coins, LeaderHeads] +softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads] loadbefore: [Multiverse-Core] commands: island: