Permalink
Browse files

Sort player lists by player's display name.

  • Loading branch information...
1 parent 9131c47 commit 7d194507c0e1f6ce5b0f0b144d3fedfe90d4fde4 @mkalus committed May 1, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/main/java/de/beimax/simplespleef/game/SpleeferList.java
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.TreeSet;
import org.bukkit.entity.Player;
@@ -42,11 +43,18 @@ public static String getPrintablePlayerList(List<Spleefer> players) {
StringBuilder builder = new StringBuilder();
int i = 0;
String comma = SimpleSpleef.ll("feedback.infoComma");
- // compile list of spleefers
+
+ // Sort by display name
+ TreeSet<String> ordered = new TreeSet<String>();
for (Spleefer spleefer : players) {
+ ordered.add(spleefer.getPlayer().getDisplayName());
+ }
+
+ // compile list of spleefers
+ for (String playerName : ordered) {
if (i > 0 && i == players.size() - 1) builder.append(SimpleSpleef.ll("feedback.infoAnd")); // last element with end
else if (i > 0) builder.append(comma); // other elements with ,
- builder.append(spleefer.getPlayer().getDisplayName());
+ builder.append(playerName);
}
return builder.toString();
}

0 comments on commit 7d19450

Please sign in to comment.