cleanup: prefer List#sort over Collections#sort

This commit is contained in:
P0nk
2021-04-08 07:44:02 +02:00
parent 5730b3b42d
commit ebb3aa7ba3
14 changed files with 28 additions and 24 deletions

View File

@@ -29,7 +29,10 @@ import client.command.Command;
import constants.game.GameConstants;
import server.maps.*;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class GotoCommand extends Command {
@@ -65,7 +68,7 @@ public class GotoCommand extends Command {
public static String GOTO_AREAS_INFO = "";
private static void sortGotoEntries(List<Entry<String, Integer>> listEntries) {
Collections.sort(listEntries, (e1, e2) -> e1.getValue().compareTo(e2.getValue()));
listEntries.sort((e1, e2) -> e1.getValue().compareTo(e2.getValue()));
}
@Override

View File

@@ -188,7 +188,7 @@ public class MapleInventory implements Iterable<Item> {
}
if (ret.size() > 1) {
Collections.sort(ret, (i1, i2) -> i1.getPosition() - i2.getPosition());
ret.sort((i1, i2) -> i1.getPosition() - i2.getPosition());
}
return ret;
@@ -203,7 +203,7 @@ public class MapleInventory implements Iterable<Item> {
}
if (ret.size() > 1) {
Collections.sort(ret, (i1, i2) -> i1.getPosition() - i2.getPosition());
ret.sort((i1, i2) -> i1.getPosition() - i2.getPosition());
}
return ret;

View File

@@ -92,9 +92,9 @@ public class AssignAPProcessor {
statUpdate[2] = chr.getLuk();
statUpdate[3] = chr.getInt();
Collections.sort(eqpStrList, Collections.reverseOrder());
Collections.sort(eqpDexList, Collections.reverseOrder());
Collections.sort(eqpLukList, Collections.reverseOrder());
eqpStrList.sort(Collections.reverseOrder());
eqpDexList.sort(Collections.reverseOrder());
eqpLukList.sort(Collections.reverseOrder());
//Autoassigner looks up the 1st/2nd placed equips for their stats to calculate the optimal upgrade.
int eqpStr = getNthHighestStat(eqpStrList, (short) 0) + getNthHighestStat(eqpStrList, (short) 1);