Hello. Ok so I'm making a KitPvP plugin so when people types /kits it opens up a GUI. In the Chest GUI there are items with names of kits. And one of those items are a potion for a toxic kit. How would I change the names of a potion. This is what I thought it was Code:java // Toxic stuff. Potion toxic = new Potion(PotionType.POISON); toxic.setSplash(true); ItemMeta toxicmeta = toxic.toItemStack(1).getItemMeta(); toxicmeta.setDisplayName(ChatColor.DARK_PURPLE + "Toxic"); toxic.toItemStack(1).setItemMeta(toxicmeta); // Adding Toxic. kits.addItem(toxic.toItemStack(1)); kits is the name of the Inventory
That will not work because your creating a new instance of the ItemStack every single time you get it. Try this: // Toxic stuff. Potion toxic = new Potion(PotionType.POISON); ItemStack item = toxic.toItemStack(1); toxic.setSplash(true); ItemMeta toxicmeta = item.getItemMeta(); toxicmeta.setDisplayName(ChatColor.DARK_PURPLE + "Toxic"); item.setItemMeta(toxicmeta); // Adding Toxic. kits.addItem(item);
messageofdeath Sorry watching movie. Ill try right now! messageofdeath Ok I tried and it worked! But it didn't turn it into a splash potion. It just made it a normal potion . But I fixed it! I had to add toxic.setSplash(true); before creating the turning it into a item stack so instead of line 4 it would be line 3 and turning into itemstack would be line 4. Thanks for helping me EDIT by Moderator: merged posts, please use the edit button instead of double posting.