diff --git a/MobArena.jar b/MobArena.jar
index aaba516..86728c2 100644
Binary files a/MobArena.jar and b/MobArena.jar differ
diff --git a/src/com/garbagemule/MobArena/Arena.java b/src/com/garbagemule/MobArena/Arena.java
index 66952a9..1d64f0d 100644
--- a/src/com/garbagemule/MobArena/Arena.java
+++ b/src/com/garbagemule/MobArena/Arena.java
@@ -1292,7 +1292,7 @@ public class Arena
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()).balance() >= stack.getAmount()))
+ if (plugin.Method != null && !(plugin.Method.getAccount(p.getName()).balance() >= stack.getAmount()))
return false;
}
// Normal stack
@@ -1317,7 +1317,7 @@ public class Arena
// Take some economy money
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());
// Take any other items
diff --git a/src/com/garbagemule/MobArena/MAEntityListener.java b/src/com/garbagemule/MobArena/MAEntityListener.java
index b9eec7a..7c853d4 100644
--- a/src/com/garbagemule/MobArena/MAEntityListener.java
+++ b/src/com/garbagemule/MobArena/MAEntityListener.java
@@ -1,6 +1,8 @@
package com.garbagemule.MobArena;
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.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
@@ -62,4 +64,16 @@ public class MAEntityListener extends EntityListener
for (Arena arena : am.arenas)
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);
+ }
}
\ No newline at end of file
diff --git a/src/com/garbagemule/MobArena/MAListener.java b/src/com/garbagemule/MobArena/MAListener.java
index 4f91f7a..142100c 100644
--- a/src/com/garbagemule/MobArena/MAListener.java
+++ b/src/com/garbagemule/MobArena/MAListener.java
@@ -22,6 +22,8 @@ import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent;
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.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
@@ -434,6 +436,18 @@ public class MAListener implements ArenaListener
event.setCancelled(true);
}
}
+
+ 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)
{
diff --git a/src/com/garbagemule/MobArena/MASpawnThread.java b/src/com/garbagemule/MobArena/MASpawnThread.java
index e02bba2..29afac9 100644
--- a/src/com/garbagemule/MobArena/MASpawnThread.java
+++ b/src/com/garbagemule/MobArena/MASpawnThread.java
@@ -199,7 +199,7 @@ public class MASpawnThread implements Runnable
}
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()));
else MobArena.warning("Tried to add money, but no economy plugin detected!");
}
diff --git a/src/com/garbagemule/MobArena/MAUtils.java b/src/com/garbagemule/MobArena/MAUtils.java
index b48a396..490f238 100644
--- a/src/com/garbagemule/MobArena/MAUtils.java
+++ b/src/com/garbagemule/MobArena/MAUtils.java
@@ -479,7 +479,7 @@ public class MAUtils
// If this is money, don't add to inventory.
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());
continue;
@@ -1170,11 +1170,16 @@ public class MAUtils
stack = (ItemStack) e;
if (stack.getTypeId() == MobArena.ECONOMY_MONEY_ID)
{
- if (plugin.Methods.hasMethod())
+ if (plugin.Method != null)
{
buffy.append(plugin.Method.format(stack.getAmount()));
buffy.append(", ");
}
+ else
+ {
+ MobArena.warning("Tried to do some money stuff, but no economy plugin was detected!");
+ return buffy.toString();
+ }
continue;
}
diff --git a/src/com/garbagemule/MobArena/MobArena.java b/src/com/garbagemule/MobArena/MobArena.java
index 37aecfd..0bf3dc6 100644
--- a/src/com/garbagemule/MobArena/MobArena.java
+++ b/src/com/garbagemule/MobArena/MobArena.java
@@ -36,7 +36,6 @@ public class MobArena extends JavaPlugin
private ArenaMaster am;
// Economy stuff
- protected Methods Methods;
protected Method Method;
// 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_COMBUST, 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.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()
{
- Methods = new Methods();
- if (!Methods.hasMethod() && Methods.setMethod(this))
- {
- Method = Methods.getMethod();
+ Methods.setMethod(getServer().getPluginManager());
+
+ Method = Methods.getMethod();
+ if (Method != null)
info("Payment method found (" + Method.getName() + " version: " + Method.getVersion() + ")");
- }
+ else
+ info("No payment method found!");
}
private void setupSpout()
diff --git a/src/com/garbagemule/register/payment/Method.java b/src/com/garbagemule/register/payment/Method.java
index ec1481b..d41c81e 100644
--- a/src/com/garbagemule/register/payment/Method.java
+++ b/src/com/garbagemule/register/payment/Method.java
@@ -38,7 +38,14 @@ public interface Method {
* @return String Plugin version.
*/
public String getVersion();
-
+
+ /**
+ * Returns the amount of decimal places that get stored
+ * NOTE: it will return -1 if there is no rounding
+ *
+ * @return int for each decimal place
+ */
+ public int fractionalDigits();
/**
* Formats amounts into this payment methods style of currency display.
diff --git a/src/com/garbagemule/register/payment/Methods.java b/src/com/garbagemule/register/payment/Methods.java
index 117a236..488b676 100644
--- a/src/com/garbagemule/register/payment/Methods.java
+++ b/src/com/garbagemule/register/payment/Methods.java
@@ -12,15 +12,13 @@ import org.bukkit.plugin.PluginManager;
*
* Allowing you to check whether a payment method exists or not.
*
- *
- * * Methods also allows you to set a preferred method of payment before it captures * payment plugins in the initialization process. * + * in- * Methods methods = new Methods(); - *
bukkit.yml:
*
- * Methods methods = new Methods("iConomy");
+ * economy:
+ * preferred: "iConomy"
*
*
* @author: Nijikokun Methods 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;
- }
+ static {
+ _init();
}
/**
* Implement all methods along with their respective name & class.
- *
- * @see #Methods()
- * @see #Methods(java.lang.String)
*/
- private void _init() {
- this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo6());
- this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
- this.addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
- this.addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE6());
- this.addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE7());
- this.addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
- this.addMethod("MultiCurrency", new com.garbagemule.register.payment.methods.MCUR());
+ private static void _init() {
+ addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo6());
+ addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo5());
+ addMethod("iConomy", new com.garbagemule.register.payment.methods.iCo4());
+ addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE6());
+ addMethod("BOSEconomy", new com.garbagemule.register.payment.methods.BOSE7());
+ addMethod("Essentials", new com.garbagemule.register.payment.methods.EE17());
+ 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 Set - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin)
*/
- public SetPluginManager the plugin manager for the server
* @return boolean True on success, False on failure.
*/
- public boolean setMethod(Plugin method) {
- if(hasMethod()) return true;
- if(self) { self = false; return false; }
+ public static boolean setMethod(PluginManager manager) {
+ if (hasMethod())
+ return true;
+
+ if (self) {
+ self = false;
+ return false;
+ }
int count = 0;
boolean match = false;
Plugin plugin = null;
- PluginManager manager = method.getServer().getPluginManager();
- for(String name: this.getDependencies()) {
- if(hasMethod()) break;
- if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
- if(plugin == null) continue;
+ for (String name : getDependencies()) {
+ if (hasMethod())
+ break;
- Method current = this.createMethod(plugin);
- if(current == null) continue;
+ plugin = manager.getPlugin(name);
+ if (plugin == null)
+ continue;
- if(this.preferred.isEmpty())
- this.Method = current;
- else {
- this.Attachables.add(current);
- }
+ Method current = createMethod(plugin);
+ if (current == null)
+ continue;
+
+ if (preferred.isEmpty())
+ Method = current;
+ else
+ Attachables.add(current);
}
- if(!this.preferred.isEmpty()) {
+ if (!preferred.isEmpty()) {
do {
- if(hasMethod()) {
+ if (hasMethod())
match = true;
- } else {
- for(Method attached: this.Attachables) {
- if(attached == null) continue;
+ else {
+ for (Method attached : Attachables) {
+ if (attached == null)
+ continue;
- if(hasMethod()) {
+ if (hasMethod()) {
match = true;
break;
}
- if(this.preferred.isEmpty()) this.Method = attached;
+ if (preferred.isEmpty())
+ Method = attached;
- if(count == 0) {
- if(this.preferred.equalsIgnoreCase(attached.getName()))
- this.Method = attached;
- } else {
- this.Method = attached;
- }
+ if (count == 0)
+ if (preferred.equalsIgnoreCase(attached.getName()))
+ Method = attached;
+
+ else
+ Method = attached;
}
count++;
}
- } while(!match);
+ } while (!match);
}
return hasMethod();
}
+ /**
+ * Sets the preferred economy
+ *
+ * @return boolean
+ */
+ public static boolean setPreferred(String check) {
+ if (getDependencies().contains(check)) {
+ preferred = check;
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Grab the existing and initialized (hopefully) Method Class.
*
* @return Method or Null
*/
- public Method getMethod() {
+ public static Method getMethod() {
return Method;
}
@@ -195,9 +225,13 @@ public class Methods {
* @param method Plugin data from bukkit, Internal Class file.
* @return boolean
*/
- public boolean checkDisabled(Plugin method) {
- if(!hasMethod()) return true;
- if (Method.isCompatible(method)) Method = null;
+ public static boolean checkDisabled(Plugin method) {
+ if(!hasMethod())
+ return true;
+
+ if (Method.isCompatible(method))
+ Method = null;
+
return (Method == null);
}
}
diff --git a/src/com/garbagemule/register/payment/methods/BOSE6.java b/src/com/garbagemule/register/payment/methods/BOSE6.java
index 5dfdf3b..d5f7912 100644
--- a/src/com/garbagemule/register/payment/methods/BOSE6.java
+++ b/src/com/garbagemule/register/payment/methods/BOSE6.java
@@ -1,6 +1,7 @@
package com.garbagemule.register.payment.methods;
import com.garbagemule.register.payment.Method;
+
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
@@ -11,6 +12,7 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license