Updated Register, built against CB 1240
This commit is contained in:
Binary file not shown.
@@ -88,6 +88,23 @@ public interface Method {
|
|||||||
*/
|
*/
|
||||||
public boolean hasBankAccount(String bank, String name);
|
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>.
|
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class Methods {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
plugin = manager.getPlugin(name);
|
plugin = manager.getPlugin(name);
|
||||||
if (plugin == null)
|
if (plugin == null || !plugin.isEnabled())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Method current = createMethod(plugin);
|
Method current = createMethod(plugin);
|
||||||
@@ -172,8 +172,7 @@ public class Methods {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (hasMethod()) {
|
if (hasMethod()) {
|
||||||
match = true;
|
match = true; break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferred.isEmpty())
|
if (preferred.isEmpty())
|
||||||
|
|||||||
@@ -58,6 +58,23 @@ public class BOSE6 implements Method {
|
|||||||
|| this.BOSEconomy.isBankMember(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) {
|
public MethodAccount getAccount(String name) {
|
||||||
if(!hasAccount(name))
|
if(!hasAccount(name))
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -57,6 +57,23 @@ public class BOSE7 implements Method {
|
|||||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, 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) {
|
public MethodAccount getAccount(String name) {
|
||||||
if(!hasAccount(name))
|
if(!hasAccount(name))
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ package com.garbagemule.register.payment.methods;
|
|||||||
import com.garbagemule.register.payment.Method;
|
import com.garbagemule.register.payment.Method;
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.api.Economy;
|
import com.earth2me.essentials.api.Economy;
|
||||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
|
||||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -58,6 +55,30 @@ public class EE17 implements Method {
|
|||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
if(!hasAccount(name))
|
if(!hasAccount(name))
|
||||||
return null;
|
return null;
|
||||||
@@ -93,8 +114,8 @@ public class EE17 implements Method {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
balance = Economy.getMoney(this.name);
|
balance = Economy.getMoney(this.name);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] Failed to grab balance in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return balance;
|
return balance;
|
||||||
@@ -103,11 +124,8 @@ public class EE17 implements Method {
|
|||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.setMoney(name, amount);
|
Economy.setMoney(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,11 +135,8 @@ public class EE17 implements Method {
|
|||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.add(name, amount);
|
Economy.add(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,11 +146,8 @@ public class EE17 implements Method {
|
|||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.subtract(name, amount);
|
Economy.subtract(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,11 +157,8 @@ public class EE17 implements Method {
|
|||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.multiply(name, amount);
|
Economy.multiply(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,11 +168,8 @@ public class EE17 implements Method {
|
|||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.divide(name, amount);
|
Economy.divide(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +179,8 @@ public class EE17 implements Method {
|
|||||||
public boolean hasEnough(double amount) {
|
public boolean hasEnough(double amount) {
|
||||||
try {
|
try {
|
||||||
return Economy.hasEnough(name, amount);
|
return Economy.hasEnough(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -183,8 +189,8 @@ public class EE17 implements Method {
|
|||||||
public boolean hasOver(double amount) {
|
public boolean hasOver(double amount) {
|
||||||
try {
|
try {
|
||||||
return Economy.hasMore(name, amount);
|
return Economy.hasMore(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -193,8 +199,8 @@ public class EE17 implements Method {
|
|||||||
public boolean hasUnder(double amount) {
|
public boolean hasUnder(double amount) {
|
||||||
try {
|
try {
|
||||||
return Economy.hasLess(name, amount);
|
return Economy.hasLess(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -203,8 +209,8 @@ public class EE17 implements Method {
|
|||||||
public boolean isNegative() {
|
public boolean isNegative() {
|
||||||
try {
|
try {
|
||||||
return Economy.isNegative(name);
|
return Economy.isNegative(name);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -53,6 +53,16 @@ public class MCUR implements Method {
|
|||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new MCurrencyAccount(name);
|
return new MCurrencyAccount(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,32 @@ public class iCo4 implements Method {
|
|||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,25 @@ public class iCo5 implements Method {
|
|||||||
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ public class iCo6 implements Method {
|
|||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount((new Accounts()).get(name));
|
return new iCoAccount((new Accounts()).get(name));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user