From f25ed62599cf78a9c1d95e620318e702c7ebc449 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 May 2020 15:36:27 -0700 Subject: [PATCH 01/38] Make setup system less confusing to new players --- TShockAPI/Commands.cs | 24 +++++++++--------------- TShockAPI/TShock.cs | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 636f269d..1dc490d8 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -4996,23 +4996,17 @@ namespace TShockAPI { if (TShock.SetupToken == 0) { - if (args.Player.Group.Name == new SuperAdminGroup().Name) - args.Player.SendInfoMessage("The initial setup system is already disabled."); - else - { - args.Player.SendWarningMessage("The initial setup system is disabled. This incident has been logged."); - TShock.Log.Warn("{0} attempted to use the initial setup system even though it's disabled.", args.Player.IP); - return; - } + args.Player.SendWarningMessage("The initial setup system is disabled. This incident has been logged."); + args.Player.SendWarningMessage("If you are locked out of all admin accounts, ask for help on https://tshock.co/"); + TShock.Log.Warn("{0} attempted to use the initial setup system even though it's disabled.", args.Player.IP); + return; } - // If the user account is already a superadmin (permanent), disable the system + // If the user account is already logged in, turn off the setup system if (args.Player.IsLoggedIn && args.Player.tempGroup == null) { args.Player.SendSuccessMessage("Your new account has been verified, and the {0}setup system has been turned off.", Specifier); - args.Player.SendSuccessMessage("You can always use the {0}user command to manage players.", Specifier); - args.Player.SendSuccessMessage("The setup system will remain disabled as long as a superadmin exists (even if you delete setup.lock)."); - args.Player.SendSuccessMessage("Share your server, talk with other admins, and more on GitHub! -- https://tshock.co/"); + args.Player.SendSuccessMessage("Share your server, talk with admins, and chill on GitHub & Discord. -- https://tshock.co/"); args.Player.SendSuccessMessage("Thank you for using TShock for Terraria!"); FileTools.CreateFile(Path.Combine(TShock.SavePath, "setup.lock")); File.Delete(Path.Combine(TShock.SavePath, "setup-code.txt")); @@ -5038,11 +5032,11 @@ namespace TShockAPI args.Player.tempGroup = new SuperAdminGroup(); args.Player.SendInfoMessage("Temporary system access has been given to you, so you can run one command."); - args.Player.SendInfoMessage("Please use the following to create a permanent account for you."); - args.Player.SendInfoMessage("{0}user add owner", Specifier); + args.Player.SendWarningMessage("Please use the following to create a permanent account for you."); + args.Player.SendWarningMessage("{0}user add owner", Specifier); args.Player.SendInfoMessage("Creates: with the password as part of the owner group."); args.Player.SendInfoMessage("Please use {0}login after this process.", Specifier); - args.Player.SendInfoMessage("If you understand, please {0}login now, and then type {0}setup.", Specifier); + args.Player.SendWarningMessage("If you understand, please {0}login now, and then type {0}setup.", Specifier); return; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index a8a164d0..d0b174b4 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -846,7 +846,7 @@ namespace TShockAPI if (File.Exists(Path.Combine(SavePath, "setup-code.txt"))) { - Log.ConsoleInfo("A superadmin account has been detected in the user database, but setup-code.txt is still present."); + Log.ConsoleInfo("An account has been detected in the user database, but setup-code.txt is still present."); Log.ConsoleInfo("TShock will now disable the initial setup system and remove setup-code.txt as it is no longer needed."); File.Delete(Path.Combine(SavePath, "setup-code.txt")); } From 63522354b2a82f088e947822d6675f37111b9158 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 01:28:25 +0000 Subject: [PATCH 02/38] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index abdb437d..9877a2bd 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Retrograde-i486

💻 +
Colin Bohn

💻 From 395e6ae382ff689b9b45b314981123eb24e36b16 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 01:28:26 +0000 Subject: [PATCH 03/38] docs: update README_cn.md [skip ci] --- README_cn.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README_cn.md b/README_cn.md index caed48cb..c81b18b1 100644 --- a/README_cn.md +++ b/README_cn.md @@ -82,6 +82,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Retrograde-i486

💻 +
Colin Bohn

💻 From a95306b03b699bb052a72296db581e0c7a7e7572 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 01:28:27 +0000 Subject: [PATCH 04/38] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8066f717..8c01ca76 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -86,6 +86,15 @@ "contributions": [ "code" ] + }, + { + "login": "ColinBohn", + "name": "Colin Bohn", + "avatar_url": "https://avatars0.githubusercontent.com/u/1351268?v=4", + "profile": "http://colinbohn.me", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, From 51a8c7de549d7b0831efc7725185d674c260ee7f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 02:31:14 +0000 Subject: [PATCH 05/38] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9877a2bd..001e7129 100644 --- a/README.md +++ b/README.md @@ -267,6 +267,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Retrograde-i486

💻
Colin Bohn

💻 +
mrshroomy

⚠️ From 802a66f46388c28d5127dc4cc21aef7d27937537 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 02:31:15 +0000 Subject: [PATCH 06/38] docs: update README_cn.md [skip ci] --- README_cn.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README_cn.md b/README_cn.md index c81b18b1..c20a5419 100644 --- a/README_cn.md +++ b/README_cn.md @@ -83,6 +83,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Retrograde-i486

💻
Colin Bohn

💻 +
mrshroomy

⚠️ From 3f4118ab16fbf9e9880833f688e3b80edf44b1bf Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 02:31:16 +0000 Subject: [PATCH 07/38] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8c01ca76..52d0c591 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -95,6 +95,15 @@ "contributions": [ "code" ] + }, + { + "login": "mrshroomy", + "name": "mrshroomy", + "avatar_url": "https://avatars0.githubusercontent.com/u/52048952?v=4", + "profile": "https://github.com/mrshroomy", + "contributions": [ + "test" + ] } ], "contributorsPerLine": 7, From 41ef9bff086e3992ad1506e816c2e1e149fdc737 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 02:32:16 +0000 Subject: [PATCH 08/38] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 001e7129..6842a580 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Retrograde-i486

💻
Colin Bohn

💻
mrshroomy

⚠️ +
agentsparrow

⚠️ From ec6150c2462c0153d9e151114c05defd9dca7d55 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 02:32:17 +0000 Subject: [PATCH 09/38] docs: update README_cn.md [skip ci] --- README_cn.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README_cn.md b/README_cn.md index c20a5419..70d3c33e 100644 --- a/README_cn.md +++ b/README_cn.md @@ -84,6 +84,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Retrograde-i486

💻
Colin Bohn

💻
mrshroomy

⚠️ +
agentsparrow

