From 9c34a134c1563aeb895a57be609a4d019f003e8e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 31 Aug 2016 14:58:28 +1000 Subject: [PATCH] Prevent using /hug/high5 when chat moderation is enabled, reduce code duplication for /me. --- Commands/Chat/CmdMe.cs | 14 ++++---------- Commands/Chat/MessageCmd.cs | 3 ++- Levels/Level.Fields.cs | 1 + 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Commands/Chat/CmdMe.cs b/Commands/Chat/CmdMe.cs index 197d472e4..d7ea4a69f 100644 --- a/Commands/Chat/CmdMe.cs +++ b/Commands/Chat/CmdMe.cs @@ -17,7 +17,7 @@ */ using System; namespace MCGalaxy.Commands { - public sealed class CmdMe : Command { + public sealed class CmdMe : MessageCmd { public override string name { get { return "me"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Chat; } } @@ -28,17 +28,11 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { if (message == "") { Player.Message(p, "You"); return; } if (p == null) { MessageInGameOnly(p); return; } - - if (p.joker || p.muted) { Player.Message(p, "Cannot use /me while muted or jokered."); return; } - if (Server.chatmod && !p.voice) { Player.Message(p, "Chat moderation is on, you cannot emote."); return; } + if (p.joker) { Player.Message(p, "Cannot use /me while jokered."); return; } - if (!p.level.worldChat) { - Chat.GlobalChatLevel(p, "" + p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message, false); - } else { - Player.SendChatFrom(p, p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message, false); + string msg = p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message; + if (TryMessage(p, msg) && p.level.worldChat) Player.RaisePlayerAction(p, PlayerAction.Me, message); - } - p.CheckForMessageSpam(); } public override void Help(Player p) { diff --git a/Commands/Chat/MessageCmd.cs b/Commands/Chat/MessageCmd.cs index 49ac09468..55513fc1a 100644 --- a/Commands/Chat/MessageCmd.cs +++ b/Commands/Chat/MessageCmd.cs @@ -30,13 +30,14 @@ namespace MCGalaxy.Commands { string giver = (p == null) ? "(console)" : p.ColoredName; if (!TryMessage(p, string.Format(message, giver, who.ColoredName))) return false; - if (messageWho) + if (messageWho && !who.listignored.Contains(giver)) Player.Message(who, string.Format(message, giver, "you")); return true; } protected bool TryMessage(Player p, string message) { if (p != null && p.muted) { Player.Message(p, "Cannot use /{0} while muted.", name); return false; } + if (Server.chatmod && !p.voice) { Player.Message(p, "Cannot use /{0} when chat moderation is enabled.", name); return false; } if (p.level.worldChat) { Player.SendChatFrom(p, message, false); diff --git a/Levels/Level.Fields.cs b/Levels/Level.Fields.cs index e7ef6d8d4..098a23ada 100644 --- a/Levels/Level.Fields.cs +++ b/Levels/Level.Fields.cs @@ -61,6 +61,7 @@ namespace MCGalaxy { public string theme = "Normal"; [ConfigBool("Unload", "General", null, true)] public bool unload = true; + /// true if this map sees server-wide chat, false if this map has level-only/isolated chat [ConfigBool("WorldChat", "General", null, true)] public bool worldChat = true;