From c4a3d433800bdb7e91191a40d6930a33bc8fab34 Mon Sep 17 00:00:00 2001 From: teamalpha5441 Date: Thu, 28 Nov 2013 01:46:49 +0100 Subject: [PATCH] Added TAEcon support --- lib/TAEcon.jar | Bin 0 -> 5433 bytes pom.xml | 9 +- src/net/milkbowl/vault/Vault.java | 4 + .../vault/economy/plugins/Economy_TAEcon.java | 258 ++++++++++++++++++ 4 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 lib/TAEcon.jar create mode 100644 src/net/milkbowl/vault/economy/plugins/Economy_TAEcon.java diff --git a/lib/TAEcon.jar b/lib/TAEcon.jar new file mode 100644 index 0000000000000000000000000000000000000000..f7484ba58dc1dfcd0c5a0f207f9ba008366e9c82 GIT binary patch literal 5433 zcma)=1yEG&yTEC1>28n`WCcN55M2q0r5j{v>8>S}ZV)~?L<9+?8+M7MmIf)MbXlZv z3F*8r_s;$N{&&8a`@HAOoHOq{&-*^-ojLQHpQb7<9t{@J%@80Bl*9TXXt40G)D(0< z0?O)&57j{G%8Cj)x`JwoSA$qsztx6^z^Vd*Ur1F2_(zAw>a>NXL{KZ}6&x&0RYIcL z*EksFn^KH7x90yYK$+qFj|BiXvu;k_w)QT9e$GxoNi`1LLKKm{A>WtSI)#6I8j-sz z2VkvDBZ~^+`0zMyJkR9fC@qg+jwkMI^UigLj$$!Z#*(DU5t%Ja*?DJq*N0(rrvxG0 zmx*g#`<;kUr^UimDPiaMn}lA%L}|v=wDgXmMW2lQF4-HN$=XFMAqCwDEcS6g>tR3Z zg}I6~Yi6L9{t3K}dc)AFrUH6M^l;Y>!V|&&!nDnI%&H_5wrz&U0$U_A&aqIabVY3D zGpH}LpFWTTA{2kAuB)55tJ6Ije0bZv2&H~~-%W37*nf7f7xjO;w{mrPWp8`iz1XlY zpj(JUacL1HZ8x;}to4LtcF0UmSx#5#+sybp{maMguF#iG(nl<~lmQi%7mT1OvUyW2 z5j97t-ePvMP1-Z0_`!YVm*(q9Z3 zZ_d-MYAC(;2;j`C_93!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oMx-4(0g3*G+hN&hOaibRi{=j|UBbHUVs#D&I>!)SVPWGM`XBVKS&~ z&AR`=j!iz2CVQNE4?ekg-xX~Q+1MTGF7{WoAV%K@<|HzH2-r)JBJD6e>EcN5M_%6z zo{BzB)6RmLuJkwQCBlC4y)%;iae-Ogj+6Q57AWe$9Kh+T8H5pca4ir-!y+Q1J&4bH zN;aO@qp&*ECM2)>#>d&R%L{81vjf5%M;5-Yc;-GGOxAe2<`8Pz1JU7*lDl|9S!O>_ za7Z>c`o&K)s-y`%rAfbS#hG{4VWXh3)Bi8q%ll(zuB9e@?%ew(Q!8${Wd2+ix#b(j zD?)s=$#o)PTvG8d@Sk3_uZ-1mf@4&U*N2y2mAh=tp96pR+kNF-j#VN$_Gn0Mk=TQ= zTVM`^S|N(lW6cCovSaWjG^_ja6W(MXtQZY1?V^uvr@p9S2$VunyX;1JHcRrOVPPjN z*{Ab{GAZ5KWOT>OnQBcx5~{ynZwVVX!GML%E6e#wN5aZ)kS%B2J=fX#eg3IdyvE}S zEg3-0!LXFaybF90sftPyMfi*=HjnnPQc1YhS`*5to2krEq2%-c9Cm3p>W22?nh70D z304EcbQcQOz+EK*pw+>0s)1WhsDV+)#ML2cfxW4APs9`WoJk}|$<^@`Z%A5~gt^G zWMSs!+AEGT8Sec>v$gMCc^XH_G9QAHkijFRM~qw(BA`tj->=`=vN7rBhaa|vAI7tk zoUTHSQLI)~RAy<5>Rhv*gp@Di!ktrii|-)g@Su^l4?TP%fwsww?F2MP?ju<)^z{;{aSuTpsxyXh%c*3;Jdbmx6*BxdMes4ySTbC8M%Xk)pK)x z$2Ysg;$rbZpR={^^cdWOh=1|lY1tF&2>4DpqiN5+b^eeF4*$AKK6uRyQefm=S@swMEStB4i%DAK2CugQat z%x)<}$u5ab;)X(8C~qkQ8;1t#Zu%`tXp6AcUas!{%!C6 z%)2#Re`=http://dev.bukkit.org/server-mods/vault/ Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. -Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy +Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon UTF-8 @@ -355,6 +355,13 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms system ${project.basedir}/lib/rscPermissions.jar + + net.teamalpha.taecon + TAEcon + 0.1 + system + ${project.basedir}/lib/TAEcon.jar + diff --git a/src/net/milkbowl/vault/Vault.java b/src/net/milkbowl/vault/Vault.java index 43420db..b82f8ed 100644 --- a/src/net/milkbowl/vault/Vault.java +++ b/src/net/milkbowl/vault/Vault.java @@ -55,6 +55,7 @@ import net.milkbowl.vault.economy.plugins.Economy_Gringotts; import net.milkbowl.vault.economy.plugins.Economy_McMoney; import net.milkbowl.vault.economy.plugins.Economy_MineConomy; import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency; +import net.milkbowl.vault.economy.plugins.Economy_TAEcon; import net.milkbowl.vault.economy.plugins.Economy_XPBank; import net.milkbowl.vault.economy.plugins.Economy_eWallet; import net.milkbowl.vault.economy.plugins.Economy_iConomy4; @@ -280,6 +281,9 @@ public class Vault extends JavaPlugin { // Try to load XPBank hookEconomy("XPBank", Economy_XPBank.class, ServicePriority.Normal, "com.gmail.mirelatrue.xpbank.XPBank"); + + // Try to load TAEcon + hookEconomy("TAEcon", Economy_TAEcon.class, ServicePriority.Normal, "net.teamalpha.taecon.TAEcon"); } /** diff --git a/src/net/milkbowl/vault/economy/plugins/Economy_TAEcon.java b/src/net/milkbowl/vault/economy/plugins/Economy_TAEcon.java new file mode 100644 index 0000000..ceb5ca0 --- /dev/null +++ b/src/net/milkbowl/vault/economy/plugins/Economy_TAEcon.java @@ -0,0 +1,258 @@ +/* This file is part of Vault. + + Vault is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Vault is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Vault. If not, see . + */ +package net.milkbowl.vault.economy.plugins; + +import java.util.ArrayList; +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 net.milkbowl.vault.economy.EconomyResponse; +import net.milkbowl.vault.economy.EconomyResponse.ResponseType; +import net.teamalpha.taecon.TAEcon; + +public class Economy_TAEcon implements net.milkbowl.vault.economy.Economy { + private static final Logger log = Logger.getLogger("Minecraft"); + + private final String name = "TAEcon"; + private Plugin plugin = null; + private TAEcon economy = null; + + public Economy_TAEcon(Plugin plugin){ + this.plugin = plugin; + Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin); + + if (economy == null) { + Plugin taecon = plugin.getServer().getPluginManager().getPlugin(name); + + if (taecon != null && taecon.isEnabled()) { + economy = (TAEcon) taecon; + log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name)); + } + } + } + + public class EconomyServerListener implements Listener { + Economy_TAEcon economy = null; + + public EconomyServerListener(Economy_TAEcon economy) { + this.economy = economy; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPluginEnable(PluginEnableEvent event) { + if (economy.economy == null) { + Plugin taecon = event.getPlugin(); + + if (taecon.getDescription().getName().equals(economy.name)) { + economy.economy = (TAEcon) taecon; + log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name)); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPluginDisable(PluginDisableEvent event) { + if (economy.economy != null) { + if (event.getPlugin().getDescription().getName().equals(economy.name)) { + economy.economy = null; + log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name)); + } + } + } + } + + @Override + public boolean isEnabled() { + return economy != null; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean hasBankSupport() { + return false; + } + + @Override + public int fractionalDigits() { + return 0; + } + + @Override + public String format(double amount) { + amount = Math.ceil(amount); + if (amount == 1) { + return String.format("%d %s", (int)amount, currencyNameSingular()); + } else { + return String.format("%d %s", (int)amount, currencyNamePlural()); + } + } + + @Override + public String currencyNamePlural() { + return economy.getCurrencyName(true); + } + + @Override + public String currencyNameSingular() { + return economy.getCurrencyName(false); + } + + @Override + public boolean hasAccount(String playerName) { + return true; + } + + @Override + public double getBalance(String playerName) { + return economy.getBalance(playerName); + } + + @Override + public boolean has(String playerName, double amount) { + return getBalance(playerName) >= amount; + } + + @Override + public EconomyResponse withdrawPlayer(String playerName, double amount) { + ResponseType rt; + String message; + int iamount = (int)Math.ceil(amount); + + if (has(playerName, amount)) { + if (economy.removeBalance(playerName, iamount)) { + rt = ResponseType.SUCCESS; + message = null; + } else { + rt = ResponseType.SUCCESS; + message = "ERROR"; + } + } else { + rt = ResponseType.FAILURE; + message = "Not enough money"; + } + + return new EconomyResponse(iamount, getBalance(playerName), rt, message); + } + + @Override + public EconomyResponse depositPlayer(String playerName, double amount) { + ResponseType rt; + String message; + int iamount = (int)Math.floor(amount); + + if (economy.addBalance(playerName, iamount)) { + rt = ResponseType.SUCCESS; + message = null; + } else { + rt = ResponseType.SUCCESS; + message = "ERROR"; + } + + return new EconomyResponse(iamount, getBalance(playerName), rt, message); + } + + @Override + public EconomyResponse createBank(String name, String player) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse deleteBank(String name) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse bankBalance(String name) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse bankHas(String name, double amount) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse bankWithdraw(String name, double amount) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse bankDeposit(String name, double amount) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse isBankOwner(String name, String playerName) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public EconomyResponse isBankMember(String name, String playerName) { + return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts"); + } + + @Override + public List getBanks() { + return new ArrayList(); + } + + @Override + public boolean createPlayerAccount(String playerName) { + return false; + } + + @Override + public boolean hasAccount(String playerName, String worldName) { + return true; + } + + @Override + public double getBalance(String playerName, String world) { + return getBalance(playerName); + } + + @Override + public boolean has(String playerName, String worldName, double amount) { + return has(playerName, amount); + } + + @Override + public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) { + return withdrawPlayer(playerName, amount); + } + + @Override + public EconomyResponse depositPlayer(String playerName, String worldName, double amount) { + return depositPlayer(playerName, amount); + } + + @Override + public boolean createPlayerAccount(String playerName, String worldName) { + return false; + } +}