Plugin Help How to set a tag for item?

Discussion in 'Plugin Help/Development/Requests' started by viet1, Jun 11, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    viet1

    I create a plugin gun but it in a mode survival so people can create a gun with material and anvil to change name because my gun don't have tag and i target it by name. I hope everyone help me how to set tag for item in bukkit 1.10.2. Thank you so much!!!
     
  2. Offline

    CSharpDev

    Code:
          
    ItemMeta meta = heldItem.getItemMeta();
            if (meta.hasMetadata("test_fly")) {
                sendError(player, "That item is already a super awesome flying item");
                return;
            }
            Map<String, Object> flyData = new HashMap<String, Object>();
            Date now = new Date();
            flyData.put("created", now.toString());
            flyData.put("uses", 0);
            flyData.put("speed", 2.0);
            meta.setMetadata("test_fly", new PersistentMetadataValue(this, flyData));
            heldItem.setItemMeta(meta);
    You can set an ItemMeta being the name or any other property in Meta Data.
     
Thread Status:
Not open for further replies.

Share This Page