When I try to find, if two items are same, I can't. It's because of a attribute modifiers that have some UUIDs that are always random so I can't compare items with attribute modifiers. Even though I know I can compare items by name etc. I want to ask, if there is some way to do it with attribute modifiers.
public static Object item() {
ItemStack item = new ItemStack(Material.STICK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§2§lCool sword");
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("generic.attackDamage", 11.0, AttributeModifier.Operation.ADD_NUMBER));
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier("generic.attackSpeed", 1.4, AttributeModifier.Operation.ADD_NUMBER));
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
item.setItemMeta(meta);
return item;
}
public static void processEvent(Entity damager, LivingEntity entity) {
if (!(damager instanceof Player)) return;
Player player = (Player) damager;
if (!player.getItemInHand().isSimilar((ItemStack) item())) return;
entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING,200, 1, true, false));
}