mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
Drop support for reading version1 block/command properties. Not even the latest MCLawl version saves in version1 format.
This commit is contained in:
parent
cfa205d362
commit
46e611f8ac
@ -121,11 +121,7 @@ namespace MCGalaxy.Blocks {
|
|||||||
// Custom permissions set by the user.
|
// Custom permissions set by the user.
|
||||||
if (File.Exists(Paths.BlockPermsFile)) {
|
if (File.Exists(Paths.BlockPermsFile)) {
|
||||||
string[] lines = File.ReadAllLines(Paths.BlockPermsFile);
|
string[] lines = File.ReadAllLines(Paths.BlockPermsFile);
|
||||||
if (lines.Length > 0 && lines[0].CaselessEq("#Version 2")) {
|
ProcessLines(lines);
|
||||||
LoadVersion2(lines);
|
|
||||||
} else {
|
|
||||||
LoadVersion1(lines);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
@ -135,11 +131,11 @@ namespace MCGalaxy.Blocks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadVersion2(string[] lines) {
|
static void ProcessLines(string[] lines) {
|
||||||
string[] args = new string[4];
|
string[] args = new string[4];
|
||||||
foreach (string line in lines) {
|
foreach (string line in lines) {
|
||||||
if (line.Length == 0 || line[0] == '#') continue;
|
if (line.Length == 0 || line[0] == '#') continue;
|
||||||
//Name/ID : Lowest : Disallow : Allow
|
// Format is - Name/ID : Lowest : Disallow : Allow
|
||||||
line.Replace(" ", "").FixedSplit(args, ':');
|
line.Replace(" ", "").FixedSplit(args, ':');
|
||||||
|
|
||||||
byte block;
|
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() {
|
static void SetDefaultPerms() {
|
||||||
for (int i = 0; i < Block.Count; i++) {
|
for (int i = 0; i < Block.Count; i++) {
|
||||||
BlockPerms perms = new BlockPerms();
|
BlockPerms perms = new BlockPerms();
|
||||||
|
@ -180,11 +180,7 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
if (File.Exists(Paths.CmdPermsFile)) {
|
if (File.Exists(Paths.CmdPermsFile)) {
|
||||||
string[] lines = File.ReadAllLines(Paths.CmdPermsFile);
|
string[] lines = File.ReadAllLines(Paths.CmdPermsFile);
|
||||||
if (lines.Length > 0 && lines[0].CaselessEq("#Version 2")) {
|
ProcessLines(lines);
|
||||||
LoadVersion2(lines);
|
|
||||||
} else {
|
|
||||||
LoadVersion1(lines);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
@ -194,7 +190,7 @@ namespace MCGalaxy.Commands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadVersion2(string[] lines) {
|
static void ProcessLines(string[] lines) {
|
||||||
string[] args = new string[4];
|
string[] args = new string[4];
|
||||||
foreach (string line in lines) {
|
foreach (string line in lines) {
|
||||||
if (line.Length == 0 || line[0] == '#') continue;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user