public String[] getLore() { if (nmsStack == null) { return null; } if (nmsStack.getTag() == null) { return null; } NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { return null; } NBTTagList loreList = displayCompound.getList("Lore", NBTStaticHelper.TAG_STRING); if (loreList == null) { return null; } if (loreList.size() < 1) { return null; } String[] lore = new String[loreList.size()]; for (int i = 0; i < loreList.size(); i++) { lore[i] = loreList.getString(i).replace("\"", ""); ; } return lore; }
public AttributeUtil(ItemStack stack) { // Create a CraftItemStack (under the hood) this.nmsStack = CraftItemStack.asNMSCopy(stack); if (this.nmsStack == null) { return; } // if (nmsStack == null) { // CivLog.error("Couldn't make NMS copyyy of:"+stack); // this.nmsStack = CraftItemStack.asNMSCopy(ItemManager.createItemStack(CivData.WOOL, 1)); // if (this.nmsStack == null) { // return; // } // } // Load NBT if (nmsStack.getTag() == null) { parent = new NBTTagCompound(); nmsStack.setTag(parent); } else { parent = nmsStack.getTag(); } // Load attribute list if (parent.hasKey("AttributeModifiers")) { attributes = parent.getList("AttributeModifiers", NBTStaticHelper.TAG_COMPOUND); } else { /* No attributes on this item detected. */ attributes = new NBTTagList(); parent.set("AttributeModifiers", attributes); } }
public void setColor(Long long1) { NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { displayCompound = new NBTTagCompound(); } displayCompound.set("color", new NBTTagInt(long1.intValue())); nmsStack.getTag().set("display", displayCompound); }
public boolean hasLegacyEnhancements() { if (nmsStack == null) { return false; } if (nmsStack.getTag() == null) { return false; } return nmsStack.getTag().hasKey("civ_enhancements"); }
public void removeCivCraftCompound() { if (nmsStack == null) { return; } NBTTagCompound civcraftCompound = nmsStack.getTag().getCompound("civcraft"); if (civcraftCompound == null) { return; } nmsStack.getTag().remove("civcraft"); }
public void setSkullOwner(String string) { if (nmsStack == null) { return; } NBTTagCompound skullCompound = nmsStack.getTag().getCompound("SkullOwner"); if (skullCompound == null) { skullCompound = new NBTTagCompound(); } skullCompound.set("Name", new NBTTagString(string)); nmsStack.getTag().set("SkullOwner", skullCompound); }
public void setHideFlag(int flags) { if (nmsStack == null) { return; } nmsStack.getTag().setInt("HideFlags", flags); }
public boolean hasColor() { if (nmsStack == null) { return false; } if (nmsStack.getTag() == null) { return false; } NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { return false; } return displayCompound.hasKey("color"); }
public LinkedList<LoreEnhancement> getEnhancements() { LinkedList<LoreEnhancement> returnList = new LinkedList<LoreEnhancement>(); if (!hasEnhancements()) { return returnList; } NBTTagCompound compound = nmsStack.getTag().getCompound("item_enhancements"); for (Object keyObj : compound.c()) { if (!(keyObj instanceof String)) { continue; } String key = (String) keyObj; Object obj = compound.get(key); if (obj instanceof NBTTagCompound) { NBTTagCompound enhCompound = (NBTTagCompound) obj; String name = enhCompound.getString("name").replace("\"", ""); if (name != null) { LoreEnhancement enh = LoreEnhancement.enhancements.get(name); if (enh != null) { returnList.add(enh); } } } } return returnList; }
public int getColor() { NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { return 0; } return displayCompound.getInt("color"); }
public boolean hasEnhancement(String enhName) { NBTTagCompound compound = nmsStack.getTag().getCompound("item_enhancements"); if (compound == null) { return false; } return compound.hasKey(enhName); }
public void setLore(String[] strings) { // this.lore.add(str); NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { displayCompound = new NBTTagCompound(); } NBTTagList loreList = new NBTTagList(); for (String str : strings) { loreList.add(new NBTTagString(str)); } displayCompound.set("Lore", loreList); nmsStack.getTag().set("display", displayCompound); }
public void setName(String name) { if (nmsStack == null) { return; } if (nmsStack.getTag() == null) { nmsStack.setTag(new NBTTagCompound()); } NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { displayCompound = new NBTTagCompound(); } displayCompound.set("Name", new NBTTagString(ChatColor.RESET + name)); nmsStack.getTag().set("display", displayCompound); }
public void setCivCraftProperty(String key, String value) { if (nmsStack == null) { return; } if (nmsStack.getTag() == null) { nmsStack.setTag(new NBTTagCompound()); } NBTTagCompound civcraftCompound = nmsStack.getTag().getCompound("civcraft"); if (civcraftCompound == null) { civcraftCompound = new NBTTagCompound(); } civcraftCompound.set(key, new NBTTagString(value)); nmsStack.getTag().set("civcraft", civcraftCompound); }
public String getName() { NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { displayCompound = new NBTTagCompound(); } String name = displayCompound.getString("Name").toString(); name = name.replace("\"", ""); return name; }
public boolean isShiny() { if (nmsStack == null) { return false; } if (nmsStack.getTag() == null) { return false; } NBTTagCompound enchCompound = nmsStack.getTag().getCompound("ench"); if (enchCompound == null) { return false; } if (enchCompound.hasKey("id") && enchCompound.getShort("id") == (short) 62) { return true; } return false; }
public void setShiny() { if (nmsStack == null) { return; } if (nmsStack.getTag() == null) { nmsStack.setTag(new NBTTagCompound()); } NBTTagCompound enchCompound = nmsStack.getTag().getCompound("ench"); if (enchCompound == null) { enchCompound = new NBTTagCompound(); } enchCompound.setShort("id", (short) 62); // Enchant id 62 = Lure enchCompound.setShort("lvl", (short) 1); nmsStack.getTag().set("ench", enchCompound); this.setHideFlag(1); }
/** * Retrieve the modified item stack. * * @return The modified item stack. */ public ItemStack getStack() { if (nmsStack == null) { return ItemManager.createItemStack(CivData.WOOL, 0); } if (nmsStack.getTag() != null) { if (attributes.size() == 0) { parent.remove("AttributeModifiers"); } } return CraftItemStack.asCraftMirror(nmsStack); }
public String getEnhancementData(String enhName, String key) { if (!hasEnhancement(enhName)) { return null; } NBTTagCompound compound = nmsStack.getTag().getCompound("item_enhancements"); NBTTagCompound enhCompound = compound.getCompound(enhName); if (!enhCompound.hasKey(key)) { return null; } return enhCompound.getString(key); }
public void addEnhancement(String enhancementName, String key, String value) { if (enhancementName.equalsIgnoreCase("name")) { throw new IllegalArgumentException(); } NBTTagCompound compound = nmsStack.getTag().getCompound("item_enhancements"); if (compound == null) { compound = new NBTTagCompound(); } NBTTagCompound enhCompound = compound.getCompound(enhancementName); if (enhCompound == null) { enhCompound = new NBTTagCompound(); } if (key != null) { _setEnhancementData(enhCompound, key, value); } enhCompound.set("name", new NBTTagString(enhancementName)); compound.set(enhancementName, enhCompound); nmsStack.getTag().set("item_enhancements", compound); }
public void addLore(String str) { if (nmsStack == null) { return; } if (nmsStack.getTag() == null) { nmsStack.setTag(new NBTTagCompound()); } // this.lore.add(str); NBTTagCompound displayCompound = nmsStack.getTag().getCompound("display"); if (displayCompound == null) { displayCompound = new NBTTagCompound(); } NBTTagList loreList = displayCompound.getList("Lore", NBTStaticHelper.TAG_STRING); if (loreList == null) { loreList = new NBTTagList(); } loreList.add(new NBTTagString(str)); displayCompound.set("Lore", loreList); nmsStack.getTag().set("display", displayCompound); }
public void removeCivCraftProperty(String string) { if (nmsStack == null) { return; } NBTTagCompound civcraftCompound = nmsStack.getTag().getCompound("civcraft"); if (civcraftCompound == null) { return; } civcraftCompound.remove(string); if (civcraftCompound.isEmpty()) { removeCivCraftCompound(); } }
public String getCivCraftProperty(String key) { if (nmsStack == null) { return null; } NBTTagCompound civcraftCompound = nmsStack.getTag().getCompound("civcraft"); if (civcraftCompound == null) { return null; } NBTTagString strTag = (NBTTagString) civcraftCompound.get(key); if (strTag == null) { return null; } return strTag.toString().replace("\"", ""); }