Softmute limits chat commands and whispers.

No more chat commands for soft-muted players.  And they may send
whispers only to other soft-muted players.
This commit is contained in:
ryanhamshire 2015-11-24 10:54:23 -08:00
parent 718c3ab407
commit 37851aacbf

View File

@ -498,6 +498,13 @@ class PlayerEventHandler implements Listener
//determine target player, might be NULL //determine target player, might be NULL
Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]); Player targetPlayer = GriefPrevention.instance.getServer().getPlayer(args[1]);
//softmute feature
if(this.dataStore.isSoftMuted(player.getUniqueId()) && targetPlayer != null && !this.dataStore.isSoftMuted(targetPlayer.getUniqueId()))
{
event.setCancelled(true);
return;
}
//if eavesdrop enabled and sender doesn't have the eavesdrop permission, eavesdrop //if eavesdrop enabled and sender doesn't have the eavesdrop permission, eavesdrop
if(GriefPrevention.instance.config_whisperNotifications && !player.hasPermission("griefprevention.eavesdrop")) if(GriefPrevention.instance.config_whisperNotifications && !player.hasPermission("griefprevention.eavesdrop"))
{ {
@ -555,6 +562,13 @@ class PlayerEventHandler implements Listener
return; return;
} }
//soft mute for chat slash commands
if(category == CommandCategory.Chat && this.dataStore.isSoftMuted(player.getUniqueId()))
{
event.setCancelled(true);
return;
}
//if the slash command used is in the list of monitored commands, treat it like a chat message (see above) //if the slash command used is in the list of monitored commands, treat it like a chat message (see above)
boolean isMonitoredCommand = (category == CommandCategory.Chat || category == CommandCategory.Whisper); boolean isMonitoredCommand = (category == CommandCategory.Chat || category == CommandCategory.Whisper);
if(isMonitoredCommand) if(isMonitoredCommand)