diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dac4b32..86dc96b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,11 @@ 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 -* Fixed server crash from `/v2/players/list` & other parameterised REST endpoints. (@QuiCM) +* 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) ## 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 37b950e7..d7a6350d 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 { @@ -544,6 +545,11 @@ namespace TShockAPI { HelpText = "Toggles godmode on a player." }); + add(new Command("", ForceUngod, "ungodme") + { + HelpText = "Removes godmode from your character.", + AllowServer = false + }); add(new Command(Permissions.heal, Heal, "heal") { HelpText = "Heals a player in HP and MP." @@ -5360,12 +5366,16 @@ namespace TShockAPI { args.Player.SendErrorMessage("You are muted."); } - else if (args.Player.LastWhisper != null) + else if (args.Player.LastWhisper != null && args.Player.LastWhisper.Active) { 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,15 +6455,26 @@ 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")); } + + playerToGod.SendSuccessMessage(string.Format("You are {0} in god mode.", args.Player.GodMode ? "now" : "no longer")); + playerToGod.SendInfoMessage("Please make sure to disable godmode using /ungodme before disconnecting, otherwise your character may remain in godmode indefinitely, including singleplayer."); + } + + private static void ForceUngod(CommandArgs args) + { + var godPower = CreativePowerManager.Instance.GetPower(); + + godPower.SetEnabledState(args.Player.Index, false); + + args.Player.SendSuccessMessage("Journey Godmode has been disabled on your character."); } #endregion Cheat Comamnds diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index deac632f..879e02ce 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2571,10 +2571,6 @@ namespace TShockAPI args.Player.PlayerData.maxHealth = max; } - if (args.Player.GodMode && (cur < max)) - { - args.Player.Heal(args.TPlayer.statLifeMax2); - } return false; } @@ -3733,12 +3729,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/TShock.cs b/TShockAPI/TShock.cs index 52bef011..211efbc5 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 { @@ -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)