List items = new ArrayList<>(); for (int i = 0; i < 45; i++) { ItemStack finalStack = event.getInventory().getContents()[i]; if (finalStack == null || finalStack.getType() == Material.AIR) { continue; } if (finalStack.getItemMeta().getLore() == null) { finalStack = new ItemMaker(finalStack).addLore("&f* &7Chance: &f100.0%").build(); } else if (finalStack.getItemMeta().getLore() != null && findIndex(finalStack.getItemMeta().getLore(), "* Chance:") == -1) { finalStack = new ItemMaker(finalStack).addLore("&f* &7Chance: &f100.0%").build(); } items.add(finalStack); } // NOTE: findIndex(finalStack.getItemMeta().getLore(), "* Chance:") == -1 checks if the item has the String "* Chance:" and if it doesn't it returns a "-1"