From d919818bb6de680493092db8f747f89a62707503 Mon Sep 17 00:00:00 2001 From: Acrobot Date: Tue, 14 Jun 2011 15:07:44 +0200 Subject: [PATCH] - Fixed not checking whether Material is null before getting durability from String - Moved Register classes, should work with other plugins now - Cleaned the code a bit --- com/Acrobot/ChestShop/Chests/ChestObject.java | 2 +- .../ChestShop/Chests/MinecraftChest.java | 2 +- com/Acrobot/ChestShop/Config/Property.java | 17 ----------------- com/Acrobot/ChestShop/Economy.java | 2 +- com/Acrobot/ChestShop/Items/DataValue.java | 4 ++++ .../ChestShop/Listeners/pluginEnable.java | 2 +- com/Acrobot/ChestShop/Shop/Shop.java | 2 +- com/Acrobot/ChestShop/Utils/InventoryUtil.java | 4 ++++ .../payment/{ => forChestShop}/Method.java | 2 +- .../payment/{ => forChestShop}/Methods.java | 10 +++++----- .../{ => forChestShop}/methods/BOSE.java | 4 ++-- .../{ => forChestShop}/methods/EE17.java | 4 ++-- .../{ => forChestShop}/methods/iCo4.java | 4 ++-- .../{ => forChestShop}/methods/iCo5.java | 4 ++-- plugin.yml | 2 +- 15 files changed, 28 insertions(+), 37 deletions(-) rename com/nijikokun/register/payment/{ => forChestShop}/Method.java (97%) rename com/nijikokun/register/payment/{ => forChestShop}/Methods.java (95%) rename com/nijikokun/register/payment/{ => forChestShop}/methods/BOSE.java (97%) rename com/nijikokun/register/payment/{ => forChestShop}/methods/EE17.java (98%) rename com/nijikokun/register/payment/{ => forChestShop}/methods/iCo4.java (96%) rename com/nijikokun/register/payment/{ => forChestShop}/methods/iCo5.java (97%) diff --git a/com/Acrobot/ChestShop/Chests/ChestObject.java b/com/Acrobot/ChestShop/Chests/ChestObject.java index 9f7149b..ba05c9b 100644 --- a/com/Acrobot/ChestShop/Chests/ChestObject.java +++ b/com/Acrobot/ChestShop/Chests/ChestObject.java @@ -12,7 +12,7 @@ public interface ChestObject { public void clearSlot(int slot); - public void addItem(ItemStack item, short durability, int amount); + public void addItem(ItemStack item, int amount); public void removeItem(ItemStack item, short durability, int amount); diff --git a/com/Acrobot/ChestShop/Chests/MinecraftChest.java b/com/Acrobot/ChestShop/Chests/MinecraftChest.java index e885e40..4a8a628 100644 --- a/com/Acrobot/ChestShop/Chests/MinecraftChest.java +++ b/com/Acrobot/ChestShop/Chests/MinecraftChest.java @@ -48,7 +48,7 @@ public class MinecraftChest implements ChestObject { } } - public void addItem(ItemStack item, short durability, int amount) { + public void addItem(ItemStack item, int amount) { int left = addItem(item, amount, main); if (neighbor != null) { addItem(item, left, neighbor); diff --git a/com/Acrobot/ChestShop/Config/Property.java b/com/Acrobot/ChestShop/Config/Property.java index 39c6ea2..7a4ec0f 100644 --- a/com/Acrobot/ChestShop/Config/Property.java +++ b/com/Acrobot/ChestShop/Config/Property.java @@ -1,8 +1,5 @@ package com.Acrobot.ChestShop.Config; -import java.util.HashMap; -import java.util.Map; - /** * @author Acrobot */ @@ -21,13 +18,9 @@ public enum Property { PROTECT_SIGN_WITH_LWC(false, "Do you want to protect shop signs with LWC?"); - - private Object value; private String comment; - private static final Map names = new HashMap(); - private Property(Object value, String comment) { this.value = value; this.comment = comment; @@ -44,14 +37,4 @@ public enum Property { public String toString() { return name(); } - - public static Property lookup(String name) { - return names.get(name); - } - - static { - for (Property def : values()) { - names.put(def.name(), def); - } - } } diff --git a/com/Acrobot/ChestShop/Economy.java b/com/Acrobot/ChestShop/Economy.java index 252cfa5..851ef80 100644 --- a/com/Acrobot/ChestShop/Economy.java +++ b/com/Acrobot/ChestShop/Economy.java @@ -1,6 +1,6 @@ package com.Acrobot.ChestShop; -import com.nijikokun.register.payment.Method; +import com.nijikokun.register.payment.forChestShop.Method; /** * @author Acrobot diff --git a/com/Acrobot/ChestShop/Items/DataValue.java b/com/Acrobot/ChestShop/Items/DataValue.java index 7cd8bc7..07638e4 100644 --- a/com/Acrobot/ChestShop/Items/DataValue.java +++ b/com/Acrobot/ChestShop/Items/DataValue.java @@ -11,6 +11,10 @@ import org.bukkit.material.*; */ public class DataValue { public static byte get(String arg, Material material){ + if(material == null){ + return 0; + } + arg = arg.toUpperCase().replace(" ", "_"); diff --git a/com/Acrobot/ChestShop/Listeners/pluginEnable.java b/com/Acrobot/ChestShop/Listeners/pluginEnable.java index d706308..472117e 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginEnable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginEnable.java @@ -9,7 +9,7 @@ import com.Acrobot.ChestShop.Protection.LockettePlugin; import com.Acrobot.ChestShop.Protection.Security; import com.griefcraft.lwc.LWCPlugin; import com.nijikokun.bukkit.Permissions.Permissions; -import com.nijikokun.register.payment.Methods; +import com.nijikokun.register.payment.forChestShop.Methods; import info.somethingodd.bukkit.OddItem.OddItem; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; diff --git a/com/Acrobot/ChestShop/Shop/Shop.java b/com/Acrobot/ChestShop/Shop/Shop.java index f1c561d..6709806 100644 --- a/com/Acrobot/ChestShop/Shop/Shop.java +++ b/com/Acrobot/ChestShop/Shop/Shop.java @@ -122,7 +122,7 @@ public class Shop { } if (!isAdminShop()) { - chest.addItem(stock, stock.getDurability(), stockAmount); + chest.addItem(stock, stockAmount); } Economy.add(player.getName(), sellPrice); diff --git a/com/Acrobot/ChestShop/Utils/InventoryUtil.java b/com/Acrobot/ChestShop/Utils/InventoryUtil.java index 4b7bc8e..4813659 100644 --- a/com/Acrobot/ChestShop/Utils/InventoryUtil.java +++ b/com/Acrobot/ChestShop/Utils/InventoryUtil.java @@ -78,6 +78,10 @@ public class InventoryUtil { public static int amount(Inventory inv, ItemStack item, short durability) { int amount = 0; + if(!inv.contains(item.getType())){ + return amount; + } + ItemStack[] contents = inv.getContents(); for (ItemStack i : contents) { if (i != null) { diff --git a/com/nijikokun/register/payment/Method.java b/com/nijikokun/register/payment/forChestShop/Method.java similarity index 97% rename from com/nijikokun/register/payment/Method.java rename to com/nijikokun/register/payment/forChestShop/Method.java index 71e7b96..f4f428e 100644 --- a/com/nijikokun/register/payment/Method.java +++ b/com/nijikokun/register/payment/forChestShop/Method.java @@ -1,4 +1,4 @@ -package com.nijikokun.register.payment; +package com.nijikokun.register.payment.forChestShop; import org.bukkit.plugin.Plugin; diff --git a/com/nijikokun/register/payment/Methods.java b/com/nijikokun/register/payment/forChestShop/Methods.java similarity index 95% rename from com/nijikokun/register/payment/Methods.java rename to com/nijikokun/register/payment/forChestShop/Methods.java index 2a5d08f..461af6e 100644 --- a/com/nijikokun/register/payment/Methods.java +++ b/com/nijikokun/register/payment/forChestShop/Methods.java @@ -1,4 +1,4 @@ -package com.nijikokun.register.payment; +package com.nijikokun.register.payment.forChestShop; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; @@ -40,10 +40,10 @@ public class Methods { } private void _init() { - this.addMethod("iConomy", new com.nijikokun.register.payment.methods.iCo4()); - this.addMethod("iConomy", new com.nijikokun.register.payment.methods.iCo5()); - this.addMethod("BOSEconomy", new com.nijikokun.register.payment.methods.BOSE()); - this.addMethod("Essentials", new com.nijikokun.register.payment.methods.EE17()); + this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4()); + this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5()); + this.addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE()); + this.addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17()); } public Set getDependencies() { diff --git a/com/nijikokun/register/payment/methods/BOSE.java b/com/nijikokun/register/payment/forChestShop/methods/BOSE.java similarity index 97% rename from com/nijikokun/register/payment/methods/BOSE.java rename to com/nijikokun/register/payment/forChestShop/methods/BOSE.java index 4bd742d..6f03bd3 100644 --- a/com/nijikokun/register/payment/methods/BOSE.java +++ b/com/nijikokun/register/payment/forChestShop/methods/BOSE.java @@ -1,6 +1,6 @@ -package com.nijikokun.register.payment.methods; +package com.nijikokun.register.payment.forChestShop.methods; -import com.nijikokun.register.payment.Method; +import com.nijikokun.register.payment.forChestShop.Method; import cosine.boseconomy.BOSEconomy; import org.bukkit.plugin.Plugin; diff --git a/com/nijikokun/register/payment/methods/EE17.java b/com/nijikokun/register/payment/forChestShop/methods/EE17.java similarity index 98% rename from com/nijikokun/register/payment/methods/EE17.java rename to com/nijikokun/register/payment/forChestShop/methods/EE17.java index 7d68bd0..8d146c3 100644 --- a/com/nijikokun/register/payment/methods/EE17.java +++ b/com/nijikokun/register/payment/forChestShop/methods/EE17.java @@ -1,10 +1,10 @@ -package com.nijikokun.register.payment.methods; +package com.nijikokun.register.payment.forChestShop.methods; import com.earth2me.essentials.Essentials; import com.earth2me.essentials.api.Economy; import com.earth2me.essentials.api.NoLoanPermittedException; import com.earth2me.essentials.api.UserDoesNotExistException; -import com.nijikokun.register.payment.Method; +import com.nijikokun.register.payment.forChestShop.Method; import org.bukkit.plugin.Plugin; public class EE17 implements Method { diff --git a/com/nijikokun/register/payment/methods/iCo4.java b/com/nijikokun/register/payment/forChestShop/methods/iCo4.java similarity index 96% rename from com/nijikokun/register/payment/methods/iCo4.java rename to com/nijikokun/register/payment/forChestShop/methods/iCo4.java index b506b8a..6c352a7 100644 --- a/com/nijikokun/register/payment/methods/iCo4.java +++ b/com/nijikokun/register/payment/forChestShop/methods/iCo4.java @@ -1,8 +1,8 @@ -package com.nijikokun.register.payment.methods; +package com.nijikokun.register.payment.forChestShop.methods; import com.nijiko.coelho.iConomy.iConomy; import com.nijiko.coelho.iConomy.system.Account; -import com.nijikokun.register.payment.Method; +import com.nijikokun.register.payment.forChestShop.Method; import org.bukkit.plugin.Plugin; public class iCo4 implements Method { diff --git a/com/nijikokun/register/payment/methods/iCo5.java b/com/nijikokun/register/payment/forChestShop/methods/iCo5.java similarity index 97% rename from com/nijikokun/register/payment/methods/iCo5.java rename to com/nijikokun/register/payment/forChestShop/methods/iCo5.java index dda2467..33d93c8 100644 --- a/com/nijikokun/register/payment/methods/iCo5.java +++ b/com/nijikokun/register/payment/forChestShop/methods/iCo5.java @@ -1,11 +1,11 @@ -package com.nijikokun.register.payment.methods; +package com.nijikokun.register.payment.forChestShop.methods; import com.iConomy.iConomy; import com.iConomy.system.Account; import com.iConomy.system.BankAccount; import com.iConomy.system.Holdings; import com.iConomy.util.Constants; -import com.nijikokun.register.payment.Method; +import com.nijikokun.register.payment.forChestShop.Method; import org.bukkit.plugin.Plugin; public class iCo5 implements Method { diff --git a/plugin.yml b/plugin.yml index c5f157c..e86dc32 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ name: ChestShop main: com.Acrobot.ChestShop.ChestShop database: true -version: 3.00 BETA 2 +version: 3.00 BETA 3 author: Acrobot