Add config option to disable message social spy (#3910)

Adds a config option to allow to prevent socialspy from reading private messages. Useful if all you want from social spy is to read commands defined in the list.

Closes #1095.
This commit is contained in:
Josh Roy 2021-02-05 14:02:26 -05:00 committed by GitHub
parent cb168b0c8a
commit 500edb7860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 15 deletions

View File

@ -59,6 +59,8 @@ public interface ISettings extends IConf {
boolean getSocialSpyListenMutedPlayers();
boolean isSocialSpyMessages();
Set<String> getMuteCommands();
/**

View File

@ -379,6 +379,11 @@ public class Settings implements net.ess3.api.ISettings {
return config.getBoolean("socialspy-listen-muted-players", true);
}
@Override
public boolean isSocialSpyMessages() {
return config.getBoolean("socialspy-messages", true);
}
private Set<String> _getMuteCommands() {
final Set<String> muteCommands = new HashSet<>();
if (config.isList("mute-commands")) {

View File

@ -97,21 +97,23 @@ public class SimpleMessageRecipient implements IMessageRecipient {
sendMessage(tl("msgFormat", tl("meSender"), recipient.getDisplayName(), message));
// Better Social Spy
final User senderUser = getUser(this);
final User recipientUser = getUser(recipient);
if (senderUser != null // not null if player.
// Dont spy on chats involving socialspy exempt players
&& !senderUser.isAuthorized("essentials.chat.spy.exempt")
&& recipientUser != null && !recipientUser.isAuthorized("essentials.chat.spy.exempt")) {
for (final 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)) {
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
onlineUser.sendMessage(tl("socialMutedSpyPrefix") + tl("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message));
} else {
onlineUser.sendMessage(tl("socialSpyPrefix") + tl("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message));
if (ess.getSettings().isSocialSpyMessages()) {
final User senderUser = getUser(this);
final User recipientUser = getUser(recipient);
if (senderUser != null // not null if player.
// Dont spy on chats involving socialspy exempt players
&& !senderUser.isAuthorized("essentials.chat.spy.exempt")
&& recipientUser != null && !recipientUser.isAuthorized("essentials.chat.spy.exempt")) {
for (final 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)) {
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
onlineUser.sendMessage(tl("socialMutedSpyPrefix") + tl("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message));
} else {
onlineUser.sendMessage(tl("socialSpyPrefix") + tl("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message));
}
}
}
}

View File

@ -201,6 +201,10 @@ socialspy-commands:
# If so, they will be differentiated from those sent by normal players.
socialspy-listen-muted-players: true
# Whether social spy should spy on private messages or just the commands from the list above.
# If false, social spy will only monitor commands from the list above.
socialspy-messages: true
# The following settings listen for when a player changes worlds.
# If you use another plugin to control speed and flight, you should change these to false.