diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-08-18 22:08:57 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-08-18 22:08:57 +0100 |
commit | a6bb2cf9a003908b49f4ae5c8daeff1969347859 (patch) | |
tree | 59c8e02b447f0a6bd93d78d259e55b74ca0f2456 /Essentials | |
parent | 66c40b955f70898a9e6b608dc188d580ad96a140 (diff) | |
download | Essentials-a6bb2cf9a003908b49f4ae5c8daeff1969347859.tar Essentials-a6bb2cf9a003908b49f4ae5c8daeff1969347859.tar.gz Essentials-a6bb2cf9a003908b49f4ae5c8daeff1969347859.tar.lz Essentials-a6bb2cf9a003908b49f4ae5c8daeff1969347859.tar.xz Essentials-a6bb2cf9a003908b49f4ae5c8daeff1969347859.zip |
Fix a few issues with /list and group formatting.
Diffstat (limited to 'Essentials')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandlist.java | 23 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/utils/FormatUtil.java | 12 |
2 files changed, 24 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index 9fea6846c..18fa0a673 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -27,7 +27,7 @@ public class Commandlist extends EssentialsCommand } sender.sendMessage(listSummary(server, showHidden)); - Map<String, List<User>> playerList = getPlayerLists(server, showHidden); + final Map<String, List<User>> playerList = getPlayerLists(server, showHidden); if (args.length > 0) { @@ -66,7 +66,7 @@ public class Commandlist extends EssentialsCommand // Build the basic player list, divided by groups. private Map<String, List<User>> getPlayerLists(final Server server, final boolean showHidden) { - Map<String, List<User>> playerList = new HashMap<String, List<User>>(); + final Map<String, List<User>> playerList = new HashMap<String, List<User>>(); for (Player onlinePlayer : server.getOnlinePlayers()) { final User onlineUser = ess.getUser(onlinePlayer); @@ -74,7 +74,7 @@ public class Commandlist extends EssentialsCommand { continue; } - final String group = FormatUtil.stripFormat(onlineUser.getGroup().toLowerCase()); + final String group = FormatUtil.stripFormat(FormatUtil.stripEssentialsFormat(onlineUser.getGroup().toLowerCase())); List<User> list = playerList.get(group); if (list == null) { @@ -91,7 +91,7 @@ public class Commandlist extends EssentialsCommand { final List<User> users = getMergedList(playerList, groupName); - List<User> groupUsers = playerList.get(groupName); + final List<User> groupUsers = playerList.get(groupName); if (groupUsers != null && !groupUsers.isEmpty()) { users.addAll(groupUsers); @@ -101,13 +101,16 @@ public class Commandlist extends EssentialsCommand throw new Exception(_("groupDoesNotExist")); } - return outputFormat(groupName, listUsers(users)); + final StringBuilder displayGroupName = new StringBuilder(); + displayGroupName.append(Character.toTitleCase(groupName.charAt(0))); + displayGroupName.append(groupName.substring(1)); + return outputFormat(displayGroupName.toString(), listUsers(users)); } // Handle the merging of groups private List<User> getMergedList(final Map<String, List<User>> playerList, final String groupName) { - Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet(); + final Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet(); final List<User> users = new ArrayList<User>(); for (String configGroup : configGroups) @@ -117,6 +120,7 @@ public class Commandlist extends EssentialsCommand String[] groupValues = ess.getSettings().getListGroupConfig().get(configGroup).toString().trim().split(" "); for (String groupValue : groupValues) { + groupValue = groupValue.toLowerCase(Locale.ENGLISH); if (groupValue == null || groupValue.equals("")) { continue; @@ -137,8 +141,8 @@ public class Commandlist extends EssentialsCommand // Output the standard /list output, when no group is specified private void sendGroupedList(CommandSender sender, String commandLabel, Map<String, List<User>> playerList) { - Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet(); - List<String> asterisk = new ArrayList<String>(); + final Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet(); + final List<String> asterisk = new ArrayList<String>(); // Loop through the custom defined groups and display them for (String oConfigGroup : configGroups) @@ -161,7 +165,7 @@ public class Commandlist extends EssentialsCommand } List<User> outputUserList = new ArrayList<User>(); - List<User> matchedList = playerList.get(configGroup); + final List<User> matchedList = playerList.get(configGroup); // If the group value is an int, then we might need to truncate it if (NumberUtil.isInt(groupValue)) @@ -265,7 +269,6 @@ public class Commandlist extends EssentialsCommand final StringBuilder outputString = new StringBuilder(); outputString.append(_("listGroupTag", FormatUtil.replaceFormat(group))); outputString.append(message); - outputString.setCharAt(0, Character.toTitleCase(outputString.charAt(0))); return outputString.toString(); } } diff --git a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java index b598b8c86..9d3ef7cb0 100644 --- a/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/FormatUtil.java @@ -25,7 +25,17 @@ public class FormatUtil { return null; } - return VANILLA_PATTERN.matcher(input).replaceAll(""); + return stripColor(input, VANILLA_PATTERN); + } + + //This method is used to simply strip the & convention colour codes + public static String stripEssentialsFormat(final String input) + { + if (input == null) + { + return null; + } + return stripColor(input, REPLACE_PATTERN); } //This is the general permission sensitive message format function, checks for urls. |