From 1438230b708e68db14e54ebb668016654ed3c2fb Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 25 Sep 2012 13:23:19 +0100 Subject: Add alphabetically sorted user lists. --- .../anjocaido/groupmanager/dataholder/WorldDataHolder.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 9790efa2a..30a7e19e4 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -15,8 +15,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.TreeSet; import java.util.logging.Level; import java.util.logging.Logger; import org.anjocaido.groupmanager.GroupManager; @@ -1018,17 +1020,21 @@ public class WorldDataHolder { public static void writeUsers(WorldDataHolder ph, File usersFile) { Map root = new HashMap(); - - Map usersMap = new HashMap(); + LinkedHashMap usersMap = new LinkedHashMap(); + root.put("users", usersMap); synchronized (ph.getUsers()) { - for (String userKey : ph.getUsers().keySet()) { + + // A sorted list of users. + ArrayList names = new ArrayList(new TreeSet(ph.getUsers().keySet())); + + for (String userKey : names) { User user = ph.getUsers().get(userKey); if ((user.getGroup() == null || user.getGroup().equals(ph.getDefaultGroup())) && user.getPermissionList().isEmpty() && user.getVariables().isEmpty() && user.isSubGroupsEmpty()) { continue; } - Map aUserMap = new HashMap(); + LinkedHashMap aUserMap = new LinkedHashMap(); usersMap.put(user.getName(), aUserMap); // GROUP NODE -- cgit v1.2.3