I want to start off by saying sorry, I wasn't able to search for this problem as I couldn't exactly describe it myself.I have a series of if-statements to account for each scenario. As you can see in the mammoth block of code below, I want arguments to come in any order. How, if possible, can I shorten this?if(args[1].startsWith(u:) && args[2].startsWith(r:) && args[3].startsWith(l:)){ // u / r / l    Player p = player.getServer().getPlayer(args[1].split(:)[1]);    String r = args[2].split(:)[1];    String l = args[3].split(:)[1];    Config.addPlayer(p, r, l, player);    return true;}else if(args[1].startsWith(r:) && args[2].startsWith(l:) && args[3].startsWith(u:)){ // r / l / u    Player p = player.getServer().getPlayer(args[3].split(:)[1]);    String r = args[1].split(:)[1];    String l = args[2].split(:)[1];    Config.addPlayer(p, r, l, player);    return true;}else if(args[1].startsWith(l:) && args[2].startsWith(u:) && args[3].startsWith(r:)){ // l / u / r    Player p = player.getServer().getPlayer(args[2].split(:)[1]);    String r = args[3].split(:)[1];    String l = args[1].split(:)[1];    Config.addPlayer(p, r, l, player);    return true;}else if(args[1].startsWith(u) && args[2].startsWith(l:) && args[3].startsWith(r:)){ // u / l / r    Player p = player.getServer().getPlayer(args[1].split(:)[1]);    String r = args[3].split(:)[1];    String l = args[2].split(:)[1];    Config.addPlayer(p, r, l, player);    return true;}else if(args[1].startsWith(l:) && args[2].startsWith(r:) && args[3].startsWith(u:)){ // l / r / u    Player p = player.getServer().getPlayer(args[2].split(:)[1]);    String r = args[2].split(:)[1];    String l = args[1].split(:)[1];    Config.addPlayer(p, r, l, player);    return true;}else if(args[1].startsWith(r:) && args[2].startsWith(u:) && args[3].startsWith(l:)){ // r / u / l    Player p = player.getServer().getPlayer(args[2].split(:)[1]);    String r = args[1].split(:)[1];    String l = args[3].split(:)[1];    Config.addPlayer(p, r, l, player);    return true;}
Parsing argument list specifying a player to be added
java
It looks like you're trying to cover all possible combinations of u: r: l: parameters.In your implementation,the purpose of each if statement is to figure out the order of these parameters and act accordingly.A good first step can be to create a method that processes parameters given in the canonical order.It doesn't matter what is the canonical order,but once you define it, it will help you, for example:void parseArgs(String playerParam, String rParam, String lParam) {    Player p = player.getServer().getPlayer(playerParam.split(:)[1]);    String r = rParam.split(:)[1];    String l = lParam.split(:)[1];    Config.addPlayer(p, r, l, player);}With this method, your if branches can be simplified, for example:if(args[1].startsWith(u:) && args[2].startsWith(r:) && args[3].startsWith(l:)){ // u / r / l    parseArgs(args[1], args[2], args[3]);    return true;}else if(args[1].startsWith(r:) && args[2].startsWith(l:) && args[3].startsWith(u:)){ // r / l / u    parseArgs(args[3], args[1], args[2]);    return true;} // ... and so onIn other words, the if branches effectively perform translation:from the detected ordering to the canonical orderingfrom meaningless args[...] values to meaningful parameter names (playerParam, rParam, ...)Speaking of meaningful, r and l are very poor variable names,all this would be a lot more readable if you improved them.This is still far from good, because there are a lot of wasted operations here:If the ordering was r:u:l:, then 6 startswith calls will be evaluated before reaching the last if branch.Writing out all the combinations is tedious, and inevitably error prone:You might forget a combinationYou might accidentally write the same combination twiceYou might accidentally write the wrong args[...] values when handling a combinationWhat if you have to add more parameters x: and y:? Your number of combinations will explode and you'll go nutsAll those startswith calls are a lot of duplicated codeNotice the overlap in the logic of startswith and split: you could split in advance, and use equals instead of startswithInstead of listing all combinations, it's better to parse the arguments list in a loop:Player p = null;String r = null;String l = null;for (int i = 1; i <= 3; ++i) {    String arg = args[i];    String[] parts = arg.split(:);    String key = parts[0];    String value = parts[1];    if (key.equals(u)) {        p = player.getServer().getPlayer(value);    } else if (key.equals(r)) {        r = value;    } else if (key.equals(l)) {        l = value;    }}if (p != null && r != null && l != null) {    Config.addPlayer(p, r, l, player);    return true;}return false;This is equivalent to your code above, and easily scalable to support more parameters if needed.Notice how I used local variables to give meaning to meaningless things,for example key to refer to parts[0], and value to refer to parts[1].