diff --git a/CHANGELOG.md b/CHANGELOG.md index 743141af..31049680 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,19 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * 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 + +## TShock 4.5.2 +* Added preliminary support for Terraria 1.4.2.2. (@hakusaro) +* Removed `/ungodme` and godmode warning (no longer necessary). Also, godmode now supports silent commands. (@hakusaro) + +## TShock 4.5.1 * Fixed server crash from `/v2/players/list` & other parameterised REST endpoints. (@QuiCM, reported by @ATFGK) * Added handling to the PlayerChat hook event. (@QuiCM - Thanks for the suggestion @Arthri) * Changed the spawnboss command to support silent command specifiers. (@QuiCM, suggested by @nojomyth-dev) +* Updated /godmode to use Journey Mode's Godmode power instead of healing on damage. (requested by @tlworks, backported by @bartico6, implemented preemptive bugfix for creative powers mentioned by @Stealownz) +* Fixed /r attempting to send messages to players that have since disconnected. (@bartico6, reported by @Arthri) +* Added ban ticket ID to ban messages (@QuiCM, suggested by @Bippity) +* Refactored /wallow command. /reply no longer bypasses /wallow (@QuiCM) ## TShock 4.5.0.1 * Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle, @ATFGK) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 20c21f26..601c2591 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -37,6 +37,7 @@ using OTAPI.Tile; using TShockAPI.Localization; using System.Text.RegularExpressions; using Terraria.DataStructures; +using Terraria.GameContent.Creative; namespace TShockAPI { @@ -1522,7 +1523,7 @@ namespace TShockAPI if (banResult?.Ban != null) { - player.Disconnect($"You have been banned: {banResult.Ban.Reason}."); + player.Disconnect($"#{banResult.Ban.TicketNumber} - You have been banned: {banResult.Ban.Reason}."); } } @@ -5303,8 +5304,6 @@ namespace TShockAPI args.Player.SendFileTextAsMessage(FileTools.RulesPath); } - public static bool[] WDisabled { get; set; } = new bool[256]; - public static void Whisper(CommandArgs args) { if (args.Parameters.Count < 2) @@ -5328,12 +5327,12 @@ namespace TShockAPI else { var plr = players[0]; - var msg = string.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); - if (WDisabled[players[0].Index]) + if (!plr.AcceptingWhispers) { - args.Player.SendErrorMessage("This player has disabled people from sending whispers!"); + args.Player.SendErrorMessage("This player is not accepting whispers."); return; } + var msg = string.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); plr.SendMessage(String.Format(" {1}", args.Player.Name, msg), Color.MediumPurple); args.Player.SendMessage(String.Format(" {1}", plr.Name, msg), Color.MediumPurple); plr.LastWhisper = args.Player; @@ -5341,17 +5340,11 @@ namespace TShockAPI } } - public static void Wallow(CommandArgs args) + private static void Wallow(CommandArgs args) { - int index = args.Player.Index; - if (WDisabled[index]) - { - args.Player.SendSuccessMessage("You will now recieve whispers from other players!"); - WDisabled[index] = !WDisabled[index]; - return; - } - WDisabled[index] = !WDisabled[index]; - args.Player.SendSuccessMessage("You will now not recieve whispers from other players, type '/wallow' to recieve them again!"); + args.Player.AcceptingWhispers = !args.Player.AcceptingWhispers; + args.Player.SendSuccessMessage($"You {(args.Player.AcceptingWhispers ? "may now" : "will no longer")} receive whispers from other players."); + args.Player.SendSuccessMessage($"You can toggle this with the '{Specifier}wallow' command."); } private static void Reply(CommandArgs args) @@ -5360,12 +5353,21 @@ namespace TShockAPI { args.Player.SendErrorMessage("You are muted."); } - else if (args.Player.LastWhisper != null) + else if (args.Player.LastWhisper != null && args.Player.LastWhisper.Active) { + if (!args.Player.LastWhisper.AcceptingWhispers) + { + args.Player.SendErrorMessage("This player is not accepting whispers."); + return; + } var msg = string.Join(" ", args.Parameters); args.Player.LastWhisper.SendMessage(String.Format(" {1}", args.Player.Name, msg), Color.MediumPurple); args.Player.SendMessage(String.Format(" {1}", args.Player.LastWhisper.Name, msg), Color.MediumPurple); } + else if (args.Player.LastWhisper != null) + { + args.Player.SendErrorMessage("The player you're attempting to reply to is no longer online."); + } else { args.Player.SendErrorMessage("You haven't previously received any whispers. Please use {0}whisper to whisper to other people.", Specifier); @@ -6445,14 +6447,18 @@ namespace TShockAPI playerToGod.GodMode = !playerToGod.GodMode; - if (playerToGod == args.Player) - { - args.Player.SendSuccessMessage(string.Format("You are {0} in god mode.", args.Player.GodMode ? "now" : "no longer")); - } - else + var godPower = CreativePowerManager.Instance.GetPower(); + + godPower.SetEnabledState(playerToGod.Index, playerToGod.GodMode); + + if (playerToGod != args.Player) { args.Player.SendSuccessMessage(string.Format("{0} is {1} in god mode.", playerToGod.Name, playerToGod.GodMode ? "now" : "no longer")); - playerToGod.SendSuccessMessage(string.Format("You are {0} in god mode.", playerToGod.GodMode ? "now" : "no longer")); + } + + if (!args.Silent || (playerToGod == args.Player)) + { + playerToGod.SendSuccessMessage(string.Format("You are {0} in god mode.", args.Player.GodMode ? "now" : "no longer")); } } diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs index 5777e84c..220d778e 100644 --- a/TShockAPI/DB/BanManager.cs +++ b/TShockAPI/DB/BanManager.cs @@ -205,12 +205,12 @@ namespace TShockAPI.DB { if (ban.ExpirationDateTime == DateTime.MaxValue) { - player.Disconnect("You are banned: " + ban.Reason); + player.Disconnect($"#{ban.TicketNumber} - You are banned: {ban.Reason}"); return true; } TimeSpan ts = ban.ExpirationDateTime - DateTime.UtcNow; - player.Disconnect($"You are banned: {ban.Reason} ({ban.GetPrettyExpirationString()} remaining)"); + player.Disconnect($"#{ban.TicketNumber} - You are banned: {ban.Reason} ({ban.GetPrettyExpirationString()} remaining)"); return true; } diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 67eb764d..3345b582 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2576,10 +2576,6 @@ namespace TShockAPI args.Player.PlayerData.maxHealth = max; } - if (args.Player.GodMode && (cur < max)) - { - args.Player.Heal(args.TPlayer.statLifeMax2); - } return false; } @@ -3738,12 +3734,6 @@ namespace TShockAPI if (OnPlayerDamage(args.Player, args.Data, id, direction, dmg, pvp, crit, playerDeathReason)) return true; - if (TShock.Players[id].GodMode) - { - TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerDamageV2 rejected (god mode on) {0}", args.Player.Name); - TShock.Players[id].Heal(args.TPlayer.statLifeMax); - } - return false; } diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 1e1ba3db..b8a1fbb0 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ using System.Runtime.InteropServices; // Also, be sure to release on github with the exact assembly version tag as below // so that the update manager works correctly (via the Github releases api and mimic) -[assembly: AssemblyVersion("4.5.0.1")] -[assembly: AssemblyFileVersion("4.5.0.1")] +[assembly: AssemblyVersion("4.5.2")] +[assembly: AssemblyFileVersion("4.5.2")] diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 4c24468b..68d8e306 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -599,6 +599,11 @@ namespace TShockAPI public bool SilentJoinInProgress; + /// + /// Whether the player is accepting whispers from other users + /// + public bool AcceptingWhispers = true; + /// Checks if a player is in range of a given tile if range checks are enabled. /// The x coordinate of the tile. /// The y coordinate of the tile. diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 52bef011..c60e5961 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -44,6 +44,7 @@ using TShockAPI.Sockets; using TShockAPI.CLI; using TShockAPI.Localization; using TShockAPI.Configuration; +using Terraria.GameContent.Creative; namespace TShockAPI { @@ -57,7 +58,7 @@ namespace TShockAPI /// VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info. public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; /// VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions. - public static readonly string VersionCodename = "Stealownz + DeathCradle edition"; + public static readonly string VersionCodename = "April Lyrids edition"; /// SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins). public static string SavePath = "tshock"; @@ -1216,6 +1217,23 @@ namespace TShockAPI Players[args.Who] = null; + //Reset toggle creative powers to default, preventing potential power transfer & desync on another user occupying this slot later. + + foreach(var kv in CreativePowerManager.Instance._powersById) + { + var power = kv.Value; + + //No need to reset sliders - those are reset manually by the game, most likely an oversight that toggles don't receive this treatment. + + if (power is CreativePowers.APerPlayerTogglePower toggle) + { + if (toggle._perPlayerIsEnabled[args.Who] == toggle._defaultToggleState) + continue; + + toggle.SetEnabledState(args.Who, toggle._defaultToggleState); + } + } + if (tsplr.ReceivedInfo) { if (!tsplr.SilentKickInProgress && tsplr.State >= 3) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index e0302513..96c1bc95 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit e0302513009220a8d92ba12c867a401e7731d28a +Subproject commit 96c1bc95fe7526b294f65dc711a1494b5869c9ea