From 37851aacbf8d507d334652250b24ec20844f58bf Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Tue, 24 Nov 2015 10:54:23 -0800 Subject: [PATCH] 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. --- .../GriefPrevention/PlayerEventHandler.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index c8afd19..2a5c1e6 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -498,7 +498,14 @@ class PlayerEventHandler implements Listener //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 + //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(GriefPrevention.instance.config_whisperNotifications && !player.hasPermission("griefprevention.eavesdrop")) { //except for when the recipient has eavesdrop permission @@ -524,8 +531,8 @@ class PlayerEventHandler implements Listener } } } - - //ignore feature + + //ignore feature if(targetPlayer != null && targetPlayer.isOnline()) { //if either is ignoring the other, cancel this command @@ -555,6 +562,13 @@ class PlayerEventHandler implements Listener 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) boolean isMonitoredCommand = (category == CommandCategory.Chat || category == CommandCategory.Whisper); if(isMonitoredCommand)