Don't eavesdrop when target can eavesdrop.
This commit is contained in:
parent
fb33b28d5d
commit
2a7755d2a7
|
|
@ -454,8 +454,14 @@ class PlayerEventHandler implements Listener
|
||||||
//if a whisper
|
//if a whisper
|
||||||
if(GriefPrevention.instance.config_eavesdrop_whisperCommands.contains(command) && args.length > 1)
|
if(GriefPrevention.instance.config_eavesdrop_whisperCommands.contains(command) && args.length > 1)
|
||||||
{
|
{
|
||||||
//if eavesdrop enabled, eavesdrop
|
//determine target player, might be NULL
|
||||||
if(GriefPrevention.instance.config_whisperNotifications && !event.getPlayer().hasPermission("griefprevention.eavesdrop"))
|
Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]);
|
||||||
|
|
||||||
|
//if eavesdrop enabled and sender doesn't have the eavesdrop permission, eavesdrop
|
||||||
|
if(GriefPrevention.instance.config_whisperNotifications && !player.hasPermission("griefprevention.eavesdrop"))
|
||||||
|
{
|
||||||
|
//except for when the recipient has eavesdrop permission
|
||||||
|
if(targetPlayer == null || targetPlayer.hasPermission("griefprevention.eavesdrop"))
|
||||||
{
|
{
|
||||||
StringBuilder logMessageBuilder = new StringBuilder();
|
StringBuilder logMessageBuilder = new StringBuilder();
|
||||||
logMessageBuilder.append("[[").append(event.getPlayer().getName()).append("]] ");
|
logMessageBuilder.append("[[").append(event.getPlayer().getName()).append("]] ");
|
||||||
|
|
@ -470,15 +476,15 @@ class PlayerEventHandler implements Listener
|
||||||
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
|
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
|
||||||
for(Player onlinePlayer : players)
|
for(Player onlinePlayer : players)
|
||||||
{
|
{
|
||||||
if(onlinePlayer.hasPermission("griefprevention.eavesdrop") && !onlinePlayer.getName().equalsIgnoreCase(args[1]))
|
if(onlinePlayer.hasPermission("griefprevention.eavesdrop") && !onlinePlayer.equals(targetPlayer))
|
||||||
{
|
{
|
||||||
onlinePlayer.sendMessage(ChatColor.GRAY + logMessage);
|
onlinePlayer.sendMessage(ChatColor.GRAY + logMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//determine target player
|
//ignore feature
|
||||||
Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]);
|
|
||||||
if(targetPlayer != null && targetPlayer.isOnline())
|
if(targetPlayer != null && targetPlayer.isOnline())
|
||||||
{
|
{
|
||||||
//if either is ignoring the other, cancel this command
|
//if either is ignoring the other, cancel this command
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user