usage = "[-p page] [player]", desc = "Tell information about a player",
flags = "op:", min = 0, max = 1)
@CommandPermissions({"commandbook.whois"})
public void whois(CommandContext args, CommandSender sender) throws CommandException {
OfflinePlayer offline;
if (args.argsLength() == 0) {
offline = PlayerUtil.checkPlayer(sender);
} else {
try {
offline = InputUtil.PlayerParser.matchSinglePlayer(sender, args.getString(0));
} catch (CommandException e) {
if (args.hasFlag('o')) {
offline = CommandBook.server().getOfflinePlayer(args.getString(0));
} else {
throw e;
}
}
if (offline != sender) {
CommandBook.inst().checkPermission(sender, "commandbook.whois.other");
}
}
PlayerWhoisEvent event = new PlayerWhoisEvent(offline, sender);
event.addWhoisInformation("UUID", offline.getUniqueId());
if (offline instanceof Player) {
Player player = (Player) offline;
event.addWhoisInformation("Display name", player.getDisplayName());
event.addWhoisInformation("Entity ID #", player.getEntityId());
event.addWhoisInformation("Current vehicle", player.getVehicle());
if (CommandBook.inst().hasPermission(sender, "commandbook.ip-address")) {
event.addWhoisInformation("Address", player.getAddress().toString());
}
event.addWhoisInformation("Game mode", player.getGameMode());
}
Location bedSpawn = offline.getBedSpawnLocation();
if (bedSpawn != null) {
event.addWhoisInformation("Bed spawn location",
ChatUtil.toFriendlyString(bedSpawn));
} else {
event.addWhoisInformation(null, "No bed spawn location");
}
if (offline.hasPlayedBefore()) {
event.addWhoisInformation(null, "First joined: " + dateFormat.format(offline.getFirstPlayed())
+ "; Last joined: " + dateFormat.format(offline.getLastPlayed()));
}
CommandBook.callEvent(event);
List<String> results = new ArrayList<String>(event.getTaglessWhoisInformation());
for (Map.Entry<String, String> entry : event.getTaggedWhoisInformation().entrySet()) {
results.add(entry.getKey() + ": " + entry.getValue());
}
new PaginatedResult<String>("Name: " + offline.getName()) {
@Override
public String format(String entry) {
return entry;
}