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

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