mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-12 16:56:33 -04:00
Fix flaws with last commit
This commit is contained in:
parent
5de133b44a
commit
3a3276e181
@ -425,8 +425,15 @@ txtBackupLocation.Text = folderDialog.SelectedPath;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void btnAddRank_Click(object sender, EventArgs e) {
|
private void btnAddRank_Click(object sender, EventArgs e) {
|
||||||
string filename = Guid.NewGuid().ToString() + ".txt";
|
// Find first free rank permission
|
||||||
Group newGroup = new Group((LevelPermission)5, 600, 30, "CHANGEME", '1', String.Empty, filename);
|
int freePerm = 5;
|
||||||
|
for (int i = (int)LevelPermission.Guest; i <= (int)LevelPermission.Nobody; i++) {
|
||||||
|
if (Group.findPermInt(i) != null) continue;
|
||||||
|
|
||||||
|
freePerm = i; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Group newGroup = new Group((LevelPermission)freePerm, 600, 30, "CHANGEME", '1', "", null);
|
||||||
storedRanks.Add(newGroup);
|
storedRanks.Add(newGroup);
|
||||||
listRanks.Items.Add(newGroup.trueName + " = " + (int)newGroup.Permission);
|
listRanks.Items.Add(newGroup.trueName + " = " + (int)newGroup.Permission);
|
||||||
}
|
}
|
||||||
|
@ -83,11 +83,15 @@ namespace MCGalaxy {
|
|||||||
fileName = file;
|
fileName = file;
|
||||||
OverseerMaps = maps;
|
OverseerMaps = maps;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddAndLoadGroup(Group grp) {
|
||||||
|
GroupList.Add(grp);
|
||||||
|
grp.LoadPlayers();
|
||||||
|
|
||||||
LoadPlayers();
|
|
||||||
if (OnGroupLoaded != null)
|
if (OnGroupLoaded != null)
|
||||||
OnGroupLoaded(this);
|
OnGroupLoaded(grp);
|
||||||
OnGroupLoadedEvent.Call(this);
|
OnGroupLoadedEvent.Call(grp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Fill the commands that this group can use </summary>
|
/// <summary> Fill the commands that this group can use </summary>
|
||||||
@ -120,17 +124,17 @@ namespace MCGalaxy {
|
|||||||
GroupProperties.InitAll();
|
GroupProperties.InitAll();
|
||||||
} else {
|
} else {
|
||||||
// Add some default ranks
|
// Add some default ranks
|
||||||
GroupList.Add(new Group(LevelPermission.Builder, 400, 300, "Builder", '2', String.Empty, "builders.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.Builder, 400, 300, "Builder", '2', "", null));
|
||||||
GroupList.Add(new Group(LevelPermission.AdvBuilder, 1200, 900, "AdvBuilder", '3', String.Empty, "advbuilders.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.AdvBuilder, 1200, 900, "AdvBuilder", '3', "", null));
|
||||||
GroupList.Add(new Group(LevelPermission.Operator, 2500, 5400, "Operator", 'c', String.Empty, "operators.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.Operator, 2500, 5400, "Operator", 'c', "", null));
|
||||||
GroupList.Add(new Group(LevelPermission.Admin, 65536, int.MaxValue, "SuperOP", 'e', String.Empty, "uberOps.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.Admin, 65536, int.MaxValue, "SuperOP", 'e', "", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BannedRank == null)
|
if (BannedRank == null)
|
||||||
GroupList.Add(new Group(LevelPermission.Banned, 1, 1, "Banned", '8', String.Empty, "banned.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.Banned, 1, 1, "Banned", '8', "", null));
|
||||||
if (GuestRank == null)
|
if (GuestRank == null)
|
||||||
GroupList.Add(new Group(LevelPermission.Guest, 1, 120, "Guest", '7', String.Empty, "guest.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.Guest, 1, 120, "Guest", '7', "", null));
|
||||||
GroupList.Add(new Group(LevelPermission.Nobody, 65536, -1, "Nobody", '0', String.Empty, "nobody.txt"));
|
AddAndLoadGroup(new Group(LevelPermission.Nobody, 65536, -1, "Nobody", '0', "", null));
|
||||||
GroupList.Sort((a, b) => a.Permission.CompareTo(b.Permission));
|
GroupList.Sort((a, b) => a.Permission.CompareTo(b.Permission));
|
||||||
|
|
||||||
if (Find(Server.defaultRank) != null) {
|
if (Find(Server.defaultRank) != null) {
|
||||||
@ -161,9 +165,9 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadPlayers() {
|
void LoadPlayers() {
|
||||||
string desired = (int)Permission + "_rank";
|
string desired = (int)Permission + "_rank";
|
||||||
// Try to use the auto filename format
|
// Try to use the auto filename format
|
||||||
if (!fileName.StartsWith(desired))
|
if (fileName == null || !fileName.StartsWith(desired))
|
||||||
MoveToDesired(desired);
|
MoveToDesired(desired);
|
||||||
|
|
||||||
playerList = PlayerList.Load(fileName);
|
playerList = PlayerList.Load(fileName);
|
||||||
@ -171,7 +175,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
void MoveToDesired(string desired) {
|
void MoveToDesired(string desired) {
|
||||||
// rank doesn't exist to begin with
|
// rank doesn't exist to begin with
|
||||||
if (!File.Exists("ranks/" + fileName)) {
|
if (fileName == null || !File.Exists("ranks/" + fileName)) {
|
||||||
fileName = desired + ".txt";
|
fileName = desired + ".txt";
|
||||||
} else if (MoveToFile(desired + ".txt")) {
|
} else if (MoveToFile(desired + ".txt")) {
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,7 +106,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void AddGroup(ref Group grp) {
|
static void AddGroup(ref Group grp) {
|
||||||
Group.GroupList.Add(
|
Group.AddAndLoadGroup(
|
||||||
new Group(grp.Permission, grp.maxBlocks, grp.maxUndo, grp.trueName,
|
new Group(grp.Permission, grp.maxBlocks, grp.maxUndo, grp.trueName,
|
||||||
grp.color[0], grp.MOTD, grp.fileName, grp.OverseerMaps, grp.prefix));
|
grp.color[0], grp.MOTD, grp.fileName, grp.OverseerMaps, grp.prefix));
|
||||||
grp = null;
|
grp = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user