Implement AFK messages.

This commit makes it possible for players to set an afk message to detail their reasoning for being away to other players. This can be especially useful for the /msg command; instead of replying the user is afk, it will specify why they are afk so the sender can act further on that information.

Two methods have been added to IUser: getAfkMessage() and setAFKMessage(String).

All locale files have two new messages: userAFKWithReason and userIsAwayWithReason. They all use the messages that do not have the suffix WithReason, i.e. userAFK and userIsAway. Furthermore, the userIsAwayWithReason will not utilise the second parameter, the reason, to prevent spam and unnecessary text in global chat. However, the second parameter ({1}) is available for use in userIsAwayWithReason. userAFKWithReason, which is sent to /msg senders, does use the {1} as it controllable spam by the command sender themselves.

/afk usage is now: /afk [player/message...]
This commit is contained in:
Ali Moghnieh 2016-06-18 17:44:17 +01:00
parent ac4a1565a1
commit 5842b5f51d
29 changed files with 97 additions and 8 deletions

View file

@ -68,7 +68,12 @@ public class SimpleMessageRecipient implements IMessageRecipient {
break;
// When this recipient is AFK, notify the sender. Then, proceed to send the message.
case SUCCESS_BUT_AFK:
sendMessage(tl("userAFK", recipient.getDisplayName()));
// Currently, only IUser can be afk, so we unsafely cast to get the afk message.
if (((IUser) recipient).getAfkMessage() != null) {
sendMessage(tl("userAFKWithReason", recipient.getDisplayName(), ((IUser) recipient).getAfkMessage()));
} else {
sendMessage(tl("userAFK", recipient.getDisplayName()));
}
default:
sendMessage(tl("msgFormat", tl("me"), recipient.getDisplayName(), message));
}