Solved Changing Item Description?

Discussion in 'Plugin Development' started by xXSilentYoshiXx, Jan 3, 2013.

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

    xXSilentYoshiXx

    Whenever I play on Ghost Craft, they always change the name of the swords as well as the description of the sword. How do I do this too? Like, ItemChangeEvent, or on a command? I'd like it when a command is inserted. :)
     
  2. Offline

    gomeow

    samosaara likes this.
  3. Offline

    xXSilentYoshiXx

    Wait, so how do I do this? I keep trying, but it's not working. : P
     
  4. Offline

    Jogy34

    Are you even coding a plugin? If you are it would help if you posted some code so we can actually see what you are doing wrong
     
  5. Offline

    gomeow

    To change the name of what the player is holding:
    Code:java
    1. ItemStack is = player.getInventory().getItemInHand();
    2. ItemMeta im = is.getItemMeta();
    3.  
    4. //Set the name to MyName
    5. im.setDisplayName("MyName");
    6.  
    7. //Set the Lore
    8. List<String> lore = Arrays.asList("First line", "Second Line", "Third Line");
    9. im.setLore(lore);
    10.  
    11. //Add an enchantment
    12. im.addEnchant(Enchantment.PROTECTION_FALL, 3, false);
    13.  
    14. //Set the meta to the item
    15. is.setItemMeta(im);
     
  6. Offline

    xXSilentYoshiXx

    That doesn't work, it only changes the name to whatever I want it to be.
     
  7. Offline

    Rprrr

    The lore, the lore, don't you read what people say? :l
     
  8. Offline

    xXSilentYoshiXx

    I do read it, and I did put in the Lore. It didn't change it.
     
  9. Offline

    Rprrr

    So did you add the itemmeta to the item after you changed it?
    It might help if you show everyone the code, by the way.
     
  10. Offline

    Jogy34

    The code was already shown by gomeow on how to change the name of an item, add lore, and add enchantments
     
  11. Offline

    CubixCoders

    Try this then
    Code:
     
    ItemStack is = new ItemStack(Material.STICK, 1);
    ItemMeta im = is.getItemMeta();
    im.setDisplayName("TheName");
    ArrayList<String> lore = new ArrayList<String>();
    lore.add("Add Descriptions with this just add another lore.add()");
    im.setLore(lore);
    is.setItemMeta(im);
    
     
  12. Offline

    xXSilentYoshiXx

    I found out that I actually did it wrong. gomeow did it correctly the first time. xD
     
Thread Status:
Not open for further replies.

Share This Page