TileKill -> PlaceChest (hook changed, so did packet); +Bouncer
This commit is contained in:
parent
9f8db96188
commit
6d7c8aa019
3 changed files with 77 additions and 54 deletions
|
|
@ -68,6 +68,7 @@ Putting this stuff down here so things don't conflict as often.
|
||||||
* Added `TSPlayer` object to `GetDataHandlers.LiquidSetEventArgs`. (@hakusaro)
|
* Added `TSPlayer` object to `GetDataHandlers.LiquidSetEventArgs`. (@hakusaro)
|
||||||
* Removed `TShock.StartInvasion` for public use (moved to Utils and marked internal). (@hakusaro)
|
* Removed `TShock.StartInvasion` for public use (moved to Utils and marked internal). (@hakusaro)
|
||||||
* Fixed invasions started by TShock not reporting size correctly and probably not working at all. (@hakusaro)
|
* Fixed invasions started by TShock not reporting size correctly and probably not working at all. (@hakusaro)
|
||||||
|
* Removed `GetDataHandlers.TileKill` and replaced it with `GetDataHandlers.PlaceChest` as the packet originally designated as tile kill is now only used for chests. (@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.
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
// Setup hooks
|
// Setup hooks
|
||||||
|
|
||||||
|
GetDataHandlers.PlaceChest.Register(OnPlaceChest);
|
||||||
GetDataHandlers.LiquidSet.Register(OnLiquidSet);
|
GetDataHandlers.LiquidSet.Register(OnLiquidSet);
|
||||||
GetDataHandlers.ProjectileKill.Register(OnProjectileKill);
|
GetDataHandlers.ProjectileKill.Register(OnProjectileKill);
|
||||||
GetDataHandlers.PlayerUpdate.Register(OnPlayerUpdate);
|
GetDataHandlers.PlayerUpdate.Register(OnPlayerUpdate);
|
||||||
|
|
@ -53,6 +54,61 @@ namespace TShockAPI
|
||||||
GetDataHandlers.TileEdit.Register(OnTileEdit);
|
GetDataHandlers.TileEdit.Register(OnTileEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void OnPlaceChest(object sender, GetDataHandlers.PlaceChestEventArgs args)
|
||||||
|
{
|
||||||
|
int tileX = args.TileX;
|
||||||
|
int tileY = args.TileY;
|
||||||
|
int flag = args.Flag;
|
||||||
|
|
||||||
|
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (TShock.CheckIgnores(args.Player))
|
||||||
|
{
|
||||||
|
args.Player.SendTileSquare(tileX, tileY, 3);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag != 0 && flag != 4 // if no container or container2 placement
|
||||||
|
&& Main.tile[tileX, tileY].type != TileID.Containers
|
||||||
|
&& Main.tile[tileX, tileY].type != TileID.Dressers
|
||||||
|
&& Main.tile[tileX, tileY].type != TileID.Containers2
|
||||||
|
&& (!TShock.Utils.MaxChests() && Main.tile[tileX, tileY].type != TileID.Dirt)) //Chest
|
||||||
|
{
|
||||||
|
args.Player.SendTileSquare(tileX, tileY, 3);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag == 2) //place dresser
|
||||||
|
{
|
||||||
|
if ((TShock.Utils.TilePlacementValid(tileX, tileY + 1) && Main.tile[tileX, tileY + 1].type == TileID.Teleporter) ||
|
||||||
|
(TShock.Utils.TilePlacementValid(tileX + 1, tileY + 1) && Main.tile[tileX + 1, tileY + 1].type == TileID.Teleporter))
|
||||||
|
{
|
||||||
|
//Prevent a dresser from being placed on a teleporter, as this can cause client and server crashes.
|
||||||
|
args.Player.SendTileSquare(tileX, tileY, 3);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TShock.CheckTilePermission(args.Player, tileX, tileY))
|
||||||
|
{
|
||||||
|
args.Player.SendTileSquare(tileX, tileY, 3);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TShock.CheckRangePermission(args.Player, tileX, tileY))
|
||||||
|
{
|
||||||
|
args.Player.SendTileSquare(tileX, tileY, 3);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Handles Bouncer's liquid set anti-cheat.</summary>
|
/// <summary>Handles Bouncer's liquid set anti-cheat.</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>
|
||||||
|
|
|
||||||
|
|
@ -352,35 +352,41 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For use in a TileKill event
|
/// For use in a PlaceChest event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TileKillEventArgs : HandledEventArgs
|
public class PlaceChestEventArgs : HandledEventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>The TSPlayer that triggered the event</summary>
|
||||||
|
public TSPlayer Player { get; set; }
|
||||||
|
/// <summary>What the packet is doing (see MP packet docs).</summary>
|
||||||
|
public int Flag { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The X coordinate that is being killed
|
/// The X coordinate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TileX { get; set; }
|
public int TileX { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Y coordinate that is being killed
|
/// The Y coordinate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TileY { get; set; }
|
public int TileY { get; set; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TileKill - When a tile is removed from the world
|
/// When a chest is added or removed from the world.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HandlerList<TileKillEventArgs> TileKill;
|
public static HandlerList<PlaceChestEventArgs> PlaceChest;
|
||||||
|
|
||||||
private static bool OnTileKill(int tilex, int tiley)
|
private static bool OnPlaceChest(TSPlayer player, int flag, int tilex, int tiley)
|
||||||
{
|
{
|
||||||
if (TileKill == null)
|
if (PlaceChest == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var args = new TileKillEventArgs
|
var args = new PlaceChestEventArgs
|
||||||
{
|
{
|
||||||
|
Player = player,
|
||||||
|
Flag = flag,
|
||||||
TileX = tilex,
|
TileX = tilex,
|
||||||
TileY = tiley,
|
TileY = tiley,
|
||||||
};
|
};
|
||||||
TileKill.Invoke(null, args);
|
PlaceChest.Invoke(null, args);
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1391,7 +1397,7 @@ namespace TShockAPI
|
||||||
{ PacketTypes.ProjectileNew, HandleProjectileNew },
|
{ PacketTypes.ProjectileNew, HandleProjectileNew },
|
||||||
{ PacketTypes.TogglePvp, HandleTogglePvp },
|
{ PacketTypes.TogglePvp, HandleTogglePvp },
|
||||||
{ PacketTypes.PlayerTeam, HandlePlayerTeam },
|
{ PacketTypes.PlayerTeam, HandlePlayerTeam },
|
||||||
{ PacketTypes.TileKill, HandleTileKill },
|
{ PacketTypes.TileKill, HandlePlaceChest },
|
||||||
{ PacketTypes.LiquidSet, HandleLiquidSet },
|
{ PacketTypes.LiquidSet, HandleLiquidSet },
|
||||||
{ PacketTypes.PlayerSpawn, HandleSpawn },
|
{ PacketTypes.PlayerSpawn, HandleSpawn },
|
||||||
{ PacketTypes.ChestGetContents, HandleChestOpen },
|
{ PacketTypes.ChestGetContents, HandleChestOpen },
|
||||||
|
|
@ -2335,56 +2341,16 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool HandleTileKill(GetDataHandlerArgs args)
|
private static bool HandlePlaceChest(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
int flag = args.Data.ReadByte();
|
int flag = args.Data.ReadByte();
|
||||||
int tileX = args.Data.ReadInt16();
|
int tileX = args.Data.ReadInt16();
|
||||||
int tileY = args.Data.ReadInt16();
|
int tileY = args.Data.ReadInt16();
|
||||||
args.Data.ReadInt16(); // Ignore style
|
args.Data.ReadInt16(); // Ignore style
|
||||||
|
|
||||||
if (OnTileKill(tileX, tileY))
|
if (OnPlaceChest(args.Player, flag, tileX, tileY))
|
||||||
return true;
|
|
||||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (TShock.CheckIgnores(args.Player))
|
|
||||||
{
|
|
||||||
args.Player.SendTileSquare(tileX, tileY, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag != 0 && flag != 4 // if no container or container2 placement
|
|
||||||
&& Main.tile[tileX, tileY].type != TileID.Containers
|
|
||||||
&& Main.tile[tileX, tileY].type != TileID.Dressers
|
|
||||||
&& Main.tile[tileX, tileY].type != TileID.Containers2
|
|
||||||
&& (!TShock.Utils.MaxChests() && Main.tile[tileX, tileY].type != TileID.Dirt)) //Chest
|
|
||||||
{
|
|
||||||
args.Player.SendTileSquare(tileX, tileY, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag == 2) //place dresser
|
|
||||||
{
|
|
||||||
if ((TShock.Utils.TilePlacementValid(tileX, tileY + 1) && Main.tile[tileX, tileY + 1].type == TileID.Teleporter) ||
|
|
||||||
(TShock.Utils.TilePlacementValid(tileX + 1, tileY + 1) && Main.tile[tileX + 1, tileY + 1].type == TileID.Teleporter))
|
|
||||||
{
|
|
||||||
//Prevent a dresser from being placed on a teleporter, as this can cause client and server crashes.
|
|
||||||
args.Player.SendTileSquare(tileX, tileY, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TShock.CheckTilePermission(args.Player, tileX, tileY))
|
|
||||||
{
|
|
||||||
args.Player.SendTileSquare(tileX, tileY, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TShock.CheckRangePermission(args.Player, tileX, tileY))
|
|
||||||
{
|
|
||||||
args.Player.SendTileSquare(tileX, tileY, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue