/** * Get a copy of this ItemStack's {@link ItemMeta}. * * @return a copy of the current ItemStack's ItemData */ public ItemMeta getItemMeta() { return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone(); }
private boolean setItemMeta0(ItemMeta itemMeta, Material material) { if (itemMeta == null) { this.meta = null; return true; } if (!Bukkit.getItemFactory().isApplicable(itemMeta, material)) { return false; } this.meta = Bukkit.getItemFactory().asMetaFor(itemMeta, material); if (this.meta == itemMeta) { this.meta = itemMeta.clone(); } return true; } }
/** * Checks to see if any meta data has been defined. * * @return Returns true if some meta data has been set for this item */ public boolean hasItemMeta() { return !Bukkit.getItemFactory().equals(meta, null); }
/** * Sets the type id of this item * <p> * Note that in doing so you will reset the MaterialData for this stack * * @param type New type id to set the items in this stack to * @deprecated Magic value */ @Deprecated public void setTypeId(int type) { this.type = type; if (this.meta != null) { this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0()); } createData((byte) 0); }
@Override public boolean isApplicable(MCItemMeta meta, MCMaterial material) { ItemMeta bmeta = ((BukkitMCItemMeta) meta).asItemMeta(); Material bmat = (Material) material.getHandle(); return f.isApplicable(bmeta, bmat); }
@Override public MCColor getDefaultLeatherColor() { return BukkitMCColor.GetMCColor(f.getDefaultLeatherColor()); }
/** * Sets the type id of this item * <p> * Note that in doing so you will reset the MaterialData for this stack * * @param type New type id to set the items in this stack to * @deprecated Magic value */ @Deprecated public void setTypeId(int type) { this.type = type; if (this.meta != null) { this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0()); } createData((byte) 0); }
@Override public boolean isApplicable(MCItemMeta meta, MCItemStack stack) { ItemMeta bmeta = ((BukkitMCItemMeta) meta).asItemMeta(); ItemStack bstack = ((BukkitMCItemStack) stack).asItemStack(); return f.isApplicable(bmeta, bstack); }
if (!armorMeta.getColor().equals(Bukkit.getServer().getItemFactory().getDefaultLeatherColor())) { DyeColor c = DyeColor.getByColor(armorMeta.getColor()); color = " color:" + (c == null ? '#' + Integer.toHexString(armorMeta.getColor().asRGB()) : c.toString());
/** * Adds the specified {@link Enchantment} to this item stack. * <p> * If this item stack already contained the given enchantment (at any * level), it will be replaced. * <p> * This method is unsafe and will ignore level restrictions or item type. * Use at your own discretion. * * @param ench Enchantment to add * @param level Level of the enchantment */ public void addUnsafeEnchantment(Enchantment ench, int level) { (meta == null ? meta = Bukkit.getItemFactory().getItemMeta(getType0()) : meta).addEnchant(ench, level, true); }
public PlayerEditBookEvent(Player who, int slot, BookMeta previousBookMeta, BookMeta newBookMeta, boolean isSigning) { super(who); Validate.isTrue(slot >= 0 && slot <=8, "Slot must be in range 0-8 inclusive"); Validate.notNull(previousBookMeta, "Previous book meta must not be null"); Validate.notNull(newBookMeta, "New book meta must not be null"); Bukkit.getItemFactory().equals(previousBookMeta, newBookMeta); this.previousBookMeta = previousBookMeta; this.newBookMeta = newBookMeta; this.slot = slot; this.isSigning = isSigning; this.cancel = false; }
private boolean setItemMeta0(ItemMeta itemMeta, Material material) { if (itemMeta == null) { this.meta = null; return true; } if (!Bukkit.getItemFactory().isApplicable(itemMeta, material)) { return false; } this.meta = Bukkit.getItemFactory().asMetaFor(itemMeta, material); if (this.meta == itemMeta) { this.meta = itemMeta.clone(); } return true; } }
@Override public MCItemMeta asMetaFor(MCItemMeta meta, MCItemStack stack) { ItemMeta bmeta = ((BukkitMCItemMeta) meta).asItemMeta(); ItemStack bstack = ((BukkitMCItemStack) stack).asItemStack(); return BukkitConvertor.BukkitGetCorrectMeta(f.asMetaFor(bmeta, bstack)); }
public ImmutableItemStack(int type) { super(type); itemMeta = ServerProvider.getServer().getItemFactory().getItemMeta(getType()).clone(); }
/** * Sets the book meta that will actually be added to the book. * * @param newBookMeta new book meta * @throws IllegalArgumentException if the new book meta is null */ public void setNewBookMeta(BookMeta newBookMeta) throws IllegalArgumentException { Validate.notNull(newBookMeta, "New book meta must not be null"); Bukkit.getItemFactory().equals(newBookMeta, null); this.newBookMeta = newBookMeta.clone(); }
@Override public MCItemMeta asMetaFor(MCItemMeta meta, MCMaterial material) { ItemMeta bmeta = ((BukkitMCItemMeta) meta).asItemMeta(); Material bmat = (Material) material.getHandle(); return BukkitConvertor.BukkitGetCorrectMeta(f.asMetaFor(bmeta, bmat)); }
@Override public MCItemMeta getItemMeta(MCMaterial material) { if(material == null) { return null; } ItemMeta im = f.getItemMeta((Material) material.getHandle()); return BukkitConvertor.BukkitGetCorrectMeta(im); }
@Utility public Map<String, Object> serialize() { Map<String, Object> result = new LinkedHashMap<String, Object>(); result.put("type", getType().name()); if (getDurability() != 0) { result.put("damage", getDurability()); } if (getAmount() != 1) { result.put("amount", getAmount()); } ItemMeta meta = getItemMeta(); if (!Bukkit.getItemFactory().equals(meta, null)) { result.put("meta", meta); } return result; }
/** * Get a copy of this ItemStack's {@link ItemMeta}. * * @return a copy of the current ItemStack's ItemData */ public ItemMeta getItemMeta() { return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone(); }
/** * This method is the same as equals, but does not consider stack size * (amount). * * @param stack the item stack to compare to * @return true if the two stacks are equal, ignoring the amount */ @Utility public boolean isSimilar(ItemStack stack) { if (stack == null) { return false; } if (stack == this) { return true; } return getTypeId() == stack.getTypeId() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true); }