mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2024-11-27 12:25:52 +01:00
Reserve Support.
This commit is contained in:
parent
caab3afaa5
commit
af5d716987
10
pom.xml
10
pom.xml
@ -56,6 +56,10 @@
|
||||
<id>private</id>
|
||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>reserve-repo</id>
|
||||
<url>https://dl.bintray.com/theneweconomy/java/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -85,5 +89,11 @@
|
||||
<version>2.3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.tnemc</groupId>
|
||||
<artifactId>Reserve</artifactId>
|
||||
<version>0.1.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -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"))
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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?"),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user