mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
Removed Coins softdepend, Vault is now required if you are using it
This commit is contained in:
parent
acd2551999
commit
12eeb7bc7e
5
pom.xml
5
pom.xml
@ -39,11 +39,6 @@
|
||||
<artifactId>vault</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.nifheim.beelzebu</groupId>
|
||||
<artifactId>Coins</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.robin</groupId>
|
||||
<artifactId>leaderheads</artifactId>
|
||||
|
@ -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<Economy> registeredServiceProvider = Bukkit.getServer().getServicesManager()
|
||||
.getRegistration(Economy.class);
|
||||
RegisteredServiceProvider<Economy> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user