mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-25 17:01:28 +01:00
Added support for Reserve economy
This commit is contained in:
parent
6bb498c607
commit
2c8c6190ee
@ -15,6 +15,9 @@ dependencies {
|
|||||||
// Vault
|
// Vault
|
||||||
compileOnly (group: 'net.milkbowl', name: 'vault', version: '1.7.1')
|
compileOnly (group: 'net.milkbowl', name: 'vault', version: '1.7.1')
|
||||||
|
|
||||||
|
// Reserve
|
||||||
|
compileOnly (group: 'net.tnemc', name: 'Reserve', version: '0.1.3.0')
|
||||||
|
|
||||||
// Leaderheads
|
// Leaderheads
|
||||||
compileOnly (group: 'me.robin', name: 'leaderheads', version: '1.0')
|
compileOnly (group: 'me.robin', name: 'leaderheads', version: '1.0')
|
||||||
|
|
||||||
|
@ -3,16 +3,25 @@ package me.goodandevil.skyblock.economy;
|
|||||||
import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
|
import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import net.tnemc.core.Reserve;
|
||||||
|
import net.tnemc.core.economy.EconomyAPI;
|
||||||
|
import net.tnemc.core.permissions.PermissionsAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class EconomyManager {
|
public class EconomyManager {
|
||||||
|
|
||||||
private Economy economy = null;
|
// Vault
|
||||||
private Permission permission = null;
|
private Economy vaultEconomy = null;
|
||||||
|
private Permission vaultPermission = null;
|
||||||
|
|
||||||
|
// Reserve
|
||||||
|
private EconomyAPI reserveEconomy = null;
|
||||||
|
// private PermissionsAPI reservePermission = null;
|
||||||
|
|
||||||
public EconomyManager() {
|
public EconomyManager() {
|
||||||
setup();
|
setup();
|
||||||
@ -23,48 +32,68 @@ public class EconomyManager {
|
|||||||
RegisteredServiceProvider<Economy> economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
|
||||||
if (economyRsp != null)
|
if (economyRsp != null)
|
||||||
economy = economyRsp.getProvider();
|
this.vaultEconomy = economyRsp.getProvider();
|
||||||
|
|
||||||
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
if (permissionRsp != null)
|
if (permissionRsp != null)
|
||||||
permission = permissionRsp.getProvider();
|
this.vaultPermission = permissionRsp.getProvider();
|
||||||
|
} else if (Bukkit.getServer().getPluginManager().getPlugin("Reserve") != null) {
|
||||||
|
if (Reserve.instance().economyProvided())
|
||||||
|
this.reserveEconomy = Reserve.instance().economy();
|
||||||
|
|
||||||
|
// if (Reserve.instance().permissionsProvided())
|
||||||
|
// this.reservePermission = Reserve.instance().permissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBalance(Player player) {
|
public double getBalance(Player player) {
|
||||||
return economy == null ? 0.0D : economy.getBalance(player);
|
if (this.vaultEconomy != null)
|
||||||
|
return this.vaultEconomy.getBalance(player);
|
||||||
|
|
||||||
|
if (this.reserveEconomy != null)
|
||||||
|
return this.reserveEconomy.getHoldings(player.getUniqueId()).doubleValue();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBalance(Player player, double money) {
|
public boolean hasBalance(Player player, double money) {
|
||||||
return getBalance(player) >= money;
|
return this.getBalance(player) >= money;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void withdraw(Player player, double money) {
|
public void withdraw(Player player, double money) {
|
||||||
if (economy != null)
|
if (this.vaultEconomy != null)
|
||||||
economy.withdrawPlayer(player, money);
|
this.vaultEconomy.withdrawPlayer(player, money);
|
||||||
|
else if (this.reserveEconomy != null)
|
||||||
|
this.reserveEconomy.removeHoldings(player.getUniqueId(), new BigDecimal(money));
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deposit(Player player, double money) {
|
public void deposit(Player player, double money) {
|
||||||
if (economy != null) {
|
if (this.vaultEconomy != null)
|
||||||
economy.depositPlayer(player, money);
|
this.vaultEconomy.depositPlayer(player, money);
|
||||||
}
|
else if (this.reserveEconomy != null)
|
||||||
|
this.reserveEconomy.addHoldings(player.getUniqueId(), new BigDecimal(money));
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
|
public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
|
||||||
if (permission != null)
|
if (this.vaultPermission != null)
|
||||||
return permission.playerHas(world, offlinePlayer, perm);
|
return this.vaultPermission.playerHas(world, offlinePlayer, perm);
|
||||||
|
|
||||||
|
// if (this.reservePermission != null) {
|
||||||
|
// // TODO
|
||||||
|
// }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEconomy() {
|
public boolean isEconomy() {
|
||||||
return economy != null;
|
return this.vaultEconomy != null || this.reserveEconomy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPermission() {
|
public boolean isPermission() {
|
||||||
return permission != null;
|
return this.vaultPermission != null/* || this.reservePermission != null*/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1060,6 +1060,7 @@ public enum Materials {
|
|||||||
int data;
|
int data;
|
||||||
boolean is13Plusonly;
|
boolean is13Plusonly;
|
||||||
private Material cachedMaterial;
|
private Material cachedMaterial;
|
||||||
|
private boolean isMaterialParsed = false;
|
||||||
|
|
||||||
Materials(String old13Mat, String old12Mat, int data) {
|
Materials(String old13Mat, String old12Mat, int data) {
|
||||||
this(old13Mat, old12Mat, data, false);
|
this(old13Mat, old12Mat, data, false);
|
||||||
@ -1237,7 +1238,7 @@ public enum Materials {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Material parseMaterial() {
|
public Material parseMaterial() {
|
||||||
if (this.cachedMaterial != null)
|
if (this.cachedMaterial != null || this.isMaterialParsed)
|
||||||
return this.cachedMaterial;
|
return this.cachedMaterial;
|
||||||
|
|
||||||
if (this.isSpawner() && this != Materials.SPAWNER) {
|
if (this.isSpawner() && this != Materials.SPAWNER) {
|
||||||
@ -1260,6 +1261,7 @@ public enum Materials {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.cachedMaterial = Material.matchMaterial(old12Mat);
|
this.cachedMaterial = Material.matchMaterial(old12Mat);
|
||||||
|
this.isMaterialParsed = true;
|
||||||
return this.cachedMaterial;
|
return this.cachedMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ version: @version@
|
|||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: A unique SkyBlock plugin
|
description: A unique SkyBlock plugin
|
||||||
author: Songoda
|
author: Songoda
|
||||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
|
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
|
||||||
loadbefore: [Multiverse-Core]
|
loadbefore: [Multiverse-Core]
|
||||||
commands:
|
commands:
|
||||||
island:
|
island:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
allprojects {
|
allprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
group = 'com.goodandevil.skyblock'
|
group = 'com.goodandevil.skyblock'
|
||||||
version = 'Build-78'
|
version = 'Build-78.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
Loading…
Reference in New Issue
Block a user