Updated Register, built against CB 1240

This commit is contained in:
Garbage Mule 2011-10-04 02:23:24 +02:00
parent 69ad343e16
commit 7df41a6027
10 changed files with 166 additions and 41 deletions

Binary file not shown.

View File

@ -88,6 +88,23 @@ public interface Method {
*/
public boolean hasBankAccount(String bank, String name);
/**
* Forces an account creation
*
* @param name Account name
* @return <code>boolean</code>
*/
public boolean createAccount(String name);
/**
* Forces an account creation
*
* @param name Account name
* @param balance Initial account balance
* @return <code>boolean</code>
*/
public boolean createAccount(String name, Double balance);
/**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
*

View File

@ -149,7 +149,7 @@ public class Methods {
break;
plugin = manager.getPlugin(name);
if (plugin == null)
if (plugin == null || !plugin.isEnabled())
continue;
Method current = createMethod(plugin);
@ -172,8 +172,7 @@ public class Methods {
continue;
if (hasMethod()) {
match = true;
break;
match = true; break;
}
if (preferred.isEmpty())

View File

@ -58,6 +58,23 @@ public class BOSE6 implements Method {
|| 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))
return null;

View File

@ -57,6 +57,23 @@ public class BOSE7 implements Method {
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))
return null;

View File

@ -3,9 +3,6 @@ package com.garbagemule.register.payment.methods;
import com.garbagemule.register.payment.Method;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.api.Economy;
import com.earth2me.essentials.api.NoLoanPermittedException;
import com.earth2me.essentials.api.UserDoesNotExistException;
import org.bukkit.plugin.Plugin;
@ -58,6 +55,30 @@ public class EE17 implements Method {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
Economy.createNPC(name);
return true;
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
Economy.createNPC(name);
try {
Economy.setMoney(name, balance);
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
return true;
}
public MethodAccount getAccount(String name) {
if(!hasAccount(name))
return null;
@ -93,8 +114,8 @@ public class EE17 implements Method {
try {
balance = Economy.getMoney(this.name);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] Failed to grab balance in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return balance;
@ -103,11 +124,8 @@ public class EE17 implements Method {
public boolean set(double amount) {
try {
Economy.setMoney(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -117,11 +135,8 @@ public class EE17 implements Method {
public boolean add(double amount) {
try {
Economy.add(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -131,11 +146,8 @@ public class EE17 implements Method {
public boolean subtract(double amount) {
try {
Economy.subtract(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -145,11 +157,8 @@ public class EE17 implements Method {
public boolean multiply(double amount) {
try {
Economy.multiply(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -159,11 +168,8 @@ public class EE17 implements Method {
public boolean divide(double amount) {
try {
Economy.divide(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -173,8 +179,8 @@ public class EE17 implements Method {
public boolean hasEnough(double amount) {
try {
return Economy.hasEnough(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;
@ -183,8 +189,8 @@ public class EE17 implements Method {
public boolean hasOver(double amount) {
try {
return Economy.hasMore(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;
@ -193,8 +199,8 @@ public class EE17 implements Method {
public boolean hasUnder(double amount) {
try {
return Economy.hasLess(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;
@ -203,8 +209,8 @@ public class EE17 implements Method {
public boolean isNegative() {
try {
return Economy.isNegative(name);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;

View File

@ -53,6 +53,16 @@ public class MCUR implements Method {
return false;
}
public boolean createAccount(String name) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, 0);
return true;
}
public boolean createAccount(String name, Double balance) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, balance);
return true;
}
public MethodAccount getAccount(String name) {
return new MCurrencyAccount(name);
}

View File

@ -53,6 +53,32 @@ public class iCo4 implements Method {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
try {
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
} catch(Exception E) {
return false;
}
return true;
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
try {
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
} catch(Exception E) {
return false;
}
return true;
}
public MethodAccount getAccount(String name) {
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
}

View File

@ -56,6 +56,25 @@ public class iCo5 implements Method {
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
return com.iConomy.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));
}

View File

@ -55,6 +55,20 @@ public class iCo6 implements Method {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
return (new Accounts()).create(name);
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
return (new Accounts()).create(name, balance);
}
public MethodAccount getAccount(String name) {
return new iCoAccount((new Accounts()).get(name));
}