mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-24 03:05:52 +01:00
Order /f show
by rank. Adds #150
This commit is contained in:
parent
6107e9502e
commit
5e676bdd50
@ -7,6 +7,7 @@ import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@ -129,7 +130,7 @@ public class CmdShow extends FCommand {
|
||||
FancyMessage offline = new FancyMessage("Members offline: ").color(ChatColor.GOLD);
|
||||
boolean firstOnline = true;
|
||||
boolean firstOffline = true;
|
||||
for (FPlayer p : faction.getFPlayers()) {
|
||||
for (FPlayer p : MiscUtil.rankOrder(faction.getFPlayers())) {
|
||||
String name = p.getNameAndTitle();
|
||||
if (p.isOnline()) {
|
||||
if (firstOnline) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Creature;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.entity.EntityType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class MiscUtil {
|
||||
|
||||
@ -77,5 +79,33 @@ public class MiscUtil {
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
public static Iterable<FPlayer> rankOrder(Iterable<FPlayer> players) {
|
||||
List<FPlayer> admins = new ArrayList<FPlayer>();
|
||||
List<FPlayer> moderators = new ArrayList<FPlayer>();
|
||||
List<FPlayer> normal = new ArrayList<FPlayer>();
|
||||
|
||||
for (FPlayer player : players) {
|
||||
switch (player.getRole()) {
|
||||
case ADMIN:
|
||||
admins.add(player);
|
||||
break;
|
||||
|
||||
case MODERATOR:
|
||||
moderators.add(player);
|
||||
break;
|
||||
|
||||
case NORMAL:
|
||||
normal.add(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
ret.addAll(admins);
|
||||
ret.addAll(moderators);
|
||||
ret.addAll(normal);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user