1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.api.server.ICommandSender;
import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.user.UserData.TimestampType;
import com.earth2me.essentials.utils.DateUtil;
import lombok.Cleanup;
import org.bukkit.command.CommandSender;
public class Commandseen extends EssentialsCommand
{
@Override
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
{
seen(sender,args,true);
}
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
seen(user,args,Permissions.SEEN_BANREASON.isAuthorized(user));
}
protected void seen (final CommandSender sender, final String[] args, final boolean show) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
try
{
IUser u = getPlayer(args, 0);
sender.sendMessage(_("seenOnline", u.getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGIN))));
}
catch (NoSuchFieldException e)
{
@Cleanup
IUser u = ess.getUser(args[0]);
u.acquireReadLock();
if (u == null)
{
throw new Exception(_("playerNotFound"));
}
sender.sendMessage(_("seenOffline", u.getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGOUT))));
if (u.isBanned())
{
sender.sendMessage(_("whoisBanned", show ? u.getData().getBan().getReason() : _("true")));
}
}
}
}
|