Fix various commands still sending globally when level-only chat. Fixes #387

This commit is contained in:
UnknownShadow200 2017-06-26 12:49:51 +10:00
parent fe496b8a10
commit 32be585c35
5 changed files with 20 additions and 7 deletions

View File

@ -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 {
/// <summary> 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. </summary>
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);
}
/// <summary> Sends a message to everyone, regardless of their level, chatroom or ignoring all chat. </summary>

View File

@ -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, "<Level>" + message, false, p.level);
}
}
public override void Help(Player p) {
Player.Message(p, "%T/afk <reason>");
Player.Message(p, "%HMarks yourself as AFK. Use again to mark yourself as back");

View File

@ -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, "<Level>" + message, false, p.level);
}
p.CheckForMessageSpam();
return true;
}

View File

@ -86,10 +86,14 @@ namespace MCGalaxy {
public string theme = "Normal";
[ConfigBool("Unload", "General", null, true)]
public bool unload = true;
/// <summary> true if this map sees server-wide chat, false if this map has level-only/isolated chat </summary>
/// <summary> true if this map may see server-wide chat, false if this map has level-only/isolated chat </summary>
[ConfigBool("WorldChat", "General", null, true)]
public bool worldChat = true;
/// <summary> Whether this map sees server-wide chat. </summary>
/// <remarks> true if both worldChat and Server.worldChat are true. </remarks>
public bool SeesServerWideChat { get { return worldChat && Server.worldChat; } }
internal readonly object queueLock = new object(), saveLock = new object(), savePropsLock = new object();
public List<ulong> blockqueue = new List<ulong>();
BufferedBlockSender bulkSender;

View File

@ -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);
}
}