Fix announcer GUI exceptions

This commit is contained in:
Daniel Saukel 2017-10-05 17:00:48 +02:00
parent a3e890d704
commit 40c9547a29
2 changed files with 8 additions and 3 deletions

View File

@ -458,7 +458,11 @@ public class Announcer {
*/
public DGroup getDGroupByButton(ItemStack button) {
int index = buttons.indexOf(button);
if (dGroups.size() <= index || index < 0) {
return null;
} else {
return dGroups.get(index);
}
}
}

View File

@ -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);
}
}