New permission: essentials.seen.banreason

With this permission players can see why a user was banned, in /seen.
This commit is contained in:
KHobbits 2012-03-12 15:00:44 +00:00
parent adffbab678
commit 2da802d4b7

View File

@ -16,6 +16,17 @@ 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);
}
@Override
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"));
}
protected void seen (final Server server, final CommandSender sender, final String[] args, final boolean show) throws Exception
{ {
if (args.length < 1) if (args.length < 1)
{ {
@ -23,20 +34,20 @@ public class Commandseen extends EssentialsCommand
} }
try try
{ {
User user = getPlayer(server, args, 0); User player = getPlayer(server, args, 0);
sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin()))); sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
} }
catch (NoSuchFieldException e) catch (NoSuchFieldException e)
{ {
User user = ess.getOfflineUser(args[0]); User player = ess.getOfflineUser(args[0]);
if (user == null) if (player == null)
{ {
throw new Exception(_("playerNotFound")); throw new Exception(_("playerNotFound"));
} }
sender.sendMessage(_("seenOffline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogout()))); sender.sendMessage(_("seenOffline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogout())));
if (user.isBanned()) if (player.isBanned())
{ {
sender.sendMessage(_("whoisBanned", user.getBanReason())); sender.sendMessage(_("whoisBanned", show ? player.getBanReason() : _("true")));
} }
} }
} }