mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
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
|
||||
final User user = ess.getUser(player);
|
||||
if (!user.isAuthorized("essentials.chat.spy.exempt")) {
|
||||
final String playerName = ess.getSettings().isSocialSpyDisplayNames() ? player.getDisplayName() : player.getName();
|
||||
for (final User spyer : ess.getOnlineUsers()) {
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
|
||||
final Component base = (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers())
|
||||
? spyer.tlComponent("socialSpyMutedPrefix")
|
||||
: 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 isSocialSpyDisplayNames();
|
||||
|
||||
Set<String> getMuteCommands();
|
||||
|
||||
@Deprecated
|
||||
|
@ -456,6 +456,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("socialspy-messages", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSocialSpyDisplayNames() {
|
||||
return config.getBoolean("socialspy-uses-displaynames", true);
|
||||
}
|
||||
|
||||
private Set<String> _getMuteCommands() {
|
||||
final Set<String> muteCommands = new HashSet<>();
|
||||
if (config.isList("mute-commands")) {
|
||||
|
@ -121,15 +121,17 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||
// Dont spy on chats involving socialspy exempt players
|
||||
&& !senderUser.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()) {
|
||||
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.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 {
|
||||
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.
|
||||
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.
|
||||
# If you use another plugin to control speed and flight, you should change these to false.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user