I am making a bukkit plugin with a sign shop that opens a static inventory and you click to get kits. I have gotten the inventory set up, it opens when the sign is clicked, and the items I want are in there. However, when I click in the inventory, the first if statement returns false. Here is my code:
@EventHandler
public void onInventoryClick(InventoryClickEvent e){
if (e.getInventory() == kitInvent){
Player player = (Player) e.getWhoClicked();
player.sendMessage("Kit Shop Opened");
if (e.getCurrentItem().getItemMeta().getDisplayName() == ChatColor.DARK_PURPLE + "Grenadier Kit"){
e.setCancelled(true);
player.getInventory().clear();
Potion potion = new Potion(PotionType.INSTANT_DAMAGE, 1);
potion.setSplash(true);
ItemStack grenadeStack = new ItemStack(Material.POTION, 32);
potion.apply(grenadeStack);
player.getInventory().addItem(grenadeStack);
}
}
}
It can't get past the "if (e.getInventory() == kitInvent)" part because when I comment it out, it sends the message "Kit Shop Opened".
Also, am I doing the next if statement correctly, where it checks the item's title? I was having issues there too, but I didn't know if it was simply because of the previous if statement.
Any help is greatly appreciated!