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

@ -50,6 +50,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
private boolean enderSee = false;
private transient long teleportInvulnerabilityTimestamp = 0;
private boolean ignoreMsg = false;
private String afkMessage;
public User(final Player base, final IEssentials ess) {
super(base, ess);
@ -417,6 +418,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
afkPosition = this.getLocation();
} else if (!set && isAfk()) {
afkPosition = null;
this.afkMessage = null;
}
if (ess.getSettings().isAfkListName()) {
if(set) {
@ -750,4 +752,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
@Override public void setReplyRecipient(IMessageRecipient recipient) {
this.messageRecipient.setReplyRecipient(recipient);
}
@Override
public String getAfkMessage() {
return this.afkMessage;
}
@Override
public void setAfkMessage(String message) {
if (isAfk()) {
this.afkMessage = message;
}
}
}