i am coding a ban gui plugin but when i tested it i got this error Code (Text): public class baninventoryevent implements Listener { BanGUI plugin; public baninventoryevent(BanGUI plugin) { this.plugin = plugin; } @EventHandler public void onMenuClick(InventoryClickEvent e) { Player player = (Player) e.getWhoClicked(); if (e.getClickedInventory().getTitle().equalsIgnoreCase(ChatColor.RED + "BanGUI")) { if (e.getCurrentItem().getType() == Material.PLAYER_HEAD) { Player whoToBan = player.getServer().getPlayer(e.getCurrentItem().getItemMeta().getDisplayName()); plugin.openBanReason(player, whoToBan); } }else if (e.getClickedInventory().getTitle().equalsIgnoreCase("Reasons")) { switch (e.getCurrentItem().getType()){ case IRON_SWORD: String name = e.getClickedInventory().getItem(4).getItemMeta().getDisplayName(); player.getServer().getBanList(BanList.Type.NAME).addBan(e.getClickedInventory().getItem(4).getItemMeta().getDisplayName(), "Using combat hacks to an unfair adventage", null, player.getDisplayName()); player.sendMessage(ChatColor.RED + "Banned, Thanks for banning and help the server"); break; case BARRIER: plugin.openGUI(player); break; } } e.setCancelled(true); } } Please help
I have done looked at line 33 on the code and i didnt see nothing wornge EDITED: i am new to coding so ya dont hurt me
Maybe your Player object is null, because itemMeta#getDisplayName() return the full name of current item, with colored codes and etc.
Are you sure, that there is an item on that slot, because it seems like there is not or it has no metadata.