⚠️ From 05e56bb1ddeeeda2ac6d29d85d8c65b65afda87c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 02:32:18 +0000 Subject: [PATCH 10/38] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 52d0c591..0c5fe2b1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -104,6 +104,15 @@ "contributions": [ "test" ] + }, + { + "login": "agentsparrow", + "name": "agentsparrow", + "avatar_url": "https://avatars0.githubusercontent.com/u/16114336?v=4", + "profile": "https://github.com/agentsparrow", + "contributions": [ + "test" + ] } ], "contributorsPerLine": 7, From 341424248ca244c9b83728a893ddf6f67e1c4d9f Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 May 2020 21:44:23 -0700 Subject: [PATCH 11/38] Add changelog for TShock 4.4.0 Pre-release 5 Pre-release 1 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0563d49..88683245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. -## Upcoming changes +## TShock 4.4.0 (Pre-release 5 (Pre-release 1)) * Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder) * Make sqlite db path configurable. (@AxeelAnder) +* Terraria 1.4.0.3 experimental support. (@Patrikkk) +* Updated changelog. (@hakusaro) ## TShock 4.4.0 (Pre-release 4) * Debug logging now provides ConsoleDebug and ILog has been updated to support the concept of debug logs. Debug logs are now controlled by `config.json` instead of by preprocessor debug flag. (@hakusaro) From 56a9e27365de5b47d96819231ed4c481774957b8 Mon Sep 17 00:00:00 2001 From: Axeel Date: Thu, 21 May 2020 13:37:31 +0800 Subject: [PATCH 12/38] Fix player respawn again (#1830) * fix respawn time unit, add spawn bouncer, add respawn time config warning Co-authored-by: Lucas Nicodemus --- TShockAPI/ConfigFile.cs | 8 ++++---- TShockAPI/GetDataHandlers.cs | 5 +++++ TShockAPI/TSPlayer.cs | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 5d30da0e..fb920732 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -441,12 +441,12 @@ namespace TShockAPI [Description("Whether or not to log REST API connections.")] public bool LogRest = false; - /// The number of seconds a player must wait before being respawned. - [Description("The number of seconds a player must wait before being respawned.")] + /// The number of seconds a player must wait before being respawned. Cannot be longer than normal value now. Use at your own risk. + [Description("The number of seconds a player must wait before being respawned. Cannot be longer than normal value now. Use at your own risk.")] public int RespawnSeconds = 5; - /// The number of seconds a player must wait before being respawned if there is a boss nearby. - [Description("The number of seconds a player must wait before being respawned if there is a boss nearby.")] + /// The number of seconds a player must wait before being respawned if there is a boss nearby. Cannot be longer than normal value now. Use at your own risk. + [Description("The number of seconds a player must wait before being respawned if there is a boss nearby. Cannot be longer than normal value now. Use at your own risk.")] public int RespawnBossSeconds = 10; /// Disables a player if this number of tiles is painted within 1 second. diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 93d79dea..ade308cd 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2065,6 +2065,11 @@ namespace TShockAPI private static bool HandleSpawn(GetDataHandlerArgs args) { + if (args.Player.Dead && args.Player.RespawnTimer > 0) + { + return true; + } + byte player = args.Data.ReadInt8(); short spawnx = args.Data.ReadInt16(); short spawny = args.Data.ReadInt16(); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 8f450604..49373448 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -299,9 +299,10 @@ namespace TShockAPI /// public int RespawnTimer { - get => TPlayer.respawnTimer; - set => TPlayer.respawnTimer = value; + get => _respawnTimer; + set => TPlayer.respawnTimer = (_respawnTimer = value) * 60; } + private int _respawnTimer; /// /// Whether the player is dead or not. @@ -1196,7 +1197,7 @@ namespace TShockAPI PlayerIndex = (byte)Index, TileX = (short)tilex, TileY = (short)tiley, - RespawnTimer = respawnTimer ?? TShock.Players[Index].TPlayer.respawnTimer, + RespawnTimer = respawnTimer ?? TShock.Players[Index].RespawnTimer * 60, PlayerSpawnContext = context, }; msg.PackFull(ms); From 243b6e8c2bed9f11e7336c45c457f11c77cdb3f5 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 May 2020 23:05:46 -0700 Subject: [PATCH 13/38] Remove urgent notice banner about 1.4.x.x We have builds available now, so we don't need this banner. --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6842a580..2307ec8e 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,13 @@ TShock is a toolbox for Terraria servers and communities. That toolbox is jam packed with anti-cheat tools, server-side characters, groups, permissions, item bans, tons of commands, and limitless potential. It's one of a kind. -**We are currently polishing on Terraria 1.4.0.2 (curRelease = 226). For updates, check our [twitter, @Pryaxis](https://twitter.com/Pryaxis).** - -* Download: [Stable](https://github.com/TShock/TShock/releases) or [Experimental](#experimental-downloads). -* Download: [Plugins and tools](https://github.com/Pryaxis/plugins) that work with TShock, TSAPI, and Terraria. +* Download: [official](https://github.com/TShock/TShock/releases) or [experimental](#experimental-downloads). +* Download: [plugins and tools](https://github.com/Pryaxis/plugins) that work with TShock, TSAPI, and Terraria. * Read [the documentation](https://tshock.readme.io/) to quickly get up to speed. * Join [Discord](https://discord.gg/Cav9nYX). * Use the ancient [old forums](https://tshock.co/xf/index.php?resources/) to find old stuff. * Talk on [GitHub discussions](https://github.com/Pryaxis/TShock/discussions) to ask for help, chat, and other things. This is the best way to get help if Discord isn't your thing. +* For news, follow [@Pryaxis](https://twitter.com/Pryaxis) on Twitter. ---- From 00d387082b80ed7b4fb6168f04042e0e9e4063e7 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Thu, 21 May 2020 00:35:11 -0700 Subject: [PATCH 14/38] Update submodule (OTAPI 2.0.0.34)/Terraria 1.4.0.3 --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index e39f6fe7..190cc8be 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit e39f6fe7526ddb6e67fe6c428e3614bae38d0c04 +Subproject commit 190cc8bebbd430e292c3bddbe6788224b01cd9ed From c7fa0ec8b6f616d1d9ea809ab6a1cf01d211ad56 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Thu, 21 May 2020 00:40:28 -0700 Subject: [PATCH 15/38] Update TSAPI submod again for Terraria 1.4.0.3 --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 190cc8be..fd45935c 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 190cc8bebbd430e292c3bddbe6788224b01cd9ed +Subproject commit fd45935cc73825a19272e3c8af3dac2cd9657dca From 0a717bb7ec42abc43d919f06ef017d0515a998ec Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Thu, 21 May 2020 01:06:10 -0700 Subject: [PATCH 16/38] Update submodule for OTAPI 2.0.0.35 --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index fd45935c..049f2775 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit fd45935cc73825a19272e3c8af3dac2cd9657dca +Subproject commit 049f27750cb70f97ff33e106dec108595980e76d From d58a26d884194a1a4263ca8c9dc6f338221d1407 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Thu, 21 May 2020 01:09:37 -0700 Subject: [PATCH 17/38] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88683245..a47d9c27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. -## TShock 4.4.0 (Pre-release 5 (Pre-release 1)) +## TShock 4.4.0 (Pre-release 6) +* Updates to OTAPI 2.0.0.35 (@DeathCradle). + +## TShock 4.4.0 (Pre-release 5) * Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder) * Make sqlite db path configurable. (@AxeelAnder) * Terraria 1.4.0.3 experimental support. (@Patrikkk) From 83eb707761dc37ebb0b7a90aadeca5896fb568f0 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Fri, 22 May 2020 13:27:03 +0930 Subject: [PATCH 18/38] Update SendMessage and SendMessageFromPlayer to use inbuilt Terraria chat messaging --- TShockAPI/TSPlayer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 49373448..8ef56027 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1421,7 +1421,15 @@ namespace TShockAPI } return; } - SendData(PacketTypes.SmartTextMessage, msg, 255, red, green, blue, -1); + + if (this.Index == -1) //-1 is our broadcast index - this implies we're using TSPlayer.All.SendMessage and broadcasting to all clients + { + Terraria.Chat.ChatHelper.BroadcastChatMessage(NetworkText.FromFormattable(msg), new Color(red, green, blue)); + } + else + { + Terraria.Chat.ChatHelper.SendChatMessageToClient(NetworkText.FromFormattable(msg), new Color(red, green, blue), this.Index); + } } /// @@ -1443,7 +1451,7 @@ namespace TShockAPI } return; } - SendDataFromPlayer(PacketTypes.SmartTextMessage, ply, msg, red, green, blue, -1); + Terraria.Chat.ChatHelper.BroadcastChatMessageAs((byte)ply, NetworkText.FromFormattable(msg), new Color(red, green, blue)); } /// From b9b83dd36f31b2e038e5720cd844ae43878bc267 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Fri, 22 May 2020 14:41:52 +0930 Subject: [PATCH 19/38] Resolve null reference on REST user group name. Solves #1850 --- TShockAPI/Rest/RestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index f0c43aa0..95d9a39a 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -411,7 +411,7 @@ namespace TShockAPI var players = new ArrayList(); foreach (TSPlayer tsPlayer in TShock.Players.Where(p => null != p)) { - var p = PlayerFilter(tsPlayer, args.Parameters, ((args.TokenData.UserGroupName) != "" && TShock.Groups.GetGroupByName(args.TokenData.UserGroupName).HasPermission(RestPermissions.viewips))); + var p = PlayerFilter(tsPlayer, args.Parameters, (!string.IsNullOrEmpty(args.TokenData.UserGroupName) && TShock.Groups.GetGroupByName(args.TokenData.UserGroupName).HasPermission(RestPermissions.viewips))); if (null != p) players.Add(p); } From 836fd1d156c7b96960bd90a1a3afce47e8c84907 Mon Sep 17 00:00:00 2001 From: Olink Date: Fri, 22 May 2020 13:35:02 -0400 Subject: [PATCH 20/38] Fix for spawn issues when using SSC and beds It looks like the only time the client informs the server of the spawn location is via the PlayerSpawn packet. In SSC, understandably, we don't trust any updates from the client if we can avoid it. In this scenario, we have code in PlayerSpawn to check for beds when they attempt to spawn, but no code to handle negative spawn locations. The client sends -1,-1 coordinates when the player has no spawn. We should trust this. --- CHANGELOG.md | 3 +++ TShockAPI/GetDataHandlers.cs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47d9c27..a17689f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. +## TShock 4.4.0 (Pre-release ?) +* Fix bed spawn issues when trying to remove spawn point in SSC (@Olink) + ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index ade308cd..b45bb270 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2079,6 +2079,13 @@ namespace TShockAPI if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny, respawnTimer, context)) return true; + if ((Main.ServerSideCharacter) && (spawnx == -1 && spawny == -1)) //this means they want to spawn to vanilla spawn + { + args.Player.sX = Main.spawnTileX; + args.Player.sY = Main.spawnTileY; + args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); + } + if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY))) { From 7d83e06e834599c98392508fc4d709fb9604d202 Mon Sep 17 00:00:00 2001 From: Olink Date: Fri, 22 May 2020 18:02:03 -0400 Subject: [PATCH 21/38] Fix the snake flute item. --- CHANGELOG.md | 1 + TShockAPI/GetDataHandlers.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a17689f3..0bfac74d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## TShock 4.4.0 (Pre-release ?) * Fix bed spawn issues when trying to remove spawn point in SSC (@Olink) +* Fix Snake Flute (@Olink) ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index b45bb270..efc032c1 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3360,6 +3360,7 @@ namespace TShockAPI { ProjectileID.EbonsandBallGun, TileID.Ebonsand }, { ProjectileID.PearlSandBallGun, TileID.Pearlsand }, { ProjectileID.CrimsandBallGun, TileID.Crimsand }, + { ProjectileID.MysticSnakeCoil, TileID.MysticSnakeRope } }; internal static Dictionary ropeCoilPlacements = new Dictionary From 7a5c2e4d260d797bdd03c28e9b8475effa5ba9ac Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 15:34:04 -0700 Subject: [PATCH 22/38] Add verbose logging for many bouncer packets This type of change is designed to make it easier to debug problems with Bouncer's anticheat checks and antigrief checks by allowing server operators to send better reports. In particular, the logs will help us diagnose precisely which checks are tripping, and they can cross correlate the item with the check to adjust the precise check. More work is needed to add more checks in more places, but you can't just do this naively and need to actually think when adding things. --- TShockAPI/Bouncer.cs | 75 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 0231e9a9..528caac5 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -366,6 +366,7 @@ namespace TShockAPI && selectedItem.type != ItemID.MulticolorWrench && selectedItem.type != ItemID.WireKite) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from place wire from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -379,6 +380,7 @@ namespace TShockAPI && selectedItem.type != ItemID.WireKite && selectedItem.type != ItemID.MulticolorWrench) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from wire cutter from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -389,6 +391,7 @@ namespace TShockAPI // If they aren't selecting the actuator and don't have the Presserator equipped, they're hacking. if (selectedItem.type != ItemID.Actuator && !args.Player.TPlayer.autoActuator) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from actuator/presserator from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -398,6 +401,7 @@ namespace TShockAPI { if (action == EditAction.KillWall) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from sts allow cut from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -408,6 +412,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from wire cutter from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -416,6 +421,7 @@ namespace TShockAPI if (!args.Player.HasModifiedIceSuccessfully(tileX, tileY, editData, action) && !args.Player.HasBuildPermission(tileX, tileY)) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from ice/build from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -434,7 +440,7 @@ namespace TShockAPI args.Handled = false; return; } - + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from explosives/fuses from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -442,6 +448,8 @@ namespace TShockAPI if (args.Player.TileKillThreshold >= TShock.Config.TileKillThreshold) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from tile kill threshold from {0}, (value: {1})", args.Player.Name, args.Player.TileKillThreshold); + TShock.Log.ConsoleDebug("If this player wasn't hacking, please report the damage value they were disabled for to TShock so we can improve this!"); args.Player.Disable("Reached TileKill threshold.", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; @@ -450,6 +458,8 @@ namespace TShockAPI if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from tile place threshold from {0}, (value: {1})", args.Player.Name, args.Player.TilePlaceThreshold); + TShock.Log.ConsoleDebug("If this player wasn't hacking, please report the damage value they were disabled for to TShock so we can improve this!"); args.Player.Disable("Reached TilePlace threshold.", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; @@ -458,6 +468,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from throttled from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -486,6 +497,8 @@ namespace TShockAPI } catch { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from weird confusing flow control from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("If you're seeing this message and you know what that player did, please report it to TShock for further investigation."); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -503,6 +516,7 @@ namespace TShockAPI if (args.Player.HasPermission(Permissions.allowclientsideworldedit)) { + TShock.Log.ConsoleDebug("Bouncer / SendTileSquare rejected clientside world edit from {0}", args.Player.Name); args.Handled = false; return; } @@ -511,12 +525,14 @@ namespace TShockAPI // IIRC it's because 5 means a 5x5 square which is normal for a tile square, and anything bigger is a non-vanilla tile modification attempt if (size > 5) { + TShock.Log.ConsoleDebug("Bouncer / SendTileSquare rejected from non-vanilla tilemod from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / SendTileSquare rejected from throttle from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, size); args.Handled = true; return; @@ -524,6 +540,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / SendTileSquare rejected from being disabled from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, size); args.Handled = true; return; @@ -682,6 +699,7 @@ namespace TShockAPI args.Player.SendTileSquare(tileX, tileY, size); } + TShock.Log.ConsoleDebug("Bouncer / SendTileSquare rejected from spaghetti from {0}", args.Player.Name); args.Handled = true; } @@ -703,6 +721,7 @@ namespace TShockAPI { // Causes item duplications. Will be re added later if necessary //args.Player.SendData(PacketTypes.ItemDrop, "", id); + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from attempt crash from {0}", args.Player.Name); args.Handled = true; return; } @@ -712,6 +731,8 @@ namespace TShockAPI // will break item pickups on the client. if (prefix > PrefixID.Count) { + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from prefix check from {0}", args.Player.Name); + args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; return; @@ -725,6 +746,7 @@ namespace TShockAPI { // Causes item duplications. Will be re added if necessary //args.Player.SendData(PacketTypes.ItemDrop, "", id); + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from dupe range check from {0}", args.Player.Name); args.Handled = true; return; } @@ -735,6 +757,7 @@ namespace TShockAPI if (!args.Player.IsInRange((int)(pos.X / 16f), (int)(pos.Y / 16f))) { + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from range check from {0}", args.Player.Name); args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; return; @@ -744,6 +767,7 @@ namespace TShockAPI // only if the client isn't picking up the item if (Main.item[id].active && Main.item[id].netID != type) { + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from item drop/pickup check from {0}", args.Player.Name); args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; return; @@ -753,6 +777,7 @@ namespace TShockAPI item.netDefaults(type); if ((stacks > item.maxStack || stacks <= 0) || (TShock.Itembans.ItemIsBanned(EnglishLanguage.GetItemNameById(item.type), args.Player) && !args.Player.HasPermission(Permissions.allowdroppingbanneditems))) { + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from drop item ban check / max stack check / min stack check from {0}", args.Player.Name); args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; return; @@ -763,6 +788,7 @@ namespace TShockAPI { //Player is probably trying to sneak items onto the server in their hands!!! TShock.Log.ConsoleInfo("Player {0} tried to sneak {1} onto the server!", args.Player.Name, item.Name); + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from sneaky from {0}", args.Player.Name); args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; return; @@ -771,6 +797,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnItemDrop rejected from disabled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; return; @@ -793,6 +820,7 @@ namespace TShockAPI if (index > Main.maxProjectiles) { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from above projectile limit from {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -801,6 +829,7 @@ namespace TShockAPI if (TShock.ProjectileBans.ProjectileIsBanned(type, args.Player)) { args.Player.Disable(String.Format("Player does not have permission to create projectile {0}.", type), DisableFlags.WriteToLogAndConsole); + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from permission check from {0} {1}", args.Player.Name, type); args.Player.SendErrorMessage("You do not have permission to create that projectile."); args.Player.RemoveProjectile(ident, owner); args.Handled = true; @@ -810,6 +839,7 @@ namespace TShockAPI if (damage > TShock.Config.MaxProjDamage && !args.Player.HasPermission(Permissions.ignoredamagecap)) { args.Player.Disable(String.Format("Projectile damage is higher than {0}.", TShock.Config.MaxProjDamage), DisableFlags.WriteToLogAndConsole); + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from projectile damage limit from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxProjDamage); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -817,6 +847,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from disabled from {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -838,6 +869,7 @@ namespace TShockAPI // possible for players to create. (Source: Ijwu, QuiCM) if (Main.projHostile[type]) { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from hostile projectile from {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -846,6 +878,7 @@ namespace TShockAPI // Tombstones should never be permitted by players if (type == ProjectileID.Tombstone) { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from tombstones from {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -865,10 +898,12 @@ namespace TShockAPI || (type >= ProjectileID.MartianTurretBolt && type <= ProjectileID.RayGunnerLaser) || type == ProjectileID.CultistBossLightningOrb) { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from weird check from {0} {1}", args.Player.Name, type); TShock.Log.Debug("Certain projectiles have been ignored for cheat detection."); } else { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile please report to tshock about this! normally this is a reject from {0} {1}", args.Player.Name, type); // args.Player.Disable(String.Format("Does not have projectile permission to update projectile. ({0})", type), DisableFlags.WriteToLogAndConsole); // args.Player.RemoveProjectile(ident, owner); } @@ -879,6 +914,7 @@ namespace TShockAPI if (args.Player.ProjectileThreshold >= TShock.Config.ProjectileThreshold) { args.Player.Disable("Reached projectile update threshold.", DisableFlags.WriteToLogAndConsole); + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from proj update threshold from {0} {1}/{2}", args.Player.Name, args.Player.ProjectileThreshold, TShock.Config.ProjectileThreshold); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -886,6 +922,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer throttle from {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); args.Handled = true; return; @@ -935,11 +972,13 @@ namespace TShockAPI if (TShock.Config.KickOnDamageThresholdBroken) { args.Player.Kick(string.Format("NPC damage exceeded {0}.", TShock.Config.MaxDamage)); + TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from kodtb from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage); args.Handled = true; return; } else { + TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from dtb from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage); args.Player.Disable(String.Format("NPC damage exceeded {0}.", TShock.Config.MaxDamage), DisableFlags.WriteToLogAndConsole); } args.Player.SendData(PacketTypes.NpcUpdate, "", id); @@ -949,6 +988,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from disabled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.NpcUpdate, "", id); args.Handled = true; return; @@ -957,6 +997,7 @@ namespace TShockAPI if (TShock.Config.RangeChecks && !args.Player.IsInRange((int)(Main.npc[id].position.X / 16f), (int)(Main.npc[id].position.Y / 16f), 128)) { + TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from range checks from {0}", args.Player.Name); args.Player.SendData(PacketTypes.NpcUpdate, "", id); args.Handled = true; return; @@ -964,6 +1005,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnNPCStrike rejected from bouncer throttle from {0}", args.Player.Name); args.Player.SendData(PacketTypes.NpcUpdate, "", id); args.Handled = true; return; @@ -977,12 +1019,14 @@ namespace TShockAPI { if (args.ProjectileIndex < 0) { + TShock.Log.ConsoleDebug("Bouncer / OnProjectileKill rejected from negative projectile index from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnProjectileKill rejected from disabled from {0}", args.Player.Name); args.Player.RemoveProjectile(args.ProjectileIdentity, args.ProjectileOwner); args.Handled = true; return; @@ -990,6 +1034,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnProjectileKill rejected from bouncer throttle from {0}", args.Player.Name); args.Player.RemoveProjectile(args.ProjectileIdentity, args.ProjectileOwner); args.Handled = true; return; @@ -1009,12 +1054,14 @@ namespace TShockAPI if (args.Player.TPlayer.chest != id) { + TShock.Log.ConsoleDebug("Bouncer / OnChestItemChange rejected from chest mismatch from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnChestItemChange rejected from disable from {0}", args.Player.Name); args.Player.SendData(PacketTypes.ChestItem, "", id, slot); args.Handled = true; return; @@ -1022,12 +1069,14 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(Main.chest[id].x, Main.chest[id].y) && TShock.Config.RegionProtectChests) { + TShock.Log.ConsoleDebug("Bouncer / OnChestItemChange rejected from region protection? from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.IsInRange(Main.chest[id].x, Main.chest[id].y)) { + TShock.Log.ConsoleDebug("Bouncer / OnChestItemChange rejected from range check from {0}", args.Player.Name); args.Handled = true; return; } @@ -1040,18 +1089,21 @@ namespace TShockAPI { if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnChestOpen rejected from disabled from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.IsInRange(args.X, args.Y)) { + TShock.Log.ConsoleDebug("Bouncer / OnChestOpen rejected from range check from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.HasBuildPermission(args.X, args.Y) && TShock.Config.RegionProtectChests) { + TShock.Log.ConsoleDebug("Bouncer / OnChestOpen rejected from region check from {0}", args.Player.Name); args.Handled = true; return; } @@ -1071,12 +1123,14 @@ namespace TShockAPI if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from invalid check from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from disabled from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; return; @@ -1088,6 +1142,7 @@ namespace TShockAPI && Main.tile[tileX, tileY].type != TileID.Containers2 && (!TShock.Utils.HasWorldReachedMaxChests() && Main.tile[tileX, tileY].type != TileID.Dirt)) //Chest { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from weird check from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; return; @@ -1098,6 +1153,7 @@ namespace TShockAPI 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)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from weird placement check from {0}", args.Player.Name); //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; @@ -1107,6 +1163,7 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(tileX, tileY)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from invalid permission from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; return; @@ -1114,6 +1171,7 @@ namespace TShockAPI if (!args.Player.IsInRange(tileX, tileY)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceChest rejected from range check from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; return; @@ -1150,6 +1208,7 @@ namespace TShockAPI || (args.Zone2[4] && !hasStardustTower) ) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerZone rejected from {0}", args.Player.Name); args.Handled = true; return; } @@ -1163,6 +1222,7 @@ namespace TShockAPI { if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerAnimation rejected from disabled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index); args.Handled = true; return; @@ -1170,6 +1230,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerAnimation rejected from throttle from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index); args.Handled = true; return; @@ -1188,12 +1249,14 @@ namespace TShockAPI if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected invalid check from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected disabled from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -1201,6 +1264,7 @@ namespace TShockAPI if (args.Player.TileLiquidThreshold >= TShock.Config.TileLiquidThreshold) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected from liquid threshold from {0} {1}/{2}", args.Player.Name, args.Player.TileLiquidThreshold, TShock.Config.TileLiquidThreshold); args.Player.Disable("Reached TileLiquid threshold.", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; @@ -1241,6 +1305,7 @@ namespace TShockAPI if (type == 1 && !(bucket == 2 || bucket == 0)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 1 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); args.Player.Disable("Spreading lava without holding a lava bucket", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); @@ -1250,6 +1315,7 @@ namespace TShockAPI if (type == 1 && TShock.Itembans.ItemIsBanned("Lava Bucket", args.Player)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected lava bucket from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); args.Player.Disable("Using banned lava bucket without permissions", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); @@ -1259,6 +1325,7 @@ namespace TShockAPI if (type == 0 && !(bucket == 1 || bucket == 0 || bucket == 4)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 2 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); args.Player.Disable("Spreading water without holding a water bucket", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); @@ -1268,6 +1335,7 @@ namespace TShockAPI if (type == 0 && TShock.Itembans.ItemIsBanned("Water Bucket", args.Player)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 3 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); args.Player.Disable("Using banned water bucket without permissions", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); @@ -1277,6 +1345,7 @@ namespace TShockAPI if (type == 2 && !(bucket == 3 || bucket == 0)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 4 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); args.Player.Disable("Spreading honey without holding a honey bucket", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); @@ -1286,6 +1355,7 @@ namespace TShockAPI if (type == 2 && TShock.Itembans.ItemIsBanned("Honey Bucket", args.Player)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 5 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); args.Player.Disable("Using banned honey bucket without permissions", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(tileX, tileY, 1); @@ -1296,6 +1366,7 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(tileX, tileY)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected build permission from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -1303,6 +1374,7 @@ namespace TShockAPI if (!args.Player.IsInRange(tileX, tileY, 16)) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected range checks from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -1310,6 +1382,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected throttle from {0}", args.Player.Name); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; From 03e41a521ed5aaa3fa9ca6d2a3ef28fb6c019d7b Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 19:34:55 -0700 Subject: [PATCH 23/38] Add more logging to Bouncer to debug antihack This adds more logging in Bouncer so as to detect more false positives. --- TShockAPI/Bouncer.cs | 57 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 528caac5..2e40c9d0 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1400,12 +1400,14 @@ namespace TShockAPI if (TShock.Players[id] == null) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected null check"); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected disabled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAddBuff, "", id); args.Handled = true; return; @@ -1413,6 +1415,7 @@ namespace TShockAPI if (id >= Main.maxPlayers) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected player cap from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAddBuff, "", id); args.Handled = true; return; @@ -1420,6 +1423,7 @@ namespace TShockAPI if (!TShock.Players[id].TPlayer.hostile || !Main.pvpBuff[type]) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected hostile/pvp from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAddBuff, "", id); args.Handled = true; return; @@ -1427,6 +1431,7 @@ namespace TShockAPI if (!args.Player.IsInRange(TShock.Players[id].TileX, TShock.Players[id].TileY, 50)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected range check from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAddBuff, "", id); args.Handled = true; return; @@ -1434,6 +1439,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected throttled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerAddBuff, "", id); args.Handled = true; return; @@ -1441,6 +1447,7 @@ namespace TShockAPI if (WhitelistBuffMaxTime[type] > 0 && time <= WhitelistBuffMaxTime[type]) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerBuff rejected buff time whitelists from {0}", args.Player.Name); args.Handled = false; return; } @@ -1457,6 +1464,7 @@ namespace TShockAPI if (id >= Main.npc.Length) { + TShock.Log.ConsoleDebug("Bouncer / OnNPCAddBuff rejected out of bounds NPC update from {0}", args.Player.Name); args.Handled = true; return; } @@ -1465,12 +1473,14 @@ namespace TShockAPI if (npc == null) { + TShock.Log.ConsoleDebug("Bouncer / OnNPCAddBuff rejected null npc from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnNPCAddBuff rejected disabled from {0}", args.Player.Name); args.Handled = true; return; } @@ -1500,7 +1510,7 @@ namespace TShockAPI if (detectedNPCBuffTimeCheat) { - + TShock.Log.ConsoleDebug("Bouncer / OnNPCAddBuff rejected abnormal buff ({1}) from {0}", args.Player.Name, type); args.Player.Kick($"Added buff to NPC abnormally.", true); args.Handled = true; } @@ -1520,6 +1530,7 @@ namespace TShockAPI { args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY, Convert.ToByte(Main.npc[id].homeless)); + TShock.Log.ConsoleDebug("Bouncer / OnUpdateNPCHome rejected npc home build permission from {0}", args.Player.Name); args.Handled = true; return; } @@ -1528,6 +1539,7 @@ namespace TShockAPI { args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY, Convert.ToByte(Main.npc[id].homeless)); + TShock.Log.ConsoleDebug("Bouncer / OnUpdateNPCHome rejected range checks from {0}", args.Player.Name); args.Handled = true; return; } @@ -1543,6 +1555,7 @@ namespace TShockAPI if (amount <= 0 || Main.player[plr] == null || !Main.player[plr].active) { + TShock.Log.ConsoleDebug("Bouncer / OnHealOtherPlayer rejected null checks"); args.Handled = true; return; } @@ -1552,6 +1565,7 @@ namespace TShockAPI // and the healing you can do with that is 20% of your damage. if (amount > TShock.Config.MaxDamage * 0.2) { + TShock.Log.ConsoleDebug("Bouncer / OnUpdateNPCHome 0.2 check from {0}", args.Player.Name); args.Player.Disable("HealOtherPlayer cheat attempt!", DisableFlags.WriteToLogAndConsole); args.Handled = true; return; @@ -1559,6 +1573,7 @@ namespace TShockAPI if (args.Player.HealOtherThreshold > TShock.Config.HealOtherThreshold) { + TShock.Log.ConsoleDebug("Bouncer / OnUpdateNPCHome rejected heal other threshold from {0} {1}/{2}", args.Player.Name, args.Player.HealOtherThreshold, TShock.Config.HealOtherThreshold); args.Player.Disable("Reached HealOtherPlayer threshold.", DisableFlags.WriteToLogAndConsole); args.Handled = true; return; @@ -1566,6 +1581,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled() || args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnUpdateNPCHome rejected disabled/throttled from {0}", args.Player.Name); args.Handled = true; return; } @@ -1589,18 +1605,21 @@ namespace TShockAPI if (type < 0 || type >= Main.maxTileSets) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected out of bounds tile from {0}", args.Player.Name); args.Handled = true; return; } if (x < 0 || x >= Main.maxTilesX) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected out of bounds tile x from {0}", args.Player.Name); args.Handled = true; return; } if (y < 0 || y >= Main.maxTilesY) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected out of bounds tile y from {0}", args.Player.Name); args.Handled = true; return; } @@ -1609,6 +1628,7 @@ namespace TShockAPI //These two items cause localised lag and rendering issues if (type == TileID.FakeContainers && (style == 52 || style == 53)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected fake containers from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 4); args.Handled = true; return; @@ -1617,6 +1637,7 @@ namespace TShockAPI // TODO: REMOVE. This does NOT look like Bouncer code. if (TShock.TileBans.TileIsBanned(type, args.Player)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected banned tiles from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 1); args.Player.SendErrorMessage("You do not have permission to place this tile."); args.Handled = true; @@ -1625,6 +1646,7 @@ namespace TShockAPI if (!TShock.Utils.TilePlacementValid(x, y)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected valid placements from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 1); args.Handled = true; return; @@ -1632,6 +1654,7 @@ namespace TShockAPI if (args.Player.Dead && TShock.Config.PreventDeadModification) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected dead people don't do things from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 4); args.Handled = true; return; @@ -1639,6 +1662,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected disabled from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 4); args.Handled = true; return; @@ -1649,6 +1673,7 @@ namespace TShockAPI // without selecting the right item. if (type != args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].createTile) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected awkward tile creation/selection from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 4); args.Handled = true; return; @@ -1657,6 +1682,7 @@ namespace TShockAPI TileObjectData tileData = TileObjectData.GetTileData(type, style, 0); if (tileData == null) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected null tile data from {0}", args.Player.Name); args.Handled = true; return; } @@ -1671,6 +1697,7 @@ namespace TShockAPI if (!args.Player.HasModifiedIceSuccessfully(i, j, type, EditAction.PlaceTile) && !args.Player.HasBuildPermission(i, j)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected mad loop from {0}", args.Player.Name); args.Player.SendTileSquare(i, j, 4); args.Handled = true; return; @@ -1685,6 +1712,7 @@ namespace TShockAPI || type != TileID.WebRope) && !args.Player.IsInRange(x, y)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected range checks from {0}", args.Player.Name); args.Player.SendTileSquare(x, y, 4); args.Handled = true; return; @@ -1692,6 +1720,7 @@ namespace TShockAPI if (args.Player.TilePlaceThreshold >= TShock.Config.TilePlaceThreshold) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected tile place threshold from {0} {1}/{2}", args.Player.Name, args.Player.TilePlaceThreshold, TShock.Config.TilePlaceThreshold); args.Player.Disable("Reached TilePlace threshold.", DisableFlags.WriteToLogAndConsole); args.Player.SendTileSquare(x, y, 4); args.Handled = true; @@ -1715,18 +1744,21 @@ namespace TShockAPI { if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected disabled from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.HasBuildPermission(args.X, args.Y)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected permissions from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.IsInRange(args.X, args.Y)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected range checks from {0}", args.Player.Name); args.Handled = true; return; } @@ -1739,6 +1771,7 @@ namespace TShockAPI { if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected disabled from {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, NetworkText.Empty, args.ItemFrame.ID, 0, 1); args.Handled = true; return; @@ -1746,6 +1779,7 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(args.X, args.Y)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected permissions from {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, NetworkText.Empty, args.ItemFrame.ID, 0, 1); args.Handled = true; return; @@ -1753,6 +1787,7 @@ namespace TShockAPI if (!args.Player.IsInRange(args.X, args.Y)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected range checks from {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, NetworkText.Empty, args.ItemFrame.ID, 0, 1); args.Handled = true; return; @@ -1765,6 +1800,7 @@ namespace TShockAPI //belongs to the player who sent the packet. if (args.Player.Index != args.TargetPlayerIndex) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerPortalTeleport rejected untargetable teleport from {0}", args.Player.Name); //If the player who sent the packet is not the player being teleported, cancel this packet args.Player.Disable("Malicious portal attempt.", DisableFlags.WriteToLogAndConsole); //Todo: this message is not particularly clear - suggestions wanted args.Handled = true; @@ -1775,6 +1811,7 @@ namespace TShockAPI if (args.NewPosition.X > Main.maxTilesX || args.NewPosition.X < 0 || args.NewPosition.Y > Main.maxTilesY || args.NewPosition.Y < 0) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerPortalTeleport rejected teleport out of bounds from {0}", args.Player.Name); args.Handled = true; return; } @@ -1782,6 +1819,7 @@ namespace TShockAPI //May as well reject teleport attempts if the player is being throttled if (args.Player.IsBeingDisabled() || args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerPortalTeleport rejected disabled/throttled from {0}", args.Player.Name); args.Handled = true; return; } @@ -1794,24 +1832,28 @@ namespace TShockAPI { if (args.X < 0 || args.Y < 0 || args.X >= Main.maxTilesX || args.Y >= Main.maxTilesY) { + TShock.Log.ConsoleDebug("Bouncer / OnGemLockToggle rejected boundaries check from {0}", args.Player.Name); args.Handled = true; return; } if (!TShock.Utils.TilePlacementValid(args.X, args.Y) || (args.Player.Dead && TShock.Config.PreventDeadModification)) { + TShock.Log.ConsoleDebug("Bouncer / OnGemLockToggle invalid placement/deadmod from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnGemLockToggle rejected disabled from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.HasBuildPermission(args.X, args.Y)) { + TShock.Log.ConsoleDebug("Bouncer / OnGemLockToggle rejected permissions check from {0}", args.Player.Name); args.Handled = true; return; } @@ -1845,18 +1887,21 @@ namespace TShockAPI if (!TShock.Utils.TilePlacementValid(x, y) || (args.Player.Dead && TShock.Config.PreventDeadModification)) { + TShock.Log.ConsoleDebug("Bouncer / OnMassWireOperation rejected valid placement from {0}", args.Player.Name); args.Handled = true; return; } if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnMassWireOperation rejected disabled from {0}", args.Player.Name); args.Handled = true; return; } if (!args.Player.HasBuildPermission(x, y)) { + TShock.Log.ConsoleDebug("Bouncer / OnMassWireOperation rejected build perms from {0}", args.Player.Name); args.Handled = true; return; } @@ -1876,6 +1921,7 @@ namespace TShockAPI if (id >= Main.maxPlayers || TShock.Players[id] == null) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected null check"); args.Handled = true; return; } @@ -1884,12 +1930,14 @@ namespace TShockAPI { if (TShock.Config.KickOnDamageThresholdBroken) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage); args.Player.Kick(string.Format("Player damage exceeded {0}.", TShock.Config.MaxDamage)); args.Handled = true; return; } else { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected damage threshold2 from {0} {1}/{2}", args.Player.Name, damage, TShock.Config.MaxDamage); args.Player.Disable(String.Format("Player damage exceeded {0}.", TShock.Config.MaxDamage), DisableFlags.WriteToLogAndConsole); } args.Player.SendData(PacketTypes.PlayerHp, "", id); @@ -1900,6 +1948,7 @@ namespace TShockAPI if (!TShock.Players[id].TPlayer.hostile && pvp && id != args.Player.Index) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected hostile from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerHp, "", id); args.Player.SendData(PacketTypes.PlayerUpdate, "", id); args.Handled = true; @@ -1908,6 +1957,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected disabled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerHp, "", id); args.Player.SendData(PacketTypes.PlayerUpdate, "", id); args.Handled = true; @@ -1916,6 +1966,7 @@ namespace TShockAPI if (!args.Player.IsInRange(TShock.Players[id].TileX, TShock.Players[id].TileY, 100)) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected range checks from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerHp, "", id); args.Player.SendData(PacketTypes.PlayerUpdate, "", id); args.Handled = true; @@ -1924,6 +1975,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected throttled from {0}", args.Player.Name); args.Player.SendData(PacketTypes.PlayerHp, "", id); args.Player.SendData(PacketTypes.PlayerUpdate, "", id); args.Handled = true; @@ -1943,6 +1995,7 @@ namespace TShockAPI if (damage > 20000) //Abnormal values have the potential to cause infinite loops in the server. { + TShock.Log.ConsoleDebug("Bouncer / OnKillMe rejected high damage from {0} {1}", args.Player.Name, damage); args.Player.Kick("Failed to shade polygon normals.", true, true); TShock.Log.ConsoleError("Death Exploit Attempt: Damage {0}", damage); args.Handled = true; @@ -1951,6 +2004,7 @@ namespace TShockAPI if (id >= Main.maxPlayers) { + TShock.Log.ConsoleDebug("Bouncer / OnKillMe rejected index check from {0}", args.Player.Name); args.Handled = true; return; } @@ -1960,6 +2014,7 @@ namespace TShockAPI { if (playerDeathReason.GetDeathText(TShock.Players[id].Name).ToString().Length > 500) { + TShock.Log.ConsoleDebug("Bouncer / OnKillMe rejected bad length death text from {0}", args.Player.Name); TShock.Players[id].Kick("Death reason outside of normal bounds.", true); args.Handled = true; return; From 5d2945ab1f4be47ab031220ffca9d5ae9d6b4fc4 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Sat, 23 May 2020 13:05:22 +0930 Subject: [PATCH 24/38] Change SendMessage & SendMessageFromPlayer to use FromLiteral not FromFormattable. Solves #1856 --- TShockAPI/TSPlayer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 8ef56027..8076dcef 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1424,11 +1424,11 @@ namespace TShockAPI if (this.Index == -1) //-1 is our broadcast index - this implies we're using TSPlayer.All.SendMessage and broadcasting to all clients { - Terraria.Chat.ChatHelper.BroadcastChatMessage(NetworkText.FromFormattable(msg), new Color(red, green, blue)); + Terraria.Chat.ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(msg), new Color(red, green, blue)); } else { - Terraria.Chat.ChatHelper.SendChatMessageToClient(NetworkText.FromFormattable(msg), new Color(red, green, blue), this.Index); + Terraria.Chat.ChatHelper.SendChatMessageToClient(NetworkText.FromLiteral(msg), new Color(red, green, blue), this.Index); } } @@ -1451,7 +1451,7 @@ namespace TShockAPI } return; } - Terraria.Chat.ChatHelper.BroadcastChatMessageAs((byte)ply, NetworkText.FromFormattable(msg), new Color(red, green, blue)); + Terraria.Chat.ChatHelper.BroadcastChatMessageAs((byte)ply, NetworkText.FromLiteral(msg), new Color(red, green, blue)); } /// From f227a2a1e4c86da7a2c7d13c57c3448bbf9569c1 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 21:06:16 -0700 Subject: [PATCH 25/38] Add verbose logging to rest of GetDataHandlers Should help put the nail in the coffin of many 1.4 bugs --- TShockAPI/GetDataHandlers.cs | 75 +++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index efc032c1..e8ffee48 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1880,12 +1880,14 @@ namespace TShockAPI if (OnPlayerInfo(args.Player, args.Data, playerid, hair, skinVariant, difficulty, name)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected plugin phase {0}", name); args.Player.Kick("A plugin on this server stopped your login.", true, true); return true; } if (name.Trim().Length == 0) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected name length 0"); args.Player.Kick("You have been Bounced.", true, true); return true; } @@ -1914,11 +1916,13 @@ namespace TShockAPI } if (TShock.Config.MediumcoreOnly && difficulty < 1) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected mediumcore required"); args.Player.Kick("You need to join with a mediumcore player or higher.", true, true); return true; } if (TShock.Config.HardcoreOnly && difficulty < 2) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected hardcore required"); args.Player.Kick("You need to join with a hardcore player.", true, true); return true; } @@ -1950,6 +1954,7 @@ namespace TShockAPI return true; if (args.Player.IgnoreSSCPackets) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerSlot rejected ignore ssc packets"); args.Player.SendData(PacketTypes.PlayerSlot, "", args.Player.Index, slot, prefix); return true; } @@ -2055,6 +2060,7 @@ namespace TShockAPI if (TShock.Utils.GetActivePlayerCount() + 1 > TShock.Config.MaxSlots && !args.Player.HasPermission(Permissions.reservedslot)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleGetSection rejected reserve slot"); args.Player.Kick(TShock.Config.ServerFullReason, true, true); return true; } @@ -2067,6 +2073,7 @@ namespace TShockAPI { if (args.Player.Dead && args.Player.RespawnTimer > 0) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn rejected dead player spawn request {0}", args.Player.Name); return true; } @@ -2084,6 +2091,7 @@ namespace TShockAPI args.Player.sX = Main.spawnTileX; args.Player.sY = Main.spawnTileY; args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport 'vanilla spawn' {0}", args.Player.Name); } if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY))) @@ -2093,13 +2101,19 @@ namespace TShockAPI args.Player.sY = args.TPlayer.SpawnY; if (((Main.tile[args.Player.sX, args.Player.sY - 1].active() && Main.tile[args.Player.sX, args.Player.sY - 1].type == 79)) && (WorldGen.StartRoomCheck(args.Player.sX, args.Player.sY - 1))) + { args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport phase 1 {0}", args.Player.Name); + } } else if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0)) { if (((Main.tile[args.Player.sX, args.Player.sY - 1].active() && Main.tile[args.Player.sX, args.Player.sY - 1].type == 79)) && (WorldGen.StartRoomCheck(args.Player.sX, args.Player.sY - 1))) + { args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport phase 2 {0}", args.Player.Name); + } } if (respawnTimer > 0) @@ -2135,6 +2149,7 @@ namespace TShockAPI { originalPosition = new Vector2?(args.Data.ReadVector2()); homePosition = new Vector2?(args.Data.ReadVector2()); + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerUpdate home position delta {0}", args.Player.Name); } if (OnPlayerUpdate(args.Player, args.Data, playerID, controls, miscData1, miscData2, miscData3, selectedItem, position, velocity, originalPosition, homePosition)) @@ -2154,6 +2169,7 @@ namespace TShockAPI if (max > TShock.Config.MaxHP && !args.Player.HasPermission(Permissions.ignorehp)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerHp rejected over max hp {0}", args.Player.Name); args.Player.Disable("Maximum HP beyond limit", DisableFlags.WriteToLogAndConsole); return true; } @@ -2202,11 +2218,13 @@ namespace TShockAPI if (x >= Main.maxTilesX || y >= Main.maxTilesY || x < 0 || y < 0) // Check for out of range { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected out of range door {0}", args.Player.Name); return true; } if (type < 0 || type > 5) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected type 0 5 check {0}", args.Player.Name); return true; } @@ -2216,6 +2234,7 @@ namespace TShockAPI && tileType != TileID.TallGateClosed && tileType != TileID.TallGateOpen && tileType != TileID.TrapdoorClosed && tileType != TileID.TrapdoorOpen) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected door gap check {0}", args.Player.Name); return true; } @@ -2310,6 +2329,7 @@ namespace TShockAPI { args.Player.SendErrorMessage("You do not have permission to hurt this NPC."); args.Player.SendData(PacketTypes.NpcUpdate, "", id); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcStrike rejected npc strike {0}", args.Player.Name); return true; } @@ -2334,6 +2354,7 @@ namespace TShockAPI if (type == ProjectileID.Tombstone) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleProjectileKill rejected tombstone {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); return true; } @@ -2344,8 +2365,11 @@ namespace TShockAPI // https://github.com/Pryaxis/TShock/commit/a5aa9231239926f361b7246651e32144bbf28dda if (type == ProjectileID.Bomb || type == ProjectileID.DeathLaser) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleProjectileKill permitted skeletron prime exemption {0}", args.Player.Name); + TShock.Log.ConsoleDebug("If this was not skeletron prime related, please report to TShock what happened."); return false; } + TShock.Log.ConsoleDebug("GetDataHandlers / HandleProjectileKill rejected banned projectile {0}", args.Player.Name); args.Player.RemoveProjectile(ident, owner); return true; } @@ -2363,11 +2387,15 @@ namespace TShockAPI return true; if (id != args.Player.Index) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTogglePvp rejected index mismatch {0}", args.Player.Name); return true; + } string pvpMode = TShock.Config.PvPMode.ToLowerInvariant(); if (pvpMode == "disabled" || pvpMode == "always" || (DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTogglePvp rejected fastswitch {0}", args.Player.Name); args.Player.SendData(PacketTypes.TogglePvp, "", id); return true; } @@ -2402,6 +2430,7 @@ namespace TShockAPI item.netDefaults(type); if (stacks > item.maxStack) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleChestItem rejected max stacks {0}", args.Player.Name); return true; } @@ -2426,6 +2455,7 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(x, y) && TShock.Config.RegionProtectChests) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleChestActive rejected build permission and region check {0}", args.Player.Name); args.Player.SendData(PacketTypes.ChestOpen, "", -1); return true; } @@ -2450,6 +2480,7 @@ namespace TShockAPI { if (args.Player == null || args.TPlayer == null || args.Data == null) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerZone rejected null check"); return true; } @@ -2560,6 +2591,7 @@ namespace TShockAPI if (max > TShock.Config.MaxMP && !args.Player.HasPermission(Permissions.ignoremp)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerMana rejected max mana {0} {1}/{2}", args.Player.Name, max, TShock.Config.MaxMP); args.Player.Disable("Maximum MP beyond limit", DisableFlags.WriteToLogAndConsole); return true; } @@ -2586,6 +2618,7 @@ namespace TShockAPI if ((DateTime.UtcNow - args.Player.LastPvPTeamChange).TotalSeconds < 5) { args.Player.SendData(PacketTypes.PlayerTeam, "", id); + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerTeam rejected team fastswitch {0}", args.Player.Name); return true; } @@ -2606,12 +2639,14 @@ namespace TShockAPI if (!args.Player.HasBuildPermission(x, y)) { args.Player.SendData(PacketTypes.SignNew, "", id); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSign rejected sign on build permission {0}", args.Player.Name); return true; } if (!args.Player.IsInRange(x, y)) { args.Player.SendData(PacketTypes.SignNew, "", id); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSign rejected sign range check {0}", args.Player.Name); return true; } return false; @@ -2645,7 +2680,10 @@ namespace TShockAPI buff = 0; if (Netplay.Clients[args.TPlayer.whoAmI].State < 2 && (buff == 156 || buff == 47 || buff == 149)) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerBuffList zeroed player buff due to below state 2 {0} {1}", args.Player.Name, buff); buff = 0; + } args.TPlayer.buffType[i] = buff; if (args.TPlayer.buffType[i] > 0) @@ -2658,7 +2696,7 @@ namespace TShockAPI } } - + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerBuffList handled event and sent data {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.PlayerBuff, -1, args.Player.Index, NetworkText.Empty, args.Player.Index); return true; } @@ -2673,13 +2711,16 @@ namespace TShockAPI if (type == 1 && TShock.Config.DisableDungeonGuardian) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected type 1 for {0}", args.Player.Name); args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple); args.Player.Spawn(PlayerSpawnContext.RecallFromItem); return true; } + // typo? type == 3 & !args.... if (type == 3 & !args.Player.HasPermission(Permissions.usesundial)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected enchanted sundial type 3 binary and (warn) {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial!"); return true; } @@ -2724,6 +2765,7 @@ namespace TShockAPI if (!args.Player.HasPermission(Permissions.movenpc)) { + TShock.Log.ConsoleDebug("GetDataHandlers / UpdateNPCHome rejected no permission {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to relocate NPCs."); args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY, Convert.ToByte(Main.npc[id].homeless)); @@ -2739,6 +2781,7 @@ namespace TShockAPI { if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected bouner throttled {0}", args.Player.Name); return true; } @@ -2749,18 +2792,21 @@ namespace TShockAPI if (bosses.Contains(thingType) && !args.Player.HasPermission(Permissions.summonboss)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected boss {0} {1}", args.Player.Name, thingType); args.Player.SendErrorMessage("You don't have permission to summon a boss."); return true; } if (invasions.Contains(thingType) && !args.Player.HasPermission(Permissions.startinvasion)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected invasion {0} {1}", args.Player.Name, thingType); args.Player.SendErrorMessage("You don't have permission to start an invasion."); return true; } if (pets.Contains(thingType) && !args.Player.HasPermission(Permissions.spawnpets)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawnBoss rejected pet {0} {1}", args.Player.Name, thingType); args.Player.SendErrorMessage("You don't have permission to spawn pets."); return true; } @@ -2814,6 +2860,7 @@ namespace TShockAPI if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY || t > Main.numTileColors) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected range check {0}", args.Player.Name); return true; } if (OnPaintTile(args.Player, args.Data, x, y, t)) @@ -2831,6 +2878,7 @@ namespace TShockAPI !args.Player.Accessories.Any(i => i != null && i.stack > 0 && (i.type == ItemID.PaintSprayer || i.type == ItemID.ArchitectGizmoPack))) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected select consistency {0}", args.Player.Name); args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color()); return true; } @@ -2839,6 +2887,7 @@ namespace TShockAPI !args.Player.HasPaintPermission(x, y) || !args.Player.IsInRange(x, y)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected throttle/permission/range check {0}", args.Player.Name); args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color()); return true; } @@ -2858,6 +2907,7 @@ namespace TShockAPI if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY || t > Main.numTileColors) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected range check {0}", args.Player.Name); return true; } if (OnPaintWall(args.Player, args.Data, x, y, t)) @@ -2875,6 +2925,7 @@ namespace TShockAPI !args.Player.Accessories.Any(i => i != null && i.stack > 0 && (i.type == ItemID.PaintSprayer || i.type == ItemID.ArchitectGizmoPack))) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected selector consistency {0}", args.Player.Name); args.Player.SendData(PacketTypes.PaintWall, "", x, y, Main.tile[x, y].wallColor()); return true; } @@ -2883,6 +2934,7 @@ namespace TShockAPI !args.Player.HasPaintPermission(x, y) || !args.Player.IsInRange(x, y)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected throttle/permission/range {0}", args.Player.Name); args.Player.SendData(PacketTypes.PaintWall, "", x, y, Main.tile[x, y].wallColor()); return true; } @@ -2930,6 +2982,7 @@ namespace TShockAPI //Rod of Discord teleport (usually (may be used by modded clients to teleport)) if (type == 0 && !args.Player.HasPermission(Permissions.rod)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type); args.Player.SendErrorMessage("You do not have permission to teleport."); args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); return true; @@ -2938,6 +2991,7 @@ namespace TShockAPI //NPC teleport if (type == 1 && id >= Main.maxNPCs) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected npc teleport {0} {1}", args.Player.Name, type); return true; } @@ -2946,11 +3000,13 @@ namespace TShockAPI { if (id >= Main.maxPlayers || Main.player[id] == null || TShock.Players[id] == null) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected p2p extents {0} {1}", args.Player.Name, type); return true; } if (!args.Player.HasPermission(Permissions.wormhole)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleport rejected p2p wormhole permission {0} {1}", args.Player.Name, type); args.Player.SendErrorMessage("You do not have permission to teleport."); args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); return true; @@ -2978,6 +3034,7 @@ namespace TShockAPI if (Main.npc[npcID]?.catchItem == 0) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleCatchNpc catch zero {0}", args.Player.Name); Main.npc[npcID].active = true; NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID); return true; @@ -2996,6 +3053,7 @@ namespace TShockAPI private static bool HandleNumberOfAnglerQuestsCompleted(GetDataHandlerArgs args) { // Never sent by vanilla client, ignore this + TShock.Log.ConsoleDebug("GetDataHandlers / HandleNumberOfAnglerQuestsCompleted surprise packet! Someone tell the TShock team! {0}", args.Player.Name); return true; } @@ -3078,16 +3136,19 @@ namespace TShockAPI if (position.X < 0 || position.X >= Main.maxTilesX || position.Y < 0 || position.Y >= Main.maxTilesY) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected extents check {0}", args.Player.Name); return true; } if (!Main.expertMode) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected expert mode check {0}", args.Player.Name); return true; } if (!args.Player.IsInRange((int)position.X, (int)position.Y)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected range check {0}", args.Player.Name); return true; } @@ -3104,6 +3165,7 @@ namespace TShockAPI { if (projectile.owner != args.TPlayer.whoAmI) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleKillPortal rejected owner mismatch check {0}", args.Player.Name); return true; } } @@ -3140,12 +3202,14 @@ namespace TShockAPI if (projectile == null || !projectile.active) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTeleportPortal rejected null check {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcIndex); return true; } if (projectile.type != ProjectileID.PortalGunGate) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcTeleportPortal rejected not thinking with portals {0}", args.Player.Name); NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcIndex); return true; } @@ -3185,6 +3249,7 @@ namespace TShockAPI { if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleToggleParty rejected no party {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to start a party."); return true; } @@ -3196,11 +3261,13 @@ namespace TShockAPI { if (args.Player.IsBouncerThrottled()) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleOldOnesArmy rejected throttled {0}", args.Player.Name); return true; } if (!args.Player.HasPermission(Permissions.startdd2)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleOldOnesArmy rejected permissions {0}", args.Player.Name); args.Player.SendErrorMessage("You don't have permission to start the Old One's Army event."); return true; } @@ -3227,6 +3294,7 @@ namespace TShockAPI if (TShock.Players[id].GodMode) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerDamageV2 rejected (god mode on) {0}", args.Player.Name); TShock.Players[id].Heal(args.TPlayer.statLifeMax); } @@ -3270,10 +3338,14 @@ namespace TShockAPI if (shouldBan) { if (!args.Player.Ban(banReason, false, "TShock")) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty); args.Player.Kick("You died! Normally, you'd be banned.", true, true); + } } else if (shouldKick) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 kicked with difficulty {0} {1}", args.Player.Name, args.TPlayer.difficulty); args.Player.Kick(kickReason, true, true, null, false); } } @@ -3282,6 +3354,7 @@ namespace TShockAPI { if (TShock.CharacterDB.RemovePlayer(args.Player.Account.ID)) { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerKillMeV2 ssc delete {0} {1}", args.Player.Name, args.TPlayer.difficulty); args.Player.SendErrorMessage("You have fallen in hardcore mode, and your items have been lost forever."); TShock.CharacterDB.SeedInitialData(args.Player.Account); } From b87f5d0a1bc4706b473875eeb7100df65c2d35f9 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 21:11:37 -0700 Subject: [PATCH 26/38] Fix probable typo in sundail special perm This check used & instead of && which is technically possible but probably not the right thing to do here. --- TShockAPI/GetDataHandlers.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index e8ffee48..7a6ece8e 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2717,10 +2717,9 @@ namespace TShockAPI return true; } - // typo? type == 3 & !args.... - if (type == 3 & !args.Player.HasPermission(Permissions.usesundial)) + if (type == 3 && !args.Player.HasPermission(Permissions.usesundial)) { - TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected enchanted sundial type 3 binary and (warn) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected enchanted sundial permission {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial!"); return true; } From dbc4bd474709194783c4e126df974beba217d129 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 22:16:41 -0700 Subject: [PATCH 27/38] Add verbose debug log for rangechecks --- TShockAPI/TSPlayer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 8076dcef..86642e69 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -601,8 +601,11 @@ namespace TShockAPI /// True if the player is in range of a tile or if range checks are off. False if not. public bool IsInRange(int x, int y, int range = 32) { - if (TShock.Config.RangeChecks && ((Math.Abs(TileX - x) > range) || (Math.Abs(TileY - y) > range))) + int rgX = Math.Abs(TileX - x); + int rgY = Math.Abs(TileY - y); + if (TShock.Config.RangeChecks && ((rgX > range) || (rgY > range))) { + TShock.Log.ConsoleDebug("Rangecheck failed for {0} ({1}, {2}) (rg: {3}/{5}, {4}/{5})", Name, x, y, rgX, rgY, range); return false; } return true; From a457e8c9eeb36c6a555f0327818741d52688a329 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 23:22:48 -0700 Subject: [PATCH 28/38] Support lava absorbant sponge (fixes #1852) --- CHANGELOG.md | 1 + TShockAPI/Bouncer.cs | 31 ++++++++++++++++++------------- TShockAPI/GetDataHandlers.cs | 17 ++++++++++++++--- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bfac74d..f956c63b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## TShock 4.4.0 (Pre-release ?) * Fix bed spawn issues when trying to remove spawn point in SSC (@Olink) * Fix Snake Flute (@Olink) +* Fix lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 2e40c9d0..d0541809 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1245,7 +1245,7 @@ namespace TShockAPI int tileX = args.TileX; int tileY = args.TileY; byte amount = args.Amount; - byte type = args.Type; + LiquidType type = args.Type; if (!TShock.Utils.TilePlacementValid(tileX, tileY) || (args.Player.Dead && TShock.Config.PreventDeadModification)) { @@ -1281,29 +1281,34 @@ namespace TShockAPI if (amount != 0) { int bucket = -1; - if (args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type == ItemID.EmptyBucket) + int selectedItemType = args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type; + if (selectedItemType == ItemID.EmptyBucket) { bucket = 0; } - else if (args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type == ItemID.WaterBucket) + else if (selectedItemType == ItemID.WaterBucket) { bucket = 1; } - else if (args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type == ItemID.LavaBucket) + else if (selectedItemType == ItemID.LavaBucket) { bucket = 2; } - else if (args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type == ItemID.HoneyBucket) + else if (selectedItemType == ItemID.HoneyBucket) { bucket = 3; } - else if (args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type == ItemID.BottomlessBucket || - args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type == ItemID.SuperAbsorbantSponge) + else if (selectedItemType == ItemID.BottomlessBucket || + selectedItemType == ItemID.SuperAbsorbantSponge) { bucket = 4; } + else if (selectedItemType == ItemID.LavaAbsorbantSponge) + { + bucket = 5; + } - if (type == 1 && !(bucket == 2 || bucket == 0)) + if (type == LiquidType.Lava && !(bucket == 2 || bucket == 0 || bucket == 5)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 1 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); @@ -1313,7 +1318,7 @@ namespace TShockAPI return; } - if (type == 1 && TShock.Itembans.ItemIsBanned("Lava Bucket", args.Player)) + if (type == LiquidType.Lava && TShock.Itembans.ItemIsBanned("Lava Bucket", args.Player)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected lava bucket from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); @@ -1323,7 +1328,7 @@ namespace TShockAPI return; } - if (type == 0 && !(bucket == 1 || bucket == 0 || bucket == 4)) + if (type == LiquidType.Water && !(bucket == 1 || bucket == 0 || bucket == 4)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 2 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); @@ -1333,7 +1338,7 @@ namespace TShockAPI return; } - if (type == 0 && TShock.Itembans.ItemIsBanned("Water Bucket", args.Player)) + if (type == LiquidType.Water && TShock.Itembans.ItemIsBanned("Water Bucket", args.Player)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 3 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); @@ -1343,7 +1348,7 @@ namespace TShockAPI return; } - if (type == 2 && !(bucket == 3 || bucket == 0)) + if (type == LiquidType.Honey && !(bucket == 3 || bucket == 0)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 4 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); @@ -1353,7 +1358,7 @@ namespace TShockAPI return; } - if (type == 2 && TShock.Itembans.ItemIsBanned("Honey Bucket", args.Player)) + if (type == LiquidType.Honey && TShock.Itembans.ItemIsBanned("Honey Bucket", args.Player)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 5 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 7a6ece8e..19c6f4b0 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1129,10 +1129,21 @@ namespace TShockAPI /// public byte Amount { get; set; } /// - /// Type of Liquid: 0=water, 1=lave, 2=honey + /// Type of Liquid: 0=water, 1=lava, 2=honey /// - public byte Type { get; set; } + public LiquidType Type { get; set; } } + + /// + /// LiquidType - supported liquid types + /// + public enum LiquidType : byte + { + Water = 0, + Lava = 1, + Honey = 2 + } + /// /// LiquidSet - When ever a liquid is set /// @@ -1149,7 +1160,7 @@ namespace TShockAPI TileX = tilex, TileY = tiley, Amount = amount, - Type = type, + Type = (LiquidType) type, }; LiquidSet.Invoke(null, args); return args.Handled; From 7452d3c91d56e85e622b1e3d8ce2afdcbc913911 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 23:33:09 -0700 Subject: [PATCH 29/38] Support using bottomless lava bucket This is in response to discussion #1859. Due to the nature of this already terrible handler, I refuse to add any other types of checks for whether or not this item is banned and lava. If you want to ban lava, ban a lava bucket. Don't ban an infinite lava bucket, because finite lava is still infinite lava in this topsy turvy game where the client rules the world. --- CHANGELOG.md | 2 ++ TShockAPI/Bouncer.cs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f956c63b..62a96234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Fix bed spawn issues when trying to remove spawn point in SSC (@Olink) * Fix Snake Flute (@Olink) * Fix lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) +* Fix bottomless lava bucket from not being able to create lava. (@hakusaro) + * Ban a lava bucket to ban lava on the server entirely, until we figure out a better way to handle liquids. ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index d0541809..5803f67f 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1307,8 +1307,12 @@ namespace TShockAPI { bucket = 5; } + else if (selectedItemType == ItemID.BottomlessLavaBucket) + { + bucket = 6; + } - if (type == LiquidType.Lava && !(bucket == 2 || bucket == 0 || bucket == 5)) + if (type == LiquidType.Lava && !(bucket == 2 || bucket == 0 || bucket == 5 || bucket == 6)) { TShock.Log.ConsoleDebug("Bouncer / OnLiquidSet rejected bucket check 1 from {0}", args.Player.Name); args.Player.SendErrorMessage("You do not have permission to perform this action."); From c5ec45bc02c19fb3d2ceb2d069a1ebf1b178219f Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 22 May 2020 23:53:34 -0700 Subject: [PATCH 30/38] Support using the scarab bomb (fixes #1808) Also fixes #1781. Partially fixes #1865. --- CHANGELOG.md | 1 + TShockAPI/Bouncer.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62a96234..02a15e84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Fix lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) * Fix bottomless lava bucket from not being able to create lava. (@hakusaro) * Ban a lava bucket to ban lava on the server entirely, until we figure out a better way to handle liquids. +* Fix scarab bombs not detonating on pick style tiles. (@hakusaro) ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 5803f67f..4beb9980 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -943,7 +943,8 @@ namespace TShockAPI if ((type == ProjectileID.Bomb || type == ProjectileID.Dynamite || type == ProjectileID.StickyBomb - || type == ProjectileID.StickyDynamite)) + || type == ProjectileID.StickyDynamite + || type == ProjectileID.ScarabBomb)) { // Denotes that the player has recently set a fuse - used for cheat detection. args.Player.RecentFuse = 10; From d610ab929b748713da393dc50cbfb153b5a51c5f Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 00:38:03 -0700 Subject: [PATCH 31/38] Support dirt bomb (fixes #1853, fixes #1865) This commits adds rudamentary support for dirt bombs. There's probably some edge cases in here but the entire handler really needs to be rewritten. This is total spaghetti and completely unreadable and unrecognizable. --- TShockAPI/Bouncer.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 4beb9980..ee0671ce 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -440,7 +440,15 @@ namespace TShockAPI args.Handled = false; return; } - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from explosives/fuses from {0}", args.Player.Name); + + // Dirt bomb makes dirt everywhere + if ((action == EditAction.PlaceTile || action == EditAction.SlopeTile) && editData == TileID.Dirt && args.Player.RecentFuse > 0) + { + args.Handled = false; + return; + } + + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from explosives/fuses from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -944,7 +952,8 @@ namespace TShockAPI || type == ProjectileID.Dynamite || type == ProjectileID.StickyBomb || type == ProjectileID.StickyDynamite - || type == ProjectileID.ScarabBomb)) + || type == ProjectileID.ScarabBomb + || type == ProjectileID.DirtBomb)) { // Denotes that the player has recently set a fuse - used for cheat detection. args.Player.RecentFuse = 10; From eb8aad8a3b9e7885c8c0c453deaec0eaa81df29c Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 00:39:39 -0700 Subject: [PATCH 32/38] Add extra debug logs to OnTileEdit Bouncer call --- TShockAPI/Bouncer.cs | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index ee0671ce..d11cb758 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -205,7 +205,7 @@ namespace TShockAPI { if (editData < 0) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (editData check) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (editData check) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -213,7 +213,7 @@ namespace TShockAPI if (!TShock.Utils.TilePlacementValid(tileX, tileY)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tile placement valid) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tile placement valid) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -221,14 +221,14 @@ namespace TShockAPI if (action == EditAction.KillTile && Main.tile[tileX, tileY].type == TileID.MagicalIceBlock) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit super accepted from (ice block) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit super accepted from (ice block) {0} {1} {2}", args.Player.Name, action, editData); args.Handled = false; return; } if (args.Player.Dead && TShock.Config.PreventDeadModification) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (pdm) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (pdm) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -242,7 +242,7 @@ namespace TShockAPI { if (TShock.TileBans.TileIsBanned(editData, args.Player)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tb) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tb) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Player.SendErrorMessage("You do not have permission to place this tile."); args.Handled = true; @@ -257,7 +257,7 @@ namespace TShockAPI // If the tile is an axe tile and they aren't selecting an axe, they're hacking. if (Main.tileAxe[tile.type] && ((args.Player.TPlayer.mount.Type != 8 && selectedItem.axe == 0) && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (axe) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (axe) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -265,7 +265,7 @@ namespace TShockAPI // If the tile is a hammer tile and they aren't selecting a hammer, they're hacking. else if (Main.tileHammer[tile.type] && ((args.Player.TPlayer.mount.Type != 8 && selectedItem.hammer == 0) && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (hammer) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (hammer) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -275,7 +275,7 @@ namespace TShockAPI else if (tile.type != TileID.ItemFrame && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type] && tile.wall == 0 && args.Player.TPlayer.mount.Type != 8 && selectedItem.pick == 0 && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (pick) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (pick) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -286,7 +286,7 @@ namespace TShockAPI // If they aren't selecting a hammer, they could be hacking. if (selectedItem.hammer == 0 && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0 && selectedItem.createWall == 0) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (hammer2) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (hammer2) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -302,7 +302,7 @@ namespace TShockAPI (MaxPlaceStyles.ContainsKey(editData) && style > MaxPlaceStyles[editData]) && (ExtraneousPlaceStyles.ContainsKey(editData) && style > ExtraneousPlaceStyles[editData])) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (ms1) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (ms1) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -313,23 +313,27 @@ namespace TShockAPI (editData != (action == EditAction.PlaceTile ? selectedItem.createTile : selectedItem.createWall) && !(ropeCoilPlacements.ContainsKey(selectedItem.netID) && editData == ropeCoilPlacements[selectedItem.netID]))) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (ms2) {0}", args.Player.Name); - - args.Player.SendTileSquare(tileX, tileY, 4); - args.Handled = true; - return; + // Rather than attempting to figure out what the above if statement does, we'll just patch it + // Adds exception to this check to allow dirt bombs to create dirt tiles + if (!(selectedItem.netID == ItemID.DirtBomb && action == EditAction.PlaceTile && editData == TileID.Dirt)) + { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (ms2) {0} {1} {2}", args.Player.Name, action, editData); + args.Player.SendTileSquare(tileX, tileY, 4); + args.Handled = true; + return; + } } if (editData >= (action == EditAction.PlaceTile ? Main.maxTileSets : Main.maxWallTypes)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (ms3) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (ms3) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; } if (action == EditAction.PlaceTile && (editData == TileID.PiggyBank || editData == TileID.Safes) && Main.ServerSideCharacter) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (sscprotect) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (sscprotect) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendErrorMessage("You cannot place this tile because server side characters are enabled."); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; @@ -339,7 +343,7 @@ namespace TShockAPI { if (TShock.Utils.HasWorldReachedMaxChests()) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (chestcap) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (chestcap) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendErrorMessage("The world's chest limit has been reached - unable to place more."); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; @@ -348,7 +352,7 @@ namespace TShockAPI if ((TShock.Utils.TilePlacementValid(tileX, tileY + 1) && Main.tile[tileX, tileY + 1].type == TileID.Boulder) || (TShock.Utils.TilePlacementValid(tileX + 1, tileY + 1) && Main.tile[tileX + 1, tileY + 1].type == TileID.Boulder)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (validplacement) {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (validplacement) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; return; @@ -366,7 +370,7 @@ namespace TShockAPI && selectedItem.type != ItemID.MulticolorWrench && selectedItem.type != ItemID.WireKite) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from place wire from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from place wire from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -380,7 +384,7 @@ namespace TShockAPI && selectedItem.type != ItemID.WireKite && selectedItem.type != ItemID.MulticolorWrench) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from wire cutter from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from wire cutter from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -391,7 +395,7 @@ namespace TShockAPI // If they aren't selecting the actuator and don't have the Presserator equipped, they're hacking. if (selectedItem.type != ItemID.Actuator && !args.Player.TPlayer.autoActuator) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from actuator/presserator from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from actuator/presserator from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -401,7 +405,7 @@ namespace TShockAPI { if (action == EditAction.KillWall) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from sts allow cut from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from sts allow cut from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; @@ -412,7 +416,7 @@ namespace TShockAPI if (args.Player.IsBeingDisabled()) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from wire cutter from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from wire cutter from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -421,7 +425,7 @@ namespace TShockAPI if (!args.Player.HasModifiedIceSuccessfully(tileX, tileY, editData, action) && !args.Player.HasBuildPermission(tileX, tileY)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from ice/build from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from ice/build from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; @@ -476,7 +480,7 @@ namespace TShockAPI if (args.Player.IsBouncerThrottled()) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from throttled from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from throttled from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; return; From 1f1591b8038a4d4d65dc05729d1d45bdc588171d Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 00:41:09 -0700 Subject: [PATCH 33/38] Update changelog --- CHANGELOG.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02a15e84..b812fe7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,14 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. ## TShock 4.4.0 (Pre-release ?) -* Fix bed spawn issues when trying to remove spawn point in SSC (@Olink) -* Fix Snake Flute (@Olink) -* Fix lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) -* Fix bottomless lava bucket from not being able to create lava. (@hakusaro) +* Fixed bed spawn issues when trying to remove spawn point in SSC. (@Olink) +* Fixed Snake Flute. (@Olink) +* Fixed lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) +* Fixed bottomless lava bucket from not being able to create lava. (@hakusaro) * Ban a lava bucket to ban lava on the server entirely, until we figure out a better way to handle liquids. -* Fix scarab bombs not detonating on pick style tiles. (@hakusaro) +* Fixed scarab bombs not detonating on pick style tiles. (@hakusaro) +* Fixed dirt bombs not creating dirt. (@hakusaro) +* Added a ridiculous amount of debug information. If you're experiencing any problems with 1.4 items being caught by the TShock anticheat system, please turn on DebugLogs in your config file and capture log data. It'll be extremely helpful in narrowing down precisely how to fix your problem. (@hakusaro) ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). From bc71e357c81346d19a793df1f370a7795bb963c3 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 13:00:40 -0700 Subject: [PATCH 34/38] Update changelog version --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b812fe7e..2c8fa9b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. -## TShock 4.4.0 (Pre-release ?) +## TShock 4.4.0 (Pre-release 6 (Entangled)) * Fixed bed spawn issues when trying to remove spawn point in SSC. (@Olink) * Fixed Snake Flute. (@Olink) * Fixed lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) From 767faa4389355a710dd02554e89c627353d4e011 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 13:01:16 -0700 Subject: [PATCH 35/38] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8fa9b8..fd23eee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Fixed scarab bombs not detonating on pick style tiles. (@hakusaro) * Fixed dirt bombs not creating dirt. (@hakusaro) * Added a ridiculous amount of debug information. If you're experiencing any problems with 1.4 items being caught by the TShock anticheat system, please turn on DebugLogs in your config file and capture log data. It'll be extremely helpful in narrowing down precisely how to fix your problem. (@hakusaro) +* Released with entangled support for 1.4.0.4 based on @Patrikkk local build and latest snapshot gen-dev. (@hakusaro) ## TShock 4.4.0 (Pre-release 6) * Updates to OTAPI 2.0.0.35 (@DeathCradle). From 698647528dc056e2fa5eccbccefa713f75ffefb7 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 13:02:03 -0700 Subject: [PATCH 36/38] Fix counting problem --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd23eee4..bf13517b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. -## TShock 4.4.0 (Pre-release 6 (Entangled)) +## TShock 4.4.0 (Pre-release 7 (Entangled)) * Fixed bed spawn issues when trying to remove spawn point in SSC. (@Olink) * Fixed Snake Flute. (@Olink) * Fixed lava absorbant sponge not capturing lava. `LiquidSetEventArgs` now returns a `LiquidType` instead of a byte type. (@hakusaro) From c5f69f3ea635e566c98342f1a89afcfa8045c496 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 17:30:38 -0700 Subject: [PATCH 37/38] Update to OTAPI 2.0.0.36 / Terraria 1.4.0.4 --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 049f2775..891380c8 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 049f27750cb70f97ff33e106dec108595980e76d +Subproject commit 891380c8946dd53e670d34002d984e88d1c6179e From d6a6b1514b4eca407e57e9be0651fcd3a36cead6 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 23 May 2020 17:33:03 -0700 Subject: [PATCH 38/38] Update changelog! --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf13517b..e019fbd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. +## Upcoming release +* Update for OTAPI 2.0.0.36 and Terraria 1.4.0.4. (@hakusaro, @Patrikkk, @DeathCradle) + ## TShock 4.4.0 (Pre-release 7 (Entangled)) * Fixed bed spawn issues when trying to remove spawn point in SSC. (@Olink) * Fixed Snake Flute. (@Olink)