Setting ItemMeta Issues

Discussion in 'Plugin Development' started by Im_Zeus, Sep 30, 2013.

Thread Status:
Not open for further replies.
  1. I'm having issues setting the item meta. I did it myself, and when it didn't work I checked out PogoStick29 's youtube, and he is doing it the same way? Maybe I have to have some other plugin to see it? I don't know.

    List<String> lore = new ArrayList<String>();
                    ItemMeta meta = drop.getItemMeta();
    Trying to get some people in here.
  2. Offline


    Please do not tag us for help. Can we see the full code?
  3. Code:
     else if(rarity%100 == 0 && rarity == 10000) {
                    drop = new ItemStack(Material.DIAMOND_SWORD,1);
                    drop.addEnchantment(getEnchantByID(16), 5);
                    drop.addEnchantment(getEnchantByID(17), 5);
                    drop.addEnchantment(getEnchantByID(18), 5);
                    drop.addEnchantment(getEnchantByID(19), 2);
                    drop.addEnchantment(getEnchantByID(20), 2);
                    drop.addEnchantment(getEnchantByID(21), 3);
                    drop.addEnchantment(getEnchantByID(34), 3);
                    List<String> lore = new ArrayList<String>();
                    lore.add(ChatColor.BLACK + "////////////////");
                    lore.add(ChatColor.BLACK + "// Demonic /////");
                    ItemMeta meta = drop.getItemMeta();
                    if(e.getEntity().getKiller() instanceof Player) {
                        e.getEntity().getServer().broadcastMessage(((Player)e.getEntity().getKiller()).getName() + " has just gotten a Demonic weapon drop!");
    That's one piece of it. You don't want to be reading for too long. ;)
  4. Offline


    Im_Zeus First: Where from do you know me? :D
    And Second: Maybe it is e.getDrops().set(drop) because otherwise you will have the old and the new drop. (I dont know if the set Method exists because I am currently not on my PC to test it)

    Im_Zeus Which Event do you use? PlayerDeathEvent?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 4, 2016
  5. Yes, I'm using PlayerDeathEvent.
    etaxi341 I saw you helping another person and it was pretty solid advice, so I tagged you. x_x
    I'm just adding it on to the original drop. I'm adding Lore to armor and dropping it, if that helps any.
  6. Offline


    Im_Zeus Will this Message be shown?:
    ((Player)e.getEntity().getKiller()).getName() + " has just gotten a Demonic weapon drop!"
  7. etaxi341 It has shown up, just the weapon doesn't have the lore.:(
  8. Offline


    Im_Zeus So you can be Sure that this Method is called?
  9. Yeah, I'm sure the method is working. It adds the enchantments, but it doesn't add the lore. It also appends the new drop to the old drop.
  10. Offline


    Im_Zeus So it does also add the Enchantments to this Drop and It drops it but it doesnt have the lore? Only the lore is missing? But then there is an other question if only the lore doesnt work. Why isnt the Broadcast beeing called...
  11. The broadcast is being called. Just the lore doesn't work.
  12. Offline


    Im_Zeus Ohh okay... Could you add a Debug Message after this:
    1. meta.setLore(lore);

    The Debug Message should be this:
    1. Bukkit.broadcastMessage(lore.toString())

    If this will show the Lore in the Chat tell it to me.
  13. Offline

    SkillSam can try to use this as an example, as it works. I'm not really sure where the problem lies...

    1. @EventHandler
    2. public void onPlayerDeath (PlayerDeathEvent e) {
    3. if (!(e.getEntity() instanceof Player)) return;
    4. e.getDrops().clear();
    6. //Item 1
    7. ItemStack i = new ItemStack(Material.GOLD_INGOT);
    8. ItemMeta im = i.getItemMeta();
    9. im.setDisplayName(ChatColor.RED + "Credits");
    10. im.setLore(Arrays.asList(ChatColor.GREEN + "Money for killing!"));
    11. im.addEnchant(Enchantment.DAMAGE_ALL, 5, true);
    12. im.addEnchant(Enchantment.FIRE_ASPECT, 2, true);
    13. im.addEnchant(Enchantment.KNOCKBACK, 2, true);
    14. i.setItemMeta(im);
    15. e.getDrops().add(i);
    17. //Item 2
    18. ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
    19. ItemMeta meta = item.getItemMeta();
    20. meta.setDisplayName(ChatColor.DARK_GRAY + "Demonic Sword");
    21. meta.setLore(Arrays.asList(
    22. ChatColor.GRAY + "/////////////",
    23. ChatColor.GRAY + "// DEMONIC //",
    24. ChatColor.GRAY + "/////////////"
    25. ));
    26. meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
    27. meta.addEnchant(Enchantment.DAMAGE_ARTHROPODS, 10, true);
    28. meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 10, true);
    29. meta.addEnchant(Enchantment.FIRE_ASPECT, 10, true);
    30. meta.addEnchant(Enchantment.KNOCKBACK, 10, true);
    31. meta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 10, true);
    32. meta.addEnchant(Enchantment.DURABILITY, 10, true);
    33. item.setItemMeta(meta);
    34. e.getDrops().add(item);
    35. }
  14. Offline


    I'm sorry to hear my code didn't work.
Thread Status:
Not open for further replies.

Share This Page