cleanup: prefer List#sort over Collections#sort
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -451,7 +451,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
timedBuffs.add(new Pair<>(curtime - pb.usedTime, pb));
|
||||
}
|
||||
|
||||
Collections.sort(timedBuffs, (p1, p2) -> p1.getLeft().compareTo(p2.getLeft()));
|
||||
timedBuffs.sort((p1, p2) -> p1.getLeft().compareTo(p2.getLeft()));
|
||||
|
||||
return timedBuffs;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PartySearchStorage {
|
||||
pscList.add(new PartySearchCharacter(chr));
|
||||
}
|
||||
|
||||
Collections.sort(pscList, (c1, c2) -> {
|
||||
pscList.sort((c1, c2) -> {
|
||||
int levelP1 = c1.getLevel(), levelP2 = c2.getLevel();
|
||||
return levelP1 > levelP2 ? 1 : (levelP1 == levelP2 ? 0 : -1);
|
||||
});
|
||||
|
||||
@@ -579,7 +579,7 @@ public class MapleSessionCoordinator {
|
||||
public void printSessionTrace() {
|
||||
if (!onlineClients.isEmpty()) {
|
||||
List<Entry<Integer, MapleClient>> elist = new ArrayList<>(onlineClients.entrySet());
|
||||
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
|
||||
System.out.println("Current online clients: ");
|
||||
for (Entry<Integer, MapleClient> e : elist) {
|
||||
@@ -600,7 +600,7 @@ public class MapleSessionCoordinator {
|
||||
if (!loginRemoteHosts.isEmpty()) {
|
||||
List<Entry<String, Set<IoSession>>> elist = new ArrayList<>(loginRemoteHosts.entrySet());
|
||||
|
||||
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
|
||||
System.out.println("Current login sessions: ");
|
||||
for (Entry<String, Set<IoSession>> e : elist) {
|
||||
@@ -614,7 +614,7 @@ public class MapleSessionCoordinator {
|
||||
|
||||
if (!onlineClients.isEmpty()) {
|
||||
List<Entry<Integer, MapleClient>> elist = new ArrayList<>(onlineClients.entrySet());
|
||||
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
|
||||
str += ("Current online clients:\r\n");
|
||||
for (Entry<Integer, MapleClient> e : elist) {
|
||||
@@ -635,7 +635,7 @@ public class MapleSessionCoordinator {
|
||||
if (!loginRemoteHosts.isEmpty()) {
|
||||
List<Entry<String, Set<IoSession>>> elist = new ArrayList<>(loginRemoteHosts.entrySet());
|
||||
|
||||
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
|
||||
|
||||
str += ("Current login sessions:\r\n");
|
||||
for (Entry<String, Set<IoSession>> e : elist) {
|
||||
|
||||
@@ -234,7 +234,7 @@ public class MapleMonsterAggroCoordinator {
|
||||
|
||||
if (!toRemoveIdx.isEmpty()) {
|
||||
// last to first indexes
|
||||
Collections.sort(toRemoveIdx, (p1, p2) -> p1 < p2 ? 1 : p1.equals(p2) ? 0 : -1);
|
||||
toRemoveIdx.sort((p1, p2) -> p1 < p2 ? 1 : p1.equals(p2) ? 0 : -1);
|
||||
|
||||
for (int idx : toRemoveIdx) {
|
||||
sortedAggro.remove(idx);
|
||||
|
||||
@@ -211,7 +211,7 @@ public class MapleParty {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
Collections.sort(histList, (o1, o2) -> (o1.getValue()).compareTo(o2.getValue()));
|
||||
histList.sort((o1, o2) -> (o1.getValue()).compareTo(o2.getValue()));
|
||||
|
||||
List<Integer> histSort = new LinkedList<>();
|
||||
for (Entry<Integer, Integer> e : histList) {
|
||||
|
||||
@@ -461,7 +461,7 @@ public class World {
|
||||
list.add(e);
|
||||
}
|
||||
|
||||
Collections.sort(list, (o1, o2) -> o1.getKey() - o2.getKey());
|
||||
list.sort((o1, o2) -> o1.getKey() - o2.getKey());
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -1844,7 +1844,7 @@ public class World {
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(hmsAvailable, (p1, p2) -> p1.getLeft().getPrice() - p2.getLeft().getPrice());
|
||||
hmsAvailable.sort((p1, p2) -> p1.getLeft().getPrice() - p2.getLeft().getPrice());
|
||||
|
||||
hmsAvailable.subList(0, Math.min(hmsAvailable.size(), 200)); //truncates the list to have up to 200 elements
|
||||
return hmsAvailable;
|
||||
|
||||
@@ -233,7 +233,7 @@ public class MapleStorage {
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
Collections.sort(items, (o1, o2) -> {
|
||||
items.sort((o1, o2) -> {
|
||||
if (o1.getInventoryType().getType() < o2.getInventoryType().getType()) {
|
||||
return -1;
|
||||
} else if (o1.getInventoryType() == o2.getInventoryType()) {
|
||||
|
||||
@@ -31,7 +31,6 @@ import tools.MaplePacketCreator;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -92,7 +91,7 @@ public class MaplePlayerNPCPodium {
|
||||
playerNpcs.add((MaplePlayerNPC) mmo);
|
||||
}
|
||||
|
||||
Collections.sort(playerNpcs, (p1, p2) -> {
|
||||
playerNpcs.sort((p1, p2) -> {
|
||||
return p1.getScriptId() - p2.getScriptId(); // scriptid as playernpc history
|
||||
});
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@ import server.maps.MapleMapObjectType;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -141,7 +143,7 @@ public class MaplePlayerNPCPositioner {
|
||||
playerNpcs.add((MaplePlayerNPC) mmo);
|
||||
}
|
||||
|
||||
Collections.sort(playerNpcs, (p1, p2) -> {
|
||||
playerNpcs.sort((p1, p2) -> {
|
||||
return p1.getScriptId() - p2.getScriptId(); // scriptid as playernpc history
|
||||
});
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ItemAction extends MapleQuestAction {
|
||||
items.add(new ItemData(Integer.parseInt(iEntry.getName()), id, count, prop, job, gender, period));
|
||||
}
|
||||
|
||||
Collections.sort(items, (o1, o2) -> o1.map - o2.map);
|
||||
items.sort((o1, o2) -> o1.map - o2.map);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -986,7 +986,7 @@ public class MaplePacketCreator {
|
||||
}
|
||||
List<Pair<MapleStat, Integer>> mystats = stats;
|
||||
if (mystats.size() > 1) {
|
||||
Collections.sort(mystats, (o1, o2) -> {
|
||||
mystats.sort((o1, o2) -> {
|
||||
int val1 = o1.getLeft().getValue();
|
||||
int val2 = o2.getLeft().getValue();
|
||||
return (val1 < val2 ? -1 : (val1 == val2 ? 0 : 1));
|
||||
|
||||
Reference in New Issue
Block a user