Added /list -a. Resolves #194

This commit is contained in:
unknown 2014-06-22 18:07:02 +02:00
parent 499472a126
commit 1fb14ca1dd
2 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Sun Jun 22 17:51:33 CEST 2014 #Sun Jun 22 18:05:43 CEST 2014
build.number=871 build.number=876

View File

@ -15,13 +15,14 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH) @CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a]", aliases = "who") @CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i]", aliases = "who")
public class Command_list extends TFM_Command public class Command_list extends TFM_Command
{ {
private static enum ListFilter private static enum ListFilter
{ {
ALL, ALL,
ADMINS; ADMINS,
IMPOSTORS;
} }
@Override @Override
@ -43,7 +44,26 @@ public class Command_list extends TFM_Command
return true; return true;
} }
final Command_list.ListFilter listFilter = (args.length == 1 && args[0].equals("-a") ? Command_list.ListFilter.ADMINS : Command_list.ListFilter.ALL); final ListFilter listFilter;
if (args.length == 1)
{
if ("-a".equals(args[0]))
{
listFilter = ListFilter.ADMINS;
}
else if ("-i".equals(args[0]))
{
listFilter = ListFilter.IMPOSTORS;
}
else
{
return false;
}
}
else
{
listFilter = ListFilter.ALL;
}
final StringBuilder onlineStats = new StringBuilder(); final StringBuilder onlineStats = new StringBuilder();
final StringBuilder onlineUsers = new StringBuilder(); final StringBuilder onlineUsers = new StringBuilder();
@ -55,9 +75,12 @@ public class Command_list extends TFM_Command
final List<String> names = new ArrayList<String>(); final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
final boolean userSuperadmin = TFM_AdminList.isSuperAdmin(player); if (listFilter == ListFilter.ADMINS && !TFM_AdminList.isSuperAdmin(player))
{
continue;
}
if (listFilter == Command_list.ListFilter.ADMINS && !userSuperadmin) if (listFilter == ListFilter.IMPOSTORS && !TFM_AdminList.isAdminImpostor(player))
{ {
continue; continue;
} }