diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index f72969f5b..be75ef50d 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -76,8 +76,6 @@ public interface ISettings extends IConf int getHomeLimit(User user); - boolean getSortListByGroups(); - int getSpawnMobLimit(); int getStartingBalance(); @@ -191,4 +189,6 @@ public interface ISettings extends IConf public void setEssentialsChatActive(boolean b); long getMaxTempban(); + + public Map getListGroupConfig(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index a24f3d807..80b3e9a1c 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -258,6 +258,7 @@ public class Settings implements ISettings return socialspyCommands; } + @Override public Set getSocialSpyCommands() { return socialSpyCommands; @@ -452,11 +453,15 @@ public class Settings implements ISettings { return config.getBoolean("per-warp-permission", false); } - + @Override - public boolean getSortListByGroups() + public Map getListGroupConfig() { - return config.getBoolean("sort-list-by-groups", true); + if (config.isConfigurationSection("list")) + { + return config.getConfigurationSection("list").getValues(false); + } + return new HashMap(); } @Override diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index c981f45c1..c2fa954a5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -40,7 +40,7 @@ public class Commandlist extends EssentialsCommand } } - String online; + String online; if (showhidden && playerHidden > 0) { online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers()); @@ -51,99 +51,188 @@ public class Commandlist extends EssentialsCommand } sender.sendMessage(online); - if (ess.getSettings().getSortListByGroups()) + + Map> sort = new HashMap>(); + for (Player OnlinePlayer : server.getOnlinePlayers()) { - Map> sort = new HashMap>(); - for (Player OnlinePlayer : server.getOnlinePlayers()) + final User player = ess.getUser(OnlinePlayer); + if (player.isHidden() && !showhidden) { - final User player = ess.getUser(OnlinePlayer); - if (player.isHidden() && !showhidden) + continue; + } + final String group = player.getGroup().toLowerCase(); + List list = sort.get(group); + if (list == null) + { + list = new ArrayList(); + sort.put(group, list); + } + list.add(player); + } + final StringBuilder groupString = new StringBuilder(); + Set keys = ess.getSettings().getListGroupConfig().keySet(); + if (args.length > 0) + { + final List users = new ArrayList(); + String group = args[0].toLowerCase(); + for (String key : keys) + { + String groupValue = ess.getSettings().getListGroupConfig().get(key).toString().trim(); + if(key.equalsIgnoreCase(group) && groupValue.contains(",")) + { + String[] groups = groupValue.split(","); + for (String g : groups) + { + if (g == null || g.equals("")) + { + continue; + } + List u = sort.get(g.trim()); + if (u == null || u.isEmpty()) + { + continue; + } + users.addAll(u); + } + } + } + List groupUsers = sort.get(group); + if (groupUsers != null && !groupUsers.isEmpty()) + { + users.addAll(groupUsers); + } + if (users == null || users.isEmpty()) + { + throw new Exception(_("groupDoesNotExist")); + } + groupString.append(_("listGroupTag", Util.replaceFormat(group))); + groupString.append(listUsers(users)); + groupString.setCharAt(0, Character.toTitleCase(groupString.charAt(0))); + sender.sendMessage(groupString.toString()); + groupString.setLength(0); + } + else + { + Map usedGroups = new HashMap(); + for (String group : keys) + { + boolean userLimit = false; + String groupValue = ess.getSettings().getListGroupConfig().get(group).toString().trim(); + usedGroups.put(group.toLowerCase(), groupValue); + if (groupValue.equals("hidden")) { continue; } - final String group = player.getGroup(); - List list = sort.get(group); - if (list == null) + if (Util.isInt(groupValue)) { - list = new ArrayList(); - sort.put(group, list); + userLimit = true; } - list.add(player); + group = group.toLowerCase(); + final List users = new ArrayList(); + List u = sort.get(group); + if (u != null && !u.isEmpty()) + { + users.addAll(u); + if (userLimit) + { + int limit = Integer.parseInt(groupValue); + if (u.size() > limit) + { + groupString.append(_("listGroupTag", Util.replaceFormat(group))); + groupString.append(_("groupNumber", u.size(), commandLabel, group)); + groupString.setCharAt(0, Character.toTitleCase(groupString.charAt(0))); + sender.sendMessage(groupString.toString()); + groupString.setLength(0); + continue; + } + } + } + + if (groupValue.contains(",") || sort.containsKey(groupValue.toLowerCase())) + { + if (sort.containsKey(groupValue)) + { + u = sort.get(groupValue); + if (u == null || u.isEmpty()) + { + continue; + } + users.addAll(u); + } + else + { + String[] groups = groupValue.split(","); + for (String g : groups) + { + if (g == null || g.equals("")) + { + continue; + } + u = sort.get(g.trim()); + if (u == null || u.isEmpty()) + { + continue; + } + users.addAll(u); + } + } + } + if (users == null || users.isEmpty()) + { + continue; + } + groupString.append(_("listGroupTag", Util.replaceFormat(group))); + groupString.append(listUsers(users)); + groupString.setCharAt(0, Character.toTitleCase(groupString.charAt(0))); + sender.sendMessage(groupString.toString()); + groupString.setLength(0); } final String[] groups = sort.keySet().toArray(new String[0]); Arrays.sort(groups, String.CASE_INSENSITIVE_ORDER); for (String group : groups) { - final StringBuilder groupString = new StringBuilder(); - groupString.append(_("listGroupTag", Util.replaceFormat(group))); - final List users = sort.get(group); - Collections.sort(users); - boolean first = true; - for (User user : users) - { - if (!first) - { - groupString.append(", "); - } - else - { - first = false; - } - if (user.isAfk()) - { - groupString.append(_("listAfkTag")); - } - if (user.isHidden()) - { - groupString.append(_("listHiddenTag")); - } - user.setDisplayNick(); - groupString.append(user.getDisplayName()); - groupString.append("§f"); - } - sender.sendMessage(groupString.toString()); - } - } - else - { - final List users = new ArrayList(); - for (Player OnlinePlayer : server.getOnlinePlayers()) - { - final User player = ess.getUser(OnlinePlayer); - if (player.isHidden() && !showhidden) + group = group.toLowerCase(); + if (usedGroups.containsKey(group)) { continue; } - users.add(player); + groupString.append(_("listGroupTag", Util.replaceFormat(group))); + final List users = sort.get(group); + groupString.append(listUsers(users)); + groupString.setCharAt(0, Character.toTitleCase(groupString.charAt(0))); + sender.sendMessage(groupString.toString()); + groupString.setLength(0); } - Collections.sort(users); - - final StringBuilder onlineUsers = new StringBuilder(); - onlineUsers.append(_("connectedPlayers")); - boolean first = true; - for (User user : users) - { - if (!first) - { - onlineUsers.append(", "); - } - else - { - first = false; - } - if (user.isAfk()) - { - onlineUsers.append(_("listAfkTag")); - } - if (user.isHidden()) - { - onlineUsers.append(_("listHiddenTag")); - } - user.setDisplayNick(); - onlineUsers.append(user.getDisplayName()); - onlineUsers.append("§f"); - } - sender.sendMessage(onlineUsers.toString()); } } + + private String listUsers(List users) + { + final StringBuilder groupString = new StringBuilder(); + Collections.sort(users); + boolean first = true; + for (User user : users) + { + if (!first) + { + groupString.append(", "); + } + else + { + first = false; + } + if (user.isAfk()) + { + groupString.append(_("listAfkTag")); + } + if (user.isHidden()) + { + groupString.append(_("listHiddenTag")); + } + user.setDisplayNick(); + groupString.append(user.getDisplayName()); + groupString.append("§f"); + } + return groupString.toString(); + } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 6b31ae275..0edc1796e 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -284,9 +284,23 @@ backup: # Set this true to enable permission per warp. per-warp-permission: false -# Sort output of /list command by groups. -sort-list-by-groups: false - +# Sort output of /list command by groups.] +# You are not allowed to have duplicate keys. +list: + # this will merge the two groups owner and co-owner together in the list group "admin", + # make sure you set the groups you merge to "hidden" to prevent duplicate names. + # this accepts a comma separated list, so simply separate the groups you want merged together with a comma. + # like this: + Admin: owner, admin + # Setting the value to hidden will hide these from /list, they will still show on /list + # If a group is already defined as a merged group, then you don't need to set it to hidden, so in this case "admin" is automatically hidden. + # And they will also show in merged groups, like the ones above. + Owner: hidden + # Setting the value to a number limits the group. + # When there are more users online in the group than your limit it will truncate it to a simple, configurable message, + # The message will state how many users are online in that group and how to see a list of users in that group. + default: 20 + # More output to the console. debug: false diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index d9a96bf91..f91589c6f 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=\u00a74disabled\u00a76 for\u00a7c {0}. godEnabledFor=\u00a7aenabled\u00a76 for\u00a7c {0}. godMode=\u00a76God mode\u00a7c {0}\u00a76. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a74You cannot use this item as a hat! hatEmpty=\u00a74You are not wearing a hat. hatFail=\u00a74You must have something to wear in your hand. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 0876a19c4..18e535930 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -138,6 +138,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=zakazan pro {0} godEnabledFor=povolen pro {0} godMode=\u00a77God mode {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cError, you cannot use this item as a hat! hatEmpty=\u00a7cYou are not wearing a hat. hatFail=\u00a7cYou must have something to wear in your hand. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 99ab37172..bb83a37c2 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=deaktiveret for {0} godEnabledFor=aktiveret for {0} godMode=\u00a77Gud mode {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cError, you cannot use this item as a hat! hatEmpty=\u00a7cYou are not wearing a hat. hatFail=\u00a7cYou must have something to wear in your hand. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index f2f0f454f..3e883c40b 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=deaktiviert f\u00fcr {0} godEnabledFor=aktiviert f\u00fcr {0} godMode=\u00a77Unsterblichkeit {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cError, you cannot use this item as a hat! hatEmpty=\u00a7cSie tragen keinen Hut. hatFail=\u00a7cYou must have something to wear in your hand. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index d9a96bf91..f91589c6f 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=\u00a74disabled\u00a76 for\u00a7c {0}. godEnabledFor=\u00a7aenabled\u00a76 for\u00a7c {0}. godMode=\u00a76God mode\u00a7c {0}\u00a76. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a74You cannot use this item as a hat! hatEmpty=\u00a74You are not wearing a hat. hatFail=\u00a74You must have something to wear in your hand. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 398704ed9..8b5846aa9 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Se a dado\u00a7c {0} \u00a76de\u00a7c {1} a\u00a7c {2}\u00a76. godDisabledFor=desactivado para {0} godEnabledFor=activado para {0} godMode=\u00a77Modo de dios {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cNo puedes usar este item como sombrero! hatEmpty=\u00a7cNo estas usando un sombrero. hatFail=\u00a7cDebes tener un item en tu mano para usarlo de sombrero. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index dbe35b5a2..f2a3b2be7 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=poistettu pelaajalta {0} godEnabledFor=laitettu pelaajalle {0} godMode=\u00a77God muoto {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cVirhe, et voi k\u00e4ytt\u00e4\u00e4 t\u00e4t\u00e4 tavaraa hattuna! hatEmpty=\u00a7cYou are not wearing a hat. hatFail=\u00a7cSinulla tulee olla jotain k\u00e4dess\u00e4si, mit\u00e4 k\u00e4ytt\u00e4\u00e4 hattuna. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 77630a4ad..b6b034b62 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=d\u00e9sactiv\u00e9 pour {0} godEnabledFor=activ\u00e9 pour {0} godMode=\u00a77Mode Dieu {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cErreur, vous ne pouvez pas utliser cet item comme chapeau ! hatEmpty=\u00a7cVous ne portez pas de chapeau. hatFail=\u00a7cVous devez avoir quelque chose \u00e0 porter dans votre main. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 6e6253df0..cd2af2066 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=God disabilitato per {0} godEnabledFor=God abilitato per {0} godMode=\u00a77Modalita'' God {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cError, you cannot use this item as a hat! hatEmpty=\u00a7cYou are not wearing a hat. hatFail=\u00a7cYou must have something to wear in your hand. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index cb140acd4..41396db51 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=uitgeschakeld voor {0} godEnabledFor=ingeschakeld voor {0} godMode=\u00a77God modus {0}. +groupNumber={0} on-line, voor de volledige lijst type /{1} {2}. +groupDoesNotExist=\u00a74Er is niemand on-line in deze groep! hatArmor=\u00a7cFout, je kunt dit voorwerp niet als hoed gebruiken. hatEmpty=\u00a7cJe draagt geen hoed. hatFail=\u00a7cJe hebt iets nodig om te dragen als hoed. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 1861e8116..2421853f5 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a77Dales\u00a7c {0} \u00a77of\u00a7c {1} to\u00a7c {2}\u00a77. godDisabledFor=\u00a74wylaczony\u00a77 dla\u00a7c {0}. godEnabledFor=\u00a7awlaczony\u00a77 dla\u00a7c {0}. godMode=\u00a77Godmode\u00a7c {0}\u00a77. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a74Blad, nie mozesz uzyc tego jako kapelusz. hatEmpty=\u00a74Nie nosisz aktualnie kapelusza. hatFail=\u00a74Musisz cos trzymac w dloni. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index bc85e54ee..16e6b5955 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76. godDisabledFor=desativado para {0} godEnabledFor=ativado para {0} godMode=\u00a77Modo Deus {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cDe erro, voce nao pode usar este item como um chapeu! hatEmpty=\u00a7cYou are not wearing a hat. hatFail=\u00a7cVoce deve ter algo para vestir na sua mao. diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index 57c098d16..ca79368eb 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -135,6 +135,8 @@ giveSpawn=\u00a76Ger\u00a7c {0} \u00a76av\u00a7c {1} till\u00a7c {2}\u00a76. godDisabledFor=inaktiverat f\u00f6r {0} godEnabledFor=aktiverat f\u00f6r {0} godMode=\u00a77Od\u00f6dlighet {0}. +groupNumber={0} online, for the full list type /{1} {2} +groupDoesNotExist=\u00a74There's no one online in this group! hatArmor=\u00a7cFel, du kan inte anv\u00e4nda den h\u00e4r saken som en hatt! hatEmpty=\u00a7cDu har inte p\u00e5 dig en hatt. hatFail=\u00a7cDu m\u00e5ste ha n\u00e5gonting att b\u00e4ra i din hand. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index fe8a756a7..5931e1cf6 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -220,7 +220,7 @@ commands: aliases: [elightning,shock,eshock,smite,esmite,strike,estrike,thor,ethor] list: description: List all online players. - usage: / + usage: / [group] aliases: [elist,online,eonline,playerlist,eplayerlist,plist,eplist,who,ewho] mail: description: Manages inter-player, intra-server mail.