Add setting to use usernames over display names for social spy (#5613)
Co-authored-by: Bobcat00 <Bobcat00@users.noreply.github.com> Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
6b521e78a6
commit
622c8147a9
|
@ -640,12 +640,13 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||||
|| (!pluginCommand.getName().equals("msg") && !pluginCommand.getName().equals("r"))) { // /msg and /r are handled in SimpleMessageRecipient
|
|| (!pluginCommand.getName().equals("msg") && !pluginCommand.getName().equals("r"))) { // /msg and /r are handled in SimpleMessageRecipient
|
||||||
final User user = ess.getUser(player);
|
final User user = ess.getUser(player);
|
||||||
if (!user.isAuthorized("essentials.chat.spy.exempt")) {
|
if (!user.isAuthorized("essentials.chat.spy.exempt")) {
|
||||||
|
final String playerName = ess.getSettings().isSocialSpyDisplayNames() ? player.getDisplayName() : player.getName();
|
||||||
for (final User spyer : ess.getOnlineUsers()) {
|
for (final User spyer : ess.getOnlineUsers()) {
|
||||||
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
|
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
|
||||||
final Component base = (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers())
|
final Component base = (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers())
|
||||||
? spyer.tlComponent("socialSpyMutedPrefix")
|
? spyer.tlComponent("socialSpyMutedPrefix")
|
||||||
: spyer.tlComponent("socialSpyPrefix");
|
: spyer.tlComponent("socialSpyPrefix");
|
||||||
spyer.sendComponent(base.append(AdventureUtil.legacyToAdventure(player.getDisplayName())).append(Component.text(": " + event.getMessage())));
|
spyer.sendComponent(base.append(AdventureUtil.legacyToAdventure(playerName)).append(Component.text(": " + event.getMessage())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@ public interface ISettings extends IConf {
|
||||||
|
|
||||||
boolean isSocialSpyMessages();
|
boolean isSocialSpyMessages();
|
||||||
|
|
||||||
|
boolean isSocialSpyDisplayNames();
|
||||||
|
|
||||||
Set<String> getMuteCommands();
|
Set<String> getMuteCommands();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
|
@ -456,6 +456,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return config.getBoolean("socialspy-messages", true);
|
return config.getBoolean("socialspy-messages", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSocialSpyDisplayNames() {
|
||||||
|
return config.getBoolean("socialspy-uses-displaynames", true);
|
||||||
|
}
|
||||||
|
|
||||||
private Set<String> _getMuteCommands() {
|
private Set<String> _getMuteCommands() {
|
||||||
final Set<String> muteCommands = new HashSet<>();
|
final Set<String> muteCommands = new HashSet<>();
|
||||||
if (config.isList("mute-commands")) {
|
if (config.isList("mute-commands")) {
|
||||||
|
|
|
@ -121,15 +121,17 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||||
// Dont spy on chats involving socialspy exempt players
|
// Dont spy on chats involving socialspy exempt players
|
||||||
&& !senderUser.isAuthorized("essentials.chat.spy.exempt")
|
&& !senderUser.isAuthorized("essentials.chat.spy.exempt")
|
||||||
&& recipientUser != null && !recipientUser.isAuthorized("essentials.chat.spy.exempt")) {
|
&& recipientUser != null && !recipientUser.isAuthorized("essentials.chat.spy.exempt")) {
|
||||||
|
final String senderName = ess.getSettings().isSocialSpyDisplayNames() ? getDisplayName() : getName();
|
||||||
|
final String recipientName = ess.getSettings().isSocialSpyDisplayNames() ? recipient.getDisplayName() : recipient.getName();
|
||||||
for (final User onlineUser : ess.getOnlineUsers()) {
|
for (final User onlineUser : ess.getOnlineUsers()) {
|
||||||
if (onlineUser.isSocialSpyEnabled()
|
if (onlineUser.isSocialSpyEnabled()
|
||||||
// Don't send socialspy messages to message sender/receiver to prevent spam
|
// Don't send socialspy messages to message sender/receiver to prevent spam
|
||||||
&& !onlineUser.equals(senderUser)
|
&& !onlineUser.equals(senderUser)
|
||||||
&& !onlineUser.equals(recipient)) {
|
&& !onlineUser.equals(recipient)) {
|
||||||
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
||||||
onlineUser.sendComponent(AdventureUtil.miniMessage().deserialize(tlSender("socialSpyMutedPrefix") + tlLiteral("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message)));
|
onlineUser.sendComponent(AdventureUtil.miniMessage().deserialize(tlSender("socialSpyMutedPrefix") + tlLiteral("socialSpyMsgFormat", senderName, recipientName, message)));
|
||||||
} else {
|
} else {
|
||||||
onlineUser.sendComponent(AdventureUtil.miniMessage().deserialize(tlLiteral("socialSpyPrefix") + tlLiteral("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message)));
|
onlineUser.sendComponent(AdventureUtil.miniMessage().deserialize(tlLiteral("socialSpyPrefix") + tlLiteral("socialSpyMsgFormat", senderName, recipientName, message)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,6 +213,10 @@ socialspy-listen-muted-players: true
|
||||||
# If false, social spy will only monitor commands from the list above.
|
# If false, social spy will only monitor commands from the list above.
|
||||||
socialspy-messages: true
|
socialspy-messages: true
|
||||||
|
|
||||||
|
# Whether social spy should use formatted display names which may include color.
|
||||||
|
# If false, social spy will use only the actual player names.
|
||||||
|
socialspy-uses-displaynames: true
|
||||||
|
|
||||||
# The following settings listen for when a player changes worlds.
|
# 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.
|
# If you use another plugin to control speed and flight, you should change these to false.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue