More sorting cleanup & lambda functions in F Top Command.
This commit is contained in:
parent
c2a90e857f
commit
25ac8f026e
@ -9,8 +9,6 @@ import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class CmdTop extends FCommand {
|
||||
|
||||
@ -47,9 +45,7 @@ public class CmdTop extends FCommand {
|
||||
|
||||
// TODO: Better way to sort?
|
||||
if (criteria.equalsIgnoreCase("members")) {
|
||||
factionList.sort(new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
factionList.sort((f1, f2) -> {
|
||||
int f1Size = f1.getFPlayers().size();
|
||||
int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size) {
|
||||
@ -58,12 +54,9 @@ public class CmdTop extends FCommand {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else if (criteria.equalsIgnoreCase("start")) {
|
||||
Collections.sort(factionList, new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
factionList.sort((f1, f2) -> {
|
||||
long f1start = f1.getFoundedDate();
|
||||
long f2start = f2.getFoundedDate();
|
||||
// flip signs because a smaller date is farther in the past
|
||||
@ -73,12 +66,9 @@ public class CmdTop extends FCommand {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else if (criteria.equalsIgnoreCase("power")) {
|
||||
Collections.sort(factionList, new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
factionList.sort((f1, f2) -> {
|
||||
int f1Size = f1.getPowerRounded();
|
||||
int f2Size = f2.getPowerRounded();
|
||||
if (f1Size < f2Size) {
|
||||
@ -87,12 +77,9 @@ public class CmdTop extends FCommand {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else if (criteria.equalsIgnoreCase("land")) {
|
||||
Collections.sort(factionList, new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
factionList.sort((f1, f2) -> {
|
||||
int f1Size = f1.getLandRounded();
|
||||
int f2Size = f2.getLandRounded();
|
||||
if (f1Size < f2Size) {
|
||||
@ -101,12 +88,9 @@ public class CmdTop extends FCommand {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else if (criteria.equalsIgnoreCase("online")) {
|
||||
factionList.sort(new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
factionList.sort((f1, f2) -> {
|
||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||
if (f1Size < f2Size) {
|
||||
@ -115,12 +99,9 @@ public class CmdTop extends FCommand {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else if (criteria.equalsIgnoreCase("money") || criteria.equalsIgnoreCase("balance") || criteria.equalsIgnoreCase("bal")) {
|
||||
factionList.sort(new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
factionList.sort((f1, f2) -> {
|
||||
double f1Size = Econ.getBalance(f1.getAccountId());
|
||||
// Lets get the balance of /all/ the players in the Faction.
|
||||
for (FPlayer fp : f1.getFPlayers()) {
|
||||
@ -136,7 +117,6 @@ public class CmdTop extends FCommand {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
msg(TL.COMMAND_TOP_INVALID, criteria);
|
||||
|
Loading…
Reference in New Issue
Block a user