mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-10 18:38:18 +01:00
[Feature] Added an option to spy chat messages from muted players (#1430)
Related to https://github.com/drtshock/Essentials/issues/1420
This commit is contained in:
parent
7fbc721db6
commit
fd63a7df4e
@ -77,7 +77,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
if (user.isMuted()) {
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(tl("voiceSilenced"));
|
||||
LOGGER.info(tl("mutedUserSpeaks", user.getName()));
|
||||
LOGGER.info(tl("mutedUserSpeaks", user.getName(), event.getMessage()));
|
||||
}
|
||||
try {
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
@ -408,28 +408,34 @@ public class EssentialsPlayerListener implements Listener {
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
if (ess.getUser(player).isMuted() && (ess.getSettings().getMuteCommands().contains(cmd) || ess.getSettings().getMuteCommands().contains("*"))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(tl("voiceSilenced"));
|
||||
LOGGER.info(tl("mutedUserSpeaks", player.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PluginCommand pluginCommand = ess.getServer().getPluginCommand(cmd);
|
||||
|
||||
|
||||
if (ess.getSettings().getSocialSpyCommands().contains(cmd) || ess.getSettings().getSocialSpyCommands().contains("*")) {
|
||||
if (pluginCommand == null
|
||||
|| (!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
|
||||
User user = ess.getUser(player);
|
||||
if (!user.isAuthorized("essentials.chat.spy.exempt")) {
|
||||
for (User spyer : ess.getOnlineUsers()) {
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
|
||||
spyer.sendMessage(tl("socialSpyPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
if (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
||||
spyer.sendMessage(tl("socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
}
|
||||
else {
|
||||
spyer.sendMessage(tl("socialSpyPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getUser(player).isMuted() && (ess.getSettings().getMuteCommands().contains(cmd) || ess.getSettings().getMuteCommands().contains("*"))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(tl("voiceSilenced"));
|
||||
LOGGER.info(tl("mutedUserSpeaks", player.getName(), event.getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean broadcast = true; // whether to broadcast the updated activity
|
||||
boolean update = true; // Only modified when the command is afk
|
||||
|
@ -54,6 +54,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
Set<String> getSocialSpyCommands();
|
||||
|
||||
boolean getSocialSpyListenMutedPlayers();
|
||||
|
||||
Set<String> getMuteCommands();
|
||||
|
||||
Map<String, Object> getKit(String name);
|
||||
|
@ -281,6 +281,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return socialSpyCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSocialSpyListenMutedPlayers() {
|
||||
return config.getBoolean("socialspy-listen-muted-players", true);
|
||||
}
|
||||
|
||||
private Set<String> muteCommands = new HashSet<String>();
|
||||
|
||||
private Set<String> _getMuteCommands() {
|
||||
|
@ -95,8 +95,12 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||
if (onlineUser.isSocialSpyEnabled()
|
||||
// Don't send socialspy messages to message sender/receiver to prevent spam
|
||||
&& !onlineUser.equals(senderUser)
|
||||
&& !onlineUser.equals(recipient)) {
|
||||
onlineUser.sendMessage(tl("socialSpyPrefix") + tl("msgFormat", getDisplayName(), recipient.getDisplayName(), message));
|
||||
&& !onlineUser.equals(recipient)) {
|
||||
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
||||
onlineUser.sendMessage(tl("socialMutedSpyPrefix") + tl("msgFormat", getDisplayName(), recipient.getDisplayName(), message));
|
||||
} else {
|
||||
onlineUser.sendMessage(tl("socialSpyPrefix") + tl("msgFormat", getDisplayName(), recipient.getDisplayName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,10 @@ socialspy-commands:
|
||||
- ewhisper
|
||||
- pm
|
||||
|
||||
# Whether the private and public messages from muted players should appear in the social spy.
|
||||
# If so, they will be differentiated from those sent by normal players.
|
||||
socialspy-listen-muted-players: true
|
||||
|
||||
# Mute Commands
|
||||
# These commands will be disabled when a player is muted.
|
||||
# Use '*' to disable every command.
|
||||
|
@ -257,7 +257,7 @@ muteNotify=\u00a7c{0} \u00a76has muted player \u00a7c{1}\u00a76.
|
||||
muteNotifyFor=\u00a7c{0} \u00a76has muted player \u00a7c{1}\u00a76 for\u00a7c {2}\u00a76.
|
||||
mutedPlayer=\u00a76Player\u00a7c {0} \u00a76muted.
|
||||
mutedPlayerFor=\u00a76Player\u00a7c {0} \u00a76muted for\u00a7c {1}\u00a76.
|
||||
mutedUserSpeaks={0} tried to speak, but is muted.
|
||||
mutedUserSpeaks={0} tried to speak, but is muted: {1}
|
||||
nearbyPlayers=\u00a76Players nearby\:\u00a7r {0}
|
||||
negativeBalanceError=\u00a74User is not allowed to have a negative balance.
|
||||
nickChanged=\u00a76Nickname changed.
|
||||
@ -414,6 +414,7 @@ similarWarpExist=\u00a74A warp with a similar name already exists.
|
||||
slimeMalformedSize=\u00a74Malformed size.
|
||||
socialSpy=\u00a76SocialSpy for \u00a7c{0}\u00a76\: \u00a7c{1}
|
||||
socialSpyPrefix=\u00a7f[\u00a76SS\u00a7f] \u00a7r
|
||||
socialSpyMutedPrefix==\u00a7f[\u00a76SS\u00a7f] \u00a77(muted) \u00a7r
|
||||
soloMob=\u00a74That mob likes to be alone.
|
||||
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
||||
spawned=spawned
|
||||
|
Loading…
Reference in New Issue
Block a user