From 59f9440d174504b69ec81f3368c1b501f0148fb4 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Mon, 12 Dec 2022 17:15:34 -0800 Subject: [PATCH 01/50] Use same TSPlayer.Active check --- TShockAPI/Bouncer.cs | 6 +++--- TShockAPI/Commands.cs | 8 ++++---- TShockAPI/Rest/RestManager.cs | 6 +++--- TShockAPI/Utils.cs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index affa1609f..e86501b1e 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1878,7 +1878,7 @@ void Reject(bool shouldResync = true) return; } - if (TShock.Players[id] == null) + if (TShock.Players[id] == null || !TShock.Players[id].Active) { TShock.Log.ConsoleDebug(GetString( "Bouncer / OnPlayerBuff rejected {0} ({1}) applying buff {2} to {3} for {4} ticks: target is null", args.Player.Name, @@ -2081,7 +2081,7 @@ internal void OnHealOtherPlayer(object sender, GetDataHandlers.HealOtherPlayerEv short amount = args.Amount; byte plr = args.TargetPlayerIndex; - if (amount <= 0 || Main.player[plr] == null || !Main.player[plr].active) + if (amount <= 0 || TShock.Players[plr] == null || !TShock.Players[plr].Active) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnHealOtherPlayer rejected null checks")); args.Handled = true; @@ -2589,7 +2589,7 @@ internal void OnPlayerDamage(object sender, GetDataHandlers.PlayerDamageEventArg byte direction = args.Direction; PlayerDeathReason reason = args.PlayerDeathReason; - if (id >= Main.maxPlayers || TShock.Players[id] == null) + if (id >= Main.maxPlayers || TShock.Players[id] == null || !TShock.Players[id].Active) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerDamage rejected null check")); args.Handled = true; diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2214f252d..74fa4f429 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -3070,12 +3070,12 @@ private static void TPHere(CommandArgs args) args.Player.SendErrorMessage(GetString("You do not have permission to teleport all other players.")); return; } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (var player in TShock.Players) { - if (Main.player[i].active && (Main.player[i] != args.TPlayer)) + if (player != null && player.Active && player.Index != args.Player.Index) { - if (TShock.Players[i].Teleport(args.TPlayer.position.X, args.TPlayer.position.Y)) - TShock.Players[i].SendSuccessMessage(GetString("You were teleported to {0}.", args.Player.Name)); + if (player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y)) + player.SendSuccessMessage(GetString("You were teleported to {0}.", args.Player.Name)); } } args.Player.SendSuccessMessage(GetString("Teleported everyone to yourself.")); diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index c41e7767b..b6efd6c5f 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -402,7 +402,7 @@ private object ServerStatusV2(RestRequestArgs args) {"serverversion", Main.versionNumber}, {"tshockversion", TShock.VersionNum}, {"port", TShock.Config.Settings.ServerPort}, - {"playercount", Main.player.Where(p => null != p && p.active).Count()}, + {"playercount", TShock.Utils.GetActivePlayerCount()}, {"maxplayers", TShock.Config.Settings.MaxSlots}, {"world", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)}, {"uptime", (DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime).ToString(@"d'.'hh':'mm':'ss")}, @@ -944,8 +944,8 @@ private object PlayerMute(RestRequestArgs args) [Token] private object PlayerList(RestRequestArgs args) { - var activeplayers = Main.player.Where(p => null != p && p.active).ToList(); - return new RestObject() { { "players", string.Join(", ", activeplayers.Select(p => p.name)) } }; + var activeplayers = TShock.Players.Where(p => null != p && p.Active).Select(p => p.Name); + return new RestObject() { { "players", string.Join(", ", activeplayers) } }; } [Description("Fetches detailed user information on all connected users, and can be filtered by specifying a key value pair filter users where the key is a field and the value is a users field value.")] diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index efe171301..a7291e73f 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -172,7 +172,7 @@ public void SendLogs(string log, Color color, TSPlayer excludedPlayer = null) foreach (TSPlayer player in TShock.Players) { if (player != null && player != excludedPlayer && player.Active && player.HasPermission(Permissions.logs) && - player.DisplayLogs && TShock.Config.Settings.DisableSpewLogs == false) + player.DisplayLogs && !TShock.Config.Settings.DisableSpewLogs) player.SendMessage(log, color); } } @@ -183,7 +183,7 @@ public void SendLogs(string log, Color color, TSPlayer excludedPlayer = null) /// The number of active players on the server. public int GetActivePlayerCount() { - return Main.player.Where(p => null != p && p.active).Count(); + return TShock.Players.Count(p => null != p && p.Active); } //Random should not be generated in a method From 10aca8573dc2c3dd8ca7d3866bf6e5f0e676ff9a Mon Sep 17 00:00:00 2001 From: Stargazing Koishi Date: Tue, 7 Mar 2023 18:39:38 -0800 Subject: [PATCH 02/50] Remove Connection: Close for REST api fix #2923 --- TShockAPI/Rest/Rest.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/TShockAPI/Rest/Rest.cs b/TShockAPI/Rest/Rest.cs index 58cc23d8f..a6e681e2a 100644 --- a/TShockAPI/Rest/Rest.cs +++ b/TShockAPI/Rest/Rest.cs @@ -351,7 +351,6 @@ protected virtual void OnRequest(object sender, RequestEventArgs e) { str = string.Format("{0}({1});", jsonp, str); } - e.Response.Connection.Type = ConnectionType.Close; e.Response.ContentType = new ContentTypeHeader("application/json; charset=utf-8"); e.Response.Add(serverHeader); var bytes = Encoding.UTF8.GetBytes(str); From 1948ad3d2cf960619bd9954bec87072d6aa207b1 Mon Sep 17 00:00:00 2001 From: Stargazing Koishi Date: Thu, 9 Mar 2023 21:01:09 -0800 Subject: [PATCH 03/50] Update changelog.md --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index be96f88c8..8af0bada4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -106,6 +106,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Allowed multiple test cases to be in TShock's test suite. (@drunderscore) * Fixed unable to use Purification/Evil Powder in jungle. (@sgkoishi) * Set the `GetDataHandledEventArgs.Player` property for the `SyncTilePicking` data handler. (@drunderscore) +* Fixed unable to transfer long response body for REST API. (@sgkoishi, #2925) ## TShock 5.1.3 * Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef) From 823d942b4728b34dcb380572600452f8ddfde888 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Fri, 28 Apr 2023 15:55:14 -0700 Subject: [PATCH 04/50] Update changelog --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index c4a95d142..88a8c518f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -110,6 +110,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Allowed Flower Boots to place Ash Flowers on Ash Grass blocks. (@punchready) * Removed unnecessary range check that artifically shortened quick stack reach. (@boddyn, #2885, @bcat) * Improved the exploit protection in tile rect handling. (@punchready) +* Changed the use of `Player.active` to `TSPlayer.Active` for consistency. (@sgkoishi, #2939) ## TShock 5.1.3 * Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef) From 3d11d84d7339ffe7f165cf2f15316a1d6660dd48 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Sat, 13 May 2023 03:56:07 -0700 Subject: [PATCH 05/50] Fix dump-reference-data mutate command name --- TShockAPI/Permissions.cs | 15 +++------------ docs/changelog.md | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index d7ec7166d..debc8ea59 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -529,18 +529,9 @@ public static void DumpDescriptions() field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute; var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : GetString("No description available."); - var commands = GetCommands(name); - foreach (var c in commands) - { - for (var i = 0; i < c.Names.Count; i++) - { - c.Names[i] = "/" + c.Names[i]; - } - } - var strs = - commands.Select( - c => - c.Name + (c.Names.Count > 1 ? " ({0})".SFormat(string.Join(" ", c.Names.ToArray(), 1, c.Names.Count - 1)) : "")); + var strs = GetCommands(name).Select(c => c.Names.Count > 1 + ? $"{c.Name} ({string.Join(" ", c.Names.Skip(1).Select(n => $"/{n}"))})" + : c.Name); sb.AppendLine($"## {name}"); sb.AppendLine($"{desc}"); diff --git a/docs/changelog.md b/docs/changelog.md index 3f64f3554..d7b1d19f3 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! +* Fixed `/dump-reference-data` mutate the command names. (#2943, @sgkoishi) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 51ecef73a16dd1df10bf093ef529be57c5bd1b64 Mon Sep 17 00:00:00 2001 From: Stargazing Koishi Date: Sat, 13 May 2023 04:09:15 -0700 Subject: [PATCH 06/50] Optimize Linq Co-authored-by: Arthri <41360489+Arthri@users.noreply.github.com> --- TShockAPI/Permissions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index debc8ea59..99ac5d7d2 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -530,8 +530,8 @@ public static void DumpDescriptions() var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : GetString("No description available."); var strs = GetCommands(name).Select(c => c.Names.Count > 1 - ? $"{c.Name} ({string.Join(" ", c.Names.Skip(1).Select(n => $"/{n}"))})" - : c.Name); + ? $"/{c.Name} (/{string.Join(" /", c.Names.Skip(1))})" + : $"/{c.Name}"); sb.AppendLine($"## {name}"); sb.AppendLine($"{desc}"); From c3f5994451b02a0b93230b41519f34fa97ac9a9a Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 10:08:02 +0700 Subject: [PATCH 07/50] Added optional arguments `stack` and `prefixId` to the `NetItem` constructor --- TShockAPI/NetItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 278fda1cd..03596a1f2 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -155,7 +155,7 @@ public int Stack /// The net ID. /// The stack. /// The prefix ID. - public NetItem(int netId, int stack, byte prefixId) + public NetItem(int netId, int stack = 1, byte prefixId = 0) { _netId = netId; _stack = stack; From 62b8e5067ce3d97055ff7ed8063d9994909816c4 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 10:13:25 +0700 Subject: [PATCH 08/50] Added the `NetItem.Build' method. The method will create a Terraria.Item instance based on the data from the structure. --- TShockAPI/NetItem.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 03596a1f2..095d3f1c0 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -162,6 +162,24 @@ public NetItem(int netId, int stack = 1, byte prefixId = 0) _prefixId = prefixId; } + /// + /// Creates based on data from this structure. + /// + /// A copy of the item. + /// If the item ID is 0. + public Item Build() + { + if (_netId == 0) + throw new Exception("It is impossible to create an item whose ID is 0."); + Item item = new Item(); + + item.netDefaults(_netId); + item.stack = _stack; + item.prefix = _prefixId; + + return item; + } + /// /// Converts the to a string. /// From 86be1738ccc2f6d8930d4fe3dea411acc310dd49 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 10:13:59 +0700 Subject: [PATCH 09/50] Added a constructor with arguments taking `Terraria.Item`. --- TShockAPI/NetItem.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 095d3f1c0..86fe82a72 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -162,6 +162,17 @@ public NetItem(int netId, int stack = 1, byte prefixId = 0) _prefixId = prefixId; } + /// + /// Creates a new . + /// + /// Item in the game. + public NetItem(Item item) + { + _netId = item.netID; + _stack = item.stack; + _prefixId = item.prefix; + } + /// /// Creates based on data from this structure. /// From 7ab05707869366b884cce0680efee356cfc6ea7e Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 10:22:39 +0700 Subject: [PATCH 10/50] Update changelog.md --- docs/changelog.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 3f64f3554..54e6ff668 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,7 +78,10 @@ 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! +* Updated `TShockAPI.NetItem` (@AgaSpace): + * Added constructor overload with parameter `Terraria.Item`. + * Added the `Build` method to get a copy of `Terraria.Item`. + * In the constructor I added optional parameters `stack` and `prefix`. ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 22d8575e01bad823c7e6fac60e24413d77bde990 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 12:04:17 +0700 Subject: [PATCH 11/50] Corrected the `UserAccountNotExistException` documentation. --- TShockAPI/DB/UserManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index 0354989e7..7b8fe4a28 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -619,7 +619,7 @@ public UserAccountExistsException(string name) public class UserAccountNotExistException : UserAccountManagerException { /// Creates a new UserAccountNotExistException object, with the user account name in the message. - /// The user account name to be pasesd in the message. + /// The user account name to be passed in the message. /// A new UserAccountNotExistException object with a message containing the user account name that does not exist. public UserAccountNotExistException(string name) : base(GetString($"User account {name} does not exist")) From 8a0920b6eabadb40bc43cb65a4eb565366ff0f75 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 12:08:11 +0700 Subject: [PATCH 12/50] Added a hook `AccountHooks.AccountGroupUpdate`. --- TShockAPI/Hooks/AccountHooks.cs | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/TShockAPI/Hooks/AccountHooks.cs b/TShockAPI/Hooks/AccountHooks.cs index 9c08b26dc..e224b467d 100644 --- a/TShockAPI/Hooks/AccountHooks.cs +++ b/TShockAPI/Hooks/AccountHooks.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.ComponentModel; using TShockAPI.DB; namespace TShockAPI.Hooks { @@ -39,6 +40,37 @@ public AccountCreateEventArgs(UserAccount account) } } + public abstract class AccountGroupUpdateEventArgs : HandledEventArgs + { + public string AccountName { get; private set; } + public Group Group { get; set; } + + public AccountGroupUpdateEventArgs(string accountName, Group group) + { + this.AccountName = accountName; + this.Group = group; + } + } + + public class AccountGroupUpdateByPluginEventArgs : AccountGroupUpdateEventArgs + { + public AccountGroupUpdateByPluginEventArgs(string accountName, Group group) : base(accountName, group) + { + } + } + public class AccountGroupUpdateByPlayerEventArgs : AccountGroupUpdateEventArgs + { + /// + /// The player who updated the user's group + /// + public TSPlayer Player { get; private set; } + + public AccountGroupUpdateByPlayerEventArgs(TSPlayer player, string accountName, Group group) : base(accountName, group) + { + this.Player = player; + } + } + public class AccountHooks { public delegate void AccountCreateD(AccountCreateEventArgs e); @@ -62,5 +94,25 @@ public static void OnAccountDelete(UserAccount u) AccountDelete(new AccountDeleteEventArgs(u)); } + + public delegate void AccountGroupUpdateD(AccountGroupUpdateEventArgs e); + public static event AccountGroupUpdateD AccountGroupUpdate; + + public static bool OnAccountGroupUpdate(UserAccount account, TSPlayer author, ref Group group) + { + AccountGroupUpdateEventArgs args = new AccountGroupUpdateByPlayerEventArgs(author, account.Name, group); + AccountGroupUpdate?.Invoke(args); + group = args.Group; + + return args.Handled; + } + public static bool OnAccountGroupUpdate(UserAccount account, ref Group group) + { + AccountGroupUpdateEventArgs args = new AccountGroupUpdateByPluginEventArgs(account.Name, group); + AccountGroupUpdate?.Invoke(args); + group = args.Group; + + return args.Handled; + } } } From 1e037748c1d511fdc3449ff6261a55a049b4e96d Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 12:13:56 +0700 Subject: [PATCH 13/50] Updated the `UserManager.SetUserGroup`. Added an exception `UserGroupUpdateLockedException`, which appears when a hook locks a group change. Added an overload for `UserManager.SetUserGroup`, with the `TSPlayer` parameter (author) --- TShockAPI/DB/UserManager.cs | 51 ++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index 7b8fe4a28..6411b289e 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License using System.Text.RegularExpressions; using BCrypt.Net; using System.Security.Cryptography; +using TShockAPI.Hooks; namespace TShockAPI.DB { @@ -166,7 +167,41 @@ public void SetUserGroup(UserAccount account, string group) if (null == grp) throw new GroupNotExistsException(group); - if (_database.Query("UPDATE Users SET UserGroup = @0 WHERE Username = @1;", group, account.Name) == 0) + if (AccountHooks.OnAccountGroupUpdate(account, ref grp)) + throw new UserGroupUpdateLockedException(account.Name); + + if (_database.Query("UPDATE Users SET UserGroup = @0 WHERE Username = @1;", grp.Name, account.Name) == 0) + throw new UserAccountNotExistException(account.Name); + + try + { + // Update player group reference for any logged in player + foreach (var player in TShock.Players.Where(p => p != null && p.Account != null && p.Account.Name == account.Name)) + { + player.Group = grp; + } + } + catch (Exception ex) + { + throw new UserAccountManagerException(GetString("SetUserGroup SQL returned an error"), ex); + } + } + /// + /// Sets the group for a given username + /// + /// Who changes the group + /// The user account + /// The user account group to be set + public void SetUserGroup(TSPlayer author, UserAccount account, string group) + { + Group grp = TShock.Groups.GetGroupByName(group); + if (null == grp) + throw new GroupNotExistsException(group); + + if (AccountHooks.OnAccountGroupUpdate(account, author, ref grp)) + throw new UserGroupUpdateLockedException(account.Name); + + if (_database.Query("UPDATE Users SET UserGroup = @0 WHERE Username = @1;", grp.Name, account.Name) == 0) throw new UserAccountNotExistException(account.Name); try @@ -627,6 +662,20 @@ public UserAccountNotExistException(string name) } } + /// The UserGroupUpdateLockedException used when the user group update failed and the request failed as a result.. + [Serializable] + public class UserGroupUpdateLockedException : UserAccountManagerException + { + /// Creates a new UserGroupUpdateLockedException object. + /// The name of the user who failed to change the group. + /// New UserGroupUpdateLockedException object with a message containing the name of the user account that failed to change the group. + public UserGroupUpdateLockedException(string name) : + base(GetString($"The user {name} group could not be updated")) + { + } + } + + /// A GroupNotExistsException, used when a group does not exist. [Serializable] public class GroupNotExistsException : UserAccountManagerException From 230d9b094591b196b40aff2905e90d8bf88ec9f8 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 12:17:47 +0700 Subject: [PATCH 14/50] Updated the `SetUserGroup` in the commands. --- TShockAPI/Commands.cs | 6 +++++- TShockAPI/Rest/RestManager.cs | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2214f252d..164bda891 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1176,7 +1176,7 @@ private static void ManageUsers(CommandArgs args) try { - TShock.UserAccounts.SetUserGroup(account, args.Parameters[2]); + TShock.UserAccounts.SetUserGroup(args.Player, account, args.Parameters[2]); TShock.Log.ConsoleInfo(GetString("{0} changed account {1} to group {2}.", args.Player.Name, account.Name, args.Parameters[2])); args.Player.SendSuccessMessage(GetString("Account {0} has been changed to group {1}.", account.Name, args.Parameters[2])); @@ -1193,6 +1193,10 @@ private static void ManageUsers(CommandArgs args) { args.Player.SendErrorMessage(GetString($"User {account.Name} does not exist.")); } + catch (UserGroupUpdateLockedException) + { + args.Player.SendErrorMessage(GetString("Hook blocked the attempt to change the user group.")); + } catch (UserAccountManagerException e) { args.Player.SendErrorMessage(GetString($"User {account.Name} could not be added. Check console for details.")); diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index c41e7767b..0a96b004b 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -555,7 +555,8 @@ private object UserUpdateV2(RestRequestArgs args) { try { - TShock.UserAccounts.SetUserGroup(account, group); + TShock.UserAccounts.SetUserGroup(new TSRestPlayer(args.TokenData.Username, TShock.Groups.GetGroupByName(args.TokenData.UserGroupName)), + account, group); response.Add("group-response", "Group updated successfully"); } catch (Exception e) From 4e85c5ddac099fad4ecfb4ae472854d526729d2a Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 12:19:05 +0700 Subject: [PATCH 15/50] 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 3f64f3554..ebfcd8952 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 a hook `AccountHooks.AccountGroupUpdate`, which is called when you change the user group. (@AgaSpace) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From cc753cf1dac747db6dc613d9c0b7faed9045fdda Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:00:18 +0700 Subject: [PATCH 16/50] Removed unnecessary abstraction. --- TShockAPI/Hooks/AccountHooks.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/TShockAPI/Hooks/AccountHooks.cs b/TShockAPI/Hooks/AccountHooks.cs index e224b467d..ae9fff244 100644 --- a/TShockAPI/Hooks/AccountHooks.cs +++ b/TShockAPI/Hooks/AccountHooks.cs @@ -40,7 +40,7 @@ public AccountCreateEventArgs(UserAccount account) } } - public abstract class AccountGroupUpdateEventArgs : HandledEventArgs + public class AccountGroupUpdateEventArgs : HandledEventArgs { public string AccountName { get; private set; } public Group Group { get; set; } @@ -52,12 +52,6 @@ public AccountGroupUpdateEventArgs(string accountName, Group group) } } - public class AccountGroupUpdateByPluginEventArgs : AccountGroupUpdateEventArgs - { - public AccountGroupUpdateByPluginEventArgs(string accountName, Group group) : base(accountName, group) - { - } - } public class AccountGroupUpdateByPlayerEventArgs : AccountGroupUpdateEventArgs { /// @@ -108,7 +102,7 @@ public static bool OnAccountGroupUpdate(UserAccount account, TSPlayer author, re } public static bool OnAccountGroupUpdate(UserAccount account, ref Group group) { - AccountGroupUpdateEventArgs args = new AccountGroupUpdateByPluginEventArgs(account.Name, group); + AccountGroupUpdateEventArgs args = new AccountGroupUpdateEventArgs(account.Name, group); AccountGroupUpdate?.Invoke(args); group = args.Group; From 914d7432646080ab7eae8d0ccebd4c375f7c7439 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Tue, 6 Jun 2023 19:15:58 +0700 Subject: [PATCH 17/50] Changed the method from `NetItem.Build` to `NetItem.ToItem`. --- TShockAPI/NetItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 86fe82a72..0a3e0c998 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -16,7 +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; using System.Collections.Generic; using System.Linq; using System.Text; @@ -178,7 +178,7 @@ public NetItem(Item item) /// /// A copy of the item. /// If the item ID is 0. - public Item Build() + public Item ToItem() { if (_netId == 0) throw new Exception("It is impossible to create an item whose ID is 0."); From 3a90029d5199e724baeaf04a1aea010b9be3e103 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:33:32 +0700 Subject: [PATCH 18/50] Allowed to receive an item if it is 0. --- TShockAPI/NetItem.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 0a3e0c998..13f3f49da 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -180,8 +180,6 @@ public NetItem(Item item) /// If the item ID is 0. public Item ToItem() { - if (_netId == 0) - throw new Exception("It is impossible to create an item whose ID is 0."); Item item = new Item(); item.netDefaults(_netId); From b3f314985070afc450da441524698c1640d6dccc Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:34:06 +0700 Subject: [PATCH 19/50] 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 54e6ff668..e02dcbdc5 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -80,7 +80,7 @@ Use past tense when adding new entries; sign your name off when you add or chang ## Upcoming changes * Updated `TShockAPI.NetItem` (@AgaSpace): * Added constructor overload with parameter `Terraria.Item`. - * Added the `Build` method to get a copy of `Terraria.Item`. + * Added the `ToItem` method to get a copy of `Terraria.Item`. * In the constructor I added optional parameters `stack` and `prefix`. ## TShock 5.2 From 4eb2aa49de40e5c64b4dc09acacdf554634737c6 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 8 Jun 2023 18:11:26 +0700 Subject: [PATCH 20/50] Removed unnecessary documentation --- TShockAPI/NetItem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 13f3f49da..0f0dc6e35 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -177,7 +177,6 @@ public NetItem(Item item) /// Creates based on data from this structure. /// /// A copy of the item. - /// If the item ID is 0. public Item ToItem() { Item item = new Item(); From 5498f84942c5487b651214db20a331c7f7b87dc6 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Thu, 8 Jun 2023 18:12:25 +0700 Subject: [PATCH 21/50] 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 e02dcbdc5..d1f486b26 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -81,7 +81,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Updated `TShockAPI.NetItem` (@AgaSpace): * Added constructor overload with parameter `Terraria.Item`. * Added the `ToItem` method to get a copy of `Terraria.Item`. - * In the constructor I added optional parameters `stack` and `prefix`. + * In the constructor `stack` and `prefix` are now optional parameters. ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From a6666ff21abf1d40133a98eb5dfe2e5e0c6b8c58 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sat, 10 Jun 2023 13:59:38 +0700 Subject: [PATCH 22/50] Updated the message --- TShockAPI/DB/UserManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index 6411b289e..6fc50d98d 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -670,7 +670,7 @@ public class UserGroupUpdateLockedException : UserAccountManagerException /// The name of the user who failed to change the group. /// New UserGroupUpdateLockedException object with a message containing the name of the user account that failed to change the group. public UserGroupUpdateLockedException(string name) : - base(GetString($"The user {name} group could not be updated")) + base(GetString($"Unable to update group of user {name}.")) { } } From b6041a738e61f9c995e2b3bbcd3c101f658f3ff5 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Thu, 21 Dec 2023 20:39:43 -0800 Subject: [PATCH 23/50] Whitelist the Striking Moment (`ParryDamageBuff`) buff --- TShockAPI/Bouncer.cs | 6 ++++++ docs/changelog.md | 1 + 2 files changed, 7 insertions(+) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 6ff7fd1aa..4a41a42ca 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -434,6 +434,12 @@ internal Bouncer() CanBeAddedWithoutHostile = true, CanOnlyBeAppliedToSender = true }; + PlayerAddBuffWhitelist[BuffID.WindPushed] = new BuffLimit + { + MaxTicks = 2, + CanBeAddedWithoutHostile = true, + CanOnlyBeAppliedToSender = true + }; #endregion Whitelist } diff --git a/docs/changelog.md b/docs/changelog.md index 035df8ada..235b5ec91 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -90,6 +90,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added a property `TSPlayer.Hostile`, which gets pvp player mode. (@AgaSpace) * Fixed typo in `/gbuff`. (@sgkoishi, #2955) * Rewrote the `.dockerignore` file into a denylist. (@timschumi) +* Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) to the `PlayerAddBuffWhitelist` (@sgkoishi, #3005) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 3c2a3f3e53e2eb25ba3d6eeb2ebf066136dcdaa8 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Thu, 21 Dec 2023 20:43:41 -0800 Subject: [PATCH 24/50] Add unstaged changes --- TShockAPI/Bouncer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 4a41a42ca..594d76fff 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -434,9 +434,9 @@ internal Bouncer() CanBeAddedWithoutHostile = true, CanOnlyBeAppliedToSender = true }; - PlayerAddBuffWhitelist[BuffID.WindPushed] = new BuffLimit + PlayerAddBuffWhitelist[BuffID.ParryDamageBuff] = new BuffLimit { - MaxTicks = 2, + MaxTicks = 300, CanBeAddedWithoutHostile = true, CanOnlyBeAppliedToSender = true }; From cf726368c51647f6189729bead08ef658644951d Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Fri, 22 Dec 2023 13:19:58 -0800 Subject: [PATCH 25/50] Use seconds as the time unit --- TShockAPI/Bouncer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 594d76fff..22d6461aa 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -424,7 +424,7 @@ internal Bouncer() }; PlayerAddBuffWhitelist[BuffID.BrainOfConfusionBuff] = new BuffLimit { - MaxTicks = 240, + MaxTicks = 60 * 4, CanBeAddedWithoutHostile = true, CanOnlyBeAppliedToSender = true }; @@ -436,7 +436,7 @@ internal Bouncer() }; PlayerAddBuffWhitelist[BuffID.ParryDamageBuff] = new BuffLimit { - MaxTicks = 300, + MaxTicks = 60 * 5, CanBeAddedWithoutHostile = true, CanOnlyBeAppliedToSender = true }; From dbca317639625fe3e317d05f521fb04b6cb37d96 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Wed, 27 Dec 2023 13:01:55 -0800 Subject: [PATCH 26/50] Update CursedInferno time limit --- TShockAPI/Bouncer.cs | 2 +- docs/changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 22d6461aa..aed7ac040 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -2860,7 +2860,7 @@ internal static int GetMaxPlaceStyle(int tileID) { BuffID.Poisoned, 3600 }, // BuffID: 20 { BuffID.OnFire, 1200 }, // BuffID: 24 { BuffID.Confused, short.MaxValue }, // BuffID: 31 Brain of Confusion Internal Item ID: 3223 - { BuffID.CursedInferno, 420 }, // BuffID: 39 + { BuffID.CursedInferno, 600 }, // BuffID: 39 { BuffID.Frostburn, 900 }, // BuffID: 44 { BuffID.Ichor, 1200 }, // BuffID: 69 { BuffID.Venom, 1800 }, // BuffID: 70 diff --git a/docs/changelog.md b/docs/changelog.md index 235b5ec91..2a4fbfcde 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -90,7 +90,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added a property `TSPlayer.Hostile`, which gets pvp player mode. (@AgaSpace) * Fixed typo in `/gbuff`. (@sgkoishi, #2955) * Rewrote the `.dockerignore` file into a denylist. (@timschumi) -* Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) to the `PlayerAddBuffWhitelist` (@sgkoishi, #3005) +* Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) for player, updated `CursedInferno` buff for NPC (@sgkoishi, #3005) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From aa526223a6a941933cf7a46fb2177ef58d5eb5cc Mon Sep 17 00:00:00 2001 From: Johannes Grimm Date: Tue, 30 Jan 2024 17:55:39 +0100 Subject: [PATCH 27/50] fix: off no save command Added seting SaveOnSeverExit befor shutting down the server Fixes #2938 --- TShockAPI/Commands.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index d39b84e0c..496669bbd 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2044,6 +2044,7 @@ private static void Off(CommandArgs args) private static void OffNoSave(CommandArgs args) { string reason = ((args.Parameters.Count > 0) ? GetString("Server shutting down: ") + String.Join(" ", args.Parameters) : GetString("Server shutting down.")); + Netplay.SaveOnServerExit = false; TShock.Utils.StopServer(false, reason); } From 8df09cb4a8a8707524390265744e61e3dbe690c6 Mon Sep 17 00:00:00 2001 From: Cai <13110818005@qq.com> Date: Wed, 31 Jul 2024 19:11:50 +0800 Subject: [PATCH 28/50] fix: /help, /me, and /p commands can't work in non-English languages --- TShockAPI/Localization/EnglishLanguage.cs | 26 +++++++++++++++++++++++ TShockAPI/TShock.cs | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Localization/EnglishLanguage.cs b/TShockAPI/Localization/EnglishLanguage.cs index 1ec4ecea8..975071416 100644 --- a/TShockAPI/Localization/EnglishLanguage.cs +++ b/TShockAPI/Localization/EnglishLanguage.cs @@ -20,7 +20,9 @@ You should have received a copy of the GNU General Public License using System.Collections.Generic; using System.Linq; using Terraria; +using Terraria.Initializers; using Terraria.Localization; +using Terraria.UI.Chat; namespace TShockAPI.Localization { @@ -37,6 +39,8 @@ public static class EnglishLanguage private static readonly Dictionary Buffs = new Dictionary(); + private static readonly Dictionary VanillaCommands = new Dictionary(); + internal static void Initialize() { var culture = Language.ActiveCulture; @@ -71,6 +75,15 @@ internal static void Initialize() var i = (int)field.GetValue(null); Prefixs.Add(i, Lang.prefix[i].Value); } + + ChatInitializer.Load(); + foreach (var command in ChatManager.Commands._localizedCommands) + { + if (VanillaCommands.ContainsKey(command.Value._name)) + continue; + VanillaCommands.Add(command.Value._name,command.Key.Value); + } + ChatManager.Commands._localizedCommands.Clear(); } finally { @@ -136,5 +149,18 @@ public static string GetBuffNameById(int id) return null; } + + /// + /// Get vanilla command text in English + /// + /// vanilla command name + /// vanilla command text English + public static string GetCommandTextByName(string name) + { + string commandText; + if (VanillaCommands.TryGetValue(name, out commandText)) + return commandText; + return null; + } } } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 054e31dfa..48fab88d1 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1497,11 +1497,11 @@ private void OnChat(ServerChatEventArgs args) { if (!String.IsNullOrEmpty(text)) { - text = item.Key.Value + ' ' + text; + text = EnglishLanguage.GetCommandTextByName(item.Value._name) + ' ' + text; } else { - text = item.Key.Value; + text = EnglishLanguage.GetCommandTextByName(item.Value._name); } break; } From b90182f1e5a8cc47057fbb809bd2ee3311c13714 Mon Sep 17 00:00:00 2001 From: Cai <13110818005@qq.com> Date: Wed, 31 Jul 2024 19:16:23 +0800 Subject: [PATCH 29/50] update changelog --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index b19745463..d2e1444ed 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -93,6 +93,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Rewrote the `.dockerignore` file into a denylist. (@timschumi) * Added CI for Docker images. (@timschumi) * Fixed Cursed Flares kicking players for invalid buff. (@Arthri) +* Fixed /help, /me, and /p commands can't work in non-English languages (@ACaiCat) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From a8624a816344dd39a63a701e98fe57c086613a34 Mon Sep 17 00:00:00 2001 From: Cai <13110818005@qq.com> Date: Wed, 31 Jul 2024 19:16:23 +0800 Subject: [PATCH 30/50] update changelog --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index b19745463..d2e1444ed 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -93,6 +93,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Rewrote the `.dockerignore` file into a denylist. (@timschumi) * Added CI for Docker images. (@timschumi) * Fixed Cursed Flares kicking players for invalid buff. (@Arthri) +* Fixed /help, /me, and /p commands can't work in non-English languages (@ACaiCat) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 7419205548fb9779f83bc924222c1df9741ddff5 Mon Sep 17 00:00:00 2001 From: Cai <13110818005@qq.com> Date: Wed, 31 Jul 2024 19:24:53 +0800 Subject: [PATCH 31/50] rename --- TShockAPI/Localization/EnglishLanguage.cs | 14 +++++++------- TShockAPI/TShock.cs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Localization/EnglishLanguage.cs b/TShockAPI/Localization/EnglishLanguage.cs index 975071416..334c47804 100644 --- a/TShockAPI/Localization/EnglishLanguage.cs +++ b/TShockAPI/Localization/EnglishLanguage.cs @@ -39,7 +39,7 @@ public static class EnglishLanguage private static readonly Dictionary Buffs = new Dictionary(); - private static readonly Dictionary VanillaCommands = new Dictionary(); + private static readonly Dictionary VanillaCommandsPrefixs = new Dictionary(); internal static void Initialize() { @@ -79,9 +79,9 @@ internal static void Initialize() ChatInitializer.Load(); foreach (var command in ChatManager.Commands._localizedCommands) { - if (VanillaCommands.ContainsKey(command.Value._name)) + if (VanillaCommandsPrefixs.ContainsKey(command.Value._name)) continue; - VanillaCommands.Add(command.Value._name,command.Key.Value); + VanillaCommandsPrefixs.Add(command.Value._name,command.Key.Value); } ChatManager.Commands._localizedCommands.Clear(); } @@ -151,14 +151,14 @@ public static string GetBuffNameById(int id) } /// - /// Get vanilla command text in English + /// Get vanilla command prefix in English /// /// vanilla command name - /// vanilla command text English - public static string GetCommandTextByName(string name) + /// vanilla command prefix in English + public static string GetCommandPrefixByName(string name) { string commandText; - if (VanillaCommands.TryGetValue(name, out commandText)) + if (VanillaCommandsPrefixs.TryGetValue(name, out commandText)) return commandText; return null; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 48fab88d1..9c1015bc2 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1497,11 +1497,11 @@ private void OnChat(ServerChatEventArgs args) { if (!String.IsNullOrEmpty(text)) { - text = EnglishLanguage.GetCommandTextByName(item.Value._name) + ' ' + text; + text = EnglishLanguage.GetCommandPrefixByName(item.Value._name) + ' ' + text; } else { - text = EnglishLanguage.GetCommandTextByName(item.Value._name); + text = EnglishLanguage.GetCommandPrefixByName(item.Value._name); } break; } From 68bb381ece3fca103ddb6f5c2197046de70be498 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 13:24:14 +0100 Subject: [PATCH 32/50] docker: Bump docker/build-push-action to v6 --- .github/workflows/ci-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index deb811a2b..41454ae46 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -15,7 +15,7 @@ jobs: - name: Set up buildx uses: docker/setup-buildx-action@v3 - name: Build image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64,linux/arm/v7,windows/amd64 From a82881b7d3a01f002c2cc15151f6c50ed5cdbc92 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 13:33:23 +0100 Subject: [PATCH 33/50] docker: Tag and push images to GHCR automatically Co-authored-by: BrailleBennett Co-authored-by: TheSuperGamer20578 --- .github/workflows/ci-docker.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 41454ae46..691c8e813 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -5,6 +5,8 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest + permissions: + packages: write steps: - name: Checkout uses: actions/checkout@v4 @@ -14,12 +16,25 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up buildx uses: docker/setup-buildx-action@v3 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Generate version information + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} - name: Build image uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64,linux/arm/v7,windows/amd64 - push: false + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} pull: true cache-from: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }} From cc3d2af15f100d6b3a23a4cb252a40b67fe6e006 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 13:45:19 +0100 Subject: [PATCH 34/50] docker: Generate build provenance attestations Co-authored-by: BrailleBennett Co-authored-by: TheSuperGamer20578 --- .github/workflows/ci-docker.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 691c8e813..82e152a9c 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -6,6 +6,8 @@ jobs: build: runs-on: ubuntu-latest permissions: + attestations: write + id-token: write packages: write steps: - name: Checkout @@ -28,6 +30,7 @@ jobs: with: images: ghcr.io/${{ github.repository }} - name: Build image + id: build uses: docker/build-push-action@v6 with: context: . @@ -38,3 +41,9 @@ jobs: pull: true cache-from: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }} + - name: Generate build provenance attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ghcr.io/${{ github.repository }} + subject-digest: ${{ steps.build.outputs.digest }} + push-to-registry: true From ca3dfcdf17947b09b525fe593e2ac8bf17602a4c Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 14:04:57 +0100 Subject: [PATCH 35/50] docker: Push semver tags if a version tag is pushed --- .github/workflows/ci-docker.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 82e152a9c..cb09fc936 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -29,6 +29,14 @@ jobs: uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag,enable=${{ !startsWith(github.ref, 'refs/tags/v') }} + type=ref,event=pr + type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - name: Build image id: build uses: docker/build-push-action@v6 From 660ec5bc601f075860f77d4330cf2c37fa2180c2 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 14:14:38 +0100 Subject: [PATCH 36/50] docker: Restrict tagging 'latest' to version tags --- .github/workflows/ci-docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index cb09fc936..6965c773d 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -37,6 +37,8 @@ jobs: type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} + flavor: | + latest=${{ startsWith(github.ref, 'refs/tags/v') }} - name: Build image id: build uses: docker/build-push-action@v6 From cbdae5b15eedd5237199f0539ffc6d6b7d92e185 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 14:29:40 +0100 Subject: [PATCH 37/50] Add a changelog entry for publishing to GHCR --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index b19745463..b5303c5f4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -93,6 +93,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Rewrote the `.dockerignore` file into a denylist. (@timschumi) * Added CI for Docker images. (@timschumi) * Fixed Cursed Flares kicking players for invalid buff. (@Arthri) +* Added automatic publishing of Docker images to GHCR. (@timschumi) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From d54711651b9f2732f8200db238c710561e126e2d Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 4 Jan 2025 14:36:58 +0100 Subject: [PATCH 38/50] docker: Update documentation for officially provided Docker images --- docs/docker.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index ca0185103..afc4bdfc9 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -14,32 +14,27 @@ Open ports can also be passed through using `-p :`. For Example: ```bash -# Building the image using buildx and loading it into docker -docker buildx build -t tshock:latest --load . - -# Running the image docker run -p 7777:7777 -p 7878:7878 \ -v /home/cider/tshock/:/tshock \ -v /home/cider/.local/share/Terraria/Worlds:/worlds \ -v /home/cider/tshock/plugins:/plugins \ - --rm -it tshock:latest \ + --rm -it ghcr.io/pryaxis/tshock:latest \ -world /worlds/backflip.wld -motd "OMFG DOCKER" ``` -## Building for Other Platforms +## Building custom images -Using `docker buildx`, you could build [multi-platform images](https://docs.docker.com/build/building/multi-platform/) for TShock. +Occasionally, it may be necessary to adjust TShock with customizations that are not included in the upstream project. +Therefore, these changes are also not available in the officially provided Docker images. + +To build and load a Docker image from your local checkout, use the following `buildx` command: -For Example: ```bash -# Building the image using buildx and loading it into docker -docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load . +docker buildx build -t tshock:latest --load . +``` -# Running the image -docker run -p 7777:7777 -p 7878:7878 \ - -v /home/cider/tshock/:/tshock \ - -v /home/cider/.local/share/Terraria/Worlds:/worlds \ - -v /home/cider/tshock/plugins:/plugins \ - --rm -it tshock:linux-arm64 \ - -world /worlds/backflip.wld -motd "ARM64 ftw" +It is also possible to build [multi-platform images](https://docs.docker.com/build/building/multi-platform/) for TShock (e.g. an image targeting `arm64`, on a host that is not `arm64`): + +```bash +docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load . ``` From 02ce8fdf0deac5c52a98070d9970fbd1b5654490 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 5 Jan 2025 01:30:28 +0100 Subject: [PATCH 39/50] docker: Don't push to the registry for Pull Requests This requires more thought on how to handle secrets, and whether to just omit it permanently. --- .github/workflows/ci-docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 6965c773d..3d47d3c67 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -45,13 +45,14 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64,linux/arm/v7,windows/amd64 - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} pull: true cache-from: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }} - name: Generate build provenance attestation + if: ${{ github.event_name != 'pull_request' }} uses: actions/attest-build-provenance@v2 with: subject-name: ghcr.io/${{ github.repository }} From 78dd32a8374c9d8a0bc5b5a80b37c38708fb21f1 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 25 Jan 2025 21:28:24 +0900 Subject: [PATCH 40/50] Fix changelog versioning --- docs/changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index b19745463..54b23a8ab 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,6 +78,9 @@ 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 +* You know the drill + +## TShock 5.2.1 * Updated `TSPlayer.GodMode`. (@AgaSpace) * Previously the field was used as some kind of dataset changed by /godmode command, but now it is a property that receives/changes data in journey mode. * Added the `TSPlayer.Client` property. It allows the developer to get the `RemoteClient` player, without an additional call to `Terraria.Netplay.Clients`. (@AgaSpace) From b4968adb7d964f851633f840d407654e6e90b9aa Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 25 Jan 2025 22:27:48 +0900 Subject: [PATCH 41/50] Fix typo in config file Closes https://github.com/Pryaxis/TShock/pull/3052 --- TShockAPI/Configuration/TShockConfig.cs | 4 ++-- docs/changelog.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index 79c374b25..c91466fec 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -320,8 +320,8 @@ public class TShockSettings [Description("The reason given if banning a mediumcore player on death.")] public string MediumcoreBanReason = GetString("Death results in a ban"); - /// Disbales IP bans by default, if no arguments are passed to the ban command. - [Description("Disbales IP bans by default, if no arguments are passed to the ban command.")] + /// Disables IP bans by default, if no arguments are passed to the ban command. + [Description("Disables IP bans by default, if no arguments are passed to the ban command.")] public bool DisableDefaultIPBan; /// Enable or disable the whitelist based on IP addresses in the whitelist.txt file. diff --git a/docs/changelog.md b/docs/changelog.md index 683cddcb7..00aec595e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -79,6 +79,8 @@ Use past tense when adding new entries; sign your name off when you add or chang ## Upcoming changes * Fixed `/dump-reference-data` mutate the command names. (#2943, @sgkoishi) +* You know the drill +* Fix typo in config for IP bans. (@redchess64) ## TShock 5.2.1 * Updated `TSPlayer.GodMode`. (@AgaSpace) From 9aba57dab6d6886f61f76a4a0597116f5efe1cb7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 25 Jan 2025 13:31:02 +0000 Subject: [PATCH 42/50] Update dependency MySql.Data to 8.4.0 --- TShockAPI/TShockAPI.csproj | 2 +- TShockLauncher/TShockLauncher.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 9da8cd085..34df3c74c 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -34,7 +34,7 @@ - + diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj index e3c4ac327..fbe428bb1 100644 --- a/TShockLauncher/TShockLauncher.csproj +++ b/TShockLauncher/TShockLauncher.csproj @@ -30,7 +30,7 @@ - + From 8246b95739b0a3e8e0e20491be7b1c7a6ae13275 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 25 Jan 2025 22:50:15 +0900 Subject: [PATCH 43/50] Disable stupid semantic commits --- renovate.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 159ec1e22..4292e6787 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,8 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "config:base" + "config:base", + ":semanticCommitsDisabled" ], "git-submodules": { "enabled": true From 7e9b97be29849720f815eecc6daa1fa523d872a6 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 25 Jan 2025 22:51:42 +0900 Subject: [PATCH 44/50] Disable renovate This is really irritating --- renovate.json | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 renovate.json diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 4292e6787..000000000 --- a/renovate.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base", - ":semanticCommitsDisabled" - ], - "git-submodules": { - "enabled": true - }, - "packageRules": [ - { - "matchPackageNames": ["OTAPI.Upcoming", "ModFramework", "TerrariaServerAPI"], - "ignoreUnstable": "false", - "bumpVersion": "prerelease", - "groupName": "OTAPI things" - } - ] -} From 61a81bb4ff8d0a07f9870cc776045fe3a741448b Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Sun, 26 Jan 2025 01:00:17 +0900 Subject: [PATCH 45/50] Fix merge conflict --- docs/changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 75e8d2516..841bba3bf 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -130,6 +130,10 @@ Use past tense when adding new entries; sign your name off when you add or chang * Allowed multiple test cases to be in TShock's test suite. (@drunderscore) * Fixed unable to use Purification/Evil Powder in jungle. (@sgkoishi) * Set the `GetDataHandledEventArgs.Player` property for the `SyncTilePicking` data handler. (@drunderscore) +* Relaxed custom death message restrictions to allow Inferno potions in PvP. (@drunderscore) +* Allowed Flower Boots to place Ash Flowers on Ash Grass blocks. (@punchready) +* Removed unnecessary range check that artifically shortened quick stack reach. (@boddyn, #2885, @bcat) +* Re-wrote tile rect handling from scratch, fixing a certain exploitable flaw in the old code and significantly reducing the potential exploit surface, potentially even down to zero. (@punchready) ## TShock 5.1.3 * Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef) From b984ff8b65433e54478459421dba9247df2c62bb Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 26 Jan 2025 08:45:11 +0900 Subject: [PATCH 46/50] Apply patch from https://github.com/Pryaxis/TShock/pull/3018 This applies https://github.com/Pryaxis/TShock/pull/3018 as a patch per @punchready because they deleted the head repository so that we can't merge it and none of the git objects have valid refs anymore on the command line and we can't merge it on the gui. --- TShockAPI/Commands.cs | 11 ++++++----- docs/changelog.md | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index e7491632d..1006b50f8 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -4622,21 +4622,22 @@ private static void Wind(CommandArgs args) { if (args.Parameters.Count != 1) { - args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}wind .", Specifier)); + args.Player.SendErrorMessage(GetString("Invalid syntax. Proper syntax: {0}wind .", Specifier)); return; } - int speed; - if (!int.TryParse(args.Parameters[0], out speed) || speed * 100 < 0) + float mph; + if (!float.TryParse(args.Parameters[0], out mph) || mph is < -40f or > 40f) { - args.Player.SendErrorMessage(GetString("Invalid wind speed.")); + args.Player.SendErrorMessage(GetString("Invalid wind speed (must be between -40 and 40).")); return; } + float speed = mph / 50f; // -40 to 40 mph -> -0.8 to 0.8 Main.windSpeedCurrent = speed; Main.windSpeedTarget = speed; TSPlayer.All.SendData(PacketTypes.WorldInfo); - TSPlayer.All.SendInfoMessage(GetString("{0} changed the wind speed to {1}.", args.Player.Name, speed)); + TSPlayer.All.SendInfoMessage(GetString("{0} changed the wind speed to {1}mph.", args.Player.Name, mph)); } #endregion Time/PvpFun Commands diff --git a/docs/changelog.md b/docs/changelog.md index 4866e01cb..41fa28533 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -83,6 +83,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Changed the use of `Player.active` to `TSPlayer.Active` for consistency. (@sgkoishi, #2939) * Fix typo in config for IP bans. (@redchess64) * Fixed unable to transfer long response body for REST API. (@sgkoishi, #2925) +* Fixed the `/wind` command not being very helpful. (@punchready) ## TShock 5.2.1 * Updated `TSPlayer.GodMode`. (@AgaSpace) From fdee582dc74266b9e5231414c78ee34a13baf7e8 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 26 Jan 2025 09:00:41 +0900 Subject: [PATCH 47/50] Redirect ikebukuro to wiki This redirects the hosted docs on github pages to the wiki, which is easier for normal people to edit. --- docs/index.html | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/index.html b/docs/index.html index 2ae1df82e..0cfccf115 100644 --- a/docs/index.html +++ b/docs/index.html @@ -11,12 +11,7 @@
From 52ed275be2393a496edf26430b1f7d05a8fe72b5 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Sun, 26 Jan 2025 13:00:06 +0900 Subject: [PATCH 48/50] Fix #2895 --- TShockPluginManager/Nuget.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/TShockPluginManager/Nuget.cs b/TShockPluginManager/Nuget.cs index 9fdefb6b1..1d00fe1c9 100644 --- a/TShockPluginManager/Nuget.cs +++ b/TShockPluginManager/Nuget.cs @@ -30,7 +30,6 @@ You should have received a copy of the GNU General Public License namespace TShockPluginManager { - public class Nugetter { // this object can figure out the right framework folders to use from a set of packages @@ -82,15 +81,13 @@ async Task GetPackageDependencies( // make sure the source repository can actually tell us about dependencies var dependencyInfoResource = await sourceRepository.GetResourceAsync(); // get the try and dependencies - // (the above function returns a nullable value, but doesn't properly indicate it as such) - #pragma warning disable CS8602 - var dependencyInfo = await dependencyInfoResource?.ResolvePackage( + if (dependencyInfoResource is null) continue; + var dependencyInfo = await dependencyInfoResource.ResolvePackage( package, framework, cacheContext, logger, CancellationToken.None); - #pragma warning restore CS8602 // oop, we don't have the ability to get dependency info from this repository, or // it wasn't found. let's try the next source repository! - if (dependencyInfo == null) continue; + if (dependencyInfo is null) continue; availablePackages.Add(dependencyInfo); foreach (var dependency in dependencyInfo.Dependencies) @@ -302,8 +299,11 @@ public void InstallPackage(SourcePackageDependencyInfo pkg, string pkgPath, Pack var relativeFolder = Path.GetDirectoryName(packageRelativeFilePath); var targetFolder = Path.Join(isPlugin ? "./ServerPlugins" : "./bin", relativeFolder); - Directory.CreateDirectory(targetFolder); - File.Copy(filePath, Path.Join(targetFolder, Path.GetFileName(filePath)), true); + if (File.Exists(filePath)) + { + Directory.CreateDirectory(targetFolder); + File.Copy(filePath, Path.Join(targetFolder, Path.GetFileName(filePath)), true); + } } } } From 74a07150f82eefb4a3359bb7f3b0911f91d8f5ae Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 26 Jan 2025 13:37:38 +0900 Subject: [PATCH 49/50] Update submodule --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 8a3fffd71..d4bb7e3a2 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 8a3fffd71db401736ea80619122c70c449c10ff3 +Subproject commit d4bb7e3a21e875cfeb23bcf5cf847c85d9470ccf From c4a141308e58d4c7cc9ac07fac8143434597b13d Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Sun, 26 Jan 2025 15:11:15 +0900 Subject: [PATCH 50/50] Automatic language detection --- TShockAPI/I18n.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TShockAPI/I18n.cs b/TShockAPI/I18n.cs index e8f5eedbb..ac2985d09 100644 --- a/TShockAPI/I18n.cs +++ b/TShockAPI/I18n.cs @@ -60,6 +60,12 @@ static CultureInfo Redirect(CultureInfo cultureInfo) } } + if (LanguageManager.Instance.ActiveCulture == GameCulture.DefaultCulture) + { + var bf = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static; + // LanguageManager.SetLanguage will change this so we need to reset it back to null + typeof(CultureInfo).GetField("s_currentThreadUICulture", bf)?.SetValue(null, null); + } return CultureInfo.CurrentUICulture; } }