diff --git a/MCGalaxy/Blocks/BlockPerms.cs b/MCGalaxy/Blocks/BlockPerms.cs index 386ba050d..636daf583 100644 --- a/MCGalaxy/Blocks/BlockPerms.cs +++ b/MCGalaxy/Blocks/BlockPerms.cs @@ -121,11 +121,7 @@ namespace MCGalaxy.Blocks { // Custom permissions set by the user. if (File.Exists(Paths.BlockPermsFile)) { string[] lines = File.ReadAllLines(Paths.BlockPermsFile); - if (lines.Length > 0 && lines[0].CaselessEq("#Version 2")) { - LoadVersion2(lines); - } else { - LoadVersion1(lines); - } + ProcessLines(lines); } else { Save(); } @@ -135,11 +131,11 @@ namespace MCGalaxy.Blocks { } } - static void LoadVersion2(string[] lines) { + static void ProcessLines(string[] lines) { string[] args = new string[4]; foreach (string line in lines) { if (line.Length == 0 || line[0] == '#') continue; - //Name/ID : Lowest : Disallow : Allow + // Format is - Name/ID : Lowest : Disallow : Allow line.Replace(" ", "").FixedSplit(args, ':'); byte block; @@ -162,26 +158,7 @@ namespace MCGalaxy.Blocks { } List[perms.BlockID] = perms; } - } - - static void LoadVersion1(string[] lines) { - foreach (string line in lines) { - if (line.Length == 0 || line[0] == '#') continue; - - try { - byte block = Block.Byte(line.SplitSpaces()[0]); - Group group = Group.Find(line.SplitSpaces()[2]); - - if (group != null) - List[block].MinRank = group.Permission; - else - throw new InvalidDataException("Line " + line + " is invalid."); - } catch { - Logger.Log(LogType.Warning, "Could not find the rank given on {0}. Using default", line); - } - } - } - + } static void SetDefaultPerms() { for (int i = 0; i < Block.Count; i++) { diff --git a/MCGalaxy/Commands/CommandPerms.cs b/MCGalaxy/Commands/CommandPerms.cs index 709557e33..41710c11a 100644 --- a/MCGalaxy/Commands/CommandPerms.cs +++ b/MCGalaxy/Commands/CommandPerms.cs @@ -180,11 +180,7 @@ namespace MCGalaxy.Commands { if (File.Exists(Paths.CmdPermsFile)) { string[] lines = File.ReadAllLines(Paths.CmdPermsFile); - if (lines.Length > 0 && lines[0].CaselessEq("#Version 2")) { - LoadVersion2(lines); - } else { - LoadVersion1(lines); - } + ProcessLines(lines); } else { Save(); } @@ -192,9 +188,9 @@ namespace MCGalaxy.Commands { foreach (Group grp in Group.GroupList) { grp.SetUsableCommands(); } - } + } - static void LoadVersion2(string[] lines) { + static void ProcessLines(string[] lines) { string[] args = new string[4]; foreach (string line in lines) { if (line.Length == 0 || line[0] == '#') continue; @@ -213,22 +209,5 @@ namespace MCGalaxy.Commands { } } } - - static void LoadVersion1(string[] lines) { - foreach (string line in lines) { - if (line.Length == 0 || line[0] == '#') continue; - - string cmd = line.Split('=')[0].Trim(); - string value = line.Split('=')[1].Trim(); - - if (Group.Find(value) == null) { - Logger.Log(LogType.Warning, "No group found for command {0}, using default value.", cmd); - } else { - LevelPermission lowestRank = Group.Find(value).Permission; - Set(cmd, lowestRank, null, null); - } - } - } - } }