diff --git a/pom.xml b/pom.xml
index 152cf26..44e19de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,10 @@
private
http://repo.songoda.com/artifactory/private/
+
+ reserve-repo
+ https://dl.bintray.com/theneweconomy/java/
+
@@ -85,5 +89,11 @@
2.3.2
provided
+
+ net.tnemc
+ Reserve
+ 0.1.3.0
+ provided
+
diff --git a/src/main/java/com/songoda/epicfurnaces/EpicFurnaces.java b/src/main/java/com/songoda/epicfurnaces/EpicFurnaces.java
index 8452399..673c807 100644
--- a/src/main/java/com/songoda/epicfurnaces/EpicFurnaces.java
+++ b/src/main/java/com/songoda/epicfurnaces/EpicFurnaces.java
@@ -5,6 +5,7 @@ import com.songoda.epicfurnaces.boost.BoostManager;
import com.songoda.epicfurnaces.command.CommandManager;
import com.songoda.epicfurnaces.economy.Economy;
import com.songoda.epicfurnaces.economy.PlayerPointsEconomy;
+import com.songoda.epicfurnaces.economy.ReserveEconomy;
import com.songoda.epicfurnaces.economy.VaultEconomy;
import com.songoda.epicfurnaces.furnace.Furnace;
import com.songoda.epicfurnaces.furnace.FurnaceBuilder;
@@ -107,13 +108,15 @@ public class EpicFurnaces extends JavaPlugin {
this.boostManager = new BoostManager();
this.blacklistHandler = new BlacklistHandler();
+ PluginManager pluginManager = Bukkit.getPluginManager();
+
// Setup Economy
- if (Setting.VAULT_ECONOMY.getBoolean()
- && getServer().getPluginManager().getPlugin("Vault") != null)
- this.economy = new VaultEconomy(this);
- else if (Setting.PLAYER_POINTS_ECONOMY.getBoolean()
- && getServer().getPluginManager().getPlugin("PlayerPoints") != null)
- this.economy = new PlayerPointsEconomy(this);
+ if (Setting.VAULT_ECONOMY.getBoolean() && pluginManager.isPluginEnabled("Vault"))
+ this.economy = new VaultEconomy();
+ else if (Setting.RESERVE_ECONOMY.getBoolean() && pluginManager.isPluginEnabled("Reserve"))
+ this.economy = new ReserveEconomy();
+ else if (Setting.PLAYER_POINTS_ECONOMY.getBoolean() && pluginManager.isPluginEnabled("PlayerPoints"))
+ this.economy = new PlayerPointsEconomy();
this.checkStorage();
@@ -126,8 +129,6 @@ public class EpicFurnaces extends JavaPlugin {
FurnaceTask.startTask(this);
HologramTask.startTask(this);
- PluginManager pluginManager = Bukkit.getPluginManager();
-
// Register Hologram Plugin
if (Setting.HOLOGRAMS.getBoolean()
&& pluginManager.isPluginEnabled("HolographicDisplays"))
diff --git a/src/main/java/com/songoda/epicfurnaces/economy/PlayerPointsEconomy.java b/src/main/java/com/songoda/epicfurnaces/economy/PlayerPointsEconomy.java
index fcfbaf7..bb244d5 100644
--- a/src/main/java/com/songoda/epicfurnaces/economy/PlayerPointsEconomy.java
+++ b/src/main/java/com/songoda/epicfurnaces/economy/PlayerPointsEconomy.java
@@ -1,19 +1,15 @@
package com.songoda.epicfurnaces.economy;
-import com.songoda.epicfurnaces.EpicFurnaces;
import org.black_ixx.playerpoints.PlayerPoints;
+import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
public class PlayerPointsEconomy implements Economy {
- private final EpicFurnaces plugin;
-
private final PlayerPoints playerPoints;
- public PlayerPointsEconomy(EpicFurnaces plugin) {
- this.plugin = plugin;
-
- this.playerPoints = (PlayerPoints) plugin.getServer().getPluginManager().getPlugin("PlayerPoints");
+ public PlayerPointsEconomy() {
+ this.playerPoints = (PlayerPoints) Bukkit.getServer().getPluginManager().getPlugin("PlayerPoints");
}
private int convertAmount(double amount) {
diff --git a/src/main/java/com/songoda/epicfurnaces/economy/ReserveEconomy.java b/src/main/java/com/songoda/epicfurnaces/economy/ReserveEconomy.java
new file mode 100644
index 0000000..f73317d
--- /dev/null
+++ b/src/main/java/com/songoda/epicfurnaces/economy/ReserveEconomy.java
@@ -0,0 +1,32 @@
+package com.songoda.epicfurnaces.economy;
+
+import net.tnemc.core.Reserve;
+import net.tnemc.core.economy.EconomyAPI;
+import org.bukkit.OfflinePlayer;
+
+import java.math.BigDecimal;
+
+public class ReserveEconomy implements Economy {
+
+ EconomyAPI economyAPI;
+
+ public ReserveEconomy() {
+ if (Reserve.instance().economyProvided())
+ economyAPI = Reserve.instance().economy();
+ }
+
+ @Override
+ public boolean hasBalance(OfflinePlayer player, double cost) {
+ return economyAPI.hasHoldings(player.getUniqueId(), new BigDecimal(cost));
+ }
+
+ @Override
+ public boolean withdrawBalance(OfflinePlayer player, double cost) {
+ return economyAPI.removeHoldings(player.getUniqueId(), new BigDecimal(cost));
+ }
+
+ @Override
+ public boolean deposit(OfflinePlayer player, double amount) {
+ return economyAPI.addHoldings(player.getUniqueId(), new BigDecimal(amount));
+ }
+}
diff --git a/src/main/java/com/songoda/epicfurnaces/economy/VaultEconomy.java b/src/main/java/com/songoda/epicfurnaces/economy/VaultEconomy.java
index ebb6c57..834808d 100644
--- a/src/main/java/com/songoda/epicfurnaces/economy/VaultEconomy.java
+++ b/src/main/java/com/songoda/epicfurnaces/economy/VaultEconomy.java
@@ -1,18 +1,13 @@
package com.songoda.epicfurnaces.economy;
-import com.songoda.epicfurnaces.EpicFurnaces;
+import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
public class VaultEconomy implements Economy {
-
- private final EpicFurnaces plugin;
-
private final net.milkbowl.vault.economy.Economy vault;
- public VaultEconomy(EpicFurnaces plugin) {
- this.plugin = plugin;
-
- this.vault = plugin.getServer().getServicesManager().
+ public VaultEconomy() {
+ this.vault = Bukkit.getServicesManager().
getRegistration(net.milkbowl.vault.economy.Economy.class).getProvider();
}
diff --git a/src/main/java/com/songoda/epicfurnaces/utils/settings/Setting.java b/src/main/java/com/songoda/epicfurnaces/utils/settings/Setting.java
index 259b809..cc2ca19 100644
--- a/src/main/java/com/songoda/epicfurnaces/utils/settings/Setting.java
+++ b/src/main/java/com/songoda/epicfurnaces/utils/settings/Setting.java
@@ -53,6 +53,9 @@ public enum Setting {
VAULT_ECONOMY("Economy.Use Vault Economy", true,
"Should Vault be used?"),
+ RESERVE_ECONOMY("Economy.Use Reserve Economy", true,
+ "Should Reserve be used?"),
+
PLAYER_POINTS_ECONOMY("Economy.Use Player Points Economy", false,
"Should PlayerPoints be used?"),