Don't eavesdrop when target can eavesdrop.

This commit is contained in:
ryanhamshire 2015-07-16 21:00:53 -07:00
parent fb33b28d5d
commit 2a7755d2a7

View File

@ -454,8 +454,14 @@ class PlayerEventHandler implements Listener
//if a whisper
if(GriefPrevention.instance.config_eavesdrop_whisperCommands.contains(command) && args.length > 1)
{
//if eavesdrop enabled, eavesdrop
if(GriefPrevention.instance.config_whisperNotifications && !event.getPlayer().hasPermission("griefprevention.eavesdrop"))
//determine target player, might be NULL
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();
logMessageBuilder.append("[[").append(event.getPlayer().getName()).append("]] ");
@ -470,15 +476,15 @@ class PlayerEventHandler implements Listener
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
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);
}
}
}
}
//determine target player
Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]);
//ignore feature
if(targetPlayer != null && targetPlayer.isOnline())
{
//if either is ignoring the other, cancel this command