From 2f57336fe8b4f4ae21baf5017b4b9f221ee2563b Mon Sep 17 00:00:00 2001 From: ProfessorXZ Date: Sun, 31 Jul 2016 22:33:07 +0200 Subject: [PATCH] Fixes #1252 and #1160, remove the optional parameter from TSPlayer.SendMessage() --- TShockAPI/GetDataHandlers.cs | 39 ++++++++++++++++++++++++++++++++++++ TShockAPI/TSPlayer.cs | 12 +++++------ TShockAPI/TSServerPlayer.cs | 2 +- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 526f1f0b..74bff63b 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -30,6 +30,8 @@ using TShockAPI.DB; using TShockAPI.Net; using Terraria; using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.GameContent.Tile_Entities; namespace TShockAPI { @@ -1255,6 +1257,7 @@ namespace TShockAPI { PacketTypes.CatchNPC, HandleCatchNpc }, { PacketTypes.KillPortal, HandleKillPortal }, { PacketTypes.PlaceTileEntity, HandlePlaceTileEntity }, + { PacketTypes.PlaceItemFrame, HandlePlaceItemFrame }, { PacketTypes.ToggleParty, HandleToggleParty } }; } @@ -4140,6 +4143,42 @@ namespace TShockAPI return false; } + private static bool HandlePlaceItemFrame(GetDataHandlerArgs args) + { + var x = args.Data.ReadInt16(); + var y = args.Data.ReadInt16(); + var itemID = args.Data.ReadInt16(); + var prefix = args.Data.ReadInt8(); + var stack = args.Data.ReadInt16(); + var itemFrame = (TEItemFrame)TileEntity.ByID[TEItemFrame.Find(x, y)]; + + if (TShock.CheckIgnores(args.Player)) + { + NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + return true; + } + + if (TShock.CheckTilePermission(args.Player, x, y)) + { + NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + return true; + } + + if (TShock.CheckRangePermission(args.Player, x, y)) + { + NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + return true; + } + + if (itemFrame.item?.netID == args.TPlayer.inventory[args.TPlayer.selectedItem]?.netID) + { + NetMessage.SendData(86, -1, -1, "", itemFrame.ID, 0, 1); + return true; + } + + return false; + } + private static bool HandleToggleParty(GetDataHandlerArgs args) { if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty)) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index f6c60839..858b4ba9 100755 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -974,8 +974,7 @@ namespace TShockAPI /// The amount of red color to factor in. Max: 255. /// The amount of green color to factor in. Max: 255 /// The amount of blue color to factor in. Max: 255 - /// The number of pixels before the message splits lines. Defaults to -1, which is the client's screen width. - public virtual void SendMessage(string msg, byte red, byte green, byte blue, int messageLength = -1) + public virtual void SendMessage(string msg, byte red, byte green, byte blue) { if (msg.Contains("\n")) { @@ -986,7 +985,7 @@ namespace TShockAPI } return; } - SendData(PacketTypes.SmartTextMessage, msg, 255, red, green, blue, messageLength); + SendData(PacketTypes.SmartTextMessage, msg, 255, red, green, blue, -1); } /// @@ -997,8 +996,7 @@ namespace TShockAPI /// The amount of green color to factor in. Max: 255. /// The amount of blue color to factor in. Max: 255. /// The player who receives the message. - /// The number of pixels before the message splits lines. Defaults to -1, which is the client's screen width. - public virtual void SendMessageFromPlayer(string msg, byte red, byte green, byte blue, int ply, int messageLength = -1) + public virtual void SendMessageFromPlayer(string msg, byte red, byte green, byte blue, int ply) { if (msg.Contains("\n")) { @@ -1009,7 +1007,7 @@ namespace TShockAPI } return; } - SendDataFromPlayer(PacketTypes.SmartTextMessage, ply, msg, red, green, blue, messageLength); + SendDataFromPlayer(PacketTypes.SmartTextMessage, ply, msg, red, green, blue, -1); } /// @@ -1246,7 +1244,7 @@ namespace TShockAPI SendMessage(msg, color.R, color.G, color.B); } - public override void SendMessage(string msg, byte red, byte green, byte blue, int messageLength = -1) + public override void SendMessage(string msg, byte red, byte green, byte blue) { this.CommandOutput.Add(msg); } diff --git a/TShockAPI/TSServerPlayer.cs b/TShockAPI/TSServerPlayer.cs index c658d9a1..7618e0ca 100644 --- a/TShockAPI/TSServerPlayer.cs +++ b/TShockAPI/TSServerPlayer.cs @@ -50,7 +50,7 @@ namespace TShockAPI SendMessage(msg, color.R, color.G, color.B); } - public override void SendMessage(string msg, byte red, byte green, byte blue, int messageLength = -1) + public override void SendMessage(string msg, byte red, byte green, byte blue) { Console.WriteLine(msg); }