Create & move OnPlaceTileEntity to Bouncer; fix unreachable code
This commit is contained in:
parent
64facfc10c
commit
de017f2d41
3 changed files with 78 additions and 16 deletions
|
|
@ -78,6 +78,7 @@ Putting this stuff down here so things don't conflict as often.
|
||||||
* Added `TSPlayer` to `GetDataHandlers.NPCStrike`. (@hakusaro)
|
* Added `TSPlayer` to `GetDataHandlers.NPCStrike`. (@hakusaro)
|
||||||
* Added `TSPlayer` to `GetDataHandlers.PlayerAnimation`. (@hakusaro)
|
* Added `TSPlayer` to `GetDataHandlers.PlayerAnimation`. (@hakusaro)
|
||||||
* Added `GetDataHandlers.MassWireOperation` hook and related arguments. (@hakusaro)
|
* Added `GetDataHandlers.MassWireOperation` hook and related arguments. (@hakusaro)
|
||||||
|
* Added `GetDataHandlers.PlaceTileEntity` hook and related arguments. (@hakusaro)
|
||||||
|
|
||||||
## TShock 4.3.25
|
## 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.
|
* 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.
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
// Setup hooks
|
// Setup hooks
|
||||||
|
|
||||||
|
GetDataHandlers.PlaceTileEntity.Register(OnPlaceTileEntity);
|
||||||
GetDataHandlers.PlayerAnimation.Register(OnPlayerAnimation);
|
GetDataHandlers.PlayerAnimation.Register(OnPlayerAnimation);
|
||||||
GetDataHandlers.NPCStrike.Register(OnNPCStrike);
|
GetDataHandlers.NPCStrike.Register(OnNPCStrike);
|
||||||
GetDataHandlers.ItemDrop.Register(OnItemDrop);
|
GetDataHandlers.ItemDrop.Register(OnItemDrop);
|
||||||
|
|
@ -60,6 +61,30 @@ namespace TShockAPI
|
||||||
GetDataHandlers.TileEdit.Register(OnTileEdit);
|
GetDataHandlers.TileEdit.Register(OnTileEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Fired when a PlaceTileEntity occurs for basic anti-cheat on perms and range.</summary>
|
||||||
|
/// <param name="sender">The object that triggered the event.</param>
|
||||||
|
/// <param name="args">The packet arguments that the event has.</param>
|
||||||
|
internal void OnPlaceTileEntity(object sender, GetDataHandlers.PlaceTileEntityEventArgs args)
|
||||||
|
{
|
||||||
|
if (TShock.CheckIgnores(args.Player))
|
||||||
|
{
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TShock.CheckTilePermission(args.Player, args.X, args.Y))
|
||||||
|
{
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TShock.CheckRangePermission(args.Player, args.X, args.Y))
|
||||||
|
{
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Handles validation of of basic anti-cheat on mass wire operations.</summary>
|
/// <summary>Handles validation of of basic anti-cheat on mass wire operations.</summary>
|
||||||
/// <param name="sender">The object that triggered the event.</param>
|
/// <param name="sender">The object that triggered the event.</param>
|
||||||
/// <param name="args">The packet arguments that the event has.</param>
|
/// <param name="args">The packet arguments that the event has.</param>
|
||||||
|
|
@ -87,16 +112,22 @@ namespace TShockAPI
|
||||||
y = p.Y;
|
y = p.Y;
|
||||||
|
|
||||||
if (!TShock.Utils.TilePlacementValid(x, y) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
if (!TShock.Utils.TilePlacementValid(x, y) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||||
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TShock.CheckIgnores(args.Player))
|
if (TShock.CheckIgnores(args.Player))
|
||||||
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TShock.CheckTilePermission(args.Player, x, y))
|
if (TShock.CheckTilePermission(args.Player, x, y))
|
||||||
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,8 +528,10 @@ namespace TShockAPI
|
||||||
int flag = args.Flag;
|
int flag = args.Flag;
|
||||||
|
|
||||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||||
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TShock.CheckIgnores(args.Player))
|
if (TShock.CheckIgnores(args.Player))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1304,6 +1304,42 @@ namespace TShockAPI
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>For use in a PlaceTileEntity event.</summary>
|
||||||
|
public class PlaceTileEntityEventArgs : HandledEventArgs
|
||||||
|
{
|
||||||
|
/// <summary>The TSPlayer that triggered the event.</summary>
|
||||||
|
public TSPlayer Player { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The X coordinate of the event.</summary>
|
||||||
|
public short X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The Y coordinate of the event.</summary>
|
||||||
|
public short Y { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The Type of event.</summary>
|
||||||
|
public byte Type { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Fired when a PlaceTileEntity event occurs.</summary>
|
||||||
|
public static HandlerList<PlaceTileEntityEventArgs> PlaceTileEntity;
|
||||||
|
|
||||||
|
private static bool OnPlaceTileEntity(TSPlayer player, short x, short y, byte type)
|
||||||
|
{
|
||||||
|
if (PlaceTileEntity == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var args = new PlaceTileEntityEventArgs
|
||||||
|
{
|
||||||
|
Player = player,
|
||||||
|
X = x,
|
||||||
|
Y = y,
|
||||||
|
Type = type
|
||||||
|
};
|
||||||
|
|
||||||
|
PlaceTileEntity.Invoke(null, args);
|
||||||
|
return args.Handled;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For use with a NPCSpecial event
|
/// For use with a NPCSpecial event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3175,7 +3211,14 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
var x = args.Data.ReadInt16();
|
var x = args.Data.ReadInt16();
|
||||||
var y = args.Data.ReadInt16();
|
var y = args.Data.ReadInt16();
|
||||||
var type = args.Data.ReadByte();
|
var type = (byte) args.Data.ReadByte();
|
||||||
|
|
||||||
|
if (OnPlaceTileEntity(args.Player, x, y, type))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemBan subsystem
|
||||||
|
|
||||||
if (TShock.TileBans.TileIsBanned((short)TileID.LogicSensor, args.Player))
|
if (TShock.TileBans.TileIsBanned((short)TileID.LogicSensor, args.Player))
|
||||||
{
|
{
|
||||||
|
|
@ -3184,21 +3227,6 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TShock.CheckIgnores(args.Player))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TShock.CheckTilePermission(args.Player, x, y))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TShock.CheckRangePermission(args.Player, x, y))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue