}
public void messagePlayer(CommandSender sender, String target, String message) throws CommandException {
CommandSender receiver =
InputUtil.PlayerParser.matchPlayerOrConsole(sender, target);
UserSession receiverSession = sessions.getSession(UserSession.class, receiver);
AFKComponent.AFKSession afkSession = sessions.getSession(AFKComponent.AFKSession.class, receiver);
if (afkSession.isAFK()) {
String status = afkSession.getIdleStatus();
sender.sendMessage(config.pmColor + ChatUtil.toColoredName(receiver, config.pmColor) + " is afk. "
+ "They might not see your message."
+ (status.trim().length() == 0 ? "" : " (" + status + ")"));
}
receiver.sendMessage(config.pmColor + "(From "
+ ChatUtil.toColoredName(sender, config.pmColor) + "): "
+ config.pmTextColor + message);
sender.sendMessage(config.pmColor + "(To "
+ ChatUtil.toColoredName(receiver, config.pmColor) + "): "
+ config.pmTextColor + message);
CommandBook.logger().info("(PM) " + ChatUtil.toColoredName(sender, ChatColor.RESET) + " -> "
+ ChatUtil.toColoredName(receiver, ChatColor.RESET) + ": " + message);
sessions.getSession(UserSession.class, sender).setLastRecipient(receiver);
// If the receiver hasn't had any player talk to them yet or hasn't
// send a message, then we add it to the receiver's last message target
// so s/he can /reply easily
receiverSession.setNewLastRecipient(sender);
}