Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-586

HideFlags API Not Working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None

      Hi

      There seems to be an issue with the new HideFlags API. From the Java Docs the following should set the item unbreaking and set to hide the unbreaking tag in the lore.

      Test Snippet
              ItemStack stack = new ItemStack(Material.DIAMOND_SWORD, 1);
              ItemMeta meta = stack.getItemMeta();
              meta.spigot().setUnbreakable(true);
              meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
              stack.setItemMeta(meta);
      
      

      Now it does apply the unbreakable but does not hide the unbreakable tag in the client.

      I did a small test and created the same Item using following give command

      /give Relicum minecraft:diamond_sword 1 0

      {HideFlags:4,Unbreakable:1}

      I then used NBTexplorer to see that was actually being written to my players dat file. The image shows to entries from my inventory.

      Slot 0 contains the item created by the Give command.
      Slot 2 contains the items from the code snippet above.

      I presume you meant for the actual tag to be HideFlags not ItemFlags. Also minecraft saved the Unbreakable tag as an int where you have it saved as a byte, that might be intentional thought i'd point it out. If i manually change it in NBTexplorer to match what is in slot 0 the tag now gets hidden as expected.

      Serialization doesn't work but I presume that's a knock on effect of the possible miss naming of the tag. Here is what it gets serialized to.

      ==: org.bukkit.inventory.ItemStack
      type: DIAMOND_SWORD
      meta:
      ==: ItemMeta
      meta-type: UNSPECIFIC
      Unbreakable: true
      hideFlags: !!set
      HIDE_UNBREAKABLE: null

      Hope this gives you enough to go on. Sorry for the spelling remember I'm dyslexic.

      Regards
      Relicum

            Thinkofdeath Thinkofname
            Relicum Chris Lutte
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: