From 4621a2f7f5b6d3a0541ed8d824e2db9d1757d0b5 Mon Sep 17 00:00:00 2001 From: yuyu Date: Sun, 23 Oct 2022 20:36:05 +0800 Subject: [PATCH 1/2] Update Bouncer / OnNPCAddBuff --- TShockAPI/Bouncer.cs | 66 +++++++++++++++++++++++++--------------- TShockAPI/Permissions.cs | 5 ++- docs/changelog.md | 1 + 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 8d7a92a6..a2d7ac0e 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1737,7 +1737,7 @@ namespace TShockAPI { bucket = 6; } - else if (selectedItemType == ItemID.BottomlessHoneyBucket + else if (selectedItemType == ItemID.BottomlessHoneyBucket || selectedItemType == ItemID.HoneyAbsorbantSponge) { bucket = 7; @@ -1981,36 +1981,52 @@ namespace TShockAPI return; } - bool detectedNPCBuffTimeCheat = false; - - if (NPCAddBuffTimeMax.ContainsKey(type)) + if (!args.Player.HasPermission(Permissions.ignorenpcbuffdetection)) { - if (time > NPCAddBuffTimeMax[type]) + bool detectedNPCBuffTimeCheat = false; + + if (NPCAddBuffTimeMax.ContainsKey(type)) + { + if (time > NPCAddBuffTimeMax[type]) + { + detectedNPCBuffTimeCheat = true; + } + + if (npc.townNPC) + { + if (type != BuffID.Poisoned + && type != BuffID.OnFire + && type != BuffID.Confused + && type != BuffID.CursedInferno + && type != BuffID.Ichor + && type != BuffID.Venom + && type != BuffID.Midas + && type != BuffID.Wet + && type != BuffID.Lovestruck + && type != BuffID.Stinky + && type != BuffID.Slimed + && type != BuffID.DryadsWard + && type != BuffID.GelBalloonBuff + && type != BuffID.OnFire3 + && type != BuffID.Frostburn2 + && type != BuffID.Shimmer) + { + detectedNPCBuffTimeCheat = true; + } + } + } + else { detectedNPCBuffTimeCheat = true; } - if (npc.townNPC && npc.netID != NPCID.Guide && npc.netID != NPCID.Clothier) + if (detectedNPCBuffTimeCheat) { - if (type != BuffID.Lovestruck && type != BuffID.Stinky && type != BuffID.DryadsWard && - type != BuffID.Wet && type != BuffID.Slimed && type != BuffID.GelBalloonBuff && type != BuffID.Frostburn2 && - type != BuffID.Shimmer) - { - detectedNPCBuffTimeCheat = true; - } + TShock.Log.ConsoleDebug(GetString("Bouncer / OnNPCAddBuff rejected abnormal buff ({0}) added to {1} ({2}) from {3}.", type, npc.TypeName, npc.netID, args.Player.Name)); + args.Player.Kick(GetString($"Added buff to {npc.TypeName} NPC abnormally."), true); + args.Handled = true; } } - else - { - detectedNPCBuffTimeCheat = true; - } - - if (detectedNPCBuffTimeCheat) - { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnNPCAddBuff rejected abnormal buff ({0}) added to {1} ({2}) from {3}.", type, npc.TypeName, npc.netID, args.Player.Name)); - args.Player.Kick(GetString($"Added buff to {npc.TypeName} NPC abnormally."), true); - args.Handled = true; - } } /// The Bouncer handler for when an NPC is rehomed. @@ -2842,12 +2858,12 @@ namespace TShockAPI { BuffID.MaceWhipNPCDebuff, 240 }, // BuffID: 319 { BuffID.GelBalloonBuff, 1800 }, // BuffID: 320 { BuffID.OnFire3, 1200 }, // BuffID: 323 - { BuffID.Frostburn2, 900 }, // BuffID: 324 + { BuffID.Frostburn2, 1200 }, // BuffID: 324 { BuffID.BoneWhipNPCDebuff, 240 }, // BuffID: 326 { BuffID.TentacleSpike, 540 }, // BuffID: 337 { BuffID.CoolWhipNPCDebuff, 240 }, // BuffID: 340 { BuffID.BloodButcherer, 540 }, // BuffID: 344 - { BuffID.Shimmer, 100 }, // BuffID: 353 + { BuffID.Shimmer, 100 }, // BuffID: 353 }; /// diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 3e1f535a..4f18e780 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -155,6 +155,9 @@ namespace TShockAPI [Description("Prevents your actions from being ignored if damage is too high.")] public static readonly string ignoredamagecap = "tshock.ignore.damage"; + [Description("Prevents your from being kicked by npc buff hack detection.")] + public static readonly string ignorenpcbuffdetection = "tshock.ignore.npcbuff"; + [Description("Bypass server side character checks.")] public static readonly string bypassssc = "tshock.ignore.ssc"; @@ -439,7 +442,7 @@ namespace TShockAPI [Description("User can kill others.")] public static readonly string kill = "tshock.kill"; - + [Description("Player can respawn themselves.")] public static readonly string respawn = "tshock.respawn"; diff --git a/docs/changelog.md b/docs/changelog.md index 90100cea..3d2733fe 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -69,6 +69,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Check loadout slots for hacked item stacks. (@drunderscore) * Fix players being kicked after using the Flamethrower to apply the `OnFire3` debuff for `1200` ticks. (@BashGuy10) * Fix being kicked for using the new sponge types on liquid. (@BashGuy10) +* Allow flask buffs to be applied on town npc due to the Flymeal. Add a permission could skip the buff detection. (@KawaiiYuyu) ## TShock 4.5.18 * Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@PotatoCider) From dfbf2b3b3cea03f6ca913aae5d53a4c6fb5ba25f Mon Sep 17 00:00:00 2001 From: yuyu Date: Sun, 23 Oct 2022 23:08:45 +0800 Subject: [PATCH 2/2] Update permissions reference --- TShockAPI/Utils.cs | 3 +++ docs/permission-descriptions.md | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index e3adaa62..ffd9ce5f 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -945,6 +945,9 @@ namespace TShockAPI { PrepareLangForDump(); // Lang.setLang(true); + + Directory.CreateDirectory("docs"); + Configuration.TShockConfig.DumpDescriptions(); Permissions.DumpDescriptions(); Configuration.ServerSideConfig.DumpDescriptions(); diff --git a/docs/permission-descriptions.md b/docs/permission-descriptions.md index ff11f678..926b486d 100644 --- a/docs/permission-descriptions.md +++ b/docs/permission-descriptions.md @@ -210,6 +210,10 @@ Prevents you from being disabled by liquid set abuse detection. Prevents you from being disabled by abnormal MP. * **Commands**: `None` +## tshock.ignore.npcbuff +Prevents your from being kicked by npc buff hack detection. +* **Commands**: `None` + ## tshock.ignore.paint Prevents you from being disabled by paint abuse detection. * **Commands**: `None`