diff --git a/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java b/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java index 5fd5e2c8..2819556e 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/announcer/Announcer.java @@ -458,7 +458,11 @@ public class Announcer { */ public DGroup getDGroupByButton(ItemStack button) { int index = buttons.indexOf(button); - return dGroups.get(index); + if (dGroups.size() <= index || index < 0) { + return null; + } else { + return dGroups.get(index); + } } } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/announcer/AnnouncerListener.java b/src/main/java/io/github/dre2n/dungeonsxl/announcer/AnnouncerListener.java index a0b795b6..a2d376e5 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/announcer/AnnouncerListener.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/announcer/AnnouncerListener.java @@ -23,6 +23,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Wool; /** * @author Daniel Saukel @@ -37,9 +38,9 @@ public class AnnouncerListener implements Listener { Player player = (Player) event.getWhoClicked(); Inventory gui = event.getInventory(); - ItemStack button = gui.getItem(event.getSlot()); + ItemStack button = event.getCurrentItem(); Announcer announcer = DungeonsXL.getInstance().getAnnouncers().getByGUI(gui); - if (announcer != null) { + if (announcer != null && button != null && button.getData() instanceof Wool) { announcer.clickGroupButton(player, button); } }