From 5e676bdd5029d55bf092accc1b1ca5b0a21b1c93 Mon Sep 17 00:00:00 2001 From: eueln Date: Sat, 6 Dec 2014 21:44:00 -0600 Subject: [PATCH] Order `/f show` by rank. Adds #150 --- .../massivecraft/factions/cmd/CmdShow.java | 3 +- .../massivecraft/factions/util/MiscUtil.java | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 552bda4f..a3414cd5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -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) { diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java index c54366ba..8db8044c 100644 --- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java +++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java @@ -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 rankOrder(Iterable players) { + List admins = new ArrayList(); + List moderators = new ArrayList(); + List normal = new ArrayList(); + + 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 ret = new ArrayList(); + ret.addAll(admins); + ret.addAll(moderators); + ret.addAll(normal); + return ret; + } }