diff --git a/Commands/CmdOverseer.cs b/Commands/CmdOverseer.cs index 3a6f933e4..ec9c27944 100644 --- a/Commands/CmdOverseer.cs +++ b/Commands/CmdOverseer.cs @@ -267,24 +267,13 @@ namespace MCGalaxy.Commands { Level.SaveSettings(p.level); Player.Message(p, value + " has been removed from your map's blacklist."); - } else if (cmd == "BLACKLIST") { - string path = "levels/blacklists/" + p.level.name + ".txt"; - if (!File.Exists(path)) { - Player.Message(p, "There are no blacklisted players on this map."); - } else { - Player.Message(p, "Current blocked players on level &b" + p.level.name + "%S:"); - string blocked = ""; - string[] lines = File.ReadAllLines(path); - foreach (string line in lines) { - string player = line.Split(' ')[1]; - blocked += player + ", "; - } - Player.Message(p, blocked); - } - + } else if (cmd == "BLACKLIST") { List blacklist = p.level.VisitAccess.Blacklisted; - if (blacklist.Count > 0) + if (blacklist.Count > 0) { Player.Message(p, "Blacklisted players: " + blacklist.Join()); + } else { + Player.Message(p, "There are no blacklisted players on this map."); + } } else { Player.MessageLines(p, zoneHelp); } diff --git a/Levels/Level.cs b/Levels/Level.cs index 10c6124fc..7a9b4632c 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -146,10 +146,6 @@ namespace MCGalaxy { public bool CanJoin(Player p) { if (p == null) return true; - if (Player.BlacklistCheck(p.name, name)) { - Player.Message(p, "You are blacklisted from going to {0}.", name); return false; - } - if (!VisitAccess.CheckDetailed(p, p.ignorePermission)) return false; if (File.Exists("text/lockdown/map/" + name)) { Player.Message(p, "The level " + name + " is locked."); return false; diff --git a/Player/Player.cs b/Player/Player.cs index d611ab7a7..853bbae1f 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -498,13 +498,6 @@ namespace MCGalaxy { CurrentAmountOfTnt--; } - public static bool BlacklistCheck(string name, string foundLevel) { - string path = "levels/blacklists/" + foundLevel + ".txt"; - if (!File.Exists(path)) return false; - if (File.ReadAllText(path).Contains(name)) return true; - return false; - } - internal static bool CheckVote(string message, Player p, string a, string b, ref int totalVotes) { if (!p.voted && (message == a || message == b)) { totalVotes++; diff --git a/Server/Server.Init.cs b/Server/Server.Init.cs index 3700f988e..f4ad2fe76 100644 --- a/Server/Server.Init.cs +++ b/Server/Server.Init.cs @@ -70,7 +70,7 @@ namespace MCGalaxy { void LoadPlayerLists() { agreed = new PlayerList("ranks/agreed.txt"); try { - CheckOldAgreed(); + UpgradeOldAgreed(); agreed = PlayerList.Load("agreed.txt"); } catch (Exception ex) { Server.ErrorLog(ex); @@ -95,7 +95,34 @@ namespace MCGalaxy { whiteList = PlayerList.Load("whitelist.txt"); } - void CheckOldAgreed() { + static void UpgradeOldBlacklist() { + if (!Directory.Exists("levels/blacklists")) return; + string[] files = Directory.GetFiles("levels/blacklists"); + for (int i = 0; i < files.Length; i++) { + string[] blacklist = File.ReadAllLines(files[i]); + List names = new List(); + + // Lines are in the format: day.month.year name+ + foreach (string entry in blacklist) { + string[] parts = entry.Split(' '); + string name = parts[parts.Length - 1]; + name = name.Substring(0, name.Length - 1); + names.Add(name); + } + + if (names.Count > 0) { + string lvlName = Path.GetFileNameWithoutExtension(files[i]); + string propsPath = LevelInfo.PropertiesPath(lvlName); + using (StreamWriter w = new StreamWriter(propsPath, true)) { + w.WriteLine("VisitBlacklist = " + names.Join()); + } + } + File.Delete(files[i]); + } + Directory.Delete("levels/blacklists"); + } + + static void UpgradeOldAgreed() { // agreed.txt format used to be names separated by spaces, we need to fix that up. if (!File.Exists("ranks/agreed.txt")) return; diff --git a/Server/Server.cs b/Server/Server.cs index 9fcf4d532..06ecdf5ab 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -102,6 +102,7 @@ namespace MCGalaxy { Background.QueueOnce(CombineEnvFiles); Background.QueueOnce(LoadMainLevel); Plugin.Load(); + Background.QueueOnce(UpgradeOldBlacklist); Background.QueueOnce(LoadPlayerLists); Background.QueueOnce(LoadAutoloadCommands); Background.QueueOnce(MovePreviousLevelFiles);