Merge pull request #2398 from drunderscore/feature/force-character-gamemodes

Introduce `SoftcoreOnly` config option to allow only softcore characters to connect.
This commit is contained in:
Chris 2021-08-02 20:09:17 +09:30 committed by GitHub
commit 98dd1177fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View file

@ -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)
* Fix some typos that have been in the repository for over a lustrum. (@Killia0)
* Added a `tshock.npc.summonboss` permission check for Lunatic Cultist, players who do not have this permission will not be able to kill Cultist Archers/Devotees to summon the Lunatic Cultist. (@moisterrific)
* Added more usage examples for the `ban` command under `ban help examples` to explain how users can ban: offline players by account, offline players by IP, and online players by player index - useful for banning hard to type character names. (@moisterrific)

View file

@ -133,6 +133,10 @@ namespace TShockAPI.Configuration
[Description("Prevents softcore players from connecting.")]
public bool MediumcoreOnly;
/// <summary>Prevents non-softcore players from connecting.</summary>
[Description("Prevents non-softcore players from connecting.")]
public bool SoftcoreOnly;
/// <summary>Disables any placing, or removal of blocks.</summary>
[Description("Disables any placing, or removal of blocks.")]
public bool DisableBuild;

View file

@ -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");