From 78b72df79d2333b58589093d5b1b6457526d39fb Mon Sep 17 00:00:00 2001 From: quake1337 <3310937+bartico6@users.noreply.github.com> Date: Fri, 16 Apr 2021 10:14:46 +0200 Subject: [PATCH] Address JourneyMode Godmode issues - Add /ungodme to allow unstucking godmode for involuntarily godmodded characters - Warn player about disabling Godmode before disconnecting - Minor change to command format to reduce code copypaste. --- TShockAPI/Commands.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index c59c4962..d10ec1c3 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -545,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." @@ -6450,15 +6455,20 @@ namespace TShockAPI godPower.SetEnabledState(playerToGod.Index, playerToGod.GodMode); - if (playerToGod == args.Player) - { - args.Player.SendSuccessMessage(string.Format("You are {0} in god mode.", args.Player.GodMode ? "now" : "no longer")); - } - else + 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); } #endregion Cheat Comamnds