Renaming Items

Discussion in 'Plugin Development' started by Hectic_Will, Mar 4, 2013.

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

    Hectic_Will

    Hi,

    Does anyone know how I can rename items so in-game they are renamed to what I want to name them as? Here's my list of what I want to name:

    Sugar = Cocaine
    Gunpowder = Heroine
    Emerald = Crystalized Meth
    Emerald Ore = Crystalized Meth Ore
    Red & Brown Mushrooms = Shrooms
    Cactus Dye = Marijuana
    Cactus = Marijuana Plant
    Seeds = Pills

    Also, how can I rename certain items for certain ranks? For the cops I want

    Stick = Searcher
    Blaze Rod = Baton

    If anyone has an idea, please comment, thanks
     
  2. Offline

    NinjaWAffles

    Using ItemMeta should work... Let me know if you need an example code.
     
  3. Offline

    Hectic_Will

    Yeah can you give me an example? I tried that but I don't think it worked :/
     
  4. Offline

    lcpvp

    If you wanted to rename something like Seeds to pills, first create an item stack that defines the material being renamed
    Code:java
    1.  
    2. ItemStack pills = new ItemStack(Material.SEEDS);
    3.  

    Then, you want to get the item meta of that item stack
    Code:java
    1.  
    2. ItemMeta pillsMeta = pills.getItemMeta();
    3.  

    Then, rename the item by setting display name.
    Code:java
    1.  
    2. pillsMeta.setDisplayName("Pills");
    3.  
     
  5. Offline

    RealDope

    And finish by setting that back to the item meta of the ItemStack:

    Code:JAVA
    1.  
    2. pills.setItemMeta(pillsMeta);
    3.  
     
  6. Offline

    Hectic_Will

    Wait so it this all I put or do I have to put like a whole thing?
     
  7. Offline

    RealDope

    Everything IcPvp said and then what I said at the end
     
  8. Offline

    thejackstur

    how do you do this please help me
     
Thread Status:
Not open for further replies.

Share This Page