Move OnTileEdit ban checks: Bouncer -> Itembans

This change moves the ban checks used to determine, during TileEdit
events, if an item is banned, out of Bouncer and into the newly isolated
ItemBan subsystem. Rather than creating a large pull request for all of
these, I'm just going to create a series of commits and send them in one
at a time. This should result in about one PR per hook that uses item
bans that needs to move.
This commit is contained in:
Lucas Nicodemus 2020-05-16 21:47:59 -07:00
parent b5f95d5918
commit 1993900159
No known key found for this signature in database
GPG key ID: A07BD9023D1664DB
3 changed files with 24 additions and 9 deletions

View file

@ -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.

View file

@ -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;

View file

@ -59,6 +59,7 @@ namespace TShockAPI
ServerApi.Hooks.GameUpdate.Register(plugin, OnGameUpdate);
GetDataHandlers.PlayerUpdate += OnPlayerUpdate;
GetDataHandlers.ChestItemChange += OnChestItemChange;
GetDataHandlers.TileEdit += OnTileEdit;
}
/// <summary>Called on the game update loop (the XNA tickrate).</summary>
@ -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;