Plugin Help Error when giving item to a player

Discussion in 'Plugin Help/Development/Requests' started by haussik, Dec 3, 2014.

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

    haussik

    Code:
    Code:java
    1. ItemStack crescentAxe = new ItemStack(Material.DIAMOND_SWORD);
    2. ItemMeta crescentAxeMeta= itemStack.getItemMeta();
    3. crescentAxeMeta.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + ChatColor.UNDERLINE + "Sword of Dancer");
    4. crescentAxe.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 5);
    5. crescentAxe.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
    6. crescentAxe.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 1);
    7. crescentAxe.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 1);
    8. List<String> lore = crescentAxeMeta.getLore();
    9. lore.add(ChatColor.GRAY + "Chance of looting rare item: +0.5%");
    10. lore.add(ChatColor.GRAY + "Chance of looting more blocks: +0.5%");
    11. lore.add(ChatColor.GRAY + "Critical dammage rate increase +15%");
    12. lore.add(ChatColor.GRAY + "Increase damage at level 30 ( +10% )");
    13. lore.add(ChatColor.GRAY + "Chance of life steal +10%");
    14. lore.add(ChatColor.GRAY + "Damage deal +7.5%");
    15. crescentAxeMeta.setLore(lore);
    16. crescentAxe.setItemMeta(crescentAxeMeta);
    17. playerInventory.addItem(crescentAxe);


    Error:
    Code:
    Caused by: java.lang.NullPointerException
        at com.chargon.tmrpg.listener.LootChance.rightClickLoot(LootChance.java:162) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_65]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        ... 15 more
    
    Line 162 is from 'lore.add(ChatColor.GRAY + "Chance of looting rare item: +0.5%");'

    how can i fix it ? ^^
     
  2. Offline

    Tecno_Wizard

    CresentAxeMeta.getLore() is returning null.
     
Thread Status:
Not open for further replies.

Share This Page