diff --git a/lib/Minefaconomy-0.2.jar b/lib/Minefaconomy-0.2.jar new file mode 100644 index 0000000..d8852cf Binary files /dev/null and b/lib/Minefaconomy-0.2.jar differ diff --git a/pom.xml b/pom.xml index cb9cf83..b7f5f1f 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,13 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms DroxPerms 0.5.0 + + me.coniin.plugins.minefaconomy + MineFaConomy + 0.2 + system + ${project.basedir}/lib/Minefaconomy.jar + net.krinsoft Privileges diff --git a/src/net/milkbowl/vault/Vault.java b/src/net/milkbowl/vault/Vault.java index 2b2873c..c86fc4e 100644 --- a/src/net/milkbowl/vault/Vault.java +++ b/src/net/milkbowl/vault/Vault.java @@ -60,6 +60,7 @@ import net.milkbowl.vault.economy.plugins.Economy_iConomy4; import net.milkbowl.vault.economy.plugins.Economy_iConomy5; import net.milkbowl.vault.economy.plugins.Economy_iConomy6; import net.milkbowl.vault.economy.plugins.Economy_SDFEconomy; +import net.milkbowl.vault.economy.plugins.Economy_Minefaconomy; import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.plugins.Permission_DroxPerms; import net.milkbowl.vault.permission.plugins.Permission_GroupManager; @@ -202,7 +203,10 @@ public class Vault extends JavaPlugin { private void loadEconomy() { // Try to load MiConomy hookEconomy("MiConomy", Economy_MiConomy.class, ServicePriority.Normal, "com.gmail.bleedobsidian.miconomy.Main"); - + + // Try to load MiFaConomy + hookEconomy("MineFaConomy", Economy_Minefaconomy.class, ServicePriority.Normal, "me.coniin.plugins.minefaconomy.Minefaconomy"); + // Try to load MultiCurrency hookEconomy("MultiCurrency", Economy_MultiCurrency.class, ServicePriority.Normal, "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList"); diff --git a/src/net/milkbowl/vault/economy/plugins/Economy_Minefaconomy.java b/src/net/milkbowl/vault/economy/plugins/Economy_Minefaconomy.java new file mode 100644 index 0000000..9b1dc70 --- /dev/null +++ b/src/net/milkbowl/vault/economy/plugins/Economy_Minefaconomy.java @@ -0,0 +1,219 @@ +package net.milkbowl.vault.economy.plugins; + +import java.util.List; +import java.util.logging.Logger; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.server.PluginDisableEvent; +import org.bukkit.event.server.PluginEnableEvent; +import org.bukkit.plugin.Plugin; + +import me.coniin.plugins.minefaconomy.Minefaconomy; + +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.EconomyResponse; + +public class Economy_Minefaconomy implements Economy { + private static final Logger log = Logger.getLogger("Minecraft"); + + private final String name = "Minefaconomy"; + + private Plugin plugin = null; + private Minefaconomy economy = null; + + public Economy_Minefaconomy(Plugin plugin) { + this.plugin = plugin; + Bukkit.getServer().getPluginManager() + .registerEvents(new EconomyServerListener(this), plugin); + Plugin econ = null; + // Load Plugin in case it was loaded before + if (economy == null) { + econ = plugin.getServer().getPluginManager() + .getPlugin("Minefaconomy"); + log.info("Loading Minefaconomy"); + } + if (econ != null && econ.isEnabled()) { + economy = (Minefaconomy) econ; + log.info(String.format("[%s][Economy] %s hooked.", plugin + .getDescription().getName(), this.name)); + return; + } + log.info("Error Loading Minefaconomy"); + } + + public class EconomyServerListener implements Listener { + Economy_Minefaconomy economy_minefaconomy = null; + + public EconomyServerListener(Economy_Minefaconomy economy_minefaconomy) { + this.economy_minefaconomy = economy_minefaconomy; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPluginEnable(PluginEnableEvent event) { + if (economy_minefaconomy.economy == null) { + Plugin mfc = plugin.getServer().getPluginManager().getPlugin("Minefaconomy"); + + if (mfc != null) { + economy_minefaconomy.economy = (Minefaconomy) economy; + log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy_minefaconomy.name)); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPluginDisable(PluginDisableEvent event) { + if (economy_minefaconomy.economy != null) { + if (event.getPlugin().getDescription().getName().equals("Minefaconomy")) { + economy_minefaconomy.economy = null; + log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy_minefaconomy.name)); + } + } + } + } + + @Override + public boolean isEnabled() { + return economy != null && economy.isEnabled(); + } + + @Override + public String getName() { + return name; + } + + @Override + public int fractionalDigits() { + return economy.vaultLayer.fractionalDigits(); + } + + @Override + public String format(double amount) { + return economy.vaultLayer.format(amount); + } + + @Override + public String currencyNamePlural() { + return economy.vaultLayer.currencyNamePlural(); + } + + @Override + public String currencyNameSingular() { + return economy.vaultLayer.currencyNameSingular(); + } + + @Override + public boolean hasAccount(String playerName) { + return economy.vaultLayer.hasAccount(playerName); + } + + @Override + public boolean hasAccount(String playerName, String worldName) { + return economy.vaultLayer.hasAccount(playerName); + } + + @Override + public double getBalance(String playerName) { + return economy.vaultLayer.getBalance(playerName); + } + + @Override + public double getBalance(String playerName, String world) { + return economy.vaultLayer.getBalance(playerName); + } + + @Override + public boolean has(String playerName, double amount) { + return economy.vaultLayer.has(playerName, amount); + } + + @Override + public boolean has(String playerName, String worldName, double amount) { + return economy.vaultLayer.has(playerName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(String playerName, double amount) { + return economy.vaultLayer.withdrawPlayer(playerName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(String playerName, String worldName, + double amount) { + return economy.vaultLayer.withdrawPlayer(playerName, amount); + } + + @Override + public EconomyResponse depositPlayer(String playerName, double amount) { + return economy.vaultLayer.depositPlayer(playerName, amount); + } + + @Override + public EconomyResponse depositPlayer(String playerName, String worldName, + double amount) { + return economy.vaultLayer.depositPlayer(playerName, amount); + } + + @Override + public boolean createPlayerAccount(String playerName) { + return economy.vaultLayer.createPlayerAccount(playerName); + } + + @Override + public boolean createPlayerAccount(String playerName, String worldName) { + return economy.vaultLayer.createPlayerAccount(playerName); + } + + @Override + public boolean hasBankSupport() { + return economy.vaultLayer.hasBankSupport(); + } + + @Override + public EconomyResponse createBank(String name, String player) { + return economy.vaultLayer.createBank(name, player); + } + + @Override + public EconomyResponse deleteBank(String name) { + return economy.vaultLayer.deleteBank(name); + } + + @Override + public EconomyResponse bankBalance(String name) { + return economy.vaultLayer.bankBalance(name); + } + + @Override + public EconomyResponse bankHas(String name, double amount) { + return economy.vaultLayer.bankHas(name, amount); + } + + @Override + public EconomyResponse bankWithdraw(String name, double amount) { + return economy.vaultLayer.bankWithdraw(name, amount); + } + + @Override + public EconomyResponse bankDeposit(String name, double amount) { + return economy.vaultLayer.bankDeposit(name, amount); + } + + @Override + public EconomyResponse isBankOwner(String name, String playerName) { + return economy.vaultLayer.isBankOwner(name, playerName); + } + + @Override + public EconomyResponse isBankMember(String name, String playerName) { + return economy.vaultLayer.isBankMember(name, playerName); + } + + @Override + public List getBanks() { + return economy.vaultLayer.getBanks(); + } + +}