From cf6af4630d7697a1182fc08d6dcc92c49c762c46 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 7 Jul 2020 13:52:20 -0700 Subject: [PATCH] proper InventoryClickEvent array index fix --- .../gmail/nossr50/listeners/InventoryListener.java | 12 +++++------- .../com/gmail/nossr50/util/skills/CombatUtils.java | 3 +++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 248becf37..823b1528f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -436,15 +436,13 @@ public class InventoryListener implements Listener { public void onInventoryClickEvent(InventoryClickEvent event) { SkillUtils.removeAbilityBuff(event.getCurrentItem()); if (event.getAction() == InventoryAction.HOTBAR_SWAP) { + if(event.getHotbarButton() == -1) + return; + PlayerInventory playerInventory = event.getWhoClicked().getInventory(); - //TODO: Is this a spigot bug? - if(playerInventory.getContents().length > event.getHotbarButton()) - { - if(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()) != null) - SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton())); - } - + if(playerInventory.getItem(event.getHotbarButton()) != null) + SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton())); } } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index d3b939da2..6c9931b73 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -435,6 +435,9 @@ public final class CombatUtils { Projectile arrow = (Projectile) painSource; ProjectileSource projectileSource = arrow.getShooter(); + //Determine if the arrow belongs to a bow or xbow + + if (projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) { Player player = (Player) projectileSource;