diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ee0a96..f1a85365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Renamed TShock.DB.User to TShock.DB.UserAccount, including all the related methods, classes and events. (@Ryozuki) * Update OTAPI to 2.0.0.31, which also updates Newtonsoft.Json to 10.0.3 (@Ryozuki) * Fixed DumpItems() from trying to dump older versions of certain items (negative item IDs). (@Zaicon) +* Added the `/dump-reference-data` command, which when run, runs Utils.Dump() and outputs Terraria reference data to the server folder. (@hakusaro) ## TShock 4.3.24 * Updated OpenTerraria API to 1.3.5.3 (@DeathCradle) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 592177cf..b2f08d5f 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -616,6 +616,10 @@ namespace TShockAPI { HelpText = "Sends a PM to a player." }); + add(new Command(Permissions.createdumps, CreateDumps, "dump-reference-data") + { + HelpText = "Creates a reference tables for Terraria data types and the TShock permission system in the server folder." + }); #endregion add(new Command(Aliases, "aliases") @@ -5178,6 +5182,14 @@ namespace TShockAPI args.Player.SendErrorMessage("No command or command alias matching \"{0}\" found.", givenCommandName); } + private static void CreateDumps(CommandArgs args) + { + TShock.Utils.DumpPermissionMatrix("PermissionMatrix.txt"); + TShock.Utils.Dump(false); + args.Player.SendSuccessMessage("Your reference dumps have been created in the server folder."); + return; + } + #endregion General Commands #region Cheat Commands diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index f952fee2..56c4ef15 100644 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -172,7 +172,8 @@ namespace TShockAPI.DB Permissions.serverinfo, Permissions.settempgroup, Permissions.spawnrate, - Permissions.tpoverride)); + Permissions.tpoverride, + Permissions.createdumps)); } // Load Permissions from the DB diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 37340e48..bad4148f 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -128,6 +128,9 @@ namespace TShockAPI [Description("User can download updates to plugins that are currently running.")] public static readonly string updateplugins = "tshock.cfg.updateplugins"; + [Description("User can create reference files of Terraria IDs and the permission matrix in the server folder.")] + public static readonly string createdumps = "tshock.cfg.createdumps"; + // tshock.ignore nodes [Description("Prevents you from being reverted by kill tile abuse detection.")] diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 286d50c1..e99aadd6 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1204,7 +1204,6 @@ namespace TShockAPI Permissions.DumpDescriptions(); ServerSideCharacters.ServerSideConfig.DumpDescriptions(); RestManager.DumpDescriptions(); - DumpPermissionMatrix("PermissionMatrix.txt"); DumpBuffs("BuffList.txt"); DumpItems("Items-1_0.txt", 1, 235); DumpItems("Items-1_1.txt", 235, 604); @@ -1226,9 +1225,9 @@ namespace TShockAPI 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) + /// Dumps a matrix of all permissions & all groups in Markdown table format. + /// The save destination. + internal void DumpPermissionMatrix(string path) { StringBuilder output = new StringBuilder(); output.Append("|Permission|");