mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Fix announcer GUI exceptions
This commit is contained in:
parent
a3e890d704
commit
40c9547a29
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user