Solved Lore

Discussion in 'Plugin Development' started by Cooper PluginDev, Mar 20, 2014.

Thread Status:
Not open for further replies.
  1. How come this isn't working?
    I want the item to have this lore but it won't back work?
    Code:
    Code:java
    1. else if ((args[0].equalsIgnoreCase("spider")) && (sender.hasPermission("morph.spider"))) {
    2. ItemStack spidereye = new ItemStack(Material.SPIDER_EYE);
    3. if (!((MetadataValue)p.getMetadata("morphtype").get(0)).asString().equals("spider")) {
    4. p.playSound(p.getLocation(), Sound.SPIDER_WALK, 5.0F, 10.0F);
    5. setMetadata(p, "morphtype", "spider", this);
    6. Morphs.morph(p, DisguiseType.Spider);
    7. p.getInventory().addItem(spidereye);
    8. ItemMeta im = spidereye.getItemMeta();
    9. List lore = Arrays.asList(new String[] { ChatColor.GRAY + "Damage: " + ChatColor.YELLOW + "1", ChatColor.GRAY + "Ability: " + ChatColor.YELLOW + "Spider Leap", ChatColor.GRAY + "Knockback: " + ChatColor.YELLOW + "0%"});
    10. im.setLore(lore);
    11. spidereye.setItemMeta(im);
    12.  
    13. sender.sendMessage(ChatColor.BLUE + "Morphs> " + ChatColor.GRAY + "You have morphed as a " + ChatColor.RED + "Spider" + ChatColor.GRAY + ".");
    14. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 999990, 0));
    15. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 99999, 0));
    16. p.setFoodLevel(6);
    17. } else {
    18. sender.sendMessage(ChatColor.BLUE + "Morphs> " + ChatColor.GRAY + "You are already morphed as a morphed, type /morph cancel to unmorph.");
    19. }
    20. }
     
  2. Offline

    L33m4n123

    You add it to the inventory before it has the meta assigned i guess
     
  3. L33m4n123
    I have added it?
    On this line:
    Code:java
    1. p.getInventory().addItem(spidereye);
    2.  
     
  4. Offline

    L33m4n123

    Yes. But after you do that, you set the lore. First set the lore, add the itemMeta to the Item and THEN add it to the inventory
     
  5. L33m4n123
    Awhh I understand now, thank you :D
    How do I change the title of the forum post?
     
  6. Offline

    L33m4n123

    somewhere on the top right you got a Thread T0ol or something like that
     
Thread Status:
Not open for further replies.

Share This Page