/** * Create a GlowMetaItem, copying from another if possible. * * @param meta The meta to copy from, or null. */ public GlowMetaItem(ItemMeta meta) { if (meta == null) { return; } displayName = meta.getDisplayName(); if (meta.hasLore()) { lore = new ArrayList<>(meta.getLore()); } if (meta.hasEnchants()) { enchants = new HashMap<>(meta.getEnchants()); } if (meta instanceof GlowMetaItem) { hideFlag = ((GlowMetaItem) meta).hideFlag; } else { for (ItemFlag flag : meta.getItemFlags()) { addItemFlags(flag); } } }
private boolean getBaby(Inventory i) { ItemStack is = i.getItem(47); ItemMeta im = is.getItemMeta(); return im.getLore().get(0).equals("BABY"); }
public static boolean hasRPGMetadata(ItemStack item) { if (!item.hasItemMeta()) return false; ItemMeta meta = item.getItemMeta(); if (!meta.hasLore()) return false; List<String> lore = meta.getLore(); return lore.size() != 0 && lore.get(0).contains(METADATA_PREFIX); }
public static boolean isMcMMOItem(ItemStack item) { if (!item.hasItemMeta()) { return false; } ItemMeta itemMeta = item.getItemMeta(); return itemMeta.hasLore() && itemMeta.getLore().contains("mcMMO Item"); }
ItemStack itemInMainHand = player.getInventory().getItemInMainHand(); if (itemInMainHand != null && itemInMainHand.hasItemMeta()) { ItemMeta metaOfItemInHand = itemInMainHand.getItemMeta(); if (metaOfItemInHand.hasLore()) { List<String> loreInHand = metaOfItemInHand.getLore(); for(String loreLine : loreInHand) { if(loreLine.contains("lore") { //do stuff } } } }
ItemStack itemInMainHand = player.getInventory().getItemInMainHand(); if (itemInMainHand != null && itemInMainHand.hasItemMeta()) { ItemMeta metaOfItemInHand = itemInMainHand.getItemMeta(); if (metaOfItemInHand.hasLore() && String.join(" ", metaOfItemInHand.getLore()).contains("lore")) { //do stuff } }
private AnimalColor getColor(Inventory i) { ItemStack is = i.getItem(48); ItemMeta im = is.getItemMeta(); try { return AnimalColor.valueOf(im.getLore().get(0)); } catch (IllegalArgumentException e) { return AnimalColor.WHITE; } }
private Type getCatType(Inventory i) { ItemStack is = i.getItem(48); ItemMeta im = is.getItemMeta(); try { return Type.valueOf(im.getLore().get(0)); } catch (IllegalArgumentException e) { return Type.WILD_OCELOT; } }
private Profession getProfession(Inventory i) { ItemStack is = i.getItem(48); ItemMeta im = is.getItemMeta(); try { return Profession.valueOf(im.getLore().get(0)); } catch (IllegalArgumentException e) { return Profession.FARMER; } }
public static ItemStack delLore(ItemStack is, int line) { ItemMeta meta = is.getItemMeta(); if (meta.hasLore()) { List<String> l = meta.getLore(); if (l.size() >= line) { l.remove(line); meta.setLore(l); is.setItemMeta(meta); } } return is; }
public static float getMaxEnergy(ItemStack item) { if (item == null || item.getType() == null || item.getType().equals(Material.AIR)) return 0F; if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return 0F; for (String line: item.getItemMeta().getLore()) { if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J")) { return Float.valueOf(line.split(" / ")[1].replace(" J", "")); } } return 0F; }
public ItemMetaMock(ItemMeta meta) { if (meta.hasDisplayName()) displayName = meta.getDisplayName(); if (meta.hasLore()) lore = meta.getLore(); }
public void setMinigame(Minigame minigame){ ItemMeta meta = tool.getItemMeta(); List<String> lore = meta.getLore(); lore.set(0, ChatColor.AQUA + "Minigame: " + ChatColor.WHITE + minigame.getName(false)); meta.setLore(lore); tool.setItemMeta(meta); this.minigame = minigame; }
public static float getStoredEnergy(ItemStack item) { if (item == null || item.getType() == null || item.getType().equals(Material.AIR)) return 0F; if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return 0F; for (String line: item.getItemMeta().getLore()) { if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J")) { return Float.valueOf(line.split(" / ")[0].replace(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7"), "")); } } return 0F; }
public ItemStack upgrade() { List<String> lore = new ArrayList<String>(); lore.add("&7&oEnder Infused"); lore.add(""); for (String line: getItem().getItemMeta().getLore()) { lore.add(line); } ItemStack item = new CustomItem(getItem().getType(), "&5Ender " + ChatColor.stripColor(getItem().getItemMeta().getDisplayName()), getItem().getDurability(), lore.toArray(new String[lore.size()])); return item; }
public ItemBuilder colored() { if (itemMeta.hasDisplayName()) { itemMeta.setDisplayName(TLocale.Translate.setColored(itemMeta.getDisplayName())); } if (itemMeta.hasLore()) { itemMeta.setLore(TLocale.Translate.setColored(itemMeta.getLore())); } return this; }