コード例 #1
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
  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;
  }
コード例 #2
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
  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);
  }
コード例 #3
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
  /**
   * 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);
  }
コード例 #4
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
  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);
  }
コード例 #5
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
 /**
  * Retrieve the attribute at a given index.
  *
  * @param index - the index to look up.
  * @return The attribute at that index.
  */
 public Attribute get(int index) {
   return new Attribute((NBTTagCompound) attributes.get(index));
 }
コード例 #6
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
 /**
  * Add a new attribute to the list.
  *
  * @param attribute - the new attribute.
  */
 public void add(Attribute attribute) {
   attributes.add(attribute.data);
 }
コード例 #7
0
ファイル: AttributeUtil.java プロジェクト: YourCoal/Project
 /**
  * Retrieve the number of attributes.
  *
  * @return Number of attributes.
  */
 public int size() {
   return attributes.size();
 }