diff --git a/com/Acrobot/ChestShop/Config/Config.java b/com/Acrobot/ChestShop/Config/Config.java index 8a58946..f8011ba 100644 --- a/com/Acrobot/ChestShop/Config/Config.java +++ b/com/Acrobot/ChestShop/Config/Config.java @@ -1,6 +1,6 @@ package com.Acrobot.ChestShop.Config; -import com.nijikokun.register.forChestShop.payment.Methods; +import com.nijikokun.register.payment.forChestShop.Methods; /** * @author Acrobot diff --git a/com/Acrobot/ChestShop/Config/Property.java b/com/Acrobot/ChestShop/Config/Property.java index f9378d0..83cbc93 100644 --- a/com/Acrobot/ChestShop/Config/Property.java +++ b/com/Acrobot/ChestShop/Config/Property.java @@ -26,7 +26,9 @@ public enum Property { SHOW_TRANSACTION_INFORMATION_CLIENT(true, "Do you want to show \"You bought/sold... \" messages?"), SHOW_TRANSACTION_INFORMATION_OWNER(true, "Do you want to show \"Somebody bought/sold... \" messages?"), TOWNY_INTEGRATION(false, "Do you want to only let people build inside shop plots?"), - TAX_AMOUNT(0, "Percent of the price that should go to the server's account. (100 = 100 percent)"); + WORLDGUARD_INTEGRATION(false, "Do you want to only let people build inside plots?"), + TAX_AMOUNT(0, "Percent of the price that should go to the server's account. (100 = 100 percent)"), + SHOP_REFUND_PRICE(0, "How much money do you get back when destroying a sign?"); private final Object value; diff --git a/com/Acrobot/ChestShop/Economy.java b/com/Acrobot/ChestShop/Economy.java index a5feb3f..618cfa3 100644 --- a/com/Acrobot/ChestShop/Economy.java +++ b/com/Acrobot/ChestShop/Economy.java @@ -3,7 +3,7 @@ package com.Acrobot.ChestShop; import com.Acrobot.ChestShop.Config.Config; import com.Acrobot.ChestShop.Config.Property; import com.Acrobot.ChestShop.Utils.uLongName; -import com.nijikokun.register.forChestShop.payment.Method; +import com.nijikokun.register.payment.forChestShop.Method; /** * @author Acrobot diff --git a/com/Acrobot/ChestShop/Listeners/blockBreak.java b/com/Acrobot/ChestShop/Listeners/blockBreak.java index 94295a6..b8065f5 100644 --- a/com/Acrobot/ChestShop/Listeners/blockBreak.java +++ b/com/Acrobot/ChestShop/Listeners/blockBreak.java @@ -1,9 +1,13 @@ package com.Acrobot.ChestShop.Listeners; +import com.Acrobot.ChestShop.Config.Config; +import com.Acrobot.ChestShop.Config.Property; +import com.Acrobot.ChestShop.Economy; import com.Acrobot.ChestShop.Permission; import com.Acrobot.ChestShop.Utils.uBlock; import com.Acrobot.ChestShop.Utils.uLongName; import com.Acrobot.ChestShop.Utils.uSign; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; @@ -14,6 +18,9 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.material.PistonBaseMaterial; +import java.util.ArrayList; +import java.util.List; + /** * @author Acrobot */ @@ -26,6 +33,7 @@ public class blockBreak extends BlockListener { if (isCorrectSign(sign, block)) return true; sign = uBlock.findSign(block); + if (Config.getFloat(Property.SHOP_REFUND_PRICE) != 0F && isCorrectSign(sign, block) && !playerIsNotOwner(player, sign)) Economy.add(uLongName.getName(sign.getLine(0)), Config.getFloat(Property.SHOP_REFUND_PRICE)); return isCorrectSign(sign, block) && playerIsNotOwner(player, sign); } @@ -34,10 +42,10 @@ public class blockBreak extends BlockListener { } private static boolean isCorrectSign(Sign sign, Block block) { - return sign != null && (sign.getBlock() == block || getAttachedFace(sign) == block); + return sign != null && (sign.getBlock().equals(block) || getAttachedFace(sign).equals(block)); } - private static Block getAttachedFace(Sign sign) { + public static Block getAttachedFace(Sign sign) { return sign.getBlock().getRelative(((org.bukkit.material.Sign) sign.getData()).getAttachedFace()); } @@ -46,7 +54,7 @@ public class blockBreak extends BlockListener { } public void onBlockPistonExtend(BlockPistonExtendEvent event) { - for (Block b : event.getBlocks()) { + for (Block b : getExtendBlocks(event)) { if (cancellingBlockBreak(b, null)) { event.setCancelled(true); return; @@ -72,4 +80,18 @@ public class blockBreak extends BlockListener { BlockFace pistonDirection = getPistonDirection(event.getBlock()); return pistonDirection != null ? event.getBlock().getRelative((pistonDirection), 2).getLocation().getBlock() : null; } + + private static List getExtendBlocks(BlockPistonExtendEvent event){ + BlockFace pistonDirection = getPistonDirection(event.getBlock()); + if (pistonDirection == null) return new ArrayList(); + Block piston = event.getBlock(); + ArrayList list = new ArrayList(); + for (int b = 1; b < event.getLength() + 1; b++){ + Block block = piston.getRelative(pistonDirection, b); + Material blockType = block.getType(); + if (blockType == Material.AIR) break; + list.add(block); + } + return list; + } } diff --git a/com/Acrobot/ChestShop/Listeners/playerInteract.java b/com/Acrobot/ChestShop/Listeners/playerInteract.java index 260d00c..ae9b87b 100644 --- a/com/Acrobot/ChestShop/Listeners/playerInteract.java +++ b/com/Acrobot/ChestShop/Listeners/playerInteract.java @@ -64,6 +64,7 @@ public class playerInteract extends PlayerListener { return; } + if (restrictedSign.isRestrictedShop(sign) && !restrictedSign.canAccess(sign, player)) { player.sendMessage(Config.getLocal(Language.ACCESS_DENIED)); return; diff --git a/com/Acrobot/ChestShop/Listeners/pluginDisable.java b/com/Acrobot/ChestShop/Listeners/pluginDisable.java index a67ebdd..b174093 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginDisable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginDisable.java @@ -1,7 +1,7 @@ package com.Acrobot.ChestShop.Listeners; import com.Acrobot.ChestShop.Economy; -import com.nijikokun.register.forChestShop.payment.Methods; +import com.nijikokun.register.payment.forChestShop.Methods; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.ServerListener; diff --git a/com/Acrobot/ChestShop/Listeners/pluginEnable.java b/com/Acrobot/ChestShop/Listeners/pluginEnable.java index 8f5e915..a5fc1ca 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginEnable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginEnable.java @@ -10,11 +10,13 @@ import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin; import com.Acrobot.ChestShop.Protection.Security; import com.Acrobot.ChestShop.Utils.uNumber; import com.Acrobot.ChestShop.Utils.uSign; +import com.Acrobot.ChestShop.Utils.uWorldGuard; import com.daemitus.deadbolt.Deadbolt; import com.griefcraft.lwc.LWCPlugin; import com.nijikokun.bukkit.Permissions.Permissions; -import com.nijikokun.register.forChestShop.payment.Methods; +import com.nijikokun.register.payment.forChestShop.Methods; import com.palmergames.bukkit.towny.Towny; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; import org.bukkit.plugin.Plugin; @@ -67,6 +69,9 @@ public class pluginEnable extends ServerListener { for (int i = 0; i < 4; i++) if (split.length >= i + 1 && uNumber.isInteger(split[i])) versionNumber += (Math.pow(10, (3 - i) << 1) * Integer.parseInt(split[i])); //EPIC CODE RIGHT HERE if (versionNumber < 760047) { System.out.println(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.76.0.47")); return; } uSign.towny = (Towny) plugin; + } else if (name.equals("WorldGuard")) { + if (uWorldGuard.worldGuard != null) return; + uWorldGuard.worldGuard = (WorldGuardPlugin) plugin; } PluginDescriptionFile description = plugin.getDescription(); System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded."); diff --git a/com/Acrobot/ChestShop/Listeners/signChange.java b/com/Acrobot/ChestShop/Listeners/signChange.java index 2d2128c..c444f16 100644 --- a/com/Acrobot/ChestShop/Listeners/signChange.java +++ b/com/Acrobot/ChestShop/Listeners/signChange.java @@ -82,7 +82,7 @@ public class signChange extends BlockListener { dropSign(event); return; } else if (!playerIsAdmin) { - if (!Security.canPlaceSign(player, signBlock)) { + if (!Security.canPlaceSign(player, (Sign) signBlock.getState())) { player.sendMessage(Config.getLocal(Language.ANOTHER_SHOP_DETECTED)); dropSign(event); return; @@ -90,7 +90,7 @@ public class signChange extends BlockListener { Block chestBlock = chest.getBlock(); - if (uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation())) { + if (!uWorldGuard.isNotOutsideWGplot(signBlock.getLocation()) || (uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation()))) { player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE)); dropSign(event); return; @@ -150,6 +150,7 @@ public class signChange extends BlockListener { if (uNumber.isFloat(split[0])) thirdLine = "B " + thirdLine; if (split.length == 2 && uNumber.isFloat(split[1])) thirdLine = thirdLine + " S"; if (thirdLine.length() > 15) thirdLine = thirdLine.replace(" ", ""); + thirdLine = thirdLine.toUpperCase(); return (thirdLine.length() > 15 ? null : thirdLine); } @@ -163,8 +164,9 @@ public class signChange extends BlockListener { if (materialLine.length() > maxLength) materialLine = materialLine.substring(0, maxLength); materialLine = materialLine + ':' + split[1]; } - return materialLine; + fourthLine = materialLine; } + fourthLine = fourthLine.replace("_", " "); return fourthLine; } diff --git a/com/Acrobot/ChestShop/Protection/MaskChest.java b/com/Acrobot/ChestShop/Protection/MaskChest.java index e64402e..ecf0c89 100644 --- a/com/Acrobot/ChestShop/Protection/MaskChest.java +++ b/com/Acrobot/ChestShop/Protection/MaskChest.java @@ -36,7 +36,7 @@ public class MaskChest implements Runnable { Block block = world.getBlockAt(x + pX, y + pY, z + pZ); if (block.getType() == Material.CHEST) { - if (uBlock.findSign(block) != null) { + if (uBlock.findSign2(block) != null) { Chest neighbor = uBlock.findNeighbor(block); Material nMat = returnNearestMat(block); if (neighbor != null) { diff --git a/com/Acrobot/ChestShop/Protection/Plugins/Default.java b/com/Acrobot/ChestShop/Protection/Plugins/Default.java index fad3103..5e021c0 100644 --- a/com/Acrobot/ChestShop/Protection/Plugins/Default.java +++ b/com/Acrobot/ChestShop/Protection/Plugins/Default.java @@ -14,20 +14,20 @@ import org.bukkit.entity.Player; public class Default implements Protection { public boolean isProtected(Block block) { if (!(block.getState() instanceof Chest)) return false; - if (uBlock.findSign(block) != null) return true; + if (uBlock.findSign2(block) != null) return true; Chest neighbor = uBlock.findNeighbor(block); - return neighbor != null && uBlock.findSign(neighbor.getBlock()) != null; + return neighbor != null && uBlock.findSign2(neighbor.getBlock()) != null; } public boolean canAccess(Player player, Block block) { String playerName = player.getName(); - Sign sign = uBlock.findSign(block); + Sign sign = uBlock.findSign2(block); if (sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0)); Chest neighborChest = uBlock.findNeighbor(block); - Sign neighborSign = (neighborChest != null ? uBlock.findSign(neighborChest.getBlock()) : null); + Sign neighborSign = (neighborChest != null ? uBlock.findSign2(neighborChest.getBlock()) : null); return neighborSign != null && uLongName.stripName(playerName).equals(neighborSign.getLine(0)); } diff --git a/com/Acrobot/ChestShop/Protection/Security.java b/com/Acrobot/ChestShop/Protection/Security.java index 4444102..1bae7fa 100644 --- a/com/Acrobot/ChestShop/Protection/Security.java +++ b/com/Acrobot/ChestShop/Protection/Security.java @@ -1,9 +1,11 @@ package com.Acrobot.ChestShop.Protection; +import com.Acrobot.ChestShop.Listeners.blockBreak; import com.Acrobot.ChestShop.Protection.Plugins.Default; -import com.Acrobot.ChestShop.Utils.uBlock; import com.Acrobot.ChestShop.Utils.uLongName; +import com.Acrobot.ChestShop.Utils.uSign; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -11,6 +13,7 @@ import org.bukkit.entity.Player; * @author Acrobot */ public class Security { + private static BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}; public static Protection protection = new Default(); public static boolean protect(String name, Block block) { @@ -25,10 +28,16 @@ public class Security { return protection.isProtected(block); } - public static boolean canPlaceSign(Player p, Block block) { - Sign sign = uBlock.findSign(uBlock.findChest(block).getBlock()); - if (sign == null) sign = uBlock.findSign(block); + public static boolean canPlaceSign(Player p, Sign sign) { + Block block = blockBreak.getAttachedFace(sign); + return !thereIsAnotherSignByPlayer(block, sign.getBlock(), uLongName.stripName(p.getName())); + } - return (sign == null || sign.getLine(0).equals(uLongName.stripName(p.getName()))); + private static boolean thereIsAnotherSignByPlayer(Block baseBlock, Block signBlock, String shortName){ + for (BlockFace bf : faces){ + Block block = baseBlock.getRelative(bf); + if(uSign.isSign(block) && !block.equals(signBlock) && blockBreak.getAttachedFace((Sign) block.getState()).equals(baseBlock) && !((Sign) block.getState()).getLine(0).equals(shortName)) return true; + } + return false; } } diff --git a/com/Acrobot/ChestShop/Utils/uBlock.java b/com/Acrobot/ChestShop/Utils/uBlock.java index 4bfd9aa..1c823ae 100644 --- a/com/Acrobot/ChestShop/Utils/uBlock.java +++ b/com/Acrobot/ChestShop/Utils/uBlock.java @@ -1,5 +1,6 @@ package com.Acrobot.ChestShop.Utils; +import com.Acrobot.ChestShop.Listeners.blockBreak; import com.Acrobot.ChestShop.Signs.restrictedSign; import org.bukkit.Material; import org.bukkit.block.Block; @@ -29,6 +30,18 @@ public class uBlock { } public static Sign findSign(Block block) { + for (BlockFace bf : shopFaces) { + Block faceBlock = block.getRelative(bf); + if (uSign.isSign(faceBlock)) { + Sign sign = (Sign) faceBlock.getState(); + if (uSign.isValid(sign) && (faceBlock.equals(block) || blockBreak.getAttachedFace(sign).equals(block))) return sign; + } + } + return null; + } + + //Well, I need to re-write this plugin... I hate to code like that - sorry! + public static Sign findSign2(Block block){ for (BlockFace bf : shopFaces) { Block faceBlock = block.getRelative(bf); if (uSign.isSign(faceBlock)) { @@ -44,7 +57,7 @@ public class uBlock { Block faceBlock = block.getRelative(bf); if (uSign.isSign(faceBlock)) { Sign sign = (Sign) faceBlock.getState(); - if (restrictedSign.isRestricted(sign)) return sign; + if (restrictedSign.isRestricted(sign) && (faceBlock.equals(block) || blockBreak.getAttachedFace(sign).equals(block))) return sign; } } return null; diff --git a/com/Acrobot/ChestShop/Utils/uTowny.java b/com/Acrobot/ChestShop/Utils/uTowny.java index b954170..963c130 100644 --- a/com/Acrobot/ChestShop/Utils/uTowny.java +++ b/com/Acrobot/ChestShop/Utils/uTowny.java @@ -12,8 +12,6 @@ import org.bukkit.entity.Player; * @author Acrobot */ public class uTowny { - - public static boolean isInsideShopPlot(Location chestlocation, Location signLocation) { return uSign.towny.getTownyUniverse().getTownBlock(chestlocation).getType() == TownBlockType.COMMERCIAL && uSign.towny.getTownyUniverse().getTownBlock(signLocation).getType() == TownBlockType.COMMERCIAL; } @@ -27,7 +25,6 @@ public class uTowny { } public static boolean canBuild(Player player, Location chestLocation, Location signLocation) { - System.out.println(isNotInTheWilderness(chestLocation, signLocation)); return uSign.towny == null || !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isNotInTheWilderness(chestLocation, signLocation) && isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation)); } diff --git a/com/Acrobot/ChestShop/Utils/uWorldGuard.java b/com/Acrobot/ChestShop/Utils/uWorldGuard.java new file mode 100644 index 0000000..a9ea8e6 --- /dev/null +++ b/com/Acrobot/ChestShop/Utils/uWorldGuard.java @@ -0,0 +1,18 @@ +package com.Acrobot.ChestShop.Utils; + +import com.Acrobot.ChestShop.Config.Config; +import com.Acrobot.ChestShop.Config.Property; +import com.sk89q.worldguard.bukkit.BukkitUtil; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import org.bukkit.Location; + +/** + * @author Acrobot + */ +public class uWorldGuard { + public static WorldGuardPlugin worldGuard; + + public static boolean isNotOutsideWGplot(Location l2) { + return worldGuard == null || !Config.getBoolean(Property.WORLDGUARD_INTEGRATION) || worldGuard.getGlobalRegionManager().get(l2.getWorld()).getApplicableRegions(BukkitUtil.toVector(l2)).size() != 0; + } +} diff --git a/com/nijikokun/register/forChestShop/payment/Method.java b/com/nijikokun/register/payment/forChestShop/Method.java similarity index 97% rename from com/nijikokun/register/forChestShop/payment/Method.java rename to com/nijikokun/register/payment/forChestShop/Method.java index 67b8bff..3dc792a 100644 --- a/com/nijikokun/register/forChestShop/payment/Method.java +++ b/com/nijikokun/register/payment/forChestShop/Method.java @@ -1,4 +1,4 @@ -package com.nijikokun.register.forChestShop.payment; +package com.nijikokun.register.payment.forChestShop; import org.bukkit.plugin.Plugin; @@ -103,7 +103,7 @@ public interface Method { * @param balance Initial account balance * @return boolean */ - public boolean createAccount(String name, Double balance); + public boolean createAccount(String name, double balance); /** * Returns a MethodAccount class for an account name. diff --git a/com/nijikokun/register/forChestShop/payment/Methods.java b/com/nijikokun/register/payment/forChestShop/Methods.java similarity index 81% rename from com/nijikokun/register/forChestShop/payment/Methods.java rename to com/nijikokun/register/payment/forChestShop/Methods.java index 5391a9d..3ef50f9 100644 --- a/com/nijikokun/register/forChestShop/payment/Methods.java +++ b/com/nijikokun/register/payment/forChestShop/Methods.java @@ -1,20 +1,20 @@ -package com.nijikokun.register.forChestShop.payment; - -import java.util.HashSet; -import java.util.Set; +package com.nijikokun.register.payment.forChestShop; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; +import java.util.HashSet; +import java.util.Set; + /** * The Methods initializes Methods that utilize the Method interface * based on a "first come, first served" basis. - * + *

* 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 bukkit.yml: *

  *  economy:
@@ -42,13 +42,14 @@ public class Methods {
      * Implement all methods along with their respective name & class.
      */
     private static void _init() {
-        addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo6());
-        addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo5());
-        addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo4());
-        addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE6());
-        addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE7());
-        addMethod("Essentials", new com.nijikokun.register.forChestShop.payment.methods.EE17());
-        addMethod("Currency", new com.nijikokun.register.forChestShop.payment.methods.MCUR());
+        addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo6());
+        addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
+        addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
+        addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE6());
+        addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE7());
+        addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
+        addMethod("Currency", new com.nijikokun.register.payment.forChestShop.methods.MCUR());
+        addMethod("3co", new com.nijikokun.register.payment.forChestShop.methods.ECO3());
         Dependencies.add("MultiCurrency");
     }
 
