Add a CanSpeak method to player class that returns whether player can currently speak

This commit is contained in:
UnknownShadow200 2020-05-21 20:49:35 +10:00
parent 659c25eee0
commit 3b78863c79
2 changed files with 6 additions and 1 deletions

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Chatting {
TabList.Update(p, true); TabList.Update(p, true);
p.LastAction = DateTime.UtcNow; p.LastAction = DateTime.UtcNow;
bool cantSend = p.muted || (Server.chatmod && !p.voice); bool cantSend = !p.CanSpeak();
if (p.IsAfk) { if (p.IsAfk) {
if (cantSend) { if (cantSend) {
p.Message("You are now marked as being AFK."); p.Message("You are now marked as being AFK.");

View File

@ -312,11 +312,16 @@ namespace MCGalaxy {
#endregion #endregion
/// <summary> Returns whether the player is currently allowed to talk. </summary>
public bool CanSpeak() { return !muted && (voice || !Server.chatmod); }
/// <summary> Blocks calling thread until all 'new map loaded' packets have been sent. </summary>
public void BlockUntilLoad(int sleep) { public void BlockUntilLoad(int sleep) {
while (Loading) while (Loading)
Thread.Sleep(sleep); Thread.Sleep(sleep);
} }
/// <summary> Checks if player is currently unverified, and if so, sends a message informing them </summary>
public void CheckIsUnverified() { public void CheckIsUnverified() {
if (verifiedPass) return; if (verifiedPass) return;
Unverified = Server.Config.verifyadmins && Rank >= Server.Config.VerifyAdminsRank; Unverified = Server.Config.verifyadmins && Rank >= Server.Config.VerifyAdminsRank;