Update seen to show better data for vanished users:

New Perm: essentials.seen.extra - Shows some extra information for staff
This commit is contained in:
KHobbits 2012-04-04 01:18:21 +01:00
parent 932de33349
commit e52996609a
2 changed files with 19 additions and 4 deletions

View File

@ -453,6 +453,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setHidden(final boolean hidden) public void setHidden(final boolean hidden)
{ {
this.hidden = hidden; this.hidden = hidden;
if (hidden == true)
{
setLastLogout(getLastOnlineActivity());
}
} }
//Returns true if status expired during this check //Returns true if status expired during this check

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util; import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,16 +18,16 @@ public class Commandseen extends EssentialsCommand
@Override @Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {
seen(server, sender, args, true); seen(server, sender, args, true, true);
} }
@Override @Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{ {
seen(server, user, args, user.isAuthorized("essentials.seen.banreason")); seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"));
} }
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean show) throws Exception protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra) throws Exception
{ {
if (args.length < 1) if (args.length < 1)
{ {
@ -37,6 +38,10 @@ public class Commandseen extends EssentialsCommand
User player = getPlayer(server, args, 0); User player = getPlayer(server, args, 0);
player.setDisplayNick(); player.setDisplayNick();
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin()))); sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
if (extra)
{
sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
}
} }
catch (NoSuchFieldException e) catch (NoSuchFieldException e)
{ {
@ -49,7 +54,13 @@ public class Commandseen extends EssentialsCommand
sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout()))); sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout())));
if (player.isBanned()) if (player.isBanned())
{ {
sender.sendMessage(_("whoisBanned", show ? player.getBanReason() : _("true"))); sender.sendMessage(_("whoisBanned", showBan ? player.getBanReason() : _("true")));
}
if (extra)
{
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
final Location loc = player.getLastLocation();
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
} }
} }
} }