Drop support for reading version1 block/command properties. Not even the latest MCLawl version saves in version1 format.

This commit is contained in:
UnknownShadow200 2017-11-04 17:27:00 +11:00
parent cfa205d362
commit 46e611f8ac
2 changed files with 7 additions and 51 deletions

View File

@ -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;
@ -164,25 +160,6 @@ namespace MCGalaxy.Blocks {
}
}
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++) {
BlockPerms perms = new BlockPerms();

View File

@ -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();
}
@ -194,7 +190,7 @@ namespace MCGalaxy.Commands {
}
}
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);
}
}
}
}
}