Getting Or setting the item name?

Discussion in 'Plugin Development' started by joehot2000, Feb 15, 2013.

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

    joehot2000

    Hi, how do i get (or set, but mainly get) the name of an item?
    i dont mean the type, i mean like, if i renamed it with an anvil.

    I am planning to make a few plugins with this, but i mainly would like to know due to a infinite-gun-ammo bug in my plugin (rename sulphur).

    thanks in advance!

    edit: going to bed so dont expect a conversation!
     
  2. Offline

    mastermustard

  3. Offline

    gomeow

    get the name:
    Code:java
    1. String name = "";
    2. ItemStack is = /*Get item stack here*/;
    3. ItemMeta im = is.getItemMeta();
    4. if(I'm.hasDisplayName()) {
    5. name = im.getDisplayName();
    6. }

    Set the name:
    Code:java
    1. String name = "Sword of Gomeow";
    2. ItemStack is = new ItemStack(276, 1);
    3. ItemMeta im = is.getItemMeta();
    4. im.setDisplayName(name);
    5. is.setItemMeta(im);
     
Thread Status:
Not open for further replies.

Share This Page