From 1d55c4c2bc6e22680e2879b9265f5361efc62188 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 27 Oct 2020 11:08:50 -0700 Subject: [PATCH] fix message spam bug --- .../gmail/nossr50/listeners/PlayerListener.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 6c9793acc..dfd547891 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.experience.ExperienceConfig; +import com.gmail.nossr50.datatypes.chat.ChatChannel; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; @@ -891,13 +892,15 @@ public class PlayerListener implements Listener { return; } - //If the message is allowed we cancel this event to avoid double sending messages - if(plugin.getChatManager().isMessageAllowed(mcMMOPlayer)) { - plugin.getChatManager().processPlayerMessage(mcMMOPlayer, event.getMessage(), event.isAsynchronous()); - event.setCancelled(true); - } else { - //Message wasn't allowed, remove the player from their channel - plugin.getChatManager().setOrToggleChatChannel(mcMMOPlayer, mcMMOPlayer.getChatChannel()); + if(mcMMOPlayer.getChatChannel() != ChatChannel.NONE) { + if(plugin.getChatManager().isMessageAllowed(mcMMOPlayer)) { + //If the message is allowed we cancel this event to avoid double sending messages + plugin.getChatManager().processPlayerMessage(mcMMOPlayer, event.getMessage(), event.isAsynchronous()); + event.setCancelled(true); + } else { + //Message wasn't allowed, remove the player from their channel + plugin.getChatManager().setOrToggleChatChannel(mcMMOPlayer, mcMMOPlayer.getChatChannel()); + } } }