public void checkKit(MovingVan van) { MovingVan tmp = null; for (MovingVan v : vans) { if (v.getName().equalsIgnoreCase(van.getName())) { tmp = v; } } if (tmp != null) { vans.remove(tmp); } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("Players only please!"); return true; } Player p = (Player) sender; if (cmd.getName().equalsIgnoreCase("sync") && args.length > 0 && args[0].equalsIgnoreCase("time") && p.isOp()) { p.sendMessage(ChatColor.GREEN + "Time sync'd!"); resetTime(); } if (cmd.getName().equalsIgnoreCase("kit")) { if (args.length == 1 && !args[0].equalsIgnoreCase("list")) { for (MovingVan van : vans) { if (van.getName().equalsIgnoreCase(args[0])) { van.users.add(p.getName()); write(); if (hasKit.contains(p.getName())) { p.sendMessage(ChatColor.RED + "You already have a kit!"); return true; } if (!getConfig().getString("Kits." + args[0] + ".Perm").equalsIgnoreCase("NA") && !p.hasPermission(getConfig().getString("Kits." + args[0] + ".Perm"))) { p.sendMessage(ChatColor.RED + "You don't have permission!"); return true; } p.getInventory().clear(); removeAllPotionEffects(p); for (String s : getConfig().getStringList("Kits." + args[0] + ".Items")) { String[] tmp = s.split(":"); if (Short.parseShort(tmp[2]) == 0) { p.getInventory() .addItem(new ItemStack(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]))); } else { p.getInventory() .addItem( new ItemStack( Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]), Short.parseShort(tmp[2]))); } } p.getInventory() .setHelmet(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Head"))); p.getInventory() .setChestplate(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Chest"))); p.getInventory() .setLeggings(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Legs"))); p.getInventory() .setBoots(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Boots"))); if (p.getWorld().getTime() < 12000) { for (int i : config.getIntegerList("Kits." + args[0] + ".PotionEffects.Day")) { p.addPotionEffect(new PotionEffect(PotionEffectType.getById(i), 999999999, 1)); } } else { for (int i : config.getIntegerList("Kits." + args[0] + ".PotionEffects.Night")) { p.addPotionEffect(new PotionEffect(PotionEffectType.getById(i), 999999999, 1)); } } hasKit.add(p.getName()); if (invince.contains(p.getName())) { invince.remove(p.getName()); } tpRandom(p); p.sendMessage(ChatColor.GREEN + "Kit recieved!"); return true; } } p.sendMessage(ChatColor.RED + "Kit not found!"); } else if (args.length == 1 && args[0].equalsIgnoreCase("list")) { p.sendMessage( ChatColor.DARK_GREEN + "---- " + ChatColor.GREEN + "KITS" + ChatColor.DARK_GREEN + " ----"); for (MovingVan van : vans) { p.sendMessage(ChatColor.BLUE + van.getName()); } } else if (args.length == 2 && p.isOp()) { if (args[0].equalsIgnoreCase("set")) { MovingVan tmp = new MovingVan(args[1], p.getInventory(), p.getActivePotionEffects(), "NA"); checkKit(tmp); vans.add(tmp); writeConfig(tmp, p, args[1], "NA"); write(); p.getInventory().clear(); p.getInventory().setHelmet(new ItemStack(0)); p.getInventory().setChestplate(new ItemStack(0)); p.getInventory().setLeggings(new ItemStack(0)); p.getInventory().setBoots(new ItemStack(0)); removeAllPotionEffects(p); p.sendMessage(ChatColor.GREEN + "Kit set!"); } } else if (args.length == 3 && p.isOp()) { if (args[0].equalsIgnoreCase("set")) { MovingVan tmp = new MovingVan(args[1], p.getInventory(), p.getActivePotionEffects(), args[2]); checkKit(tmp); vans.add(tmp); writeConfig(tmp, p, args[1], args[2]); write(); p.getInventory().clear(); p.getInventory().setHelmet(new ItemStack(0)); p.getInventory().setChestplate(new ItemStack(0)); p.getInventory().setLeggings(new ItemStack(0)); p.getInventory().setBoots(new ItemStack(0)); removeAllPotionEffects(p); p.sendMessage(ChatColor.GREEN + "Kit set!"); } } } return true; }