mirror of
https://github.com/filoghost/ChestCommands.git
synced 2024-11-25 11:35:32 +01:00
Notify the player about icon's onClick exception
This commit is contained in:
parent
ec057ea2e7
commit
29da6ab129
@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user