Trying to see ItemMeta of Clicked Item while Stripping Color

Discussion in 'BungeeCord Plugin Help' started by MarkIsCool, Jun 9, 2018.

  1. Hmmm, I don't think I'm doing this right.
    Currently, I'm trying to make a simple GUI.
    I'm checking to see if the item they clicked, is a certain item. If it is, then I would do the giveMageKit() or the giveWarriorKit() methods. I'm getting a ton of errors when I click them, and the if statements are simply not working. Any alternatives?

    Code (Text):

    @EventHandler
        public void onInventoryClick(InventoryClickEvent e) {

            Player player = (Player) e.getWhoClicked();

            if (!e.getInventory().getName().equals("Classes"))
                return;

            if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.stripColor("Mage"))) {
                giveMageKit(player);
                e.setCancelled(true);
            }
            if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.stripColor("Warrior"))) {
                giveWarriorKit(player);
                e.setCancelled(true);

            }

        }
     
     
  2. What are the errors that you get? Please show us the stacktrace.
     
  3. Here is the error:
    http://prntscr.com/jt1b0e
     
  4. Which one is line 124?
     
    • Like Like x 1
  5. You need to check "getCurrentItem" for null.