Java Code Examples for org.bukkit.inventory.ItemStack#setData()
The following examples show how to use
org.bukkit.inventory.ItemStack#setData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FuelManager.java From NyaaUtils with MIT License | 6 votes |
public void updateItem(ItemStack item, int fuelID, int durability) { FuelItem fuel = plugin.cfg.fuelConfig.fuel.get(fuelID); if (fuel == null) { return; } String hex = toHexString(fuelID) + toHexString(durability) + toHexString(new Random().nextInt(65535)); String str = ""; for (int i = 0; i < hex.length(); i++) { str += ChatColor.COLOR_CHAR + hex.substring(i, i + 1); } str += ChatColor.COLOR_CHAR + "r"; ItemMeta meta = fuel.getItem().getItemMeta(); List<String> lore; if (meta.hasLore()) { lore = meta.getLore(); lore.set(0, lore_prefix + str + lore.get(0)); lore.add(lore_prefix + I18n.format("user.elytra_enhance.fuel_durability", durability, fuel.getMaxDurability())); } else { lore = new ArrayList<>(); lore.add(lore_prefix + str + I18n.format("user.elytra_enhance.fuel_durability", durability, fuel.getMaxDurability())); } item.setType(fuel.getItem().getType()); item.setData(fuel.getItem().getData()); meta.setLore(lore); item.setItemMeta(meta); }
Example 2
Source File: ItemStackBuilder.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Creates a new itemStack from this * * @return itemStack */ public ItemStack build() { final ItemStack itemStack = new ItemStack(this.getType()); itemStack.setAmount(this.getAmount()); itemStack.setData(this.getData()); itemStack.setDurability(this.getDurability()); itemStack.setItemMeta(this.getItemMeta()); return itemStack; }
Example 3
Source File: ItemFrameStorage.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void setItem(ItemStack stack) { ItemFrame frame = getItemFrame(); if (frame != null) { ItemStack newStack = new ItemStack(stack.getType(), 1, stack.getDurability()); newStack.setData(stack.getData()); newStack.setItemMeta(stack.getItemMeta()); frame.setItem(newStack); } else { CivLog.warning("Frame:"+this.frameID+" was null when trying to set to "+stack.getType().name()); } }