Skip to content

Commit

Permalink
Remame ranks with duplicate/hardcoded names at first, and only if tha…
Browse files Browse the repository at this point in the history
…t fails, remove the rank
  • Loading branch information
UnknownShadow200 committed Apr 18, 2022
1 parent b2463a1 commit df6d99a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions MCGalaxy/Player/Group.cs
Expand Up @@ -321,15 +321,21 @@ public sealed partial class Group {

static void AddGroup(Group temp) {
string name = temp.Name;

// Try to rename conflicing ranks first
if (name.CaselessEq("op") || name.CaselessEq("Console")) {
Logger.Log(LogType.Warning, "Cannot have a rank named 'op' or 'console'", name);
temp.Name = "RENAMED_" + name;
} else if (Find(name) != null) {
Logger.Log(LogType.Warning, "Cannot add the rank {0} twice", name);
temp.Name = "RENAMED_" + name;
}

if (Find(temp.Name) != null) {
Logger.Log(LogType.Warning, "Cannot add the rank {0} twice", temp.Name);
} else if (Find(temp.Permission) != null) {
Logger.Log(LogType.Warning, "Cannot have 2 ranks set at permission level " + (int)temp.Permission);
} else if (temp.Permission > LevelPermission.Owner) { // also handles LevelPermission.Null
Logger.Log(LogType.Warning, "Invalid permission level for rank {0}", name);
Logger.Log(LogType.Warning, "Invalid permission level for rank {0}", temp.Name);
} else {
Register(temp);
}
Expand Down

0 comments on commit df6d99a

Please sign in to comment.