mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-23 16:41:38 +01:00
Register v0.6
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1456 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
4bd6bdcc39
commit
fa963505e8
@ -305,7 +305,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
double amount = value - account.balance();
|
||||
account.add(amount);
|
||||
account.(amount);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.earth2me.essentials.register.payment;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public interface Method {
|
||||
public Object getPlugin();
|
||||
public String getName();
|
||||
@ -11,9 +13,12 @@ public interface Method {
|
||||
public boolean hasBankAccount(String bank, String name);
|
||||
public MethodAccount getAccount(String name);
|
||||
public MethodBankAccount getBankAccount(String bank, String name);
|
||||
public boolean isCompatible(Plugin plugin);
|
||||
public void setPlugin(Plugin plugin);
|
||||
|
||||
public interface MethodAccount {
|
||||
public double balance();
|
||||
public boolean set(double amount);
|
||||
public boolean add(double amount);
|
||||
public boolean subtract(double amount);
|
||||
public boolean multiply(double amount);
|
||||
@ -32,6 +37,7 @@ public interface Method {
|
||||
public double balance();
|
||||
public String getBankName();
|
||||
public int getBankId();
|
||||
public boolean set(double amount);
|
||||
public boolean add(double amount);
|
||||
public boolean subtract(double amount);
|
||||
public boolean multiply(double amount);
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.earth2me.essentials.register.payment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class MethodFactory {
|
||||
|
||||
private static Set<Method> Methods = new HashSet<Method>();
|
||||
|
||||
public static Method createMethod(Plugin plugin) {
|
||||
for (Method method: Methods) {
|
||||
if (method.isCompatible(plugin)) {
|
||||
method.setPlugin(plugin);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addMethod(Method method) {
|
||||
Methods.add(method);
|
||||
}
|
||||
}
|
@ -1,61 +1,23 @@
|
||||
package com.earth2me.essentials.register.payment;
|
||||
|
||||
import com.iConomy.iConomy;
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
public class Methods {
|
||||
|
||||
private Method Method = null;
|
||||
public Plugin method = null;
|
||||
|
||||
|
||||
public boolean setMethod(Plugin method) {
|
||||
PluginManager loader = method.getServer().getPluginManager();
|
||||
|
||||
if(method.isEnabled()) {
|
||||
PluginDescriptionFile info = method.getDescription();
|
||||
String name = info.getName();
|
||||
|
||||
if(name.equalsIgnoreCase("iconomy")) {
|
||||
if(method.getClass().getName().equals("com.iConomy.iConomy"))
|
||||
Method = new MethodiCo5((iConomy)method);
|
||||
else { Method = new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method); }
|
||||
} else if(name.equalsIgnoreCase("boseconomy")) {
|
||||
Method = new MethodBOSEconomy((BOSEconomy)method);
|
||||
}
|
||||
if (method.isEnabled()) {
|
||||
Method plugin = MethodFactory.createMethod(method);
|
||||
if (plugin != null) Method = plugin;
|
||||
}
|
||||
|
||||
if(!hasMethod()) {
|
||||
if(loader.getPlugin("iConomy") != null) {
|
||||
method = loader.getPlugin("iConomy");
|
||||
if(method.getClass().getName().equals("com.iConomy.iConomy"))
|
||||
Method = new MethodiCo5((iConomy)method);
|
||||
else { Method = new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method); }
|
||||
} else if(loader.getPlugin("BOSEconomy") != null) {
|
||||
method = loader.getPlugin("BOSEconomy");
|
||||
Method = new MethodBOSEconomy((BOSEconomy)method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return hasMethod();
|
||||
}
|
||||
|
||||
public boolean checkDisabled(Plugin method) {
|
||||
PluginDescriptionFile info = method.getDescription();
|
||||
String name = info.getName();
|
||||
|
||||
if(name.equalsIgnoreCase("iconomy")) {
|
||||
if(method.getClass().getName().equals("com.iConomy.iConomy"))
|
||||
Method = null;
|
||||
else { Method = null; }
|
||||
} else if(name.equalsIgnoreCase("boseconomy")) {
|
||||
Method = null;
|
||||
} else if(name.equalsIgnoreCase("essentials")) {
|
||||
Method = null;
|
||||
}
|
||||
|
||||
if(!hasMethod()) return true;
|
||||
if (Method.isCompatible(method)) Method = null;
|
||||
return (Method == null);
|
||||
}
|
||||
|
||||
@ -66,5 +28,4 @@ public class Methods {
|
||||
public Method getMethod() {
|
||||
return Method;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,201 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.earth2me.essentials.register.payment.MethodFactory;
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BOSE implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
static {
|
||||
MethodFactory.addMethod(new BOSE());
|
||||
}
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.6.2";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return new BOSEBankAccount(bank, name, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public 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 Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name));
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), 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 class BOSEBankAccount implements MethodBankAccount {
|
||||
private String bank;
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEBankAccount(String bank, String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return Double.valueOf(this.BOSEconomy.getBankMoney(name));
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setBankMoney(name, IntAmount, true);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance + IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(this.name, (balance / IntAmount), 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.earth2me.essentials.register.payment.MethodFactory;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class iCo4 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
static {
|
||||
MethodFactory.addMethod(new iCo4());
|
||||
}
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "4";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.getBank().format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.iConomy.getBank().hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(this.iConomy.getBank().getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.account.getBalance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.account.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.account.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.account.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,214 @@
|
||||
package com.earth2me.essentials.register.payment.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.earth2me.essentials.register.payment.Method;
|
||||
import com.earth2me.essentials.register.payment.MethodFactory;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class iCo5 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
static {
|
||||
MethodFactory.addMethod(new iCo5());
|
||||
}
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "5";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return Constants.Banking;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.iConomy.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return (hasBank(bank)) ? false : this.iConomy.getBank(name).hasAccount(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(this.iConomy.getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user