Tutorial - Renaming Items

Discussion in 'Resources' started by JPG2000, Sep 1, 2013.

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


    For Steps 1-5, you are expected to have your onCommand method, as well as your onEnable and onDisable ready, with your Plugin.yml.

    1: Create the ItemStack. I am going to create a ItemStack names IceCream, and make it 1 piece of Sugar.
    1. ItemStack IceCream = new ItemStack(Material.SUGAR, 1);

    2: We are going to make the ItemMeta. I am going to call it IceCreamMeta.
    1. ItemMeta IceCreamMeta = IceCream.getItemMeta();

    3: This is where we do the actually renaming. You can use IceCreamMeta. to see a list, but I am just going to rename it. Also, this works with ChatColors.
    1. IceCreamMeta.setDisplayName("IceCream");

    4: We are now going to rap this up. We need to set IceCream to IceCreamMeta.
    1. IceCream.setItemMeta(IceCreamMeta);

    5: OPTIONAL: You can now give it to the player's inventory.
    1. Inventory pi = player.getInventory();
    2. pi.addItem(IceCream)

    The Final Product:
    1. if (alias.equalsIgnoreCase("GiveMeIceCream")) {
    2. Player player = (Player) sender;
    3. Inventory pi = player.getInventory();
    5. ItemStack IceCream = new ItemStack(Material.SUGAR, 1);
    6. ItemMeta IceCreamMeta = IceCream.getItemMeta();
    7. IceCreamMeta.setDisplayName("IceCream");
    8. IceCream.setItemMeta(IceCreamMeta);
    10. pi.addItem(IceCream);
    11. }

  2. JPG2000 Message a mod and ask them to move, but good, simple tutorial.
  3. Offline


    Chasechocolate is DBO staff, we need a forum mod to do this :p

    I really shouldn't tahg staff, but here goes nothing: Jade

    Otherwise, it's fine although many people can just look up "How to name items Bukkit" on google. On the other hand, some people are too stupid to do so...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 4, 2016
    chasechocolate likes this.
  4. Offline


    xTrollxDudex Banned for tagging staff. jkay.

    Moved to correct section.
    xTrollxDudex likes this.
  5. Offline


    Jade likes this.
  6. Offline


    I did. But then Jade came to the rescue 26 minutes later, which I have to say, is responding to a 911 call and finding the house completely obliterated by the fire :/. Well. Would've taken more time than tagging :p maybe Jade should get one of those page reloader thingys like chaseos has.
    KrazyRaven likes this.
Thread Status:
Not open for further replies.

Share This Page