From ad36e7eeb67024c95891f7dedff989c286c0a0f8 Mon Sep 17 00:00:00 2001 From: Arthri <41360489+a@users.noreply.github.com> Date: Tue, 9 Apr 2024 03:43:27 +0000 Subject: [PATCH 1/5] Add permission for Moondial and unrecognized SFX --- TShockAPI/GetDataHandlers.cs | 46 +++++++++++++++++++++++++++++++++--- TShockAPI/Permissions.cs | 3 +++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 1ef2f4f8b..2eb9be4fb 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3469,8 +3469,12 @@ private static bool HandleSpecial(GetDataHandlerArgs args) args.Player.Spawn(PlayerSpawnContext.RecallFromItem); return true; } - - if (type == 3) + else if (type == 2) + { + // Plays SoundID.Item1 + return false; + } + else if (type == 3) { if (!args.Player.HasPermission(Permissions.usesundial)) { @@ -3490,6 +3494,42 @@ private static bool HandleSpecial(GetDataHandlerArgs args) return true; } } + else if (type == 4) + { + // Big Mimic Spawn Smoke + return false; + } + else if (type == 5) + { + // Register Kill for Torch God in Bestiary + return false; + } + else if (type == 6) + { + if (!args.Player.HasPermission(Permissions.usemoondial)) + { + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleSpecial rejected enchanted moondial permission {args.Player.Name}")); + args.Player.SendErrorMessage(GetString("You do not have permission to use the Enchanted Moondial.")); + return true; + } + else if (TShock.Config.Settings.ForceTime != "normal") + { + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleSpecial rejected enchanted moondial permission (ForceTime) {args.Player.Name}")); + if (!args.Player.HasPermission(Permissions.cfgreload)) + { + args.Player.SendErrorMessage(GetString("You cannot use the Enchanted Moondial because time is stopped.")); + } + else + args.Player.SendErrorMessage(GetString("You must set ForceTime to normal via config to use the Enchanted Moondial.")); + return true; + } + } + else if (!args.Player.HasPermission($"tshock.specialeffects.{type}")) + { + args.Player.SendErrorMessage(GetString("You do not have permission to use this effect.")); + TShock.Log.ConsoleError(GetString("Unrecognized special effect (Packet 51). Please report this to the TShock developers.")); + return true; + } return false; } @@ -3785,7 +3825,7 @@ private static bool HandleTeleport(GetDataHandlerArgs args) if (type == 0 && !args.Player.HasPermission(Permissions.rod)) { TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type)); - args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. + args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); // Suggest renaming rod permission unless someone plans to add separate perms for the other 2 tp items. return true; } diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index d7ec7166d..6aea9859b 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -331,6 +331,9 @@ public static class Permissions [Description("Player can use the Enchanted Sundial item.")] public static readonly string usesundial = "tshock.world.time.usesundial"; + [Description("Player can use the Enchanted Moondial item.")] + public static readonly string usemoondial = "tshock.world.time.usemoondial"; + [Description("User can grow plants.")] public static readonly string grow = "tshock.world.grow"; From b0396900cc174d8f6df5a22452f8ce113137ae35 Mon Sep 17 00:00:00 2001 From: Arthri <41360489+a@users.noreply.github.com> Date: Tue, 9 Apr 2024 03:46:20 +0000 Subject: [PATCH 2/5] Update changelog --- docs/changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 035df8ada..1c3d27661 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -90,6 +90,8 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added a property `TSPlayer.Hostile`, which gets pvp player mode. (@AgaSpace) * Fixed typo in `/gbuff`. (@sgkoishi, #2955) * Rewrote the `.dockerignore` file into a denylist. (@timschumi) +* Added a new permission, `tshock.world.time.usemoondial`, for regulating use of Enchanted Moondial. (@Arthri) +* Added a set of new permissions, `tshock.specialeffects.{type}`, for regulating use of new special effects(Packet 51) which are not yet recognized by TShock. (@Arthri) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 1db76035a5255e096f98a08e45ee317f60be5e12 Mon Sep 17 00:00:00 2001 From: Arthri <41360489+a@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:03:51 +0000 Subject: [PATCH 3/5] Fix skeletron summon --- TShockAPI/GetDataHandlers.cs | 14 +++++++++----- docs/changelog.md | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 2eb9be4fb..755a9ff85 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3462,12 +3462,16 @@ private static bool HandleSpecial(GetDataHandlerArgs args) if (OnNPCSpecial(args.Player, args.Data, id, type)) return true; - if (type == 1 && TShock.Config.Settings.DisableDungeonGuardian) + if (type == 1) { - TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name)); - args.Player.SendMessage(GetString("The Dungeon Guardian returned you to your spawn point."), Color.Purple); - args.Player.Spawn(PlayerSpawnContext.RecallFromItem); - return true; + if (!args.Player.HasPermission(Permissions.summonboss)) + { + args.Player.SendErrorMessage(GetString("You do not have permission to summon the Skeletron.")); + TShock.Log.ConsoleDebug(GetString($"GetDataHandlers / HandleNpcStrike rejected Skeletron summon from {args.Player.Name}")); + return true; + } + + return false; } else if (type == 2) { diff --git a/docs/changelog.md b/docs/changelog.md index 1c3d27661..f0e19fd2e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -92,6 +92,9 @@ Use past tense when adding new entries; sign your name off when you add or chang * Rewrote the `.dockerignore` file into a denylist. (@timschumi) * Added a new permission, `tshock.world.time.usemoondial`, for regulating use of Enchanted Moondial. (@Arthri) * Added a set of new permissions, `tshock.specialeffects.{type}`, for regulating use of new special effects(Packet 51) which are not yet recognized by TShock. (@Arthri) +* Added check for `tshock.npc.summonboss` permission for Skeletron summoning. (@Arthri) +* Fixed `DisableDungeonGuardian` disabling Skeletron summon instead. The config option is useless as of writing. (@Arthri) +* Added CI for Docker images. (@timschumi) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 3295ee7a57801716e102b5c585f6444843c4226d Mon Sep 17 00:00:00 2001 From: Arthri <41360489+a@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:07:50 +0000 Subject: [PATCH 4/5] Remove unnecessary change --- docs/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 043558e99..489afccec 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -91,11 +91,11 @@ Use past tense when adding new entries; sign your name off when you add or chang * Fixed bug where when the `UseSqlLogs` config property is true, an empty log file would still get created. (@ZakFahey) * Fixed typo in `/gbuff`. (@sgkoishi, #2955) * Rewrote the `.dockerignore` file into a denylist. (@timschumi) +* Added CI for Docker images. (@timschumi) * Added a new permission, `tshock.world.time.usemoondial`, for regulating use of Enchanted Moondial. (@Arthri) * Added a set of new permissions, `tshock.specialeffects.{type}`, for regulating use of new special effects(Packet 51) which are not yet recognized by TShock. (@Arthri) * Added check for `tshock.npc.summonboss` permission for Skeletron summoning. (@Arthri) * Fixed `DisableDungeonGuardian` disabling Skeletron summon instead. The config option is useless as of writing. (@Arthri) -* Added CI for Docker images. (@timschumi) ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) From 060a3e5dfd6dd300af2f02199e4fd2f731c69e48 Mon Sep 17 00:00:00 2001 From: Arthri <41360489+a@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:09:08 +0000 Subject: [PATCH 5/5] Remove unnecessary change --- TShockAPI/GetDataHandlers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 755a9ff85..7377c7d19 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3829,7 +3829,7 @@ private static bool HandleTeleport(GetDataHandlerArgs args) if (type == 0 && !args.Player.HasPermission(Permissions.rod)) { TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type)); - args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. + args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); // Suggest renaming rod permission unless someone plans to add separate perms for the other 2 tp items. return true; }