diff --git a/MCGalaxy/Chat/Chat.cs b/MCGalaxy/Chat/Chat.cs index dea85d068..d0adb85a8 100644 --- a/MCGalaxy/Chat/Chat.cs +++ b/MCGalaxy/Chat/Chat.cs @@ -41,7 +41,7 @@ namespace MCGalaxy { foreach (Player p in players) { if (!NotIgnoring(source, p)) continue; if (visibleOnly && !Entities.CanSee(p, source)) continue; - if (!p.level.worldChat || p.Chatroom != null) continue; + if (!p.level.SeesServerWideChat || p.Chatroom != null) continue; if (p.ignoreNicks && p.ignoreTitles) Player.Message(p, msg_NNNT); else if (p.ignoreNicks) Player.Message(p, msg_NN); @@ -140,7 +140,7 @@ namespace MCGalaxy { /// Sends a message to all players, who are not in a chatroom, are not ignoring all chat, /// and are not on a level that does not have isolated/level only chat. public static void MessageGlobal(string message) { - MessageWhere(message, pl => !pl.ignoreAll && pl.level.worldChat && pl.Chatroom == null); + MessageWhere(message, pl => !pl.ignoreAll && pl.level.SeesServerWideChat && pl.Chatroom == null); } /// Sends a message to everyone, regardless of their level, chatroom or ignoring all chat. diff --git a/MCGalaxy/Commands/Chat/CmdAfk.cs b/MCGalaxy/Commands/Chat/CmdAfk.cs index fd36dfa4d..15b857c3d 100644 --- a/MCGalaxy/Commands/Chat/CmdAfk.cs +++ b/MCGalaxy/Commands/Chat/CmdAfk.cs @@ -49,7 +49,7 @@ namespace MCGalaxy.Commands.Chatting { if (cantSend) { Player.Message(p, "You are now marked as being AFK."); } else { - Chat.MessageGlobal(p, "-" + p.ColoredName + "%S- is AFK " + message, false, true); + ShowMessage(p, "-" + p.ColoredName + "%S- is AFK " + message); Player.RaisePlayerAction(p, PlayerAction.AFK, message); p.CheckForMessageSpam(); } @@ -62,13 +62,21 @@ namespace MCGalaxy.Commands.Chatting { if (cantSend) { Player.Message(p, "You are no longer marked as being AFK."); } else { - Chat.MessageGlobal(p, "-" + p.ColoredName + "%S- is no longer AFK", false, true); + ShowMessage(p, "-" + p.ColoredName + "%S- is no longer AFK"); Player.RaisePlayerAction(p, PlayerAction.UnAFK, message); p.CheckForMessageSpam(); } } } + static void ShowMessage(Player p, string message) { + if (p.level.SeesServerWideChat) { + Chat.MessageGlobal(p, message, false, true); + } else { + Chat.MessageLevel(p, "" + message, false, p.level); + } + } + public override void Help(Player p) { Player.Message(p, "%T/afk "); Player.Message(p, "%HMarks yourself as AFK. Use again to mark yourself as back"); diff --git a/MCGalaxy/Commands/Chat/MessageCmd.cs b/MCGalaxy/Commands/Chat/MessageCmd.cs index a66afba5b..1f42ce6d2 100644 --- a/MCGalaxy/Commands/Chat/MessageCmd.cs +++ b/MCGalaxy/Commands/Chat/MessageCmd.cs @@ -40,11 +40,12 @@ namespace MCGalaxy.Commands.Chatting { protected static bool TryMessage(Player p, string message, string cmd) { if (!CanSpeak(p, cmd)) return false; - if (p.level.worldChat) { + if (p.level.SeesServerWideChat) { Player.SendChatFrom(p, message, false); } else { Chat.MessageLevel(p, "" + message, false, p.level); } + p.CheckForMessageSpam(); return true; } diff --git a/MCGalaxy/Levels/Level.Fields.cs b/MCGalaxy/Levels/Level.Fields.cs index 5e1978852..645eb4769 100644 --- a/MCGalaxy/Levels/Level.Fields.cs +++ b/MCGalaxy/Levels/Level.Fields.cs @@ -86,10 +86,14 @@ 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 + /// true if this map may see server-wide chat, false if this map has level-only/isolated chat [ConfigBool("WorldChat", "General", null, true)] public bool worldChat = true; + /// Whether this map sees server-wide chat. + /// true if both worldChat and Server.worldChat are true. + public bool SeesServerWideChat { get { return worldChat && Server.worldChat; } } + internal readonly object queueLock = new object(), saveLock = new object(), savePropsLock = new object(); public List blockqueue = new List(); BufferedBlockSender bulkSender; diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index f8c20f7d3..3ccf9ea75 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -185,7 +185,7 @@ namespace MCGalaxy { foreach (Player p in players) { if (p.ignoreAll || p.ignoreIRC) continue; - if (p.level.worldChat && p.Chatroom == null) + if (p.level.SeesServerWideChat && p.Chatroom == null) Player.Message(p, message); } }