-
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2061 from Pryaxis/addtileentityinteraction
RequestTileEntityInteraction hook and handling.
- Loading branch information
Showing
5 changed files
with
141 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Terraria; | ||
using Terraria.DataStructures; | ||
using Terraria.GameContent.Tile_Entities; | ||
using static TShockAPI.GetDataHandlers; | ||
|
||
namespace TShockAPI.Handlers | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class RequestTileEntityInteractionHandler : IPacketHandler<RequestTileEntityInteractionEventArgs> | ||
{ | ||
public void OnReceive(object sender, RequestTileEntityInteractionEventArgs args) | ||
{ | ||
if (args.TileEntity is TEHatRack && !args.Player.HasBuildPermissionForTileObject(args.TileEntity.Position.X, args.TileEntity.Position.Y, TEHatRack.entityTileWidth, TEHatRack.entityTileHeight, false)) | ||
{ | ||
args.Player.SendErrorMessage("You do not have permission to modify a Hat Rack in a protected area!"); | ||
args.Handled = true; | ||
return; | ||
} | ||
else if (args.TileEntity is TEDisplayDoll && !args.Player.HasBuildPermissionForTileObject(args.TileEntity.Position.X, args.TileEntity.Position.Y, TEDisplayDoll.entityTileWidth, TEDisplayDoll.entityTileHeight, false)) | ||
{ | ||
args.Player.SendErrorMessage("You do not have permission to modify a Mannequin in a protected area!"); | ||
args.Handled = true; | ||
return; | ||
} | ||
else if (!args.Player.HasBuildPermission(args.TileEntity.Position.X, args.TileEntity.Position.Y, false)) | ||
{ | ||
args.Player.SendErrorMessage("You do not have permission to modify a TileEntity in a protected area!"); | ||
TShock.Log.ConsoleDebug($"RequestTileEntityInteractionHandler: Rejected packet due to lack of building permissions! - From {args.Player.Name} | Position X:{args.TileEntity.Position.X} Y:{args.TileEntity.Position.Y}, TileEntity type: {args.TileEntity.type}, Tile type: {Main.tile[args.TileEntity.Position.X, args.TileEntity.Position.Y].type}"); | ||
args.Handled = true; | ||
return; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters