From cabe47f26f87564b3935c81a070d452dda758df6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 30 Jun 2018 17:06:26 +1000 Subject: [PATCH] Drop support for the ancient old server/lockdown/map and level/blacklist auto-upgrading --- MCGalaxy/Server/Server.cs | 2 - MCGalaxy/Server/Tasks/UpgradeTasks.cs | 62 ++++----------------------- 2 files changed, 8 insertions(+), 56 deletions(-) diff --git a/MCGalaxy/Server/Server.cs b/MCGalaxy/Server/Server.cs index f61e1ef9f..3682626f7 100644 --- a/MCGalaxy/Server/Server.cs +++ b/MCGalaxy/Server/Server.cs @@ -111,13 +111,11 @@ namespace MCGalaxy { Background.QueueOnce(UpgradeTasks.CombineEnvFiles); Background.QueueOnce(LoadMainLevel); Plugin.LoadAll(); - Background.QueueOnce(UpgradeTasks.UpgradeOldBlacklist); Background.QueueOnce(LoadAutoloadMaps); Background.QueueOnce(UpgradeTasks.MovePreviousLevelFiles); Background.QueueOnce(UpgradeTasks.UpgradeOldTempranks); Background.QueueOnce(UpgradeTasks.UpgradeDBTimeSpent); Background.QueueOnce(LoadPlayerLists); - Background.QueueOnce(UpgradeTasks.UpgradeOldLockdown); Background.QueueOnce(UpgradeTasks.UpgradeBots); Background.QueueOnce(SetupSocket); diff --git a/MCGalaxy/Server/Tasks/UpgradeTasks.cs b/MCGalaxy/Server/Tasks/UpgradeTasks.cs index 8925ed904..ba53b1bae 100644 --- a/MCGalaxy/Server/Tasks/UpgradeTasks.cs +++ b/MCGalaxy/Server/Tasks/UpgradeTasks.cs @@ -26,34 +26,7 @@ using Newtonsoft.Json; namespace MCGalaxy.Tasks { internal static class UpgradeTasks { - - internal static void UpgradeOldBlacklist(SchedulerTask task) { - 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.SplitSpaces(); - 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.PropsPath(lvlName); - using (StreamWriter w = new StreamWriter(propsPath, true)) { - w.WriteLine("VisitBlacklist = " + names.Join()); - } - } - File.Delete(files[i]); - } - Directory.Delete("levels/blacklists"); - } - + internal 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; @@ -112,37 +85,18 @@ namespace MCGalaxy.Tasks { } } - static void Combine(string envFile) { - string name = Path.GetFileNameWithoutExtension(envFile); - string propsPath = LevelInfo.PropsPath(name); + static void Combine(string envPath) { + string map = Path.GetFileNameWithoutExtension(envPath); + string propsPath = LevelInfo.PropsPath(map); List lines = new List(); - if (File.Exists(propsPath)) { - lines = Utils.ReadAllLinesList(propsPath); - } + if (File.Exists(propsPath)) lines = Utils.ReadAllLinesList(propsPath); - using (StreamReader r = new StreamReader(envFile)) { - string line = null; - while ((line = r.ReadLine()) != null) - lines.Add(line); - } + List envLines = Utils.ReadAllLinesList(envPath); + lines.AddRange(envLines); File.WriteAllLines(propsPath, lines.ToArray()); - File.Delete(envFile); - } - - internal static void UpgradeOldLockdown(SchedulerTask task) { - if (!Directory.Exists("text/lockdown/map")) return; - - string[] files = Directory.GetFiles("text/lockdown/map"); - for (int i = 0; i < files.Length; i++) { - File.Delete(files[i]); - string level = Path.GetFileName(files[i]); - Server.lockdown.AddIfNotExists(level); - } - - Server.lockdown.Save(); - Directory.Delete("text/lockdown/map"); + File.Delete(envPath); } internal static void UpgradeOldTempranks(SchedulerTask task) {