mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 09:15:38 +00:00
Cleaned up /list
This commit is contained in:
parent
6ba96b427d
commit
c63540129f
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Sun Dec 01 12:13:00 CET 2013
|
#Sun Dec 01 12:59:44 CET 2013
|
||||||
build.number=639
|
build.number=644
|
||||||
|
@ -6,58 +6,57 @@ import java.util.List;
|
|||||||
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
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>", aliases = "who")
|
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a]", aliases = "who")
|
||||||
public class Command_list extends TFM_Command
|
public class Command_list extends TFM_Command
|
||||||
{
|
{
|
||||||
private static enum ListFilter
|
private static enum ListFilter
|
||||||
{
|
{
|
||||||
SHOW_ALL, SHOW_ADMINS
|
ALL,
|
||||||
|
ADMINS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (TFM_Util.isFromHostConsole(sender.getName()))
|
if (TFM_Util.isFromHostConsole(sender.getName()))
|
||||||
{
|
{
|
||||||
List<String> player_names = new ArrayList<String>();
|
final List<String> names = new ArrayList<String>();
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
player_names.add(player.getName());
|
names.add(player.getName());
|
||||||
}
|
}
|
||||||
playerMsg("There are " + player_names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(player_names, ", "), ChatColor.WHITE);
|
playerMsg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListFilter listFilter = ListFilter.SHOW_ALL;
|
final ListFilter listFilter = (args.length == 1 && args[0].equals("-a") ? ListFilter.ADMINS : ListFilter.ALL);
|
||||||
if (args.length >= 1)
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase("-a"))
|
|
||||||
{
|
|
||||||
listFilter = ListFilter.SHOW_ADMINS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder onlineStats = new StringBuilder();
|
final StringBuilder onlineStats = new StringBuilder();
|
||||||
StringBuilder onlineUsers = new StringBuilder();
|
final StringBuilder onlineUsers = new StringBuilder();
|
||||||
|
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
|
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
|
||||||
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
|
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
|
||||||
onlineStats.append(ChatColor.BLUE).append(" players online.");
|
onlineStats.append(ChatColor.BLUE).append(" players online.");
|
||||||
|
|
||||||
List<String> player_names = new ArrayList<String>();
|
final List<String> names = new ArrayList<String>();
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player);
|
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player);
|
||||||
|
|
||||||
if (listFilter == ListFilter.SHOW_ADMINS && !userSuperadmin)
|
if (listFilter == ListFilter.ADMINS && !userSuperadmin)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -67,41 +66,43 @@ public class Command_list extends TFM_Command
|
|||||||
if (userSuperadmin)
|
if (userSuperadmin)
|
||||||
{
|
{
|
||||||
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(player.getName());
|
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(player.getName());
|
||||||
if (entry != null && !entry.isSeniorAdmin() && entry.isTelnetAdmin())
|
if (entry == null)
|
||||||
{
|
{
|
||||||
prefix = (ChatColor.DARK_GREEN + "[STA]");
|
prefix = ChatColor.GOLD + "[SA]";
|
||||||
}
|
}
|
||||||
else if (TFM_SuperadminList.isSeniorAdmin(player))
|
else if (entry.isSeniorAdmin())
|
||||||
{
|
{
|
||||||
prefix = (ChatColor.LIGHT_PURPLE + "[SrA]");
|
prefix = ChatColor.LIGHT_PURPLE + "[SrA]";
|
||||||
}
|
}
|
||||||
else if (TFM_SuperadminList.isUserSuperadmin(player))
|
else if (entry.isTelnetAdmin())
|
||||||
{
|
{
|
||||||
prefix = (ChatColor.GOLD + "[SA]");
|
prefix = ChatColor.DARK_GREEN + "[STA]";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TFM_Util.DEVELOPERS.contains(player.getName()))
|
if (TFM_Util.DEVELOPERS.contains(player.getName()))
|
||||||
{
|
{
|
||||||
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
|
prefix = ChatColor.DARK_PURPLE + "[Dev]";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getName().equals("markbyron"))
|
if (player.getName().equals("markbyron"))
|
||||||
{
|
{
|
||||||
prefix = (ChatColor.BLUE + "[Owner]");
|
prefix = ChatColor.BLUE + "[Owner]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (player.isOp())
|
if (player.isOp())
|
||||||
{
|
{
|
||||||
prefix = (ChatColor.RED + "[OP]");
|
prefix = ChatColor.RED + "[OP]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player_names.add(prefix + player.getName() + ChatColor.WHITE);
|
names.add(prefix + player.getName() + ChatColor.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineUsers.append("Connected ").append(listFilter == ListFilter.SHOW_ADMINS ? "admins" : "players").append(": ").append(StringUtils.join(player_names, ", "));
|
onlineUsers.append("Connected ");
|
||||||
|
onlineUsers.append(listFilter == ListFilter.ADMINS ? "admins: " : "players: ");
|
||||||
|
onlineUsers.append(StringUtils.join(names, ", "));
|
||||||
|
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user