Fix announcer getter for 1.14+

This commit is contained in:
Daniel Saukel 2019-06-04 17:18:27 +02:00
parent df0d01d101
commit acedb05f55
2 changed files with 3 additions and 5 deletions

View File

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
/**
* Announcer instance manager.
@ -70,7 +70,7 @@ public class AnnouncerCache {
* @param gui the gui
* @return the announcer that has the GUI
*/
public Announcer getByGUI(Inventory gui) {
public Announcer getByGUI(InventoryView gui) {
for (Announcer announcer : announcers) {
if ((ChatColor.DARK_RED + announcer.getName()).equals(gui.getTitle())) {
return announcer;

View File

@ -22,7 +22,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
/**
@ -43,9 +42,8 @@ public class AnnouncerListener implements Listener {
}
Player player = (Player) event.getWhoClicked();
Inventory gui = event.getInventory();
ItemStack button = event.getCurrentItem();
Announcer announcer = announcers.getByGUI(gui);
Announcer announcer = announcers.getByGUI(event.getView());
if (announcer != null && button != null && Category.WOOL.containsMaterial(button.getType())) {
announcer.clickGroupButton(player, button);
}