[SOLVED ]Item Lores! | Trouble With Item Lores!

Discussion in 'Spigot Plugin Development' started by UnthinkableR, May 15, 2015.

  1. Hello i am having trouble setting item lores!!! heres my code: which is not working
    Code (Text):
    ItemStack Knight = new ItemStack(Material.IRON_CHESTPLATE);
        ItemMeta KnightMeta = Knight.getItemMeta();
       
        KnightMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&7Kit - &8&lFighter"));
        Knight.setItemMeta(KnightMeta);
        KnightLore.add(ChatColor.RED + "OMG SO COOL!");
        KnightMeta.setLore(KnightLore);
     
    #1 UnthinkableR, May 15, 2015
    Last edited: May 15, 2015
  2. @UnthinkableR
    umm lol, you actually need to tell me which line it is so I can find your error.
     
  3. Either your getMessagesConfig() is not returning anything or .getString("DeathMSG2") is not returning anything. Check if you saved/created those properly.
     
  4. Don't know if thats your error but check if killer instanceof Player
     
  5. I see you've created a FileConfiguration config = getConfig(); Maybe try creating the Messages config and Player config also.
     
  6. Does the killer's item in hand have a display name?
     
  7. Inkzzz

    Resource Staff

    Check if the killer is a player using this:
    Code (Text):
    if(e.getEntity().getKiller() instanceof Player) {
    // code
    }
     
  8. If you haven't set this as the display name in the item meta of the itemstack, then this is the default item name and thus not a display name. Which makes the getDisplayName method return null
     
  9. I really like the title...
    BLAH BLAH BLAH
    So, about your error,
    What he said.
     
  10. @UnthinkableR
    • Less static abuse
    • Use primitive types rather than their boxed types (int rather than Integer
    • Why the whole if statements thing while you can just get "DeathMSG" + random int.
    • Variables should be in lowerCamelCase.
     
    • Like Like x 1
    • Funny Funny x 1