I am trying to rename multiple items (of the same item stack type), but it only re-names them if there is one of that item. What would I change so it re-names all the items picked up, not just one? Code (Text): // Arrow if (e.getItem().getItemStack().equals(new ItemStack(Material.ARROW))) { ItemMeta arrowMeta = e.getItem().getItemStack().getItemMeta(); ArrayList<String> arrowlore = new ArrayList<String>(); arrowlore.add(ChatColor.GRAY + "- Class: Marksman"); arrowlore.add(ChatColor.GRAY + "- Level Unlocked: 0"); arrowlore.add(ChatColor.GRAY + "- The powerful arrows to lay enemies to their graves!"); arrowMeta.setLore(arrowlore); arrowMeta.setDisplayName(ChatColor.DARK_RED + "Arrow"); e.getItem().getItemStack().setItemMeta(arrowMeta); }
It's the way you're detecting what item it is. INSTEAD, use Code (Text): if (e.getItem().getItemStack().getType() == Material.ARROW) { Hope that helps! Also, I recommend checking if the item pickup is cancelled
So it doesnt give them the items even if the pickup is cancelled. EDIT: Actually, nevermind. It's been a long day, lol.
This code doesn't work. (Not sending the player "Hi", or renaming the item.) Code (Text): // Snowball if (e.getItem().getItemStack().getType().equals(new ItemStack(Material.SNOW_BALL))) { e.getPlayer().sendMessage("Hi"); ItemMeta snowMeta = e.getItem().getItemStack().getItemMeta(); ArrayList<String> snowlore = new ArrayList<String>(); snowlore.add(ChatColor.GRAY + "- Class: ANY"); snowlore.add(ChatColor.GRAY + "- Level Unlocked: 0"); snowlore.add(ChatColor.GRAY + "- Deals damage, and slows down enemies! (May give slowness)"); snowMeta.setLore(snowlore); snowMeta.setDisplayName(ChatColor.DARK_RED + "Throwing Knife"); e.getItem().getItemStack().setItemMeta(snowMeta); }
You're still checking it the wrong way. If you look back, I used ' == Material.<ITEM> ' . Don't create new itemstack, as that defaults to an itemstack of 1.