mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 04:25:14 +01:00
Remove Register - NO DEFAULT ECONOMY SUPPORT
This commit is contained in:
parent
58e2599991
commit
404f7296e0
2
pom.xml
2
pom.xml
@ -70,7 +70,7 @@
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.2.27</version>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iCo6</groupId>
|
||||
|
@ -2,7 +2,6 @@ package com.Acrobot.ChestShop;
|
||||
|
||||
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.RegisterListener;
|
||||
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.VaultListener;
|
||||
import com.Acrobot.ChestShop.Plugins.*;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
@ -34,11 +33,6 @@ public class Dependencies {
|
||||
String plugin = "Vault";
|
||||
Listener economy = VaultListener.initializeVault();
|
||||
|
||||
if (economy == null) {
|
||||
plugin = "Register";
|
||||
economy = RegisterListener.initializeRegister();
|
||||
}
|
||||
|
||||
if (economy == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,109 +0,0 @@
|
||||
package com.Acrobot.ChestShop.Listeners.Economy.Plugins;
|
||||
|
||||
import com.Acrobot.ChestShop.ChestShop;
|
||||
import com.Acrobot.ChestShop.Events.Economy.*;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Represents a Register connector
|
||||
*
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class RegisterListener implements Listener {
|
||||
private Method paymentMethod;
|
||||
|
||||
private RegisterListener(Method paymentMethod) {
|
||||
this.paymentMethod = paymentMethod;
|
||||
}
|
||||
|
||||
public static @Nullable RegisterListener initializeRegister() {
|
||||
Method method = Methods.load();
|
||||
|
||||
if (method == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new RegisterListener(method);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAmountCheck(CurrencyAmountEvent event) {
|
||||
if (!event.getAmount().equals(BigDecimal.ZERO)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setAmount(paymentMethod.getAccount(event.getAccount()).balance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCurrencyCheck(CurrencyCheckEvent event) {
|
||||
if (event.hasEnough()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean check = paymentMethod.getAccount(event.getAccount()).hasEnough(event.getDoubleAmount());
|
||||
event.hasEnough(check);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAccountCheck(AccountCheckEvent event) {
|
||||
if (event.hasAccount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean check = paymentMethod.hasAccount(event.getAccount());
|
||||
event.hasAccount(check);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCurrencyFormat(CurrencyFormatEvent event) {
|
||||
if (!event.getFormattedAmount().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String formatted = paymentMethod.format(event.getDoubleAmount());
|
||||
event.setFormattedAmount(formatted);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCurrencyAdd(CurrencyAddEvent event) {
|
||||
if (event.isAdded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
paymentMethod.getAccount(event.getTarget()).add(event.getDoubleAmount());
|
||||
event.setAdded(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCurrencySubtract(CurrencySubtractEvent event) {
|
||||
if (event.isSubtracted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
paymentMethod.getAccount(event.getTarget()).subtract(event.getDoubleAmount());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void onCurrencyTransfer(CurrencyTransferEvent event) {
|
||||
if (event.hasBeenTransferred()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(event.getAmount(), event.getSender(), event.getWorld());
|
||||
ChestShop.callEvent(currencySubtractEvent);
|
||||
|
||||
if (!currencySubtractEvent.isSubtracted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(currencySubtractEvent.getAmount(), event.getReceiver(), event.getWorld());
|
||||
ChestShop.callEvent(currencyAddEvent);
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
package com.nijikokun.register.payment.forChestShop;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by a payment method.
|
||||
*
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright Copyright (C) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public interface Method {
|
||||
/**
|
||||
* Encodes the Plugin into an Object disguised as the Plugin.
|
||||
* If you want the original Plugin Class you must cast it to the correct
|
||||
* Plugin, to do so you have to verify the name and or version then cast.
|
||||
* <p/>
|
||||
* <pre>
|
||||
* if(method.getName().equalsIgnoreCase("iConomy"))
|
||||
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
|
||||
*
|
||||
* @return <code>Object</code>
|
||||
* @see #getName()
|
||||
* @see #getVersion()
|
||||
*/
|
||||
Object getPlugin();
|
||||
|
||||
/**
|
||||
* Returns the actual name of this method.
|
||||
*
|
||||
* @return <code>String</code> Plugin name.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the actual version of this method.
|
||||
*
|
||||
* @return <code>String</code> Plugin version.
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the amount of decimal places that get stored
|
||||
* NOTE: it will return -1 if there is no rounding
|
||||
*
|
||||
* @return <code>int</code> for each decimal place
|
||||
*/
|
||||
int fractionalDigits();
|
||||
|
||||
/**
|
||||
* Formats amounts into this payment methods style of currency display.
|
||||
*
|
||||
* @param amount Double
|
||||
* @return <code>String</code> - Formatted Currency Display.
|
||||
*/
|
||||
String format(double amount);
|
||||
|
||||
/**
|
||||
* Allows the verification of bank API existence in this payment method.
|
||||
*
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
boolean hasBanks();
|
||||
|
||||
/**
|
||||
* Determines the existence of a bank via name.
|
||||
*
|
||||
* @param bank Bank name
|
||||
* @return <code>boolean</code>
|
||||
* @see #hasBanks
|
||||
*/
|
||||
boolean hasBank(String bank);
|
||||
|
||||
/**
|
||||
* Determines the existence of an account via name.
|
||||
*
|
||||
* @param name Account name
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
boolean hasAccount(String name);
|
||||
|
||||
/**
|
||||
* Check to see if an account <code>name</code> is tied to a <code>bank</code>.
|
||||
*
|
||||
* @param bank Bank name
|
||||
* @param name Account name
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
boolean hasBankAccount(String bank, String name);
|
||||
|
||||
/**
|
||||
* Forces an account creation
|
||||
*
|
||||
* @param name Account name
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
boolean createAccount(String name);
|
||||
|
||||
/**
|
||||
* Forces an account creation
|
||||
*
|
||||
* @param name Account name
|
||||
* @param balance Initial account balance
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
boolean createAccount(String name, double balance);
|
||||
|
||||
/**
|
||||
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
||||
*
|
||||
* @param name Account name
|
||||
* @return <code>MethodAccount</code> <em>or</em> <code>Null</code>
|
||||
*/
|
||||
MethodAccount getAccount(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a <code>MethodBankAccount</code> class for an account <code>name</code>.
|
||||
*
|
||||
* @param bank Bank name
|
||||
* @param name Account name
|
||||
* @return <code>MethodBankAccount</code> <em>or</em> <code>Null</code>
|
||||
*/
|
||||
MethodBankAccount getBankAccount(String bank, String name);
|
||||
|
||||
/**
|
||||
* Checks to verify the compatibility between this Method and a plugin.
|
||||
* Internal usage only, for the most part.
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
boolean isCompatible(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Set Plugin data.
|
||||
*
|
||||
* @param plugin Plugin
|
||||
*/
|
||||
void setPlugin(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Contains Calculator and Balance functions for Accounts.
|
||||
*/
|
||||
interface MethodAccount {
|
||||
double balance();
|
||||
|
||||
boolean set(double amount);
|
||||
|
||||
boolean add(double amount);
|
||||
|
||||
boolean subtract(double amount);
|
||||
|
||||
boolean multiply(double amount);
|
||||
|
||||
boolean divide(double amount);
|
||||
|
||||
boolean hasEnough(double amount);
|
||||
|
||||
boolean hasOver(double amount);
|
||||
|
||||
boolean hasUnder(double amount);
|
||||
|
||||
boolean isNegative();
|
||||
|
||||
boolean remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains Calculator and Balance functions for Bank Accounts.
|
||||
*/
|
||||
interface MethodBankAccount extends MethodAccount {
|
||||
String getBankName();
|
||||
|
||||
int getBankId();
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package com.nijikokun.register.payment.forChestShop;
|
||||
|
||||
import com.nijikokun.register.payment.forChestShop.methods.BOSE7;
|
||||
import com.nijikokun.register.payment.forChestShop.methods.iCo5;
|
||||
import com.nijikokun.register.payment.forChestShop.methods.iCo6;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class Methods {
|
||||
private static final Map<Method, String> PLUGINS_TO_LOAD = new HashMap<Method, String>() {{
|
||||
put(new iCo5(), "iConomy");
|
||||
put(new iCo6(), "iConomy");
|
||||
put(new BOSE7(), "BOSEconomy");
|
||||
}};
|
||||
private static String preferredPlugin;
|
||||
|
||||
public static void setPreferred(String plugin) {
|
||||
preferredPlugin = plugin;
|
||||
}
|
||||
|
||||
public static Method load() {
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
Method preferred = getPreferredMethod();
|
||||
if (preferred != null) {
|
||||
return preferred;
|
||||
}
|
||||
|
||||
for (String pluginName : PLUGINS_TO_LOAD.values()) {
|
||||
Plugin plugin = pluginManager.getPlugin(pluginName);
|
||||
if (plugin != null) {
|
||||
Method method = createMethod(plugin);
|
||||
if (method != null) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Method createMethod(Plugin plugin) {
|
||||
for (Method method : PLUGINS_TO_LOAD.keySet()) {
|
||||
if (method.isCompatible(plugin)) {
|
||||
method.setPlugin(plugin);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Method getPreferredMethod() {
|
||||
if (preferredPlugin == null || preferredPlugin.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(preferredPlugin);
|
||||
|
||||
if (plugin == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return createMethod(plugin);
|
||||
}
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* BOSEconomy 7 Implementation of Method
|
||||
*
|
||||
* @author Acrobot
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class BOSE7 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.7.0";
|
||||
}
|
||||
|
||||
public int fractionalDigits() {
|
||||
return this.BOSEconomy.getFractionalDigits();
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
|
||||
if (amount == 1)
|
||||
currency = this.BOSEconomy.getMoneyName();
|
||||
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name) {
|
||||
if (hasAccount(name))
|
||||
return false;
|
||||
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if (hasAccount(name))
|
||||
return false;
|
||||
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
this.BOSEconomy.setPlayerMoney(name, balance, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if (!hasAccount(name))
|
||||
createAccount(name);
|
||||
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if (!hasBankAccount(bank, name))
|
||||
return null;
|
||||
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||
&& plugin instanceof BOSEconomy
|
||||
&& !plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy) plugin;
|
||||
}
|
||||
|
||||
public static class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BOSEBankAccount implements MethodBankAccount, MethodAccount {
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getBankMoneyDouble(bank);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setBankMoney(bank, amount, true);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.BankAccount;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.iConomy.util.Constants;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* iConomy 5 Implementation of Method
|
||||
*
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo5 implements Method {
|
||||
private iConomy iconomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "5";
|
||||
}
|
||||
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return com.iConomy.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return Constants.Banking;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return com.iConomy.iConomy.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name) {
|
||||
return !hasAccount(name) && iConomy.Accounts.create(name);
|
||||
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if (hasAccount(name))
|
||||
return false;
|
||||
|
||||
if (!com.iConomy.iConomy.Accounts.create(name))
|
||||
return false;
|
||||
|
||||
getAccount(name).set(balance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name));
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iconomy = (iConomy) plugin;
|
||||
}
|
||||
|
||||
public static class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.balance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.set(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if (this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class iCoBankAccount implements MethodBankAccount {
|
||||
private BankAccount account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoBankAccount(BankAccount account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public BankAccount getiCoBankAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.account.getBankName();
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return this.account.getBankId();
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.balance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.set(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if (this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Account;
|
||||
import com.iCo6.system.Accounts;
|
||||
import com.iCo6.system.Holdings;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* iConomy 6 Implementation of Method
|
||||
*
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo6 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "6";
|
||||
}
|
||||
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return com.iCo6.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return (new Accounts()).exists(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name) {
|
||||
return !hasAccount(name) && (new Accounts()).create(name);
|
||||
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, double balance) {
|
||||
return !hasAccount(name) && (new Accounts()).create(name, balance);
|
||||
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount((new Accounts()).get(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy) plugin;
|
||||
}
|
||||
|
||||
public static class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.getBalance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if (this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ description: >
|
||||
|
||||
|
||||
softdepend: [LWC, Lockette, Deadbolt, OddItem, WorldGuard, Vault, Heroes,
|
||||
iConomy, BOSEconomy, SimpleChestLock, Residence]
|
||||
SimpleChestLock, Residence]
|
||||
commands:
|
||||
iteminfo:
|
||||
aliases: [iinfo]
|
||||
|
Loading…
Reference in New Issue
Block a user