diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a25311e..56ddb6a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Fix banned armour checks not clearing properly (thanks @tysonstrange) * Added warning message on invalid group comand (@hakusaro, thanks to IcyPhoenix, nuLLzy & Cy on Discord) * Moved item bans subsystem to isolated file/contained mini-plugin & reorganized codebase accordingly. (@hakusaro) +* Moved bouncer checks for item bans in OnTileEdit to item bans subsystem. (@hakusaro) ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6. diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index f55c7aaa..5258e7dd 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -297,15 +297,7 @@ namespace TShockAPI return; } - // Using the actuation accessory can lead to actuator hacking - if (TShock.Itembans.ItemIsBanned("Actuator", args.Player) && args.Player.TPlayer.autoActuator) - { - args.Player.SendTileSquare(tileX, tileY, 1); - args.Player.SendErrorMessage("You do not have permission to place actuators."); - args.Handled = true; - return; - } - if (TShock.Itembans.ItemIsBanned(EnglishLanguage.GetItemNameById(selectedItem.netID), args.Player) || editData >= (action == EditAction.PlaceTile ? Main.maxTileSets : Main.maxWallTypes)) + if (editData >= (action == EditAction.PlaceTile ? Main.maxTileSets : Main.maxWallTypes)) { args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; diff --git a/TShockAPI/ItemBans.cs b/TShockAPI/ItemBans.cs index b719db9c..a85f462c 100644 --- a/TShockAPI/ItemBans.cs +++ b/TShockAPI/ItemBans.cs @@ -59,6 +59,7 @@ namespace TShockAPI ServerApi.Hooks.GameUpdate.Register(plugin, OnGameUpdate); GetDataHandlers.PlayerUpdate += OnPlayerUpdate; GetDataHandlers.ChestItemChange += OnChestItemChange; + GetDataHandlers.TileEdit += OnTileEdit; } /// Called on the game update loop (the XNA tickrate). @@ -192,6 +193,27 @@ namespace TShockAPI return; } + internal void OnTileEdit(object sender, TileEditEventArgs args) + { + if (args.Action == EditAction.PlaceTile || args.Action == EditAction.PlaceWall) + { + if (args.Player.TPlayer.autoActuator && DataModel.ItemIsBanned("Actuator", args.Player)) + { + args.Player.SendTileSquare(args.X, args.Y, 1); + args.Player.SendErrorMessage("You do not have permission to place actuators."); + args.Handled = true; + return; + } + + if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(args.Player.SelectedItem.netID), args.Player)) + { + args.Player.SendTileSquare(args.X, args.Y, 4); + args.Handled = true; + return; + } + } + } + private void UnTaint(TSPlayer player) { player.IsDisabledForBannedWearable = false;