From 5c18fe940d27624a7653b508c60a071fa883904b Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 2 Jun 2020 21:31:52 +1000 Subject: [PATCH] You shouldn't be able to speak while pending /pass verification, fixes #535 (Thanks MasterlazorX) --- MCGalaxy/Commands/Chat/MessageCmd.cs | 10 +--------- MCGalaxy/Player/Player.Handlers.cs | 2 +- MCGalaxy/Player/Player.cs | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/MCGalaxy/Commands/Chat/MessageCmd.cs b/MCGalaxy/Commands/Chat/MessageCmd.cs index 7bc36d1f9..f125d10d4 100644 --- a/MCGalaxy/Commands/Chat/MessageCmd.cs +++ b/MCGalaxy/Commands/Chat/MessageCmd.cs @@ -43,15 +43,7 @@ namespace MCGalaxy.Commands.Chatting { } public static bool CanSpeak(Player p, string cmd) { - if (p.IsConsole) return true; - - if (p.muted) { - p.Message("Cannot use %T/{0} %Swhile muted.", cmd); return false; - } - if (Server.chatmod && !p.voice) { - p.Message("Cannot use %T/{0} %Swhile chat moderation is on without %T/Voice%S.", cmd); return false; - } - return true; + return p.CheckCanSpeak("use %T/" + cmd); } } diff --git a/MCGalaxy/Player/Player.Handlers.cs b/MCGalaxy/Player/Player.Handlers.cs index db1d4c605..0c3ff10da 100644 --- a/MCGalaxy/Player/Player.Handlers.cs +++ b/MCGalaxy/Player/Player.Handlers.cs @@ -442,7 +442,7 @@ namespace MCGalaxy { if (ZSGame.Instance.HandlesChatMessage(this, text)) return; // Put this after vote collection so that people can vote even when chat is moderated - if (Server.chatmod && !voice) { Message("Chat moderation is on, you cannot speak without %T/voice"); return; } + if (!CheckCanSpeak("speak")) return; // Filter out bad words if (Server.Config.ProfanityFiltering) text = ProfanityFilter.Parse(text); diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index e0abebc04..e74d4ec2d 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -314,7 +314,22 @@ namespace MCGalaxy { /// Returns whether the player is currently allowed to talk. public bool CanSpeak() { - return IsConsole || (!muted && (voice || !Server.chatmod)); + return IsConsole || (!muted && !Unverified && (voice || !Server.chatmod)); + } + + public bool CheckCanSpeak(string action) { + if (IsConsole) return true; + + if (muted) { + Message("Cannot {0} %Swhile muted", action); return false; + } + if (Server.chatmod && !voice) { + Message("Cannot {0} %Swhile chat moderation is on without %T/Voice%S", action); return false; + } + if (Unverified) { + Message("%WYou must first verify with %T/Pass [Password]"); return false; + } + return true; } /// Blocks calling thread until all 'new map loaded' packets have been sent.