public static void Load() { if (list.Count == 0) { AddDefaultPerms(); } if (!File.Exists(file)) { Save(); } using (StreamReader r = new StreamReader(file)) { string line; while ((line = r.ReadLine()) != null) { if (line.Length == 0 || line[0] == '#' || line.IndexOf(':') == -1) { continue; } try { string[] parts = line.ToLower().Split(':'); OtherPerms perms = Find(parts[0], int.Parse(parts[1])); if (perms == null) { continue; // command has no additional perms, so skip } perms.Permission = int.Parse(parts[2]); } catch (Exception ex) { Server.s.Log("Loading an additional command permission failed!!"); Server.ErrorLog(ex); } } } }
public static void Load() { if (list.Count == 0) { AddDefaultPerms(); } if (File.Exists("properties/ExtraCommandPermissions.properties")) { using (StreamReader SR = new StreamReader("properties/ExtraCommandPermissions.properties")) { string line; while (SR.EndOfStream == false) { line = SR.ReadLine(); try { if (!line.StartsWith("#") && line.Contains(':')) { string[] LINE = line.ToLower().Split(':'); OtherPerms OTPE = Find(Command.all.Find(LINE[0]), int.Parse(LINE[1])); Edit(OTPE, int.Parse(LINE[2])); } } catch { Server.s.Log("Loading an additional command permission failed!!"); } } SR.Dispose(); } } else { Save(); Load(); } }
public static void Load() { if (list.Count == 0) { AddDefaultPerms(); } if (!File.Exists("properties/ExtraCommandPermissions.properties")) { Save(); } using (StreamReader r = new StreamReader("properties/ExtraCommandPermissions.properties")) { string line; while ((line = r.ReadLine()) != null) { try { if (!line.StartsWith("#") && line.IndexOf(':') >= 0) { string[] parts = line.ToLower().Split(':'); Command cmd = Command.all.Find(parts[0]); OtherPerms perms = Find(cmd, int.Parse(parts[1])); if (perms == null && cmd != null) { continue; // command has no additional perms, so skip } Edit(perms, int.Parse(parts[2])); } } catch (Exception ex) { Server.s.Log("Loading an additional command permission failed!!"); Server.ErrorLog(ex); } } } }
public static void Edit(OtherPerms op, int perm) { if (perm > 120) { return; } OtherPerms otpe = op; list.Remove(op); otpe.Permission = perm; list.Add(otpe); }
public static void Add(Command command, int Perm, string desc, int number = 1) { if (Perm > 120) { return; } OtherPerms otpe = new OtherPerms(); otpe.cmd = command; otpe.Permission = Perm; otpe.Description = desc; otpe.number = number; list.Add(otpe); }
public static int GetMaxNumber(Command cmd) { int i = 1; bool stop = false; while (stop == false) { OtherPerms op = Find(cmd, i); if (op == null) { stop = true; } else { i++; } } return(i - 1); }
public static int GetPerm(Command cmd, int number = 1) { OtherPerms otpe = Find(cmd, number); return(otpe.Permission); }
public static void Edit(OtherPerms op, int perm) { op.Permission = perm; }
public static LevelPermission FindPerm(string cmd, LevelPermission defPerm, int number = 1) { OtherPerms perms = Find(cmd, number); return(perms == null ? defPerm : (LevelPermission)perms.Permission); }