Code: public void addFriend(Player player, Player target){ List<String> list = this.getConfig().getStringList(player.getUniqueId().toString() + ".Friends"); list.add(target.getUniqueId().toString()); this.getConfig().set(player.getUniqueId() + ".Friends", list); this.saveConfig(); player.sendMessage(ChatColor.GREEN + target.getDisplayName() + "is now your friend."); } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("friend")) { if(args[0].equalsIgnoreCase("add")){ if(sender instanceof Player){ Player player = (Player) sender; if(!(args.length > 1)){ Player target = (Bukkit.getServer().getPlayer(args[1])); if(target !=null){ addFriend(player, target); }else{ player.sendMessage(ChatColor.RED + "Player must be online to add as friend"); } }else{ player.sendMessage(ChatColor.RED + "Use /friend add <friends name>"); } }else{ sender.sendMessage(ChatColor.RED + "This must be executed by a player"); } }else if(args[0].equalsIgnoreCase("remove")){ if(sender instanceof Player){ Player player = (Player) sender; if(!(args.length > 1)){ player.sendMessage("hello"); //if is in list } }else{ sender.sendMessage(ChatColor.RED + "This must be executed by a player"); } }else{ sender.sendMessage(ChatColor.RED + "Use /friend <add/remove>"); } } return false; } In the console it said its wrong with my arguments, line 35. Am im not doing it right.
I'm guessing it says line 35 in the stack trace and it's not line 35 in the code above. If so, you need to post the full class or tell us which line it corresponds to.
@Evonoucono Exactly. You should check if the array "args" contains any elements in it before trying to access one of them.