Add /ignore nicks. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-07-04 14:58:22 +10:00
parent 94ca8f2247
commit 48eea6202d
3 changed files with 29 additions and 15 deletions

View File

@ -53,6 +53,11 @@ namespace MCGalaxy.Commands {
Player.Message(p, "{0} show before names in chat",
p.ignoreTitles ? "&cPlayer titles no longer" : "&aPlayer titles now");
CreateIgnoreFile(p); return;
} else if (action == "nicks") {
p.ignoreNicks = !p.ignoreNicks;
Player.Message(p, "{0} show in chat",
p.ignoreNicks ? "&cCustom player nicks no longer" : "&aCustom player nicks");
CreateIgnoreFile(p); return;
} else if (action == "list") {
Player.Message(p, "&cCurrently ignoring the following players:");
string names = p.listignored.Concatenate();
@ -61,6 +66,7 @@ namespace MCGalaxy.Commands {
if (p.ignoreIRC) Player.Message(p, "&cIgnoring IRC chat");
if (p.ignoreGlobal) Player.Message(p, "&cIgnoring global chat");
if (p.ignoreTitles) Player.Message(p, "&cPlayer titles do not show before names in chat.");
if (p.ignoreNicks) Player.Message(p, "&cCustom player nicks do not show in chat.");
return;
}
@ -107,6 +113,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "%H If name is \"global\", MCGalaxy global chat is ignored.");
Player.Message(p, "%H If name is \"irc\", IRC chat is ignored.");
Player.Message(p, "%H If name is \"titles\", player titles before names are ignored.");
Player.Message(p, "%H If name is \"nicks\", custom player nicks do not show in chat.");
Player.Message(p, "%HOtherwise, all chat from the player with [name] is ignored.");
}
}

View File

@ -135,7 +135,7 @@ namespace MCGalaxy {
public bool onWhitelist = false;
public bool whisper = false;
public string whisperTo = "";
public bool ignoreAll, ignoreGlobal, ignoreIRC, ignoreTitles;
public bool ignoreAll, ignoreGlobal, ignoreIRC, ignoreTitles, ignoreNicks;
public string storedMessage = "";

View File

@ -156,8 +156,7 @@ namespace MCGalaxy {
public static void SendChatFrom(Player from, string message) { SendChatFrom(from, message, true); }
public static void SendChatFrom(Player from, string message, bool showname) {
if (from == null) return; // So we don't fucking derp the hell out!
if (from == null) return;
if (Last50Chat.Count == 50) Last50Chat.RemoveAt(0);
var chatmessage = new ChatMessage();
chatmessage.text = message;
@ -165,22 +164,27 @@ namespace MCGalaxy {
chatmessage.time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
Last50Chat.Add(chatmessage);
string messageLite = message;
string msg_NT = message, msg_NN = message, msg_NNNT = message;
if (showname) {
string prefix = from.group.prefix == "" ? "" : "&f" + from.group.prefix;
messageLite = from.voicestring + prefix + from.ColoredName + ": &f" + message;
message = from.voicestring + from.FullName + ": &f" + message;
string msg = ": &f" + message;
string pre = from.voicestring + from.color + from.prefix;
message = pre + from.DisplayName + msg; // Titles + Nickname
msg_NN = pre + from.truename + msg; // Titles + Account name
pre = from.voicestring + (from.group.prefix == "" ? "" : "&f" + from.group.prefix);
msg_NT = pre + from.color + from.DisplayName + msg; // Nickname
msg_NNNT = pre + from.color + from.truename + msg; // Account name
}
Player[] players = PlayerInfo.Online.Items;
foreach (Player p in players) {
if (p.level.worldChat && p.Chatroom == null) {
if (from != null && p.listignored.Contains(from.name)) continue;
string msg = p.ignoreTitles ? messageLite : message;
if (!p.ignoreAll || (from != null && from == p))
Player.Message(p, msg);
}
if (p.Chatroom != null || p.listignored.Contains(from.name)) continue;
if (!p.level.worldChat || (p.ignoreAll && p != from)) continue;
if (p.ignoreNicks && p.ignoreTitles) Player.Message(p, msg_NNNT);
else if (p.ignoreNicks) Player.Message(p, msg_NN);
else if (p.ignoreTitles) Player.Message(p, msg_NT);
else Player.Message(p, message);
}
}
@ -529,6 +533,7 @@ Next: continue;
if (ignoreGlobal) w.WriteLine("&global");
if (ignoreIRC) w.WriteLine("&irc");
if (ignoreTitles) w.WriteLine("&titles");
if (ignoreNicks) w.WriteLine("&nicks");
foreach (string line in listignored)
w.WriteLine(line);
@ -550,6 +555,7 @@ Next: continue;
else if (line == "&all") ignoreAll = true;
else if (line == "&irc") ignoreIRC = true;
else if (line == "&titles") ignoreTitles = true;
else if (line == "&nicks") ignoreNicks = true;
else listignored.Add(line);
}
} catch (Exception ex) {
@ -557,7 +563,8 @@ Next: continue;
Server.s.Log("Failed to load ignore list for: " + name);
}
if (ignoreAll || ignoreGlobal || ignoreIRC || ignoreTitles || listignored.Count > 0)
if (ignoreAll || ignoreGlobal || ignoreIRC
|| ignoreTitles || ignoreNicks || listignored.Count > 0)
SendMessage("&cType &a/ignore list &cto see who you are still ignoring");
}