So, I'm trying to check whether a chest plate has a certain lure or not, and if so, it gives them a potion effect when they are wearing that piece of amor. Here is my code, and it currently doesn't do anything: Code (Text): if(p.getInventory().getChestplate().getType() == Material.DIAMOND_CHESTPLATE && p.getInventory().getChestplate().getItemMeta().getLore().equals(Arrays.asList(ChatColor.GOLD + "Mothers Arms II"))) { p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 2147000, 1)); p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 2147000, 1)); p.sendMessage("Activated"); }
Well first of all you should make sure the item even has an item meta & lore attached to it before you start calling it. Second, perhaps check if the lore CONTAINS your string instead of what you're doing, I think that the default lores still stick so that if statement will never return true. And finally, where exactly is this code being called?