I'm trying to create a kit plugin and I'm a noob so it shows up an error that I'm not able to fix. The code I'm showing you is EVERYTHING I've got, don't get mad if I'm missing a very basic step, since I'm new to this. Main: package com.epixel.eukits; import java.util.logging.Logger; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; import com.epixel.eukits.kits.pvp; public class Main extends JavaPlugin{ public void onEnable(){ PluginDescriptionFile pdfFile = getDescription(); Logger logger = getLogger(); getCommand("pvp").setExecutor(new pvp()); logger.info(pdfFile.getName() + " has been enabled on version" + pdfFile.getVersion() + "."); } public void onDisable(){ PluginDescriptionFile pdfFile = getDescription(); Logger logger = getLogger(); logger.info(pdfFile.getName() + " has been disabled on version" + pdfFile.getVersion() + "."); } } --------------------------------------------- The error pops up in the "pvp" class: package com.epixel.eukits.kits; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; public class pvp implements CommandExecutor{ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("pvp")) { if(!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "You need to be a player to execute this command!"); } return false; Player player = (Player) sender; PlayerInventory inv = player.getInventory(); inv.clear(); ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD, 1); ItemStack ironboots = new ItemStack(Material.IRON_BOOTS, 1); ItemStack ironchestplate = new ItemStack(Material.IRON_CHESTPLATE, 1); ItemStack ironleggings = new ItemStack(Material.IRON_LEGGINGS, 1); ItemStack ironhelmet = new ItemStack(Material.IRON_HELMET, 1); ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP, 35); diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 5); inv.addItem(diamondSword, soup); <----- ERROR MESSAGE HERE inv.setChestplate(ironchestplate); inv.setBoots(ironboots); inv.setLeggings(ironleggings); inv.setHelmet(ironhelmet); return false; } } --------------------------------------------------------------------------- The error message is: "The method addItem(ItemStack[]) in the type Inventory is not applicable for the arguments (ItemStack, ItemStack" and pops up in the line "inv.addItem(diamondSword, soup;"
Code: inv.addItem(diamondSword, soup); What exactly are you even trying to do there? The method only takes in 1 itemstack, not 2. do Code: inv.addItem(diamondSword); inv.addItem(soup);
Still same message with: package com.epixel.eukits.kits; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; public class pvp implements CommandExecutor{ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("pvp")) { if(!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "You need to be a player to execute this command!"); } return false; Player player = (Player) sender; PlayerInventory inv = player.getInventory(); inv.clear(); ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD, 1); ItemStack ironboots = new ItemStack(Material.IRON_BOOTS, 1); ItemStack ironchestplate = new ItemStack(Material.IRON_CHESTPLATE, 1); ItemStack ironleggings = new ItemStack(Material.IRON_LEGGINGS, 1); ItemStack ironhelmet = new ItemStack(Material.IRON_HELMET, 1); ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP, 35); diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 5); inv.addItem(diamondSword); inv.addItem(soup); inv.setChestplate(ironchestplate); inv.setBoots(ironboots); inv.setLeggings(ironleggings); inv.setHelmet(ironhelmet); return false; } }
@Epixel I actually think you should be getting multiple errors. Your code is unreachable. No matter what, the command will return before player is even created. You are missing an end bracket. Notice how there are four "{", but only three "}"? There needs to be a same amount for both types.
I've fixed that, but the same error message still appears, current code: package com.epixel.eukits.kits; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; public class pvp implements CommandExecutor{ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("pvp")) { if(!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "You need to be a player to execute this command!"); return false; } Player player = (Player) sender; PlayerInventory inv = player.getInventory(); inv.clear(); ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD, 1); ItemStack ironboots = new ItemStack(Material.IRON_BOOTS, 1); ItemStack ironchestplate = new ItemStack(Material.IRON_CHESTPLATE, 1); ItemStack ironleggings = new ItemStack(Material.IRON_LEGGINGS, 1); ItemStack ironhelmet = new ItemStack(Material.IRON_HELMET, 1); ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP, 35); diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 1); inv.addItem(diamondSword); inv.addItem(soup); inv.setChestplate(ironchestplate); inv.setBoots(ironboots); inv.setLeggings(ironleggings); inv.setHelmet(ironhelmet); return false; } } }
I am not going to give you the code, none of us will. Basically do this: Code: ItemStack[] asd = {ietm stack code here}; getPlayerInventory(add the item stack);