/** * 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); } } }
/** * Sets the name of the next item to be modified on this anvil. * * @param name the item name */ public void setRenameText(String name) { renameText = name; if (renameText.isEmpty()) { setItem(FIRST_ITEM_SLOT, getFirstItem()); setItem(SECOND_ITEM_SLOT, getSecondItem()); } else { ItemStack result = getFirstItem().clone(); if (!InventoryUtil.isEmpty(result)) { if (Objects.equals(result.getItemMeta().getDisplayName(), name)) { setItem(RESULT_SLOT, InventoryUtil.createEmptyStack()); } // rename the item ItemMeta m = result.getItemMeta(); m.setDisplayName(ChatColor.ITALIC + renameText); result.setItemMeta(m); setItem(RESULT_SLOT, result); } } } }
private boolean isTool(ItemStack item) { if (item == null || item.getType() == Material.AIR) return false; String name = item.getItemMeta().getDisplayName(); if (name == null) return false; // Just check the names of each tool return name.equals(AREG_NAME) || name.equals(LREG_NAME) || name.equals(WARPS_NAME) || name.equals(SPAWNS_NAME) || name.equals(CHESTS_NAME) || name.equals(MANUAL_NAME); }
private TARDISHandlesBlock getNext(int i) { if (i > 35) { return null; } ItemStack num = program.getInventory()[i]; if (num != null) { return TARDISHandlesBlock.BY_NAME.get(num.getItemMeta().getDisplayName()); } return null; }
private String getDisplay(Inventory inv, int slot) { ItemStack is = inv.getItem(slot); if (is != null) { ItemMeta im = is.getItemMeta(); return im.getDisplayName(); } else { return ""; } }
private boolean is3DGlasses(ItemStack is) { if (is != null && is.hasItemMeta()) { ItemMeta im = is.getItemMeta(); return im.hasDisplayName() && im.getDisplayName().equals("3-D Glasses"); } return false; }
private boolean isWand(ItemStack is) { if (!is.hasItemMeta()) { return false; } ItemMeta im = is.getItemMeta(); if (!im.hasDisplayName()) { return false; } return im.getDisplayName().equals("TARDIS Schematic Wand"); } }
private String getName() { ItemMeta meta = stack.getItemMeta(); if (meta.hasDisplayName()) { return meta.getDisplayName(); } return stack.getType() .name() .replace("_", " ") .toLowerCase(); } }
public static boolean isChimaeraWing(ItemStack item) { if (!isMcMMOItem(item)) { return false; } ItemMeta itemMeta = item.getItemMeta(); return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); } }
public ItemMetaMock(ItemMeta meta) { if (meta.hasDisplayName()) displayName = meta.getDisplayName(); if (meta.hasLore()) lore = meta.getLore(); }
private boolean validateCoordOrMath(int start) { ItemStack op = program[start]; if (op == null) { return false; } TARDISHandlesBlock thb = TARDISHandlesBlock.BY_NAME.get(op.getItemMeta().getDisplayName()); return thb.getCategory().equals(TARDISHandlesCategory.NUMBER) || thb.equals(TARDISHandlesBlock.SUBTRACTION); }
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; }
private boolean validateOnOff(int start) { ItemStack op = program[start]; if (op == null) { return false; } TARDISHandlesBlock thb = TARDISHandlesBlock.BY_NAME.get(op.getItemMeta().getDisplayName()); return thb.equals(TARDISHandlesBlock.ASSIGNMENT) || thb.equals(TARDISHandlesBlock.EQUALS) || thb.equals(TARDISHandlesBlock.ON) || thb.equals(TARDISHandlesBlock.OFF); }
private boolean validatePower(int start) { ItemStack op = program[start]; if (op == null) { return false; } TARDISHandlesBlock thb = TARDISHandlesBlock.BY_NAME.get(op.getItemMeta().getDisplayName()); return thb.equals(TARDISHandlesBlock.ASSIGNMENT) || thb.equals(TARDISHandlesBlock.EQUALS) || thb.equals(TARDISHandlesBlock.ON) || thb.equals(TARDISHandlesBlock.OFF) || thb.equals(TARDISHandlesBlock.SHOW) || thb.equals(TARDISHandlesBlock.REDSTONE); }
private boolean validateDoor(int start) { ItemStack op = program[start]; if (op == null) { return false; } TARDISHandlesBlock thb = TARDISHandlesBlock.BY_NAME.get(op.getItemMeta().getDisplayName()); return thb.equals(TARDISHandlesBlock.ASSIGNMENT) || thb.equals(TARDISHandlesBlock.EQUALS) || thb.equals(TARDISHandlesBlock.OPEN) || thb.equals(TARDISHandlesBlock.CLOSE) || thb.equals(TARDISHandlesBlock.LOCK) || thb.equals(TARDISHandlesBlock.UNLOCK); }
public static String getCustomName(ItemStack item) { if (item == null || item.getType().equals(Material.AIR)) { return TLocale.asString("ITEM-UTILS.EMPTY-ITEM"); } int data = item.getType().getMaxDurability() == 0 ? item.getDurability() : 0; return item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : itemLib.get(item.getType() + ":" + data) == null ? item.getType().toString() : itemLib.get(item.getType() + ":" + data); }
private void twaOff(Player player) { ItemStack chest = player.getInventory().getChestplate(); if (chest != null && chest.hasItemMeta() && chest.getItemMeta().hasDisplayName()) { String metaName = chest.getItemMeta().getDisplayName(); if (twaChests.contains(metaName)) { plugin.getServer().dispatchCommand(plugin.getConsole(), "twad ANGEL off " + player.getUniqueId()); } } } }
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; }
@EventHandler public void onPickup(EntityPickupItemEvent e) { if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) { e.setCancelled(true); e.getItem().remove(); } }
@EventHandler public void onMinecartPickup(InventoryPickupItemEvent e) { if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) { e.setCancelled(true); e.getItem().remove(); } } }