From 6d4682ed7e37722054b23c885cd6c85987605ccc Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 14 May 2023 09:11:18 +0700 Subject: [PATCH] Updated the `GodMode` field. * Changed the GodMode field to a property that is controlled by the journey mode. - Removed the call to godmode in `Commands.ToggleGodMode`. --- TShockAPI/Commands.cs | 4 ---- TShockAPI/TSPlayer.cs | 11 +++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2214f252..3d1767ea 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -6740,10 +6740,6 @@ namespace TShockAPI playerToGod.GodMode = !playerToGod.GodMode; - var godPower = CreativePowerManager.Instance.GetPower(); - - godPower.SetEnabledState(playerToGod.Index, playerToGod.GodMode); - if (playerToGod != args.Player) { args.Player.SendSuccessMessage(playerToGod.GodMode diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index ef5c3c22..f6ece337 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -34,6 +34,7 @@ using TShockAPI.Hooks; using TShockAPI.Net; using Timer = System.Timers.Timer; using System.Linq; +using Terraria.GameContent.Creative; namespace TShockAPI { @@ -935,9 +936,15 @@ namespace TShockAPI public bool LoginHarassed = false; /// - /// Player cant die, unless onehit + /// Controls the journey godmode /// - public bool GodMode = false; + public bool GodMode + { + get => + CreativePowerManager.Instance.GetPower().IsEnabledForPlayer(Index); + set => + CreativePowerManager.Instance.GetPower().SetEnabledState(Index, value); + } /// /// Players controls are inverted if using SSC