From ec8221610a471f9cb7fa065f2eb7c961dda9c866 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 24 Feb 2013 23:57:30 -0500 Subject: [PATCH] Add a few more checks for sanity on the new ability buffs. --- .../java/com/gmail/nossr50/listeners/InventoryListener.java | 5 +---- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 3 +++ .../java/com/gmail/nossr50/skills/utilities/SkillTools.java | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 385201cd9..75cae3f9f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -14,7 +14,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.ItemStack; @@ -134,8 +133,6 @@ public class InventoryListener implements Listener{ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryClickEvent(InventoryClickEvent event) { - if (event.getInventory() instanceof AnvilInventory) { - SkillTools.removeAbilityBuff(event.getCurrentItem()); - } + SkillTools.removeAbilityBuff(event.getCurrentItem()); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 6b075c69d..a1e5d4449 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -146,7 +146,10 @@ public class PlayerListener implements Listener { if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) { event.setCancelled(true); + return; } + + SkillTools.removeAbilityBuff(event.getItemDrop().getItemStack()); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index 5b6825123..d3203ba64 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -30,6 +30,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.spout.SpoutConfig; import com.gmail.nossr50.spout.SpoutTools; +import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ParticleEffectUtils; import com.gmail.nossr50.util.Permissions; @@ -544,6 +545,10 @@ public class SkillTools { return item; } + if (!ItemChecks.isPickaxe(item) && !ItemChecks.isShovel(item)) { + return item; + } + if (item.containsEnchantment(Enchantment.DIG_SPEED)) { ItemMeta itemMeta = item.getItemMeta();