From a40effd55ecd0c53710499dc21eb518111a0fa8a Mon Sep 17 00:00:00 2001 From: James Puleo Date: Tue, 13 Jul 2021 21:49:22 -0400 Subject: [PATCH] Introduce `SoftcoreOnly` config option to allow only softcore characters to connect. --- CHANGELOG.md | 1 + TShockAPI/Configuration/TShockConfig.cs | 4 ++++ TShockAPI/GetDataHandlers.cs | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cba20d9..3ab34a6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## Upcoming changes * Fixed SendTileRectHandler not sending tile rect updates like Pylons/Mannequins to other clients. (@Stealownz) +* Introduced `SoftcoreOnly` config option to allow only softcore characters to connect. (@drunderscore) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index 801a4c5f..eb28b90b 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -133,6 +133,10 @@ namespace TShockAPI.Configuration [Description("Prevents softcore players from connecting.")] public bool MediumcoreOnly; + /// Prevents non-softcore players from connecting. + [Description("Prevents non-softcore players from connecting.")] + public bool SoftcoreOnly; + /// Disables any placing, or removal of blocks. [Description("Disables any placing, or removal of blocks.")] public bool DisableBuild; diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index ed701f2f..ae459289 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2364,6 +2364,12 @@ namespace TShockAPI NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, args.Player.Index, NetworkText.FromLiteral(args.Player.Name), args.Player.Index); return true; } + if (TShock.Config.Settings.SoftcoreOnly && difficulty != 0) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected softcore required"); + args.Player.Kick("You need to join with a softcore player.", true, true); + return true; + } if (TShock.Config.Settings.MediumcoreOnly && difficulty < 1) { TShock.Log.ConsoleDebug("GetDataHandlers / HandlePlayerInfo rejected mediumcore required");