mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Implement better PM social spy. Resolves #27
This commit is contained in:
parent
83b944eb4b
commit
75d1254dda
1 changed files with 19 additions and 1 deletions
|
@ -76,6 +76,20 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
sendMessage(tl("msgFormat", tl("me"), recipient.getDisplayName(), message));
|
sendMessage(tl("msgFormat", tl("me"), recipient.getDisplayName(), message));
|
||||||
|
|
||||||
|
// Better Social Spy
|
||||||
|
User senderUser = getUser();
|
||||||
|
if (senderUser != null // not null if player.
|
||||||
|
&& !senderUser.isAuthorized("essentials.chat.spy.exempt")) {
|
||||||
|
for (User onlineUser : ess.getOnlineUsers()) {
|
||||||
|
if (onlineUser.isSocialSpyEnabled()
|
||||||
|
// Don't send socialspy messages to message sender/receiver to prevent spam
|
||||||
|
&& !onlineUser.equals(senderUser)
|
||||||
|
&& !onlineUser.equals(recipient)) {
|
||||||
|
onlineUser.sendMessage(tl("msgFormat", getDisplayName(), recipient.getDisplayName(), message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If the message was a success, set this sender's reply-recipient to the current recipient.
|
// If the message was a success, set this sender's reply-recipient to the current recipient.
|
||||||
if (messageResponse.isSuccess()) {
|
if (messageResponse.isSuccess()) {
|
||||||
|
@ -90,7 +104,7 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||||
return MessageResponse.UNREACHABLE;
|
return MessageResponse.UNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = this.parent instanceof User ? (User) this.parent : null;
|
User user = getUser();
|
||||||
boolean afk = false;
|
boolean afk = false;
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (user.isIgnoreMsg()
|
if (user.isIgnoreMsg()
|
||||||
|
@ -120,6 +134,10 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||||
this.lastMessageMs = System.currentTimeMillis();
|
this.lastMessageMs = System.currentTimeMillis();
|
||||||
return afk ? MessageResponse.SUCCESS_BUT_AFK : MessageResponse.SUCCESS;
|
return afk ? MessageResponse.SUCCESS_BUT_AFK : MessageResponse.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected User getUser() {
|
||||||
|
return this.parent instanceof User ? (User) this.parent : null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean isReachable() {
|
@Override public boolean isReachable() {
|
||||||
return this.parent.isReachable();
|
return this.parent.isReachable();
|
||||||
|
|
Loading…
Reference in a new issue