diff options
author | snowleo <schneeleo@gmail.com> | 2011-12-07 13:44:51 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-12-07 13:44:51 +0100 |
commit | 766f0a9f13f3a8e0f52e24917cf4259da9c1190d (patch) | |
tree | 41d194929ab5c2096c9e10207d7c6154c86e6f67 | |
parent | d60de76d87ce00a3b3d3a77a470852e455e58d7f (diff) | |
download | Essentials-766f0a9f13f3a8e0f52e24917cf4259da9c1190d.tar Essentials-766f0a9f13f3a8e0f52e24917cf4259da9c1190d.tar.gz Essentials-766f0a9f13f3a8e0f52e24917cf4259da9c1190d.tar.lz Essentials-766f0a9f13f3a8e0f52e24917cf4259da9c1190d.tar.xz Essentials-766f0a9f13f3a8e0f52e24917cf4259da9c1190d.zip |
Use of our Inventory code in enchant sign to be reliable.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignEnchant.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java b/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java index ee7d4feeb..efa1ee018 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java @@ -6,6 +6,7 @@ import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; +import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -61,30 +62,27 @@ public class SignEnchant extends EssentialsSign @Override protected boolean onSignInteract(ISign sign, User player, String username, IEssentials ess) throws SignException, ChargeException { - final Material search = getItemStack(sign.getLine(1), 1, ess).getType(); - int slot; + final ItemStack search = getItemStack(sign.getLine(1), 1, ess); + int slot = -1; final Trade charge = getTrade(sign, 3, ess); charge.isAffordableFor(player); - if (player.getInventory().contains(search)) + if (InventoryWorkaround.containsItem(player.getInventory(), false, search)) { - slot = player.getInventory().first(search); + slot = InventoryWorkaround.first(player.getInventory(), search, false, true); } - else + if (slot == -1) { - player.sendMessage(_("missingItems", 1, search.toString())); - return true; + throw new SignException(_("missingItems", 1, search.toString())); } final String[] enchantLevel = sign.getLine(2).split(":"); if (enchantLevel.length != 2) { - player.sendMessage(_("invalidSignLine", 2)); - return true; + throw new SignException(_("invalidSignLine", 2)); } final Enchantment enchantment = Enchantments.getByName(enchantLevel[0]); if (enchantment == null) { - player.sendMessage(_("enchantmentNotFound")); - return true; + throw new SignException(_("enchantmentNotFound")); } final ItemStack toEnchant = player.getInventory().getItem(slot); |