From 3b78863c7959b7410e794ae20ad9de561c8687ab Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 21 May 2020 20:49:35 +1000 Subject: [PATCH] Add a CanSpeak method to player class that returns whether player can currently speak --- MCGalaxy/Commands/Chat/CmdAfk.cs | 2 +- MCGalaxy/Player/Player.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/MCGalaxy/Commands/Chat/CmdAfk.cs b/MCGalaxy/Commands/Chat/CmdAfk.cs index 8a15c6e96..3513f705c 100644 --- a/MCGalaxy/Commands/Chat/CmdAfk.cs +++ b/MCGalaxy/Commands/Chat/CmdAfk.cs @@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Chatting { TabList.Update(p, true); p.LastAction = DateTime.UtcNow; - bool cantSend = p.muted || (Server.chatmod && !p.voice); + bool cantSend = !p.CanSpeak(); if (p.IsAfk) { if (cantSend) { p.Message("You are now marked as being AFK."); diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index 41f954577..d12e3e143 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -312,11 +312,16 @@ namespace MCGalaxy { #endregion + /// Returns whether the player is currently allowed to talk. + public bool CanSpeak() { return !muted && (voice || !Server.chatmod); } + + /// Blocks calling thread until all 'new map loaded' packets have been sent. public void BlockUntilLoad(int sleep) { while (Loading) Thread.Sleep(sleep); } + /// Checks if player is currently unverified, and if so, sends a message informing them public void CheckIsUnverified() { if (verifiedPass) return; Unverified = Server.Config.verifyadmins && Rank >= Server.Config.VerifyAdminsRank;