From bb167b00eb72953cc66152e58d3f77b9c67ecb67 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 7 Jul 2020 08:56:33 -0700 Subject: [PATCH] Array out of index fix --- Changelog.txt | 3 ++- .../com/gmail/nossr50/listeners/InventoryListener.java | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index e15731aa4..de88bc2c5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -15,7 +15,8 @@ Version 2.1.133 Permission node descriptions had mentions of ability changed to sub-skill and other minor corrections Smelting now has a Bonus Drops section in config.yml - Smelting now only doubles smelting results for items which have bonus drop entries in the config + Second Smelt now only doubles smelting results for items which have bonus drop entries in the config + Fixed an array out of index bug for inventory click events (These permissions are all included in the mcmmo.defaults node) New permission node 'mcmmo.commands.tridents' diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 70e69d430..248becf37 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -438,9 +438,13 @@ public class InventoryListener implements Listener { if (event.getAction() == InventoryAction.HOTBAR_SWAP) { PlayerInventory playerInventory = event.getWhoClicked().getInventory(); - if(playerInventory.getSize()) - if(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()) != null) - SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton())); + //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())); + } + } }