diff options
author | ElgarL <ElgarL@palmergames.com> | 2012-09-25 13:23:19 +0100 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2012-09-25 13:23:19 +0100 |
commit | 1438230b708e68db14e54ebb668016654ed3c2fb (patch) | |
tree | 5ef4181808c1b8fd11676ec2b603e87d6ce5cd88 /EssentialsGroupManager/src/org/anjocaido | |
parent | d4e2ed782ec0b967e7ab5f013b877c85f34bda9c (diff) | |
download | Essentials-1438230b708e68db14e54ebb668016654ed3c2fb.tar Essentials-1438230b708e68db14e54ebb668016654ed3c2fb.tar.gz Essentials-1438230b708e68db14e54ebb668016654ed3c2fb.tar.lz Essentials-1438230b708e68db14e54ebb668016654ed3c2fb.tar.xz Essentials-1438230b708e68db14e54ebb668016654ed3c2fb.zip |
Add alphabetically sorted user lists.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java | 14 |
1 files changed, 10 insertions, 4 deletions
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<String, Object> root = new HashMap<String, Object>(); - - Map<String, Object> usersMap = new HashMap<String, Object>(); + LinkedHashMap<String, Object> usersMap = new LinkedHashMap<String, Object>(); + root.put("users", usersMap); synchronized (ph.getUsers()) { - for (String userKey : ph.getUsers().keySet()) { + + // A sorted list of users. + ArrayList<String> names = new ArrayList<String>(new TreeSet<String>(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<String, Object> aUserMap = new HashMap<String, Object>(); + LinkedHashMap<String, Object> aUserMap = new LinkedHashMap<String, Object>(); usersMap.put(user.getName(), aUserMap); // GROUP NODE |