Hi, I need help for my plugin. I've created this: Code:java package 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.entity.Player;import org.bukkit.inventory.ItemStack;import org.bukkit.inventory.PlayerInventory; import Main.Main; public class Kits implements CommandExecutor { Main plugin; public Kits (Main plugin){ this.plugin = plugin; } @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if(cmd.getName().equalsIgnoreCase("mkit")){ Player p = (Player) sender; if(args.length == 0){ p.sendMessage(ChatColor.GRAY + "Usa il comando " + ChatColor.GREEN + "/mkit <nomekit>"); }else{ if(args[0].equalsIgnoreCase("Soldato")){ ItemStack dsword = (new ItemStack(Material.DIAMOND_SWORD)); ItemStack ihelmet = (new ItemStack(Material.IRON_HELMET)); ItemStack ichest = (new ItemStack(Material.IRON_CHESTPLATE)); ItemStack ilegg = (new ItemStack(Material.IRON_LEGGINGS)); ItemStack iboots = (new ItemStack(Material.IRON_BOOTS)); PlayerInventory pi1 = p.getInventory(); pi1.setHelmet(ihelmet); pi1.setChestplate(ichest); pi1.setLeggings(ilegg); pi1.setBoots(iboots); pi1.addItem(dsword); p.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "Kits" + ChatColor.GRAY + "]" + ChatColor.WHITE + "Hai selezionato il kit Soldato!"); }if(args[0].equalsIgnoreCase("Arcere")){ ItemStack wsword = (new ItemStack(Material.WOOD_SWORD)); ItemStack ihelmet = (new ItemStack(Material.IRON_HELMET)); ItemStack gchest = (new ItemStack(Material.GOLD_CHESTPLATE)); ItemStack llegg = (new ItemStack(Material.LEATHER_LEGGINGS)); ItemStack lboots = (new ItemStack(Material.LEATHER_BOOTS)); PlayerInventory pi2 = p.getInventory(); pi2.setHelmet(ihelmet); pi2.setChestplate(gchest); pi2.setLeggings(llegg); pi2.setBoots(lboots); pi2.addItem(wsword); pi2.addItem(new ItemStack(Material.BOW, 1)); pi2.addItem(new ItemStack(Material.ARROW, 500)); p.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "Kits" + ChatColor.GRAY + "]" + ChatColor.WHITE + "Hai selezionato il kit Arciere!"); } } } return false; }} But, I need help about clearing invetory and adding kit. If i take Soldato (warrior in english) Kit and I type /mkit Arciere (archer in english), I would that plugin DON'T give arciere kit if player has already the same Kit or other kits. (Sorry for my english D Any helps? I know that I can use HashMap, but I'm pretty whit Java Coding, and I'm studing it.
Maybe have a HashMap store two values, the Player and a boolean to check if they have chose a kit or not. So create a new HashMap Code: ArrayList<Player,> kitList = new ArrayList<Player>(); Then, when they choose a kit, make it check that if they are in the ArrayList Code: if(kitList.contains(player) { player.sendMessage("Sorry but you can't chose a kit!"); return; } And then add an else statement, and if they aren't in the kitList let them chose a kit. If they chose a kit and they aren't in the ArrayList, make it add them to the arraylist, and then when they die or quit make it remove them from the ArrayList. Sorry if it was confusing, just pm me for help.
I know that it's so simple, but, I really need a complete and simple, simple example about my code, if anyone would help my a will very glad
Just going to give you a tip since it seems you are new to programming in general. Since you're going to be making this for a server I would suggest using separate classes to organize your project. It not only saves time but it also saves space.