Add DumpPermissionMatrix() which dumps a markdown permission matrix
Note that -dump apparently isn't working lately. You probably want to call Utils.Dump() manually and invoke it in a custom build.
This commit is contained in:
parent
9c6c450751
commit
c869464d81
1 changed files with 48 additions and 0 deletions
|
|
@ -1204,6 +1204,7 @@ namespace TShockAPI
|
|||
Permissions.DumpDescriptions();
|
||||
ServerSideCharacters.ServerSideConfig.DumpDescriptions();
|
||||
RestManager.DumpDescriptions();
|
||||
DumpPermissionMatrix("PermissionMatrix.txt");
|
||||
DumpBuffs("BuffList.txt");
|
||||
DumpItems("Items-1_0.txt", -48, 235);
|
||||
DumpItems("Items-1_1.txt", 235, 604);
|
||||
|
|
@ -1212,6 +1213,7 @@ namespace TShockAPI
|
|||
DumpNPCs("NPCs.txt");
|
||||
DumpProjectiles("Projectiles.txt");
|
||||
DumpPrefixes("Prefixes.txt");
|
||||
|
||||
if (exit)
|
||||
{
|
||||
Environment.Exit(1);
|
||||
|
|
@ -1223,6 +1225,52 @@ namespace TShockAPI
|
|||
for(int i = 0; i < Main.recipe.Length; i++)
|
||||
Main.recipe[i] = new Recipe();
|
||||
}
|
||||
|
||||
// Dumps a matrix of all permissions and all groups in markdown format
|
||||
// Hard coded to default groups because apparently we have poor querying tools
|
||||
public void DumpPermissionMatrix(string path)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.Append("|Permission|");
|
||||
|
||||
// Traverse to build group name list
|
||||
foreach (Group g in TShock.Groups.groups)
|
||||
{
|
||||
output.Append(g.Name);
|
||||
output.Append("|");
|
||||
}
|
||||
|
||||
output.AppendLine();
|
||||
output.Append("|-------|");
|
||||
|
||||
foreach (Group g in TShock.Groups.groups)
|
||||
{
|
||||
output.Append("-------|");
|
||||
}
|
||||
output.AppendLine();
|
||||
|
||||
foreach (var field in typeof(Permissions).GetFields().OrderBy(f => f.Name))
|
||||
{
|
||||
output.Append("|");
|
||||
output.Append((string) field.GetValue(null));
|
||||
output.Append("|");
|
||||
|
||||
foreach (Group g in TShock.Groups.groups)
|
||||
{
|
||||
if (g.HasPermission((string) field.GetValue(null)))
|
||||
{
|
||||
output.Append("✔|");
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Append("|");
|
||||
}
|
||||
}
|
||||
output.AppendLine();
|
||||
}
|
||||
|
||||
File.WriteAllText(path, output.ToString());
|
||||
}
|
||||
|
||||
public void DumpBuffs(string path)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue