From 68ae73ffef338bc5584df889948ad91c116d440a Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 21 May 2021 01:16:04 -0700 Subject: [PATCH] Warn players if bypass SSC permission is enabled If a player has the tshock.ignore.ssc permission, odds are that they may want to know that their data isn't being saved or not. This change allows users to be notified if they have SSC data stored in the DB but they aren't having it loaded due to the aforementioned permission. This permission causes great confusion, but we can't really change it because we would break existing setups. This is an easy change that gives people a reason why they suddenly "have no items." This new option can be turned off in the config file for SSC if it's not desired. This change also modifies some of the log messages so that it's clear why the SSC save didn't occur for a given player. --- CHANGELOG.md | 1 + TShockAPI/Configuration/ServerSideConfig.cs | 6 ++++++ TShockAPI/DB/CharacterManager.cs | 4 ++-- TShockAPI/GetDataHandlers.cs | 6 ++++++ TShockAPI/TSPlayer.cs | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b14bd8a..635ed67c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * The default MOTD is now prettier. The MOTD format can now contain `%specifier%` to send the command specifier. (@moisterrific) * The buff commands now support `-1` as a time option to set buffs that last 415 days (the maximum buff time the game supports). (@moisterrific) * TShock defaults to saving backups every 10 minutes, and defaults to keeping backups for 4 hours. (@hakusaro) +* Updated SSC bypass messaging. Now, when you connect, you're told if you're bypassing SSC. Console logging has been improved to warn when players are not being saved due to the bypass SSC permission. To turn this warning off, change `WarnPlayersAboutBypassPermission` to `false` in the `sscconfig.json` file. (@hakusaro) ## TShock 4.5.2 * Added preliminary support for Terraria 1.4.2.2. (@hakusaro) diff --git a/TShockAPI/Configuration/ServerSideConfig.cs b/TShockAPI/Configuration/ServerSideConfig.cs index d80e4bac..6d37aa94 100644 --- a/TShockAPI/Configuration/ServerSideConfig.cs +++ b/TShockAPI/Configuration/ServerSideConfig.cs @@ -66,6 +66,12 @@ namespace TShockAPI.Configuration /// [Description("The starting default inventory for new players when SSC is enabled.")] public List StartingInventory = new List(); + + /// + /// Warns players that they have the bypass SSC permission enabled. To disable warning, turn this off. + /// + [Description("Warns players and the console if a player has the tshock.ignore.ssc permission with data in the SSC table.")] + public bool WarnPlayersAboutBypassPermission = true; } /// diff --git a/TShockAPI/DB/CharacterManager.cs b/TShockAPI/DB/CharacterManager.cs index d6e923c5..e1cb0ce9 100644 --- a/TShockAPI/DB/CharacterManager.cs +++ b/TShockAPI/DB/CharacterManager.cs @@ -167,7 +167,7 @@ namespace TShockAPI.DB if (player.HasPermission(Permissions.bypassssc) && !fromCommand) { - TShock.Log.ConsoleInfo("Skipping SSC Backup for " + player.Account.Name); // Debug code + TShock.Log.ConsoleInfo("Skipping SSC save (due to tshock.ignore.ssc) for " + player.Account.Name); return false; } @@ -237,7 +237,7 @@ namespace TShockAPI.DB if (player.HasPermission(Permissions.bypassssc)) { - TShock.Log.ConsoleInfo("Skipping SSC Backup for " + player.Account.Name); // Debug code + TShock.Log.ConsoleInfo("Skipping SSC save (due to tshock.ignore.ssc) for " + player.Account.Name); return true; } diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index f966b57e..b2c75b76 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2411,6 +2411,12 @@ namespace TShockAPI { if (args.Player.HasPermission(Permissions.bypassssc)) { + if (args.Player.PlayerData.exists && TShock.ServerSideCharacterConfig.Settings.WarnPlayersAboutBypassPermission) + { + args.Player.SendWarningMessage("Bypass SSC is enabled for your account. SSC data will not be loaded or saved."); + TShock.Log.ConsoleInfo(args.Player.Name + " has SSC data in the database, but has the tshock.ignore.ssc permission. This means their SSC data is being ignored."); + TShock.Log.ConsoleInfo("You may wish to consider removing the tshock.ignore.ssc permission or negating it for this player."); + } args.Player.PlayerData.CopyCharacter(args.Player); TShock.CharacterDB.InsertPlayerData(args.Player); } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 915399eb..8b20dfd3 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -906,7 +906,7 @@ namespace TShockAPI { if (HasPermission(Permissions.bypassssc)) { - TShock.Log.ConsoleInfo("Skipping SSC Backup for " + Account.Name); // Debug Code + TShock.Log.ConsoleInfo("Skipping SSC save (due to tshock.ignore.ssc) for " + Account.Name); return true; } PlayerData.CopyCharacter(this);