Updated economy support
This commit is contained in:
Binary file not shown.
@@ -1292,7 +1292,7 @@ public class Arena
|
|||||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||||
{
|
{
|
||||||
//if (plugin.Methods.hasMethod() && !plugin.Method.getAccount(p.getName()).hasEnough(stack.getAmount()))
|
//if (plugin.Methods.hasMethod() && !plugin.Method.getAccount(p.getName()).hasEnough(stack.getAmount()))
|
||||||
if (plugin.Methods.hasMethod() && !(plugin.Method.getAccount(p.getName()).balance() >= stack.getAmount()))
|
if (plugin.Method != null && !(plugin.Method.getAccount(p.getName()).balance() >= stack.getAmount()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Normal stack
|
// Normal stack
|
||||||
@@ -1317,7 +1317,7 @@ public class Arena
|
|||||||
|
|
||||||
// Take some economy money
|
// Take some economy money
|
||||||
for (InventoryItem item : InventoryItem.extractAllFromArray(MobArena.ECONOMY_MONEY_ID, fee))
|
for (InventoryItem item : InventoryItem.extractAllFromArray(MobArena.ECONOMY_MONEY_ID, fee))
|
||||||
if (plugin.Methods.hasMethod())
|
if (plugin.Method != null)
|
||||||
plugin.Method.getAccount(p.getName()).subtract(item.getAmount());
|
plugin.Method.getAccount(p.getName()).subtract(item.getAmount());
|
||||||
|
|
||||||
// Take any other items
|
// Take any other items
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EndermanPickupEvent;
|
||||||
|
import org.bukkit.event.entity.EndermanPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
@@ -62,4 +64,16 @@ public class MAEntityListener extends EntityListener
|
|||||||
for (Arena arena : am.arenas)
|
for (Arena arena : am.arenas)
|
||||||
arena.eventListener.onEntityTarget(event);
|
arena.eventListener.onEntityTarget(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEndermanPickup(EndermanPickupEvent event)
|
||||||
|
{
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.eventListener.onEndermanPickup(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEndermanPickup(EndermanPlaceEvent event)
|
||||||
|
{
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.eventListener.onEndermanPlace(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,8 @@ import org.bukkit.event.block.BlockEvent;
|
|||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EndermanPickupEvent;
|
||||||
|
import org.bukkit.event.entity.EndermanPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
@@ -435,6 +437,18 @@ public class MAListener implements ArenaListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEndermanPickup(EndermanPickupEvent event)
|
||||||
|
{
|
||||||
|
if (arena.inRegion(event.getBlock().getLocation()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEndermanPlace(EndermanPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (arena.inRegion(event.getLocation()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.running) return;
|
if (!arena.running) return;
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class MASpawnThread implements Runnable
|
|||||||
}
|
}
|
||||||
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||||
{
|
{
|
||||||
if (plugin.Methods.hasMethod())
|
if (plugin.Method != null)
|
||||||
MAUtils.tellPlayer(p, Msg.WAVE_REWARD, plugin.Method.format(reward.getAmount()));
|
MAUtils.tellPlayer(p, Msg.WAVE_REWARD, plugin.Method.format(reward.getAmount()));
|
||||||
else MobArena.warning("Tried to add money, but no economy plugin detected!");
|
else MobArena.warning("Tried to add money, but no economy plugin detected!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ public class MAUtils
|
|||||||
// If this is money, don't add to inventory.
|
// If this is money, don't add to inventory.
|
||||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||||
{
|
{
|
||||||
if (plugin != null && plugin.Methods.hasMethod())
|
if (plugin != null && plugin.Method != null)
|
||||||
plugin.Method.getAccount(p.getName()).add(stack.getAmount());
|
plugin.Method.getAccount(p.getName()).add(stack.getAmount());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -1170,11 +1170,16 @@ public class MAUtils
|
|||||||
stack = (ItemStack) e;
|
stack = (ItemStack) e;
|
||||||
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||||
{
|
{
|
||||||
if (plugin.Methods.hasMethod())
|
if (plugin.Method != null)
|
||||||
{
|
{
|
||||||
buffy.append(plugin.Method.format(stack.getAmount()));
|
buffy.append(plugin.Method.format(stack.getAmount()));
|
||||||
buffy.append(", ");
|
buffy.append(", ");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MobArena.warning("Tried to do some money stuff, but no economy plugin was detected!");
|
||||||
|
return buffy.toString();
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ public class MobArena extends JavaPlugin
|
|||||||
private ArenaMaster am;
|
private ArenaMaster am;
|
||||||
|
|
||||||
// Economy stuff
|
// Economy stuff
|
||||||
protected Methods Methods;
|
|
||||||
protected Method Method;
|
protected Method Method;
|
||||||
|
|
||||||
// Spout stuff
|
// Spout stuff
|
||||||
@@ -141,6 +140,8 @@ public class MobArena extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.ENDERMAN_PICKUP, entityListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.ENDERMAN_PLACE, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Monitor, this); // I know Monitor is bad, but other plugins suck! :(
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Monitor, this); // I know Monitor is bad, but other plugins suck! :(
|
||||||
}
|
}
|
||||||
@@ -163,12 +164,13 @@ public class MobArena extends JavaPlugin
|
|||||||
|
|
||||||
private void setupRegister()
|
private void setupRegister()
|
||||||
{
|
{
|
||||||
Methods = new Methods();
|
Methods.setMethod(getServer().getPluginManager());
|
||||||
if (!Methods.hasMethod() && Methods.setMethod(this))
|
|
||||||
{
|
Method = Methods.getMethod();
|
||||||
Method = Methods.getMethod();
|
if (Method != null)
|
||||||
info("Payment method found (" + Method.getName() + " version: " + Method.getVersion() + ")");
|
info("Payment method found (" + Method.getName() + " version: " + Method.getVersion() + ")");
|
||||||
}
|
else
|
||||||
|
info("No payment method found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupSpout()
|
private void setupSpout()
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ public interface Method {
|
|||||||
*/
|
*/
|
||||||
public String getVersion();
|
public 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
|
||||||
|
*/
|
||||||
|
public int fractionalDigits();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats amounts into this payment methods style of currency display.
|
* Formats amounts into this payment methods style of currency display.
|
||||||
|
|||||||
@@ -12,15 +12,13 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
*
|
*
|
||||||
* Allowing you to check whether a payment method exists or not.
|
* Allowing you to check whether a payment method exists or not.
|
||||||
*
|
*
|
||||||
* <blockquote><pre>
|
|
||||||
* Methods methods = new Methods();
|
|
||||||
* </pre></blockquote>
|
|
||||||
*
|
|
||||||
* Methods also allows you to set a preferred method of payment before it captures
|
* Methods also allows you to set a preferred method of payment before it captures
|
||||||
* payment plugins in the initialization process.
|
* payment plugins in the initialization process.
|
||||||
*
|
*
|
||||||
|
* in <code>bukkit.yml</code>:
|
||||||
* <blockquote><pre>
|
* <blockquote><pre>
|
||||||
* Methods methods = new Methods("iConomy");
|
* economy:
|
||||||
|
* preferred: "iConomy"
|
||||||
* </pre></blockquote>
|
* </pre></blockquote>
|
||||||
*
|
*
|
||||||
* @author: Nijikokun <[email protected]> (@nijikokun)
|
* @author: Nijikokun <[email protected]> (@nijikokun)
|
||||||
@@ -28,48 +26,58 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
* @license: AOL license <http://aol.nexua.org>
|
* @license: AOL license <http://aol.nexua.org>
|
||||||
*/
|
*/
|
||||||
public class Methods {
|
public class Methods {
|
||||||
private boolean self = false;
|
private static String version = null;
|
||||||
private Method Method = null;
|
private static boolean self = false;
|
||||||
private String preferred = "";
|
private static Method Method = null;
|
||||||
private Set<Method> Methods = new HashSet<Method>();
|
private static String preferred = "";
|
||||||
private Set<String> Dependencies = new HashSet<String>();
|
private static Set<Method> Methods = new HashSet<Method>();
|
||||||
private Set<Method> Attachables = new HashSet<Method>();
|
private static Set<String> Dependencies = new HashSet<String>();
|
||||||
|
private static Set<Method> Attachables = new HashSet<Method>();
|
||||||
|
|
||||||
/**
|
static {
|
||||||
* Initialize Method class
|
_init();
|
||||||
*/
|
|
||||||
public Methods() {
|
|
||||||
this._init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
|
|
||||||
* returning the first method that was initialized.
|
|
||||||
*
|
|
||||||
* @param preferred Payment method that is most preferred for this setup.
|
|
||||||
*/
|
|
||||||
public Methods(String preferred) {
|
|
||||||
this._init();
|
|
||||||
|
|
||||||
if(this.Dependencies.contains(preferred)) {
|
|
||||||
this.preferred = preferred;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement all methods along with their respective name & class.
|
* Implement all methods along with their respective name & class.
|
||||||
*
|
|
||||||
* @see #Methods()
|
|
||||||
* @see #Methods(java.lang.String)
|
|
||||||
*/
|
*/
|
||||||
private void _init() {
|
private static void _init() {
|
||||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo6());
|
addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo6());
|
||||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
|
addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
|
||||||
this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
|
addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
|
||||||
this.addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE6());
|
addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE6());
|
||||||
this.addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE7());
|
addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE7());
|
||||||
this.addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
|
addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
|
||||||
this.addMethod("MultiCurrency", new com.garbagemule.register.payment.methods.MCUR());
|
addMethod("Currency", new com.garbagemule.register.payment.methods.MCUR());
|
||||||
|
Dependencies.add("MultiCurrency");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by the plugin to setup version
|
||||||
|
*
|
||||||
|
* @param v version
|
||||||
|
*/
|
||||||
|
public static void setVersion(String v) {
|
||||||
|
version = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to reset methods during disable
|
||||||
|
*/
|
||||||
|
public static void reset() {
|
||||||
|
version = null;
|
||||||
|
self = false;
|
||||||
|
Method = null;
|
||||||
|
preferred = "";
|
||||||
|
Attachables.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to get version of Register plugin
|
||||||
|
* @return version
|
||||||
|
*/
|
||||||
|
public static String getVersion() {
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,7 +87,7 @@ public class Methods {
|
|||||||
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||||
*/
|
*/
|
||||||
public Set<String> getDependencies() {
|
public static Set<String> getDependencies() {
|
||||||
return Dependencies;
|
return Dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,18 +98,17 @@ public class Methods {
|
|||||||
* @param plugin Plugin data from bukkit, Internal Class file.
|
* @param plugin Plugin data from bukkit, Internal Class file.
|
||||||
* @return Method <em>or</em> Null
|
* @return Method <em>or</em> Null
|
||||||
*/
|
*/
|
||||||
public Method createMethod(Plugin plugin) {
|
public static Method createMethod(Plugin plugin) {
|
||||||
for (Method method: Methods) {
|
for (Method method: Methods)
|
||||||
if (method.isCompatible(plugin)) {
|
if (method.isCompatible(plugin)) {
|
||||||
method.setPlugin(plugin);
|
method.setPlugin(plugin);
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMethod(String name, Method method) {
|
private static void addMethod(String name, Method method) {
|
||||||
Dependencies.add(name);
|
Dependencies.add(name);
|
||||||
Methods.add(method);
|
Methods.add(method);
|
||||||
}
|
}
|
||||||
@@ -113,7 +120,7 @@ public class Methods {
|
|||||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||||
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||||
*/
|
*/
|
||||||
public boolean hasMethod() {
|
public static boolean hasMethod() {
|
||||||
return (Method != null);
|
return (Method != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,70 +128,93 @@ public class Methods {
|
|||||||
* Checks Plugin Class against a multitude of checks to verify it's usability
|
* Checks Plugin Class against a multitude of checks to verify it's usability
|
||||||
* as a payment method.
|
* as a payment method.
|
||||||
*
|
*
|
||||||
* @param method Plugin data from bukkit, Internal Class file.
|
* @param <code>PluginManager</code> the plugin manager for the server
|
||||||
* @return <code>boolean</code> True on success, False on failure.
|
* @return <code>boolean</code> True on success, False on failure.
|
||||||
*/
|
*/
|
||||||
public boolean setMethod(Plugin method) {
|
public static boolean setMethod(PluginManager manager) {
|
||||||
if(hasMethod()) return true;
|
if (hasMethod())
|
||||||
if(self) { self = false; return false; }
|
return true;
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
self = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
Plugin plugin = null;
|
Plugin plugin = null;
|
||||||
PluginManager manager = method.getServer().getPluginManager();
|
|
||||||
|
|
||||||
for(String name: this.getDependencies()) {
|
for (String name : getDependencies()) {
|
||||||
if(hasMethod()) break;
|
if (hasMethod())
|
||||||
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
|
break;
|
||||||
if(plugin == null) continue;
|
|
||||||
|
|
||||||
Method current = this.createMethod(plugin);
|
plugin = manager.getPlugin(name);
|
||||||
if(current == null) continue;
|
if (plugin == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(this.preferred.isEmpty())
|
Method current = createMethod(plugin);
|
||||||
this.Method = current;
|
if (current == null)
|
||||||
else {
|
continue;
|
||||||
this.Attachables.add(current);
|
|
||||||
}
|
if (preferred.isEmpty())
|
||||||
|
Method = current;
|
||||||
|
else
|
||||||
|
Attachables.add(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.preferred.isEmpty()) {
|
if (!preferred.isEmpty()) {
|
||||||
do {
|
do {
|
||||||
if(hasMethod()) {
|
if (hasMethod())
|
||||||
match = true;
|
match = true;
|
||||||
} else {
|
else {
|
||||||
for(Method attached: this.Attachables) {
|
for (Method attached : Attachables) {
|
||||||
if(attached == null) continue;
|
if (attached == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(hasMethod()) {
|
if (hasMethod()) {
|
||||||
match = true;
|
match = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.preferred.isEmpty()) this.Method = attached;
|
if (preferred.isEmpty())
|
||||||
|
Method = attached;
|
||||||
|
|
||||||
if(count == 0) {
|
if (count == 0)
|
||||||
if(this.preferred.equalsIgnoreCase(attached.getName()))
|
if (preferred.equalsIgnoreCase(attached.getName()))
|
||||||
this.Method = attached;
|
Method = attached;
|
||||||
} else {
|
|
||||||
this.Method = attached;
|
else
|
||||||
}
|
Method = attached;
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} while(!match);
|
} while (!match);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasMethod();
|
return hasMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the preferred economy
|
||||||
|
*
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
|
public static boolean setPreferred(String check) {
|
||||||
|
if (getDependencies().contains(check)) {
|
||||||
|
preferred = check;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the existing and initialized (hopefully) Method Class.
|
* Grab the existing and initialized (hopefully) Method Class.
|
||||||
*
|
*
|
||||||
* @return <code>Method</code> <em>or</em> <code>Null</code>
|
* @return <code>Method</code> <em>or</em> <code>Null</code>
|
||||||
*/
|
*/
|
||||||
public Method getMethod() {
|
public static Method getMethod() {
|
||||||
return Method;
|
return Method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,9 +225,13 @@ public class Methods {
|
|||||||
* @param method Plugin data from bukkit, Internal Class file.
|
* @param method Plugin data from bukkit, Internal Class file.
|
||||||
* @return <code>boolean</code>
|
* @return <code>boolean</code>
|
||||||
*/
|
*/
|
||||||
public boolean checkDisabled(Plugin method) {
|
public static boolean checkDisabled(Plugin method) {
|
||||||
if(!hasMethod()) return true;
|
if(!hasMethod())
|
||||||
if (Method.isCompatible(method)) Method = null;
|
return true;
|
||||||
|
|
||||||
|
if (Method.isCompatible(method))
|
||||||
|
Method = null;
|
||||||
|
|
||||||
return (Method == null);
|
return (Method == null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import cosine.boseconomy.BOSEconomy;
|
import cosine.boseconomy.BOSEconomy;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
* @copyright (c) 2011
|
* @copyright (c) 2011
|
||||||
* @license AOL license <http://aol.nexua.org>
|
* @license AOL license <http://aol.nexua.org>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class BOSE6 implements Method {
|
public class BOSE6 implements Method {
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
@@ -26,9 +28,16 @@ public class BOSE6 implements Method {
|
|||||||
return "0.6.2";
|
return "0.6.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
|
||||||
|
if(amount == 1)
|
||||||
|
currency = this.BOSEconomy.getMoneyName();
|
||||||
|
|
||||||
return amount + " " + currency;
|
return amount + " " + currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,25 +54,32 @@ public class BOSE6 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBankAccount(String bank, String name) {
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
return this.BOSEconomy.isBankOwner(bank, name)
|
||||||
|
|| this.BOSEconomy.isBankMember(bank, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
if(!hasAccount(name)) return null;
|
if(!hasAccount(name))
|
||||||
|
return null;
|
||||||
|
|
||||||
return new BOSEAccount(name, this.BOSEconomy);
|
return new BOSEAccount(name, this.BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
if(!hasBankAccount(bank, name)) return null;
|
if(!hasBankAccount(bank, name))
|
||||||
|
return null;
|
||||||
|
|
||||||
return new BOSEBankAccount(bank, BOSEconomy);
|
return new BOSEBankAccount(bank, BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
|
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||||
|
&& plugin instanceof BOSEconomy
|
||||||
|
&& plugin.getDescription().getVersion().equals("0.6.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
BOSEconomy = (BOSEconomy)plugin;
|
BOSEconomy = (BOSEconomy) plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BOSEAccount implements MethodAccount {
|
public class BOSEAccount implements MethodAccount {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
import com.garbagemule.register.payment.Method;
|
||||||
|
|
||||||
import cosine.boseconomy.BOSEconomy;
|
import cosine.boseconomy.BOSEconomy;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -27,9 +28,16 @@ public class BOSE7 implements Method {
|
|||||||
return "0.7.0";
|
return "0.7.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return this.BOSEconomy.getFractionalDigits();
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
|
||||||
|
if(amount == 1)
|
||||||
|
currency = this.BOSEconomy.getMoneyName();
|
||||||
|
|
||||||
return amount + " " + currency;
|
return amount + " " + currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,17 +58,23 @@ public class BOSE7 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
if(!hasAccount(name)) return null;
|
if(!hasAccount(name))
|
||||||
|
return null;
|
||||||
|
|
||||||
return new BOSEAccount(name, this.BOSEconomy);
|
return new BOSEAccount(name, this.BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
if(!hasBankAccount(bank, name)) return null;
|
if(!hasBankAccount(bank, name))
|
||||||
|
return null;
|
||||||
|
|
||||||
return new BOSEBankAccount(bank, BOSEconomy);
|
return new BOSEBankAccount(bank, BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
|
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||||
|
&& plugin instanceof BOSEconomy
|
||||||
|
&& !plugin.getDescription().getVersion().equals("0.6.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
|
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.NoLoanPermittedException;
|
||||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -34,6 +34,10 @@ public class EE17 implements Method {
|
|||||||
return "2.2";
|
return "2.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return Economy.format(amount);
|
return Economy.format(amount);
|
||||||
}
|
}
|
||||||
@@ -55,7 +59,9 @@ public class EE17 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
if(!hasAccount(name)) return null;
|
if(!hasAccount(name))
|
||||||
|
return null;
|
||||||
|
|
||||||
return new EEcoAccount(name);
|
return new EEcoAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +73,8 @@ public class EE17 implements Method {
|
|||||||
try { Class.forName("com.earth2me.essentials.api.Economy"); }
|
try { Class.forName("com.earth2me.essentials.api.Economy"); }
|
||||||
catch(Exception e) { return false; }
|
catch(Exception e) { return false; }
|
||||||
|
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("essentials") && plugin instanceof Essentials;
|
return plugin.getDescription().getName().equalsIgnoreCase("essentials")
|
||||||
|
&& plugin instanceof Essentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public class MCUR implements Method {
|
|||||||
return "0.09";
|
return "0.09";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return amount + " Currency";
|
return amount + " Currency";
|
||||||
}
|
}
|
||||||
@@ -58,7 +62,9 @@ public class MCUR implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
|
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|
||||||
|
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
|
||||||
|
&& plugin instanceof Currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
import com.nijiko.coelho.iConomy.iConomy;
|
import com.nijiko.coelho.iConomy.iConomy;
|
||||||
import com.nijiko.coelho.iConomy.system.Account;
|
import com.nijiko.coelho.iConomy.system.Account;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -29,8 +29,12 @@ public class iCo4 implements Method {
|
|||||||
return "4";
|
return "4";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return this.iConomy.getBank().format(amount);
|
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBanks() {
|
public boolean hasBanks() {
|
||||||
@@ -42,7 +46,7 @@ public class iCo4 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAccount(String name) {
|
public boolean hasAccount(String name) {
|
||||||
return this.iConomy.getBank().hasAccount(name);
|
return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBankAccount(String bank, String name) {
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
@@ -50,7 +54,7 @@ public class iCo4 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount(this.iConomy.getBank().getAccount(name));
|
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
@@ -58,7 +62,9 @@ public class iCo4 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||||
|
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
|
||||||
|
&& plugin instanceof iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
import com.iConomy.iConomy;
|
import com.iConomy.iConomy;
|
||||||
import com.iConomy.system.Account;
|
import com.iConomy.system.Account;
|
||||||
import com.iConomy.system.BankAccount;
|
import com.iConomy.system.BankAccount;
|
||||||
import com.iConomy.system.Holdings;
|
import com.iConomy.system.Holdings;
|
||||||
import com.iConomy.util.Constants;
|
import com.iConomy.util.Constants;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -32,8 +32,12 @@ public class iCo5 implements Method {
|
|||||||
return "5";
|
return "5";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return this.iConomy.format(amount);
|
return com.iConomy.iConomy.format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBanks() {
|
public boolean hasBanks() {
|
||||||
@@ -41,27 +45,29 @@ public class iCo5 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBank(String bank) {
|
public boolean hasBank(String bank) {
|
||||||
return (hasBanks()) && this.iConomy.Banks.exists(bank);
|
return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAccount(String name) {
|
public boolean hasAccount(String name) {
|
||||||
return this.iConomy.hasAccount(name);
|
return com.iConomy.iConomy.hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBankAccount(String bank, String name) {
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
|
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount(this.iConomy.getAccount(name));
|
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
|
return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||||
|
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
|
||||||
|
&& plugin instanceof iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.garbagemule.register.payment.methods;
|
package com.garbagemule.register.payment.methods;
|
||||||
|
|
||||||
|
import com.garbagemule.register.payment.Method;
|
||||||
import com.iCo6.iConomy;
|
import com.iCo6.iConomy;
|
||||||
import com.iCo6.system.Account;
|
import com.iCo6.system.Account;
|
||||||
import com.iCo6.system.Accounts;
|
import com.iCo6.system.Accounts;
|
||||||
import com.iCo6.system.Holdings;
|
import com.iCo6.system.Holdings;
|
||||||
|
|
||||||
import com.garbagemule.register.payment.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -31,8 +31,12 @@ public class iCo6 implements Method {
|
|||||||
return "6";
|
return "6";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
return this.iConomy.format(amount);
|
return com.iCo6.iConomy.format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBanks() {
|
public boolean hasBanks() {
|
||||||
@@ -60,10 +64,9 @@ public class iCo6 implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
try { Class.forName("com.iCo6.IO"); }
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||||
catch(Exception e) { return false; }
|
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
|
||||||
|
&& plugin instanceof iConomy;
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.iConomy") && plugin instanceof iConomy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
|||||||
Reference in New Issue
Block a user