From 65bbd80ca63689f2ac5a9448cc7759342044a128 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sun, 4 Jul 2021 21:33:48 -0400 Subject: [PATCH] Add perm check for EoL + Sundial ForceTime check If the player does not have permission to summon bosses, they should not be able to kill Prismatic Lacewing, which summons the Empress of Light. Using the Enchanted Sundial while ForceTime is set to day or night (via config) will conflict with TShock's continued attempts to set it back to day or night, this makes the world appear very glitchy. --- TShockAPI/GetDataHandlers.cs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index e92d19a9..dfb4467a 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2809,10 +2809,17 @@ namespace TShockAPI { args.Player.SendErrorMessage("You do not have permission to hurt Town NPCs."); args.Player.SendData(PacketTypes.NpcUpdate, "", id); - TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcStrike rejected npc strike {0}", args.Player.Name); + TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected npc strike {args.Player.Name}"); + return true; + } + + if (Main.npc[id].netID == NPCID.EmpressButterfly && !args.Player.HasPermission(Permissions.summonboss)) + { + args.Player.SendErrorMessage("You do not have permission to summon the Empress of Light."); + args.Player.SendData(PacketTypes.NpcUpdate, "", id); + TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected EoL summon from {args.Player.Name}"); return true; } - return false; } @@ -3201,11 +3208,20 @@ namespace TShockAPI return true; } - if (type == 3 && !args.Player.HasPermission(Permissions.usesundial)) + if (type == 3) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected enchanted sundial permission {0}", args.Player.Name); - args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial."); - return true; + if (!args.Player.HasPermission(Permissions.usesundial)) + { + TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission {args.Player.Name}"); + args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial."); + return true; + } + else if (TShock.Config.Settings.ForceTime != "normal") + { + TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission (ForceTime) { args.Player.Name}"); + args.Player.SendErrorMessage($"You must set ForceTime to normal via config to use the Enchanted Sundial."); + return true; + } } return false;