Show afk warning when pm'ing afk players.

Fix vanished leak on player matching.
This commit is contained in:
KHobbits 2013-01-20 21:52:23 +00:00
parent 50dca9abf5
commit 443a317184
14 changed files with 38 additions and 14 deletions

View File

@ -17,15 +17,15 @@ public class Commandmsg extends EssentialsCommand
{ {
super("msg"); super("msg");
} }
@Override @Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{ {
if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty()) if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty())
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
String message = getFinalArg(args, 1); String message = getFinalArg(args, 1);
if (sender instanceof Player) if (sender instanceof Player)
{ {
@ -40,12 +40,12 @@ public class Commandmsg extends EssentialsCommand
{ {
message = Util.replaceFormat(message); message = Util.replaceFormat(message);
} }
final String translatedMe = _("me"); final String translatedMe = _("me");
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo(); final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
if (args[0].equalsIgnoreCase(Console.NAME)) if (args[0].equalsIgnoreCase(Console.NAME))
{ {
sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message)); sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message));
@ -55,14 +55,14 @@ public class Commandmsg extends EssentialsCommand
Console.getConsoleReplyTo().setReplyTo(sender); Console.getConsoleReplyTo().setReplyTo(sender);
return; return;
} }
final List<Player> matchedPlayers = server.matchPlayer(args[0]); final List<Player> matchedPlayers = server.matchPlayer(args[0]);
if (matchedPlayers.isEmpty()) if (matchedPlayers.isEmpty())
{ {
throw new Exception(_("playerNotFound")); throw new Exception(_("playerNotFound"));
} }
int i = 0; int i = 0;
for (Player matchedPlayer : matchedPlayers) for (Player matchedPlayer : matchedPlayers)
{ {
@ -76,17 +76,28 @@ public class Commandmsg extends EssentialsCommand
{ {
throw new Exception(_("playerNotFound")); throw new Exception(_("playerNotFound"));
} }
for (Player matchedPlayer : matchedPlayers) for (Player matchedPlayer : matchedPlayers)
{ {
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
final User matchedUser = ess.getUser(matchedPlayer); final User matchedUser = ess.getUser(matchedPlayer);
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
if (sender instanceof Player && matchedUser.isHidden())
{
continue;
}
if (matchedUser.isAfk())
{
sender.sendMessage(_("userAFK", matchedPlayer.getDisplayName()));
}
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
if (sender instanceof Player && matchedUser.isIgnoredPlayer(ess.getUser(sender)))
{ {
continue; continue;
} }
matchedPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message)); matchedPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message));
replyTo.setReplyTo(ess.getUser(matchedPlayer)); replyTo.setReplyTo(matchedUser);
ess.getUser(matchedPlayer).setReplyTo(sender); ess.getUser(matchedPlayer).setReplyTo(sender);
} }
} }

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -496,3 +496,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond

View File

@ -493,3 +493,4 @@ muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1} messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond