Hello, I'm making a plugin that when you execute a command your inventory is set with armour and your given some potions and weapons, but I don't exactly know how to give a player potions (not the effects) Here is my code so far: Code:java if(args.length == 1) { if(args[0].equalsIgnoreCase("medic")) { if(p.hasPermission("kitpvp.kit.medic")) { p.getInventory().clear(); p.getInventory().setArmorContents(null); p.getInventory().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); p.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); p.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); p.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); Potion pt = new Potion(PotionType.INSTANT_HEAL, 2); ItemStack item = pt.toItemStack(1); p.updateInventory(); } else { p.sendMessage(prefix + ChatColor.RED + "Sorry, you don't have permission to use this kit!"); } } } return false; }}
Minecrell Code:java Potion pt = new Potion(PotionType.INSTANT_HEAL, 1); Potion pt1 = new Potion(PotionType.INSTANT_HEAL, 2); ItemStack item = pt.toItemStack(2); ItemStack item1 = pt1.toItemStack(1); p.getInventory().addItem(item); p.getInventory().addItem(item1); p.updateInventory();
Crafted Evil And that's not working? :O It should work actually... Do you get the armor added to your inventory?
Blingdaddy1 Well p.updateInventory() is used to update inventory because some of the time the items won't display in inventory, so how does that exactly work? Wouldn't that be a negative on it?
No, it's integrated into the inventory functions now, there's no need to use it. Just remove the line.
Meeeeeeeh. I wouldn't say 'integrated.' It's a good habit to use it, even though it may not necessarily perform its functions. Inventories can be really glitchy. There's literally no reason why it shouldn't add the potion to your inventory (unless the Potion.toItemStack() method doesn't work).