From 8b57f321250a03a71853e09589c1e0ce8977c02e Mon Sep 17 00:00:00 2001 From: James Puleo Date: Tue, 20 Dec 2022 21:36:31 -0500 Subject: [PATCH 01/21] Detect invalid TShock installations There are two common mistakes made by those installing/updating TShock: - Extracting TShock into the Terraria client directory - Extracting TShock 5 or newer into a legacy (TShock 4 or older) install By checking for the existence of a file named `TerrariaServer.exe`, we can potentially detect these invalid installations, and prompt the user with a more useful diagnostic, rather than (likely) crashing moments later. --- TShockLauncher/Program.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/TShockLauncher/Program.cs b/TShockLauncher/Program.cs index 4a139370..0163cc2d 100644 --- a/TShockLauncher/Program.cs +++ b/TShockLauncher/Program.cs @@ -29,12 +29,30 @@ along with this program. If not, see . using System.Reflection; using TShockPluginManager; +// On occasion, users have been seen extracting TShock into their client installation directory -- this is of course incorrect, and is known +// to cause issues. Let's attempt to catch this before anything happens (specifically, before Terraria assemblies are resolved) and prevent +// TShock from launching. +if (File.Exists("TerrariaServer.exe")) +{ + Console.ForegroundColor = ConsoleColor.Red; + Console.Error.WriteLine("A \"TerrariaServer.exe\" file has been found in the current working directory."); + Console.Error.WriteLine( + "This indicates either installation into a Terraria client directory, or installation into a legacy (TShock 4 or older) TShock directory."); + Console.Error.WriteLine( + "TShock is never to be installed inside a Terraria client directory. You should instead extract your TShock installation into it's own directory."); + Console.Error.WriteLine( + "If you are updating a legacy TShock installation, please follow the following documentation to update: https://ikebukuro.tshock.co/#/?id=upgrading-from-tshock-4"); + Console.Error.WriteLine("The launcher will now exit."); + Console.ResetColor(); + return 1; +} + if (args.Length > 0 && args[0].ToLower() == "plugins") { var items = args.ToList(); items.RemoveAt(0); await NugetCLI.Main(items); - return; + return 0; } @@ -42,7 +60,7 @@ Dictionary _cache = new Dictionary(); System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving; -Start(); +return Start(); /// /// Resolves a module from the ./bin folder, either with a .dll by preference or .exe @@ -70,7 +88,8 @@ Assembly? Default_Resolving(System.Runtime.Loader.AssemblyLoadContext arg1, Asse /// Initiates the TSAPI server. /// /// This method exists so that the resolver can attach before TSAPI needs its dependencies. -void Start() +int Start() { TerrariaApi.Server.Program.Main(args); + return 0; } From 3776baaf129eb03f16d61a3f16072a0e348e4ef7 Mon Sep 17 00:00:00 2001 From: James Puleo Date: Tue, 20 Dec 2022 21:42:50 -0500 Subject: [PATCH 02/21] Update `docs/changelog.md` --- docs/changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index f43f9651..9295ece7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -105,6 +105,8 @@ Use past tense when adding new entries; sign your name off when you add or chang * Initialized achievements and the `AchievementManager` on the server. This ensures that players cannot cause exceptions to be thrown, chat messages are always logged, and allows achievement names to be localized in the console. Also added a test case for this. (@drunderscore) * Allowed multiple test cases to be in TShock's test suite. (@drunderscore) * Fixed unable to use Purification/Evil Powder in jungle. (@sgkoishi) +* Detected invalid installations, by checking for a file named `TerrariaServer.exe`. (@drunderscore) + * This made the two most common installation mistakes (extracting into the Terraria client directory, and extracting TShock 5 or newer into a TShock 4 or older install) prompt the user with a more useful diagnostic, rather than (likely) crashing moments later. ## TShock 5.1.3 * Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef) From f18243242fcf04a15ede101db6ed827544b0e165 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:12:05 +0700 Subject: [PATCH 03/21] Update Group.cs --- TShockAPI/Group.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs index ff2ba2e9..0858dfd4 100644 --- a/TShockAPI/Group.cs +++ b/TShockAPI/Group.cs @@ -52,17 +52,17 @@ namespace TShockAPI /// /// The group that this group inherits permissions from. /// - public Group Parent { get; set; } + public virtual Group Parent { get; set; } /// /// The chat prefix for this group. /// - public string Prefix { get; set; } + public virtual string Prefix { get; set; } /// /// The chat suffix for this group. /// - public string Suffix { get; set; } + public virtual string Suffix { get; set; } /// /// The name of the parent, not particularly sure why this is here. @@ -154,15 +154,15 @@ namespace TShockAPI /// /// The group's chat color red byte. /// - public byte R = 255; + public virtual byte R { get; set; } = 255; /// /// The group's chat color green byte. /// - public byte G = 255; + public virtual byte G { get; set; } = 255; /// /// The group's chat color blue byte. /// - public byte B = 255; + public virtual byte B { get; set; } = 255; /// /// The default group attributed to unregistered users. @@ -242,7 +242,7 @@ namespace TShockAPI /// Adds a permission to the list of negated permissions. /// /// The permission to negate. - public void NegatePermission(string permission) + public virtual void NegatePermission(string permission) { // Avoid duplicates if (!negatedpermissions.Contains(permission)) @@ -256,7 +256,7 @@ namespace TShockAPI /// Adds a permission to the list of permissions. /// /// The permission to add. - public void AddPermission(string permission) + public virtual void AddPermission(string permission) { if (permission.StartsWith("!")) { @@ -276,7 +276,7 @@ namespace TShockAPI /// will parse "!permission" and add it to the negated permissions. /// /// The new list of permissions to associate with the group. - public void SetPermission(List permission) + public virtual void SetPermission(List permission) { permissions.Clear(); negatedpermissions.Clear(); @@ -288,7 +288,7 @@ namespace TShockAPI /// where "!permission" will remove a negated permission. /// /// - public void RemovePermission(string permission) + public virtual void RemovePermission(string permission) { if (permission.StartsWith("!")) { @@ -302,7 +302,7 @@ namespace TShockAPI /// Assigns all fields of this instance to another. /// /// The other instance. - public void AssignTo(Group otherGroup) + public virtual void AssignTo(Group otherGroup) { otherGroup.Name = Name; otherGroup.Parent = Parent; From 121afa963cbff2910f4418851371700dba124651 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:18:48 +0700 Subject: [PATCH 04/21] Added a `Group.Color` --- TShockAPI/Group.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs index 0858dfd4..f0d64b2d 100644 --- a/TShockAPI/Group.cs +++ b/TShockAPI/Group.cs @@ -20,6 +20,8 @@ using System; using System.Linq; using System.Collections.Generic; +using Microsoft.Xna.Framework; + namespace TShockAPI { /// @@ -164,6 +166,17 @@ namespace TShockAPI /// public virtual byte B { get; set; } = 255; + public virtual Color Color + { + get => new Color(R, G, B); + set + { + R = value.R; + G = value.G; + B = value.B; + } + } + /// /// The default group attributed to unregistered users. /// From 73e2440043f172355d537a1ef1fe5a8159caa939 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:21:52 +0700 Subject: [PATCH 05/21] Added XML documentation. --- TShockAPI/Group.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs index f0d64b2d..0867a8a0 100644 --- a/TShockAPI/Group.cs +++ b/TShockAPI/Group.cs @@ -166,6 +166,9 @@ namespace TShockAPI /// public virtual byte B { get; set; } = 255; + /// + /// Simplifies work with the , , properties. + /// public virtual Color Color { get => new Color(R, G, B); From a917beaca0ae3f63774fbb212bce51cd5d0f41e5 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Wed, 7 Jun 2023 23:44:04 +0700 Subject: [PATCH 06/21] Update changelog.md --- docs/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 3f64f355..ec7f000f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,7 +78,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. --> ## Upcoming changes -Your changes could be here! +* Added more modification options to `Group`. (@AgaSpace) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From dc817911346ac7c82180553d53a45d3325c5b5ab Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 8 Jun 2023 12:41:11 +0700 Subject: [PATCH 07/21] Removed RGB properties --- TShockAPI/Group.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs index 0867a8a0..45086eef 100644 --- a/TShockAPI/Group.cs +++ b/TShockAPI/Group.cs @@ -156,15 +156,15 @@ namespace TShockAPI /// /// The group's chat color red byte. /// - public virtual byte R { get; set; } = 255; + public byte R = 255; /// /// The group's chat color green byte. /// - public virtual byte G { get; set; } = 255; + public byte G = 255; /// /// The group's chat color blue byte. /// - public virtual byte B { get; set; } = 255; + public byte B = 255; /// /// Simplifies work with the , , properties. From b5b72e9f6c4a6d439ddc158fb6d01fb8391a0257 Mon Sep 17 00:00:00 2001 From: James Puleo Date: Fri, 9 Jun 2023 03:00:45 -0400 Subject: [PATCH 08/21] Ensure `TSPlayer.PlayerData` is non-null whilst syncing loadouts During connection, we receive a `SyncLoadout` packet before the `ContinueConnecting2` packet, meaning we have not yet created a `PlayerData` for this player. --- TShockAPI/GetDataHandlers.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 1ef2f4f8..b736a512 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -4445,6 +4445,11 @@ namespace TShockAPI return true; } + // Don't modify the player data if it isn't there. + // This is the case whilst the player is connecting, as we receive the SyncLoadout packet before the ContinueConnecting2 packet. + if (args.Player.PlayerData == null) + return false; + // The client does not sync slot changes when changing loadouts, it only tells the server the loadout index changed, // and the server will replicate the changes the client did. This means that PlayerData.StoreSlot is never called, so we need to // swap around the PlayerData items ourself. From fbc1d9dc8d792f3b9511736276ca40e8d7b35184 Mon Sep 17 00:00:00 2001 From: James Puleo Date: Fri, 9 Jun 2023 03:05:43 -0400 Subject: [PATCH 09/21] Update `docs/changelog.md` --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index f02867f8..d329a6df 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -88,6 +88,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added a method `TSPlayer.UpdateSection` with arguments `rectangle` and `isLoaded`, which will load some area from the server to the player. (@AgaSpace) * Added a method `TSPlayer.GiveItem`, which has `TShockAPI.NetItem` structure in its arguments. (@AgaSpace) * Added a property `TSPlayer.Hostile`, which gets pvp player mode. +* Ensured `TSPlayer.PlayerData` is non-null whilst syncing loadouts. (@drunderscore) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From ffed36c6fd9f1003f7d9f7094867d89420212e4d Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:00:13 +0700 Subject: [PATCH 10/21] Added hooks --- TShockAPI/Hooks/PlayerHooks.cs | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 7a3e2067..e6b68581 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -119,6 +119,53 @@ namespace TShockAPI.Hooks public string CommandPrefix { get; set; } } + /// + /// EventArgs used for the event. + /// + public class PrePlayerCommandEventArgs : HandledEventArgs + { + /// + /// The command entered by the player. + /// + public Command Command { get; } + /// + /// Command arguments. + /// + public CommandArgs Arguments { get; set; } + + public PrePlayerCommandEventArgs(Command command, CommandArgs args) + { + Command = command; + Arguments = args; + } + } + + /// + /// EventArgs used for the event. + /// + public class PostPlayerCommandEventArgs + { + /// + /// The command entered by the player. + /// + public Command Command { get; } + /// + /// Command arguments. + /// + public CommandArgs Arguments { get; } + /// + /// Is the command executed. + /// + public bool Handled { get; } + + public PostPlayerCommandEventArgs(Command command, CommandArgs arguments, bool handled) + { + Command = command; + Arguments = arguments; + Handled = handled; + } + } + /// /// EventArgs used for the event. /// @@ -343,6 +390,26 @@ namespace TShockAPI.Hooks /// public static event PlayerCommandD PlayerCommand; + /// + /// The delegate of the event. + /// + /// The EventArgs for this event. + public delegate void PrePlayerCommandD(PrePlayerCommandEventArgs e); + /// + /// Fired before the command is run. + /// + public static event PrePlayerCommandD PrePlayerCommand; + + /// + /// The delegate of the event. + /// + /// The EventArgs for this event. + public delegate void PostPlayerCommandD(PostPlayerCommandEventArgs e); + /// + /// Fired after the command is run. + /// + public static event PostPlayerCommandD PostPlayerCommand; + /// /// The delegate of the event. /// @@ -449,6 +516,40 @@ namespace TShockAPI.Hooks return playerCommandEventArgs.Handled; } + /// + /// Fires the event. + /// + /// Command to be executed + /// Command arguments + /// True if the event has been handled. + public static bool OnPrePlayerCommand(Command cmd, ref CommandArgs arguments) + { + if (PrePlayerCommand == null) + return false; + + PrePlayerCommandEventArgs args = new PrePlayerCommandEventArgs(cmd, arguments); + + PrePlayerCommand(args); + + arguments = args.Arguments; + return args.Handled; + } + + /// + /// Fires the event. + /// + /// Executed command. + /// Command arguments. + /// Is the command executed. + public static void OnPostPlayerCommand(Command cmd, CommandArgs arguments, bool handled) + { + if (PostPlayerCommand == null) + return; + + PostPlayerCommandEventArgs args = new PostPlayerCommandEventArgs(cmd, arguments, handled); + PostPlayerCommand(args); + } + /// /// Fires the event. /// From 380f823e6186667e5379f867ec09b66b66b0fa60 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:00:49 +0700 Subject: [PATCH 11/21] Added a `Run` overload to `Command`. The overload executes the CommandArgs you want. --- TShockAPI/Commands.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2214f252..f10be370 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -148,24 +148,29 @@ namespace TShockAPI Permissions = new List(); } - public bool Run(string msg, bool silent, TSPlayer ply, List parms) + public bool Run(CommandArgs args) { - if (!CanRun(ply)) + if (!CanRun(args.Player)) return false; try { - CommandDelegate(new CommandArgs(msg, silent, ply, parms)); + CommandDelegate(args); } catch (Exception e) { - ply.SendErrorMessage(GetString("Command failed, check logs for more details.")); + args.Player.SendErrorMessage(GetString("Command failed, check logs for more details.")); TShock.Log.Error(e.ToString()); } return true; } + public bool Run(string msg, bool silent, TSPlayer ply, List parms) + { + return Run(new CommandArgs(msg, silent, ply, parms)); + } + public bool Run(string msg, TSPlayer ply, List parms) { return Run(msg, false, ply, parms); @@ -704,7 +709,12 @@ namespace TShockAPI TShock.Utils.SendLogs(GetString("{0} executed: {1}{2}.", player.Name, silent ? SilentSpecifier : Specifier, cmdText), Color.PaleVioletRed, player); else TShock.Utils.SendLogs(GetString("{0} executed (args omitted): {1}{2}.", player.Name, silent ? SilentSpecifier : Specifier, cmdName), Color.PaleVioletRed, player); - cmd.Run(cmdText, silent, player, args); + + CommandArgs arguments = new CommandArgs(cmdText, silent, player, args); + bool handled = PlayerHooks.OnPrePlayerCommand(cmd, ref arguments); + if (!handled) + cmd.Run(arguments); + PlayerHooks.OnPostPlayerCommand(cmd, arguments, handled); } } return true; From 7a3b2e051f6d7fe7dd012d0457f83050238360d0 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:11:44 +0700 Subject: [PATCH 12/21] Update changelog.md --- docs/changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 3f64f355..f5a0003c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,7 +78,8 @@ Use past tense when adding new entries; sign your name off when you add or chang * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. --> ## Upcoming changes -Your changes could be here! +* Added `PlayerHooks.PrePlayerCommand` hook, which fired before command execution. +* Added `PlayerHooks.PostPlayerCommand` hook, which fired after command execution. ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From a656a1cc198014e06514c62b4f11456b29db0773 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:17:11 +0700 Subject: [PATCH 13/21] Added authorship --- docs/changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index f5a0003c..52868390 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,8 +78,8 @@ Use past tense when adding new entries; sign your name off when you add or chang * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. --> ## Upcoming changes -* Added `PlayerHooks.PrePlayerCommand` hook, which fired before command execution. -* Added `PlayerHooks.PostPlayerCommand` hook, which fired after command execution. +* Added `PlayerHooks.PrePlayerCommand` hook, which fired before command execution. (@AgaSpace) +* Added `PlayerHooks.PostPlayerCommand` hook, which fired after command execution. (@AgaSpace) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 1ef96f9537131aa5df55900ecbc39b69bc210935 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:01:52 +0700 Subject: [PATCH 14/21] Marked the `PlayerCommand` hook as obsolete. --- TShockAPI/Hooks/PlayerHooks.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index e6b68581..15cac88d 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +using System; using System.Collections.Generic; using System.ComponentModel; using TShockAPI.DB; @@ -388,6 +389,7 @@ namespace TShockAPI.Hooks /// /// Fired by players when using a command. /// + [Obsolete("There is an alternative to PlayerHooks.PrePlayerCommand")] public static event PlayerCommandD PlayerCommand; /// From 21422f25fd3b4c3a0476ea1e83ee0de8d8895cf4 Mon Sep 17 00:00:00 2001 From: Zoom L1 <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:51:01 +0700 Subject: [PATCH 15/21] Update TShockAPI/Hooks/PlayerHooks.cs Co-authored-by: Arthri <41360489+Arthri@users.noreply.github.com> --- TShockAPI/Hooks/PlayerHooks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 15cac88d..8135a3f9 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -408,7 +408,7 @@ namespace TShockAPI.Hooks /// The EventArgs for this event. public delegate void PostPlayerCommandD(PostPlayerCommandEventArgs e); /// - /// Fired after the command is run. + /// Fired after a command is run. /// public static event PostPlayerCommandD PostPlayerCommand; From b40f0e632e1dfb8966dca14a9ee707318a1ed12f Mon Sep 17 00:00:00 2001 From: Zoom L1 <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:01:43 +0700 Subject: [PATCH 16/21] Update TShockAPI/Hooks/PlayerHooks.cs Co-authored-by: Arthri <41360489+Arthri@users.noreply.github.com> --- TShockAPI/Hooks/PlayerHooks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 8135a3f9..dd35d662 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -398,7 +398,7 @@ namespace TShockAPI.Hooks /// The EventArgs for this event. public delegate void PrePlayerCommandD(PrePlayerCommandEventArgs e); /// - /// Fired before the command is run. + /// Fired before a command is run. /// public static event PrePlayerCommandD PrePlayerCommand; From db40d5034833e0a0833d50de3e87d2da99b08af7 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:03:43 +0700 Subject: [PATCH 17/21] Updated the message --- TShockAPI/Hooks/PlayerHooks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index dd35d662..183205fe 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -389,7 +389,7 @@ namespace TShockAPI.Hooks /// /// Fired by players when using a command. /// - [Obsolete("There is an alternative to PlayerHooks.PrePlayerCommand")] + [Obsolete("Use PlayerHooks.PrePlayerCommand.")] public static event PlayerCommandD PlayerCommand; /// From 723719350b07daf84ec14aa12d57e1d6691697b4 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 17:37:22 +0700 Subject: [PATCH 18/21] Made `PostPlayerCommandEventArgs` inherited from `HandledEventArgs`. --- TShockAPI/Hooks/PlayerHooks.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 183205fe..b5048274 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -144,7 +144,7 @@ namespace TShockAPI.Hooks /// /// EventArgs used for the event. /// - public class PostPlayerCommandEventArgs + public class PostPlayerCommandEventArgs : HandledEventArgs { /// /// The command entered by the player. @@ -154,10 +154,6 @@ namespace TShockAPI.Hooks /// Command arguments. /// public CommandArgs Arguments { get; } - /// - /// Is the command executed. - /// - public bool Handled { get; } public PostPlayerCommandEventArgs(Command command, CommandArgs arguments, bool handled) { From 87fabd3d260b8bc77a47e939fdc7c756dc967b59 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 15 Jun 2023 18:44:30 +0700 Subject: [PATCH 19/21] Removed the "obsolete" tag --- TShockAPI/Hooks/PlayerHooks.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index b5048274..43756464 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -385,7 +385,6 @@ namespace TShockAPI.Hooks /// /// Fired by players when using a command. /// - [Obsolete("Use PlayerHooks.PrePlayerCommand.")] public static event PlayerCommandD PlayerCommand; /// From 605be8f813dcc01cd24e3c422d545dea720f5b0c Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Mon, 27 Jan 2025 08:11:36 +0900 Subject: [PATCH 20/21] Detect xterm compatibility to avoid console spam --- TShockAPI/Utils.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 23b1e224..3b9c0286 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1149,11 +1149,15 @@ namespace TShockAPI /// If the server is empty; determines if we should use Utils.GetActivePlayerCount() for player count or 0. internal void SetConsoleTitle(bool empty) { + if (ShouldSkipTitle) + return; Console.Title = GetString("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})", !string.IsNullOrWhiteSpace(TShock.Config.Settings.ServerName) ? TShock.Config.Settings.ServerName + " - " : "", empty ? 0 : GetActivePlayerCount(), TShock.Config.Settings.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum); } + // Some terminals doesn't supports XTerm escape sequences for setting the title + private static bool ShouldSkipTitle = !System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) && !(Environment.GetEnvironmentVariable("TERM")?.Contains("xterm") ?? false); /// Determines the distance between two vectors. /// The first vector location. From 49b1003eca32fa8028d39402f48bb1932f0f5a66 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 27 Jan 2025 21:07:36 +0900 Subject: [PATCH 21/21] Update github actions upload artifact to v4 This is part of #3050, but thinking about this logically, the deprecation of v3 happens in just 3 days, so unless we want to have .NET 9 testing done in the next 3 days (unlikely?), it's not a great idea to let this break. --- .github/workflows/ci-otapi3.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-otapi3.yml b/.github/workflows/ci-otapi3.yml index f5599ffc..e72d8c22 100644 --- a/.github/workflows/ci-otapi3.yml +++ b/.github/workflows/ci-otapi3.yml @@ -63,14 +63,14 @@ jobs: tar -cvf ../../../../../../TShock-Beta-${{ matrix.arch }}-Release.tar * - name: Upload artifact (non-Windows) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ matrix.arch != 'win-x64' }} with: name: TShock-Beta-${{ matrix.arch }}-Release path: TShock-Beta-${{ matrix.arch }}-Release.tar - name: Upload artifact (Windows) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ matrix.arch == 'win-x64' }} with: name: TShock-Beta-${{ matrix.arch }}-Release