From 1ef28dfe0d90919bcd074028936977a0800286f5 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 Dec 2017 16:52:49 -0700 Subject: [PATCH 1/7] Replace TSPlayer.IgnoreActionsForInventory => IsDisabledForSSC. This is the first commit in a series to rewrite CheckIgnores() into whatever its replacement becomes. IgnoreActionsForInventory was probably used by the SSC system prior to when we had in-game support for SSC (ergo, when we just checked to make sure you had removed all items before joining and worked our way up in inventory data to track it). I could be wrong about this though. Now, IsDisabledForSSC tracks only if a player is shut down due to SSC, rather than a reason that gets broadcast. --- TShockAPI/Bouncer.cs | 4 ++-- TShockAPI/Commands.cs | 2 +- TShockAPI/GetDataHandlers.cs | 4 ++-- TShockAPI/TSPlayer.cs | 7 ++++--- TShockAPI/TShock.cs | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index a65f840c..df0a38ab 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -855,9 +855,9 @@ namespace TShockAPI { args.Player.SendErrorMessage("Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor); } - else if (args.Player.IgnoreActionsForInventory != "none") + else if (args.Player.IsDisabledForSSC == true) { - args.Player.SendErrorMessage("Disabled for Server Side Inventory: " + args.Player.IgnoreActionsForInventory); + args.Player.SendErrorMessage("Disabled. Server side characters is enabled, and you aren't logged in."); } else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn) { diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 79ed00c4..225cc8f9 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -848,7 +848,7 @@ namespace TShockAPI args.Player.tempGroup = null; args.Player.Account = account; args.Player.IsLoggedIn = true; - args.Player.IgnoreActionsForInventory = "none"; + args.Player.IsDisabledForSSC = false; if (Main.ServerSideCharacter) { diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 959ec454..df9f0cac 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1784,7 +1784,7 @@ namespace TShockAPI args.Player.tempGroup = null; args.Player.Account = account; args.Player.IsLoggedIn = true; - args.Player.IgnoreActionsForInventory = "none"; + args.Player.IsDisabledForSSC = false; if (Main.ServerSideCharacter) { @@ -1856,7 +1856,7 @@ namespace TShockAPI args.Player.tempGroup = null; args.Player.Account = account; args.Player.IsLoggedIn = true; - args.Player.IgnoreActionsForInventory = "none"; + args.Player.IsDisabledForSSC = false; if (Main.ServerSideCharacter) { diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 868f20b2..d32426b9 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -277,7 +277,8 @@ namespace TShockAPI private string CacheIP; - public string IgnoreActionsForInventory = "none"; + /// Determines if the player is disabled by the SSC subsystem for not being logged in. + public bool IsDisabledForSSC = false; public string IgnoreActionsForCheating = "none"; @@ -297,7 +298,7 @@ namespace TShockAPI /// bool - True if any ignore is not none, false, or login state differs from the required state. public bool CheckIgnores() { - return IgnoreActionsForInventory != "none" || IgnoreActionsForCheating != "none" || IgnoreActionsForDisabledArmor != "none" || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; + return IsDisabledForSSC || IgnoreActionsForCheating != "none" || IgnoreActionsForDisabledArmor != "none" || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; } /// @@ -656,7 +657,7 @@ namespace TShockAPI PlayerHooks.OnPlayerLogout(this); if (Main.ServerSideCharacter) { - IgnoreActionsForInventory = $"Server side characters is enabled! Please {Commands.Specifier}register or {Commands.Specifier}login to play!"; + IsDisabledForSSC = true; if (!IgnoreActionsForClearingTrashCan && (!Dead || TPlayer.difficulty != 2)) { PlayerData.CopyCharacter(this); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 9766b93d..d33637c5 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1684,8 +1684,8 @@ namespace TShockAPI { if (Main.ServerSideCharacter) { - player.SendErrorMessage( - player.IgnoreActionsForInventory = String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier)); + player.IsDisabledForSSC = true; + player.SendErrorMessage(String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier)); player.LoginHarassed = true; } else if (Config.RequireLogin) From 7efcfd055f7ea17dcb3504ca4cfaa4306b2e60c0 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 Dec 2017 17:19:14 -0700 Subject: [PATCH 2/7] Replace TSPlayer.IgnoreActionsForCheating w/ boolean This replaces IgnoreActionsForCheating in TSPlayer with a new IsDisabledForStackDetection field that tracks the same basic data. The previous way we did this was storing a string as the "reason" why a player was disabled for cheating, but it only stored the last hacked item stack that caused the check to fail. Since we already have OnSecondUpdate which notifies on _all_ items, we don't need to store this info in such a useless way anyway. They'll find out in one second what they need to remove in a more alarmist way. --- TShockAPI/Bouncer.cs | 6 +++--- TShockAPI/Commands.cs | 2 +- TShockAPI/GetDataHandlers.cs | 4 ++-- TShockAPI/TSPlayer.cs | 5 +++-- TShockAPI/TShock.cs | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index df0a38ab..4e270763 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -847,9 +847,9 @@ namespace TShockAPI if (distance > TShock.Config.MaxRangeForDisabled) { // We need to tell them they were disabled and why, then revert the change. - if (args.Player.IgnoreActionsForCheating != "none") + if (args.Player.IsDisabledForStackDetection == true) { - args.Player.SendErrorMessage("Disabled for cheating: " + args.Player.IgnoreActionsForCheating); + args.Player.SendErrorMessage("Disabled. You went too far with hacked item stacks."); } else if (args.Player.IgnoreActionsForDisabledArmor != "none") { @@ -857,7 +857,7 @@ namespace TShockAPI } else if (args.Player.IsDisabledForSSC == true) { - args.Player.SendErrorMessage("Disabled. Server side characters is enabled, and you aren't logged in."); + args.Player.SendErrorMessage("Disabled. You need to {0}login, since server side characters is enabled.", TShock.Config.CommandSpecifier); } else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn) { diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 225cc8f9..c76dabe3 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -862,7 +862,7 @@ namespace TShockAPI args.Player.LoginFailsBySsi = false; if (args.Player.HasPermission(Permissions.ignorestackhackdetection)) - args.Player.IgnoreActionsForCheating = "none"; + args.Player.IsDisabledForStackDetection = false; if (args.Player.HasPermission(Permissions.usebanneditem)) args.Player.IgnoreActionsForDisabledArmor = "none"; diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index df9f0cac..1fb9c2ba 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1798,7 +1798,7 @@ namespace TShockAPI args.Player.LoginFailsBySsi = false; if (args.Player.HasPermission(Permissions.ignorestackhackdetection)) - args.Player.IgnoreActionsForCheating = "none"; + args.Player.IsDisabledForStackDetection = false; if (args.Player.HasPermission(Permissions.usebanneditem)) args.Player.IgnoreActionsForDisabledArmor = "none"; @@ -1870,7 +1870,7 @@ namespace TShockAPI args.Player.LoginFailsBySsi = false; if (args.Player.HasPermission(Permissions.ignorestackhackdetection)) - args.Player.IgnoreActionsForCheating = "none"; + args.Player.IsDisabledForStackDetection = false; if (args.Player.HasPermission(Permissions.usebanneditem)) args.Player.IgnoreActionsForDisabledArmor = "none"; diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index d32426b9..43bdad2f 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -280,7 +280,8 @@ namespace TShockAPI /// Determines if the player is disabled by the SSC subsystem for not being logged in. public bool IsDisabledForSSC = false; - public string IgnoreActionsForCheating = "none"; + /// Determines if the player is disabled by Bouncer for having hacked item stacks. + public bool IsDisabledForStackDetection = false; public string IgnoreActionsForDisabledArmor = "none"; @@ -298,7 +299,7 @@ namespace TShockAPI /// bool - True if any ignore is not none, false, or login state differs from the required state. public bool CheckIgnores() { - return IsDisabledForSSC || IgnoreActionsForCheating != "none" || IgnoreActionsForDisabledArmor != "none" || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; + return IsDisabledForSSC || IsDisabledForStackDetection || IgnoreActionsForDisabledArmor != "none" || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; } /// diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index d33637c5..1db6ae71 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1106,7 +1106,7 @@ namespace TShockAPI break; } } - player.IgnoreActionsForCheating = check; + player.IsDisabledForStackDetection = true; check = "none"; // Please don't remove this for the time being; without it, players wearing banned equipment will only get debuffed once foreach (Item item in player.TPlayer.armor) From 4e186e7375a9f779448442fd6eae83bcb1ede96c Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 Dec 2017 17:26:06 -0700 Subject: [PATCH 3/7] Replace TSPlayer.IgnoreActionsForDisabledArmor -> boolean TSPlayer.IgnoreActionsForBannedArmor was useless because it only stored the last armor/dye a player had. Replaced with a boolean. --- TShockAPI/Bouncer.cs | 8 ++++---- TShockAPI/Commands.cs | 2 +- TShockAPI/GetDataHandlers.cs | 4 ++-- TShockAPI/TSPlayer.cs | 5 +++-- TShockAPI/TShock.cs | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 4e270763..a0a9c10c 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -847,15 +847,15 @@ namespace TShockAPI if (distance > TShock.Config.MaxRangeForDisabled) { // We need to tell them they were disabled and why, then revert the change. - if (args.Player.IsDisabledForStackDetection == true) + if (args.Player.IsDisabledForStackDetection) { args.Player.SendErrorMessage("Disabled. You went too far with hacked item stacks."); } - else if (args.Player.IgnoreActionsForDisabledArmor != "none") + else if (args.Player.IsDisabledForBannedWearable) { - args.Player.SendErrorMessage("Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor); + args.Player.SendErrorMessage("Disabled. You went too far with banned armor."); } - else if (args.Player.IsDisabledForSSC == true) + else if (args.Player.IsDisabledForSSC) { args.Player.SendErrorMessage("Disabled. You need to {0}login, since server side characters is enabled.", TShock.Config.CommandSpecifier); } diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index c76dabe3..5a5dc183 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -865,7 +865,7 @@ namespace TShockAPI args.Player.IsDisabledForStackDetection = false; if (args.Player.HasPermission(Permissions.usebanneditem)) - args.Player.IgnoreActionsForDisabledArmor = "none"; + args.Player.IsDisabledForBannedWearable = false; args.Player.SendSuccessMessage("Authenticated as " + account.Name + " successfully."); diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 1fb9c2ba..a48867d5 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1801,7 +1801,7 @@ namespace TShockAPI args.Player.IsDisabledForStackDetection = false; if (args.Player.HasPermission(Permissions.usebanneditem)) - args.Player.IgnoreActionsForDisabledArmor = "none"; + args.Player.IsDisabledForBannedWearable = false; args.Player.SendSuccessMessage("Authenticated as " + account.Name + " successfully."); TShock.Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + "."); @@ -1873,7 +1873,7 @@ namespace TShockAPI args.Player.IsDisabledForStackDetection = false; if (args.Player.HasPermission(Permissions.usebanneditem)) - args.Player.IgnoreActionsForDisabledArmor = "none"; + args.Player.IsDisabledForBannedWearable = false; args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 43bdad2f..7215e0c3 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -283,7 +283,8 @@ namespace TShockAPI /// Determines if the player is disabled by Bouncer for having hacked item stacks. public bool IsDisabledForStackDetection = false; - public string IgnoreActionsForDisabledArmor = "none"; + /// Determines if the player is disabled by the item bans system for having banned wearables on the server. + public bool IsDisabledForBannedWearable = false; public bool IgnoreActionsForClearingTrashCan; @@ -299,7 +300,7 @@ namespace TShockAPI /// bool - True if any ignore is not none, false, or login state differs from the required state. public bool CheckIgnores() { - return IsDisabledForSSC || IsDisabledForStackDetection || IgnoreActionsForDisabledArmor != "none" || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; + return IsDisabledForSSC || IsDisabledForStackDetection || IsDisabledForBannedWearable || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; } /// diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 1db6ae71..0a955930 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1161,7 +1161,7 @@ namespace TShockAPI break; } } - player.IgnoreActionsForDisabledArmor = check; + player.IsDisabledForBannedWearable = true; if (player.CheckIgnores()) { From 8e5ee7d286ee2c77161b9690119a13321324af1d Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 Dec 2017 17:33:18 -0700 Subject: [PATCH 4/7] Renamed IgnoreActionsForClearingTrashCan to conform w/ changes This just changes IgnoreActionsForClearingTrashCan to meet the same naming scheme for the rest of the old ignore checks. For consistency. Consistency is nice. --- TShockAPI/Bouncer.cs | 2 +- TShockAPI/Commands.cs | 6 +++--- TShockAPI/GetDataHandlers.cs | 2 +- TShockAPI/TSPlayer.cs | 7 ++++--- TShockAPI/TShock.cs | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index a0a9c10c..4447c273 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -863,7 +863,7 @@ namespace TShockAPI { args.Player.SendErrorMessage("Please /register or /login to play!"); } - else if (args.Player.IgnoreActionsForClearingTrashCan) + else if (args.Player.IsDisabledPendingTrashRemoval) { args.Player.SendErrorMessage("You need to rejoin to ensure your trash can is cleared!"); } diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5a5dc183..542d3367 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1636,7 +1636,7 @@ namespace TShockAPI args.Player.SendSuccessMessage("SSC has been saved."); foreach (TSPlayer player in TShock.Players) { - if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan) + if (player != null && player.IsLoggedIn && !player.IsDisabledPendingTrashRemoval) { TShock.CharacterDB.InsertPlayerData(player, true); } @@ -1681,7 +1681,7 @@ namespace TShockAPI args.Player.SendErrorMessage("Player \"{0}\" has to perform a /login attempt first.", matchedPlayer.Name); return; } - if (matchedPlayer.IgnoreActionsForClearingTrashCan) + if (matchedPlayer.IsDisabledPendingTrashRemoval) { args.Player.SendErrorMessage("Player \"{0}\" has to reconnect first.", matchedPlayer.Name); return; @@ -1887,7 +1887,7 @@ namespace TShockAPI { foreach (TSPlayer player in TShock.Players) { - if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan) + if (player != null && player.IsLoggedIn && !player.IsDisabledPendingTrashRemoval) { player.SaveServerCharacter(); } diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index a48867d5..f08e9772 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1612,7 +1612,7 @@ namespace TShockAPI args.Player.HasSentInventory && !args.Player.HasPermission(Permissions.bypassssc)) { // The player might have moved an item to their trash can before they performed a single login attempt yet. - args.Player.IgnoreActionsForClearingTrashCan = true; + args.Player.IsDisabledPendingTrashRemoval = true; } if (slot == 58) //this is the hand diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 7215e0c3..fc543bd5 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -286,7 +286,8 @@ namespace TShockAPI /// Determines if the player is disabled by the item bans system for having banned wearables on the server. public bool IsDisabledForBannedWearable = false; - public bool IgnoreActionsForClearingTrashCan; + /// Determines if the player is disabled for not clearing their trash. A re-login is the only way to reset this. + public bool IsDisabledPendingTrashRemoval; /// Checks to see if active throttling is happening on events by Bouncer. Rejects repeated events by malicious clients in a short window. /// If the player is currently being throttled by Bouncer, or not. @@ -300,7 +301,7 @@ namespace TShockAPI /// bool - True if any ignore is not none, false, or login state differs from the required state. public bool CheckIgnores() { - return IsDisabledForSSC || IsDisabledForStackDetection || IsDisabledForBannedWearable || IgnoreActionsForClearingTrashCan || !IsLoggedIn && TShock.Config.RequireLogin; + return IsDisabledForSSC || IsDisabledForStackDetection || IsDisabledForBannedWearable || IsDisabledPendingTrashRemoval || !IsLoggedIn && TShock.Config.RequireLogin; } /// @@ -660,7 +661,7 @@ namespace TShockAPI if (Main.ServerSideCharacter) { IsDisabledForSSC = true; - if (!IgnoreActionsForClearingTrashCan && (!Dead || TPlayer.difficulty != 2)) + if (!IsDisabledPendingTrashRemoval && (!Dead || TPlayer.difficulty != 2)) { PlayerData.CopyCharacter(this); TShock.CharacterDB.InsertPlayerData(this); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 0a955930..be0e880c 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -945,7 +945,7 @@ namespace TShockAPI foreach (TSPlayer player in Players) { // prevent null point exceptions - if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan) + if (player != null && player.IsLoggedIn && !player.IsDisabledPendingTrashRemoval) { CharacterDB.InsertPlayerData(player); @@ -1409,7 +1409,7 @@ namespace TShockAPI Utils.Broadcast(tsplr.Name + " has left.", Color.Yellow); Log.Info("{0} disconnected.", tsplr.Name); - if (tsplr.IsLoggedIn && !tsplr.IgnoreActionsForClearingTrashCan && Main.ServerSideCharacter && (!tsplr.Dead || tsplr.TPlayer.difficulty != 2)) + if (tsplr.IsLoggedIn && !tsplr.IsDisabledPendingTrashRemoval && Main.ServerSideCharacter && (!tsplr.Dead || tsplr.TPlayer.difficulty != 2)) { tsplr.PlayerData.CopyCharacter(tsplr); CharacterDB.InsertPlayerData(tsplr); From 97f48d6d4138243f22b6a819cfdf4ba5819e1998 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 Dec 2017 17:42:59 -0700 Subject: [PATCH 5/7] Renamed TSPlayer.CheckIgnores() -> TSPlayer.IsBeingDisabled() Since all of the flags it was checking have been demystified, this is pretty self explanatory now. --- CHANGELOG.md | 2 +- TShockAPI/Bouncer.cs | 40 ++++++++++++++++++++-------------------- TShockAPI/TSPlayer.cs | 13 ++++++++----- TShockAPI/TShock.cs | 4 ++-- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30241bbb..edb7a619 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added `TSPlayer` to `GetDataHandlers.GemLockToggle`. (@hakusaro) * Added `GetDataHandlers.PlaceItemFrame` hook and related arguments. (@hakusaro) * Added `TSPlayer.IsBouncerThrottled()`. (@hakusaro) -* Added `TSPlayer.CheckIgnores()` and removed `TShock.CheckIgnores(TSPlayer)`. (@hakusaro) +* Added `TSPlayer.IsBeingDisabled()` and removed `TShock.CheckIgnores(TSPlayer)`. (@hakusaro) ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6. diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 4447c273..11c550fe 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -69,7 +69,7 @@ namespace TShockAPI /// The packet arguments that the event has. internal void OnPlaceItemFrame(object sender, GetDataHandlers.PlaceItemFrameEventArgs args) { - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, NetworkText.Empty, args.ItemFrame.ID, 0, 1); args.Handled = true; @@ -108,7 +108,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Handled = true; return; @@ -126,7 +126,7 @@ namespace TShockAPI /// The packet arguments that the event has. internal void OnPlaceTileEntity(object sender, GetDataHandlers.PlaceTileEntityEventArgs args) { - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Handled = true; return; @@ -177,7 +177,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Handled = true; return; @@ -196,7 +196,7 @@ namespace TShockAPI /// args internal void OnPlayerAnimation(object sender, GetDataHandlers.PlayerAnimationEventArgs args) { - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index); args.Handled = true; @@ -245,7 +245,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendData(PacketTypes.NpcUpdate, "", id); args.Handled = true; @@ -311,7 +311,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendData(PacketTypes.PlayerHp, "", id); args.Player.SendData(PacketTypes.PlayerUpdate, "", id); @@ -421,7 +421,7 @@ namespace TShockAPI } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendData(PacketTypes.ItemDrop, "", id); args.Handled = true; @@ -444,7 +444,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendData(PacketTypes.PlayerAddBuff, "", id); args.Handled = true; @@ -503,7 +503,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendData(PacketTypes.ChestItem, "", id, slot); args.Handled = true; @@ -558,7 +558,7 @@ namespace TShockAPI /// The packet arguments that the event has. internal void OnChestOpen(object sender, GetDataHandlers.ChestOpenEventArgs args) { - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Handled = true; return; @@ -595,7 +595,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; @@ -656,7 +656,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; @@ -791,7 +791,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.RemoveProjectile(args.ProjectileIdentity, args.ProjectileOwner); args.Handled = true; @@ -841,7 +841,7 @@ namespace TShockAPI float distance = Vector2.Distance(new Vector2(pos.X / 16f, pos.Y / 16f), new Vector2(args.Player.LastNetPosition.X / 16f, args.Player.LastNetPosition.Y / 16f)); - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { // If the player has moved outside the disabled zone... if (distance > TShock.Config.MaxRangeForDisabled) @@ -982,7 +982,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.RemoveProjectile(ident, owner); args.Handled = true; @@ -1115,7 +1115,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendTileSquare(x, y, 4); args.Handled = true; @@ -1470,7 +1470,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendTileSquare(tileX, tileY, 4); args.Handled = true; @@ -1586,7 +1586,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores() || args.Player.IsBouncerThrottled()) + if (args.Player.IsBeingDisabled() || args.Player.IsBouncerThrottled()) { args.Handled = true; return; @@ -1627,7 +1627,7 @@ namespace TShockAPI return; } - if (args.Player.CheckIgnores()) + if (args.Player.IsBeingDisabled()) { args.Player.SendTileSquare(tileX, tileY, size); args.Handled = true; diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index fc543bd5..69181389 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -296,12 +296,15 @@ namespace TShockAPI return (DateTime.UtcNow - LastThreat).TotalMilliseconds < 5000; } - /// CheckIgnores - Checks a players ignores...? - /// player - The TSPlayer object. - /// bool - True if any ignore is not none, false, or login state differs from the required state. - public bool CheckIgnores() + /// Easy check if a player has any of IsDisabledForSSC, IsDisabledForStackDetection, IsDisabledForBannedWearable, or IsDisabledPendingTrashRemoval set. Or if they're not logged in and a login is required. + /// If any of the checks that warrant disabling are set on this player. If true, Disable() is repeatedly called on them. + public bool IsBeingDisabled() { - return IsDisabledForSSC || IsDisabledForStackDetection || IsDisabledForBannedWearable || IsDisabledPendingTrashRemoval || !IsLoggedIn && TShock.Config.RequireLogin; + return IsDisabledForSSC + || IsDisabledForStackDetection + || IsDisabledForBannedWearable + || IsDisabledPendingTrashRemoval + || !IsLoggedIn && TShock.Config.RequireLogin; } /// diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index be0e880c..44c6b9f1 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1083,7 +1083,7 @@ namespace TShockAPI if (Main.ServerSideCharacter && !player.IsLoggedIn) { - if (player.CheckIgnores()) + if (player.IsBeingDisabled()) { player.Disable(flags: flags); } @@ -1163,7 +1163,7 @@ namespace TShockAPI } player.IsDisabledForBannedWearable = true; - if (player.CheckIgnores()) + if (player.IsBeingDisabled()) { player.Disable(flags: flags); } From ea630e5aa2ab263d99825c59a8fafde44bbc383a Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 Dec 2017 21:32:56 -0700 Subject: [PATCH 6/7] Rephrase SSC login message to avoid grammar choice --- TShockAPI/Bouncer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 238df5b0..13c1c0a0 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -857,7 +857,7 @@ namespace TShockAPI } else if (args.Player.IsDisabledForSSC) { - args.Player.SendErrorMessage("Disabled. You need to {0}login, since server side characters is enabled.", TShock.Config.CommandSpecifier); + args.Player.SendErrorMessage("Disabled. You need to {0}login to use your server inventory and items.", TShock.Config.CommandSpecifier); } else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn) { From 7730faf94f3e97588b3117f1c6f42ee4738deccc Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Thu, 21 Dec 2017 08:22:51 -0700 Subject: [PATCH 7/7] Change diction to refer to "saved data" on Disable --- TShockAPI/Bouncer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 13c1c0a0..8e81d802 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -857,7 +857,7 @@ namespace TShockAPI } else if (args.Player.IsDisabledForSSC) { - args.Player.SendErrorMessage("Disabled. You need to {0}login to use your server inventory and items.", TShock.Config.CommandSpecifier); + args.Player.SendErrorMessage("Disabled. You need to {0}login to load your saved data.", TShock.Config.CommandSpecifier); } else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn) {