From c4129cf6450719120480e2ae4f43724d27f8185c Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 9 Dec 2017 15:19:34 +1030 Subject: [PATCH 01/12] Updates the commandline parser to not be broken. It should now correctly parse a commandline such as `["", "-flag", "-flag", "arg" ... "etc" ]` --- TShockAPI/CLI/CommandLineParser.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/TShockAPI/CLI/CommandLineParser.cs b/TShockAPI/CLI/CommandLineParser.cs index 7106abbe..d84a7732 100644 --- a/TShockAPI/CLI/CommandLineParser.cs +++ b/TShockAPI/CLI/CommandLineParser.cs @@ -165,10 +165,16 @@ namespace TShockAPI.CLI { _source = source; - for (int i = 0; i < (source.Length - 1 == 0 ? 1 : source.Length - 1); i++) + for (int i = 0; i < (source.Length - 1 == 0 ? 1 : source.Length); i++) { string flag = source[i].ToLowerInvariant(); string argument = null; + + if (string.IsNullOrWhiteSpace(flag)) + { + continue; + } + if (i + 1 < source.Length) { argument = source[i + 1]; From c1e72bbc251ebdd8ce20b1b1a8482348a4d2f641 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 9 Dec 2017 15:30:57 +1030 Subject: [PATCH 02/12] Changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14bce826..08b19051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Fixed /savessc not bothering to save ssc data for people who bypass ssc. (@hakusaro) * Default permission sets for new databases are more modern. (@hakusaro) * Added the ability to ban by account name instead of just banning a character name assuming its an account name. (@hakusaro) +* Fixed a bug in the CommandLineParser which caused some command lines to fail (@QuicM) ## TShock 4.3.24 * Updated OpenTerraria API to 1.3.5.3 (@DeathCradle) From 63179deaa57b06429623a1b2673645fd2c80d9f7 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 15:54:51 -0700 Subject: [PATCH 03/12] Adds /dumpdata which dumps the permission table & ref data. --- TShockAPI/Commands.cs | 12 ++++++++++++ TShockAPI/Permissions.cs | 3 +++ TShockAPI/Utils.cs | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 592177cf..d682c8e6 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, "datadump") + { + 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(); + args.Player.SendSuccessMessage("Your reference dumps have been created in the server folder."); + return; + } + #endregion General Commands #region Cheat Commands diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 37340e48..a02b3ff7 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -103,6 +103,9 @@ namespace TShockAPI [Description("User can get other users' info.")] public static readonly string userinfo = "tshock.admin.userinfo"; + [Description("User can create reference files of Terraria IDs and the permission matrix in the server folder.")] + public static readonly string createdumps = "tshock.admin.createdumps"; + // tshock.buff nodes [Description("User can buff self.")] diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 050515a6..b899276a 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", -48, 235); DumpItems("Items-1_1.txt", 235, 604); From 419b5415dae1c60daaa24c907a5bf59e905d9884 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 15:57:57 -0700 Subject: [PATCH 04/12] Updated the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71d26eb7..01660564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added the ability to ban by account name instead of just banning a character name assuming its an account name. (@hakusaro) * 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) +* Added the `/dumpdata` 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) From bdabf020d21d305f9eec5ef680ab7fbe609e7cd6 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 15:58:42 -0700 Subject: [PATCH 05/12] tshock.admin.createdumps is now a default owner level permission --- TShockAPI/DB/GroupManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From aa2f040787fbe6434389f5c2664bfcbe2294689c Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 16:03:12 -0700 Subject: [PATCH 06/12] Change command /datadump to /dump-reference-data --- CHANGELOG.md | 2 +- TShockAPI/Commands.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01660564..b5e80c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added the ability to ban by account name instead of just banning a character name assuming its an account name. (@hakusaro) * 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) -* Added the `/dumpdata` command, which when run, runs Utils.Dump() and outputs Terraria reference data to the server folder. (@hakusaro) +* 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 d682c8e6..7eea0927 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -616,7 +616,7 @@ namespace TShockAPI { HelpText = "Sends a PM to a player." }); - add(new Command(Permissions.createdumps, CreateDumps, "datadump") + 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." }); From 2e64d65910683d44227b407a45093ad4be50d936 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 16:09:53 -0700 Subject: [PATCH 07/12] Modify call to Utils.Dump() from the server context to not stop --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 7eea0927..b2f08d5f 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5185,7 +5185,7 @@ namespace TShockAPI private static void CreateDumps(CommandArgs args) { TShock.Utils.DumpPermissionMatrix("PermissionMatrix.txt"); - TShock.Utils.Dump(); + TShock.Utils.Dump(false); args.Player.SendSuccessMessage("Your reference dumps have been created in the server folder."); return; } From 985dcebda9cd87f3bf93407fe8e5a3bfcff28414 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 17:14:59 -0700 Subject: [PATCH 08/12] Comment what DumpPermissionMatrix does --- TShockAPI/Utils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index b899276a..a587788d 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1225,8 +1225,8 @@ 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 + /// Dumps a matrix of all permissions & all groups in Markdown table format. + /// The save destination. public void DumpPermissionMatrix(string path) { StringBuilder output = new StringBuilder(); From 14c071350ccb32ccb2c49ac2b5d56471305d25d3 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 17:15:21 -0700 Subject: [PATCH 09/12] Mark Utils.DumpPemrissionMatrix as internal --- TShockAPI/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index a587788d..73ea56af 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1227,7 +1227,7 @@ namespace TShockAPI /// Dumps a matrix of all permissions & all groups in Markdown table format. /// The save destination. - public void DumpPermissionMatrix(string path) + internal void DumpPermissionMatrix(string path) { StringBuilder output = new StringBuilder(); output.Append("|Permission|"); From 4638b85adc53eff55f4b0d4b6fec19172f54b225 Mon Sep 17 00:00:00 2001 From: Zaicon Kiroshu Date: Sat, 9 Dec 2017 18:48:40 -0600 Subject: [PATCH 10/12] Fixed IndexOutOfRange exception --- TShockAPI/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 050515a6..286d50c1 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1206,7 +1206,7 @@ namespace TShockAPI RestManager.DumpDescriptions(); DumpPermissionMatrix("PermissionMatrix.txt"); DumpBuffs("BuffList.txt"); - DumpItems("Items-1_0.txt", -48, 235); + DumpItems("Items-1_0.txt", 1, 235); DumpItems("Items-1_1.txt", 235, 604); DumpItems("Items-1_2.txt", 604, 2749); DumpItems("Items-1_3.txt", 2749, Main.maxItemTypes); From 82f53addd75fb1c06bd29f0cbaa89e226fe37753 Mon Sep 17 00:00:00 2001 From: Zaicon Date: Sat, 9 Dec 2017 20:12:12 -0600 Subject: [PATCH 11/12] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71d26eb7..0c877cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added the ability to ban by account name instead of just banning a character name assuming its an account name. (@hakusaro) * 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) ## TShock 4.3.24 * Updated OpenTerraria API to 1.3.5.3 (@DeathCradle) From 691a3684257c99055ba0875eedc511070566bf2a Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 9 Dec 2017 20:42:47 -0700 Subject: [PATCH 12/12] Change permission node to tshock.cfg.createdumps --- TShockAPI/Permissions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index a02b3ff7..bad4148f 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -103,9 +103,6 @@ namespace TShockAPI [Description("User can get other users' info.")] public static readonly string userinfo = "tshock.admin.userinfo"; - [Description("User can create reference files of Terraria IDs and the permission matrix in the server folder.")] - public static readonly string createdumps = "tshock.admin.createdumps"; - // tshock.buff nodes [Description("User can buff self.")] @@ -131,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.")]