@@ -74,6 +75,7 @@ public class Methods {
 
     /**
      * Use to get version of Register plugin
+     *
      * @return version
      */
     public static String getVersion() {
@@ -85,7 +87,7 @@ public class Methods {
      * through the _init method.
      *
      * @return Set - Array of payment methods that are loaded.
-     * @see #setMethod(org.bukkit.plugin.Plugin)
+     * @see #setMethod(org.bukkit.plugin.PluginManager)
      */
     public static Set getDependencies() {
         return Dependencies;
@@ -99,7 +101,7 @@ public class Methods {
      * @return Method or Null
      */
     public static Method createMethod(Plugin plugin) {
-        for (Method method: Methods)
+        for (Method method : Methods)
             if (method.isCompatible(plugin)) {
                 method.setPlugin(plugin);
                 return method;
@@ -117,7 +119,7 @@ public class Methods {
      * Verifies if Register has set a payment method for usage yet.
      *
      * @return boolean
-     * @see #setMethod(org.bukkit.plugin.Plugin)
+     * @see #setMethod(org.bukkit.plugin.PluginManager)
      * @see #checkDisabled(org.bukkit.plugin.Plugin)
      */
     public static boolean hasMethod() {
@@ -128,7 +130,7 @@ public class Methods {
      * Checks Plugin Class against a multitude of checks to verify it's usability
      * as a payment method.
      *
-     * @param PluginManager the plugin manager for the server
+     * @param manager the plugin manager for the server
      * @return boolean True on success, False on failure.
      */
     public static boolean setMethod(PluginManager manager) {
@@ -168,8 +170,7 @@ public class Methods {
                     match = true;
                 else {
                     for (Method attached : Attachables) {
-                        if (attached == null)
-                            continue;
+                        if (attached == null) continue;
 
                         if (hasMethod()) {
                             match = true; break;
@@ -178,12 +179,11 @@ public class Methods {
                         if (preferred.isEmpty())
                             Method = attached;
 
-                        if (count == 0)
-                            if (preferred.equalsIgnoreCase(attached.getName()))
-                                Method = attached;
-
-                        else
+                        if (count == 0) {
+                            if (preferred.equalsIgnoreCase(attached.getName())) Method = attached;
+                        } else {
                             Method = attached;
+                        }
                     }
 
                     count++;
@@ -197,6 +197,7 @@ public class Methods {
     /**
      * Sets the preferred economy
      *
+     * @param check The plugin name to check
      * @return boolean
      */
     public static boolean setPreferred(String check) {
@@ -225,7 +226,7 @@ public class Methods {
      * @return boolean
      */
     public static boolean checkDisabled(Plugin method) {
-        if(!hasMethod())
+        if (!hasMethod())
             return true;
 
         if (Method.isCompatible(method))
diff --git a/com/nijikokun/register/forChestShop/payment/methods/BOSE6.java b/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java
similarity index 97%
rename from com/nijikokun/register/forChestShop/payment/methods/BOSE6.java
rename to com/nijikokun/register/payment/forChestShop/methods/BOSE6.java
index af7f74d..160ad0c 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/BOSE6.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 
 import cosine.boseconomy.BOSEconomy;
 import org.bukkit.plugin.Plugin;
@@ -66,7 +66,7 @@ public class BOSE6 implements Method {
         return true;
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         if(hasAccount(name))
             return false;
 
diff --git a/com/nijikokun/register/forChestShop/payment/methods/BOSE7.java b/com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
similarity index 97%
rename from com/nijikokun/register/forChestShop/payment/methods/BOSE7.java
rename to com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
index 955c8b4..0b6bf4f 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/BOSE7.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 
 import cosine.boseconomy.BOSEconomy;
 import org.bukkit.plugin.Plugin;
@@ -65,7 +65,7 @@ public class BOSE7 implements Method {
         return true;
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         if(hasAccount(name))
             return false;
         
diff --git a/com/nijikokun/register/payment/forChestShop/methods/ECO3.java b/com/nijikokun/register/payment/forChestShop/methods/ECO3.java
new file mode 100644
index 0000000..1d3f0af
--- /dev/null
+++ b/com/nijikokun/register/payment/forChestShop/methods/ECO3.java
@@ -0,0 +1,137 @@
+package com.nijikokun.register.payment.forChestShop.methods;
+
+import com.nijikokun.register.payment.forChestShop.Method;
+import me.ic3d.eco.ECO;
+import org.bukkit.plugin.Plugin;
+
+/**
+ * 3co implementation of Method.
+ *
+ * @copyright (c) 2011
+ * @license AOL license 
+ */
+public class ECO3 implements Method {
+    private ECO eco;
+
+    public Object getPlugin() {
+        return this.eco;
+    }
+
+    public String getName() {
+        return "3co";
+    }
+
+    public String getVersion() {
+        return "2.0";
+    }
+
+    public int fractionalDigits() {
+        return 0;
+    }
+
+    public String format(double amount) {
+        return (int) Math.ceil(amount) + " " + (amount == 1 ? eco.singularCurrency : eco.pluralCurrency);
+    }
+
+    public boolean hasBanks() {
+        return false;
+    }
+
+    public boolean hasBank(String bank) {
+        return false;
+    }
+
+    public boolean hasAccount(String name) {
+        return eco.hasAccount(name);
+    }
+
+    public boolean hasBankAccount(String bank, String name) {
+        return false;
+    }
+
+    public boolean createAccount(String name) {
+        if (hasAccount(name)) return false;
+        eco.createAccount(name, 0);
+        return true;
+    }
+
+    public boolean createAccount(String name, double balance) {
+        if (hasAccount(name)) return false;
+        eco.createAccount(name, (int) balance);
+        return true;
+    }
+
+    public MethodAccount getAccount(String name) {
+        if (!hasAccount(name)) createAccount(name); //Still somehow fails - it's 3co's issue
+        return new ECO3Account(name);
+    }
+
+    public MethodBankAccount getBankAccount(String bank, String name) {
+        return null;
+    }
+
+    public boolean isCompatible(Plugin plugin) {
+        return plugin.getDescription().getName().equals("3co") && plugin.getClass().getName().equals("me.ic3d.eco.ECO") && plugin instanceof ECO;
+    }
+
+    public void setPlugin(Plugin plugin) {
+        this.eco = (ECO) plugin;
+    }
+
+    public class ECO3Account implements MethodAccount {
+        private String name;
+
+        public ECO3Account(String name) {
+            this.name = name;
+        }
+
+        public double balance() {
+            return eco.getMoney(name);
+        }
+
+        public boolean set(double amount) {
+            eco.setMoney(name, (int) Math.ceil(amount));
+            return true;
+        }
+
+        public boolean add(double amount) {
+            set(balance() + amount);
+            return true;
+        }
+
+        public boolean subtract(double amount) {
+            set(balance() - amount);
+            return true;
+        }
+
+        public boolean multiply(double amount) {
+            set(balance() * amount);
+            return true;
+        }
+
+        public boolean divide(double amount) {
+            set(balance() / amount);
+            return true;
+        }
+
+        public boolean hasEnough(double amount) {
+            return eco.hasEnough(name, (int) Math.ceil(amount));
+        }
+
+        public boolean hasOver(double amount) {
+            return balance() > amount;
+        }
+
+        public boolean hasUnder(double amount) {
+            return balance() < amount;
+        }
+
+        public boolean isNegative() {
+            return balance() < 0;
+        }
+
+        public boolean remove() {
+            return false;
+        }
+    }
+}
diff --git a/com/nijikokun/register/forChestShop/payment/methods/EE17.java b/com/nijikokun/register/payment/forChestShop/methods/EE17.java
similarity index 96%
rename from com/nijikokun/register/forChestShop/payment/methods/EE17.java
rename to com/nijikokun/register/payment/forChestShop/methods/EE17.java
index 34f03ba..42d3ea3 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/EE17.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/EE17.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 import com.earth2me.essentials.Essentials;
 import com.earth2me.essentials.api.Economy;
 
@@ -63,7 +63,7 @@ public class EE17 implements Method {
         return true;
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         if(hasAccount(name))
             return false;
         
diff --git a/com/nijikokun/register/forChestShop/payment/methods/MCUR.java b/com/nijikokun/register/payment/forChestShop/methods/MCUR.java
similarity index 94%
rename from com/nijikokun/register/forChestShop/payment/methods/MCUR.java
rename to com/nijikokun/register/payment/forChestShop/methods/MCUR.java
index b901c32..536999c 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/MCUR.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/MCUR.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 
 import me.ashtheking.currency.Currency;
 import me.ashtheking.currency.CurrencyList;
@@ -58,7 +58,7 @@ public class MCUR implements Method {
         return true;
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, balance);
         return true;
     }
diff --git a/com/nijikokun/register/forChestShop/payment/methods/iCo4.java b/com/nijikokun/register/payment/forChestShop/methods/iCo4.java
similarity index 95%
rename from com/nijikokun/register/forChestShop/payment/methods/iCo4.java
rename to com/nijikokun/register/payment/forChestShop/methods/iCo4.java
index bddbcdb..3f76f51 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/iCo4.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/iCo4.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 import com.nijiko.coelho.iConomy.iConomy;
 import com.nijiko.coelho.iConomy.system.Account;
 
@@ -66,7 +66,7 @@ public class iCo4 implements Method {
         return true;
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         if(hasAccount(name))
             return false;
         
diff --git a/com/nijikokun/register/forChestShop/payment/methods/iCo5.java b/com/nijikokun/register/payment/forChestShop/methods/iCo5.java
similarity index 97%
rename from com/nijikokun/register/forChestShop/payment/methods/iCo5.java
rename to com/nijikokun/register/payment/forChestShop/methods/iCo5.java
index d16fae9..3cdfa1a 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/iCo5.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/iCo5.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 import com.iConomy.iConomy;
 import com.iConomy.system.Account;
 import com.iConomy.system.BankAccount;
@@ -63,7 +63,7 @@ public class iCo5 implements Method {
         return com.iConomy.iConomy.Accounts.create(name);
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         if(hasAccount(name))
             return false;
         
diff --git a/com/nijikokun/register/forChestShop/payment/methods/iCo6.java b/com/nijikokun/register/payment/forChestShop/methods/iCo6.java
similarity index 95%
rename from com/nijikokun/register/forChestShop/payment/methods/iCo6.java
rename to com/nijikokun/register/payment/forChestShop/methods/iCo6.java
index d0c4fd8..b8f73d8 100644
--- a/com/nijikokun/register/forChestShop/payment/methods/iCo6.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/iCo6.java
@@ -1,6 +1,6 @@
-package com.nijikokun.register.forChestShop.payment.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
 
-import com.nijikokun.register.forChestShop.payment.Method;
+import com.nijikokun.register.payment.forChestShop.Method;
 import com.iCo6.iConomy;
 import com.iCo6.system.Account;
 import com.iCo6.system.Accounts;
@@ -62,7 +62,7 @@ public class iCo6 implements Method {
         return (new Accounts()).create(name);
     }
 
-    public boolean createAccount(String name, Double balance) {
+    public boolean createAccount(String name, double balance) {
         if(hasAccount(name))
             return false;
         
diff --git a/plugin.yml b/plugin.yml
index deccc9a..915139f 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -2,7 +2,7 @@ name: ChestShop
 
 main: com.Acrobot.ChestShop.ChestShop
 
-version: 3.22
+version: 3.23
 
 
 author: Acrobot
@@ -10,7 +10,7 @@ description: >
              A chest shop for economy plugins.
  
  
-softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem, Towny]
+softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem, Towny, WorldGuard]
 commands:
   iteminfo:
     aliases: [iinfo]