From 29da6ab129d536228097ef0a605fcbc99ba5d6e1 Mon Sep 17 00:00:00 2001 From: filoghost Date: Sat, 17 Oct 2020 18:47:34 +0200 Subject: [PATCH] Notify the player about icon's onClick exception --- .../chestcommands/listener/InventoryListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/me/filoghost/chestcommands/listener/InventoryListener.java b/plugin/src/main/java/me/filoghost/chestcommands/listener/InventoryListener.java index c6235fa..3fb007a 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/listener/InventoryListener.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/listener/InventoryListener.java @@ -16,6 +16,7 @@ import me.filoghost.chestcommands.menu.InternalMenu; import me.filoghost.chestcommands.menu.MenuManager; import me.filoghost.fcommons.logging.Log; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -87,12 +88,13 @@ public class InventoryListener implements Listener { clicker.closeInventory(); } } catch (Throwable t) { - handleIconClickException(menuView.getMenu(), t); + handleIconClickException(clicker, menuView.getMenu(), t); + clicker.closeInventory(); } }); } - private void handleIconClickException(Menu menu, Throwable throwable) { + private void handleIconClickException(Player clicker, Menu menu, Throwable throwable) { String menuDescription; if (menu.getPlugin() == ChestCommands.getInstance()) { menuDescription = "the menu \"" + Errors.formatPath(((InternalMenu) menu).getSourceFile()) + "\""; @@ -101,6 +103,7 @@ public class InventoryListener implements Listener { } Log.severe("Encountered exception while handling a click inside " + menuDescription, throwable); + clicker.sendMessage(ChatColor.RED + "An internal error occurred when you clicked on the item."); } }