use of com.earth2me.essentials.Console in project Essentials by drtshock.
the class SimpleMessageRecipient method onReceiveMessage.
@Override
public MessageResponse onReceiveMessage(IMessageRecipient sender, String message) {
if (!isReachable()) {
return MessageResponse.UNREACHABLE;
}
User user = getUser(this);
boolean afk = false;
if (user != null) {
if (user.isIgnoreMsg() && !(sender instanceof Console)) {
// Console must never be ignored.
return MessageResponse.MESSAGES_IGNORED;
}
afk = user.isAfk();
// Check whether this recipient ignores the sender, only if the sender is not the console.
if (sender instanceof IUser && user.isIgnoredPlayer((IUser) sender)) {
return MessageResponse.SENDER_IGNORED;
}
}
// Display the formatted message to this recipient.
sendMessage(tl("msgFormat", sender.getDisplayName(), tl("me"), message));
if (ess.getSettings().isLastMessageReplyRecipient()) {
// If this recipient doesn't have a reply recipient, initiate by setting the first
// message sender to this recipient's replyRecipient.
long timeout = ess.getSettings().getLastMessageReplyRecipientTimeout() * 1000;
if (getReplyRecipient() == null || !getReplyRecipient().isReachable() || System.currentTimeMillis() - this.lastMessageMs > timeout) {
setReplyRecipient(sender);
}
} else {
// Old message functionality, always set the reply recipient to the last person who sent us a message.
setReplyRecipient(sender);
}
this.lastMessageMs = System.currentTimeMillis();
return afk ? MessageResponse.SUCCESS_BUT_AFK : MessageResponse.SUCCESS;
}
use of com.earth2me.essentials.Console in project Essentials by EssentialsX.
the class SimpleMessageRecipient method onReceiveMessage.
@Override
public MessageResponse onReceiveMessage(IMessageRecipient sender, String message) {
if (!isReachable()) {
return MessageResponse.UNREACHABLE;
}
User user = getUser(this);
boolean afk = false;
if (user != null) {
if (user.isIgnoreMsg() && !(sender instanceof Console)) {
// Console must never be ignored.
return MessageResponse.MESSAGES_IGNORED;
}
afk = user.isAfk();
// Check whether this recipient ignores the sender, only if the sender is not the console.
if (sender instanceof IUser && user.isIgnoredPlayer((IUser) sender)) {
return MessageResponse.SENDER_IGNORED;
}
}
// Display the formatted message to this recipient.
sendMessage(tl("msgFormat", sender.getDisplayName(), tl("me"), message));
if (ess.getSettings().isLastMessageReplyRecipient()) {
// If this recipient doesn't have a reply recipient, initiate by setting the first
// message sender to this recipient's replyRecipient.
long timeout = ess.getSettings().getLastMessageReplyRecipientTimeout() * 1000;
if (getReplyRecipient() == null || !getReplyRecipient().isReachable() || System.currentTimeMillis() - this.lastMessageMs > timeout) {
setReplyRecipient(sender);
}
} else {
// Old message functionality, always set the reply recipient to the last person who sent us a message.
setReplyRecipient(sender);
}
this.lastMessageMs = System.currentTimeMillis();
return afk ? MessageResponse.SUCCESS_BUT_AFK : MessageResponse.SUCCESS;
}