Added /list [group] and some more detailed configuration regarding /list

This commit is contained in:
kukelekuuk00 2013-03-13 16:49:00 +01:00 committed by KHobbits
parent ce51a07bf1
commit 32099a4109
18 changed files with 221 additions and 87 deletions

View File

@ -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<String, Object> getListGroupConfig();
}

View File

@ -258,6 +258,7 @@ public class Settings implements ISettings
return socialspyCommands;
}
@Override
public Set<String> 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<String, Object> getListGroupConfig()
{
return config.getBoolean("sort-list-by-groups", true);
if (config.isConfigurationSection("list"))
{
return config.getConfigurationSection("list").getValues(false);
}
return new HashMap<String, Object>();
}
@Override

View File

@ -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<String, List<User>> sort = new HashMap<String, List<User>>();
for (Player OnlinePlayer : server.getOnlinePlayers())
{
Map<String, List<User>> sort = new HashMap<String, List<User>>();
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<User> list = sort.get(group);
if (list == null)
{
list = new ArrayList<User>();
sort.put(group, list);
}
list.add(player);
}
final StringBuilder groupString = new StringBuilder();
Set<String> keys = ess.getSettings().getListGroupConfig().keySet();
if (args.length > 0)
{
final List<User> users = new ArrayList<User>();
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<User> u = sort.get(g.trim());
if (u == null || u.isEmpty())
{
continue;
}
users.addAll(u);
}
}
}
List<User> 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<String, String> 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<User> list = sort.get(group);
if (list == null)
if (Util.isInt(groupValue))
{
list = new ArrayList<User>();
sort.put(group, list);
userLimit = true;
}
list.add(player);
group = group.toLowerCase();
final List<User> users = new ArrayList<User>();
List<User> 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<User> 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<User> users = new ArrayList<User>();
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<User> 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<User> 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();
}
}

View File

@ -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 <groupname>
# 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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -220,7 +220,7 @@ commands:
aliases: [elightning,shock,eshock,smite,esmite,strike,estrike,thor,ethor]
list:
description: List all online players.
usage: /<command>
usage: /<command> [group]
aliases: [elist,online,eonline,playerlist,eplayerlist,plist,eplist,who,ewho]
mail:
description: Manages inter-player, intra-server mail.