Allow unignoring offline players. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-05-18 19:02:38 +10:00
parent b8e9f1c1df
commit a2164015ec
4 changed files with 39 additions and 27 deletions

View File

@ -27,6 +27,9 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override CommandAlias[] Aliases {
get { return new [] { new CommandAlias("deafen", "ignore all") }; }
}
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
@ -35,37 +38,53 @@ namespace MCGalaxy.Commands {
if (action == "all") {
p.ignoreAll = !p.ignoreAll;
Player.Message(p, p.ignoreAll ? "&cAll chat is now ignored!" : "&aAll chat is no longer ignored!");
Player.Message(p, p.ignoreAll ? "&cNow ignoring all chat" : "&aNo longer ignoring all chat");
CreateIgnoreFile(p); return;
} else if (action == "irc") {
p.ignoreIRC = !p.ignoreIRC;
Player.Message(p, p.ignoreIRC ? "&cIRC chat is now ignored!" : "&aIRC chat is no longer ignored!");
Player.Message(p, p.ignoreIRC ? "&cNow ignoring IRC chat" : "&aNo longer ignoring IRC chat");
CreateIgnoreFile(p); return;
} else if (action == "global") {
p.ignoreGlobal = !p.ignoreGlobal;
Player.Message(p, p.ignoreGlobal ? "&cGlobal Chat is now ignored!" : "&aGlobal Chat is no longer ignored!");
Player.Message(p, p.ignoreGlobal ? "&cNow ignoring Global Chat" : "&aNo longer ignoring Global Chat");
CreateIgnoreFile(p); return;
} else if (action == "list") {
Player.Message(p, "&cCurrently ignoring the following players:");
string names = string.Join(", ", p.listignored);
if (names != "") Player.Message(p, names);
if (p.ignoreAll) Player.Message(p, "&cIgnoring all chat.");
if (p.ignoreIRC) Player.Message(p, "&cIgnoring IRC chat.");
if (p.ignoreGlobal) Player.Message(p, "&cIgnoring global chat.");
if (p.ignoreAll) Player.Message(p, "&cIgnoring all chat");
if (p.ignoreIRC) Player.Message(p, "&cIgnoring IRC chat");
if (p.ignoreGlobal) Player.Message(p, "&cIgnoring global chat");
return;
}
Player who = PlayerInfo.Find(action);
if (who == null) { Player.Message(p, "Could not find player specified."); return; }
if (who.name == p.name) { Player.Message(p, "You cannot ignore yourself."); return; }
CreateIgnoreFile(p);
string unignore = null;
for (int i = 0; i < p.listignored.Count; i++) {
if (!action.CaselessEq(p.listignored[i])) continue;
unignore = p.listignored[i]; break;
}
if (!p.listignored.Contains(who.name)) {
p.listignored.Add(who.name);
Player.Message(p, "Player now ignored: &c" + who.DisplayName + "!");
if (unignore != null) {
p.listignored.Remove(unignore);
Player.Message(p, "No longer ignoring &a{0}", unignore);
} else {
p.listignored.Remove(who.name);
Player.Message(p, "Player is no longer ignored: &a" + who.DisplayName + "!");
int matches = 0;
Player who = PlayerInfo.FindOrShowMatches(p, action);
if (who == null) {
if (matches == 0)
Player.SendMessage(p, "You must use the full name when unignoring offline players.");
return;
}
if (p.name == who.name) { Player.Message(p, "You cannot ignore yourself."); return; }
if (p.listignored.Contains(who.name)) {
p.listignored.Remove(who.name);
Player.Message(p, "No longer ignoring &a{0}", who.DisplayName);
} else {
p.listignored.Add(who.name);
Player.Message(p, "Now ignoring &c{0}", who.DisplayName);
}
}
}
@ -81,7 +100,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "%H If name is \"all\", all chat is ignored.");
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 Otherwise, the online player matching the name is ignored.");
Player.Message(p, "%H Otherwise, the online player matching the name is ignored.");
}
}
}

View File

@ -229,17 +229,11 @@ namespace MCGalaxy {
if (who == null) return;
if (who == p) { Player.Message(p, "Trying to talk to yourself, huh?"); return; }
LevelPermission perm = p == null ? LevelPermission.Nobody : p.group.Permission;
LevelPermission whoPerm = who.group.Permission;
if (who.ignoreAll) {
DoFakePM(p, who, message); return;
}
foreach (string ignored in who.listignored) {
if (p != null && ignored == p.name) {
DoFakePM(p, who, message); return;
}
}
if (p != null && who.listignored.Contains(p.name)) {
DoFakePM(p, who, message); return;
}
DoPM(p, who, message);
}

View File

@ -840,8 +840,7 @@ Next: continue;
Server.s.Log("Failed to load ignore list for: " + name);
}
if (ignoreAll || ignoreGlobal || ignoreIRC || listignored.Count > 0) {
SendMessage("&cYou are still ignoring some people from your last login.");
SendMessage("&cType &a/ignore list &cto see the list.");
SendMessage("&cType &a/ignore list &cto see who you are still ignoring");
}
}

View File

@ -195,7 +195,7 @@ namespace MCGalaxy {
foreach (T item in items) {
if (!filter(item)) continue;
string itemName = nameGetter(item);
string itemName = nameGetter(item);
if (itemName.Equals(name, comp)) { matches = 1; return item; }
if (itemName.IndexOf(name, comp) < 0) continue;