From 10e0b33e82180bde33af1e1b03b7032df9143015 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Fri, 16 Jul 2021 14:19:37 -0400 Subject: [PATCH 01/33] Add Lunatic Cultist summon permission check Didn't bother adding the broadcast stuff bc there's 4 cultists and it'll prob spam the chat if multiple players kill them at around the same time --- TShockAPI/GetDataHandlers.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index ed701f2f..430d8256 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2829,6 +2829,17 @@ namespace TShockAPI else TShock.Utils.SendLogs(string.Format($"{args.Player.Name} summoned the Empress of Light!"), Color.PaleVioletRed, args.Player); } + + if (Main.npc[id].netID == NPCID.CultistDevote || Main.npc[id].netID == NPCID.CultistArcherBlue) + { + if (!args.Player.HasPermission(Permissions.summonboss)) + { + args.Player.SendErrorMessage("You do not have permission to summon the Lunatic Cultist!"); + args.Player.SendData(PacketTypes.NpcUpdate, "", id); + TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected Cultist summon from {args.Player.Name}"); + return true; + } + } return false; } From 40f8c931189b725a6fcee0bd5d7539843ffe4547 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Fri, 16 Jul 2021 15:01:41 -0400 Subject: [PATCH 02/33] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e55df643..62f09d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Correct rejection message in LandGolfBallInCupHandler to output the proper expected player id. (@drunderscore) * Clarified the error mesage that the console is presented if a rate-limit is reached over REST to indicate that "tokens" actually refers to rate-limit tokens, and not auth tokens, and added a hint as to what config setting determines this. (@hakusaro, @patsore) * Fixed an issue where, when the console was redirected, input was disabled and commands didn't work, in TSAPI. You can now pass `-disable-commands` to disable the input thread, but by default, it will be enabled. Fixes [#1450](https://github.com/Pryaxis/TShock/issues/1450). (@DeathCradle, @QuiCM) -* Added `summonboss` permission check for Prismatic Lacewing. Players who do not have said permission will be unable to kill this critter, as it will summon the Empress of Light. Also added support for the `AnonymousBossInvasions` config option, if this is set to `false` it will now broadcast the name of the player who summoned her. (@moisterrific) +* Added `summonboss` permission check for Empress of Light and Lunatic Cultist. Players who do not have this permission will be unable to kill Prismatic Lacewings, Cultist Devotees, and Cultist Archers. Also added support for the `AnonymousBossInvasions` config option for summoning Empress of Light, if this is set to `false` it will now broadcast the name of the player who summoned her. (@moisterrific) * Added `ForceTime` config setting check for Enchanted Sundial usage. If `ForceTime` is set to anything other than `normal`, Sundial use will be rejected as this would lead to very janky game behavior. Additionally, players with `cfgreload` permission will be advised to change it back to `normal` in order to use sundial. (@moisterrific, @bartico6) * Added `%onlineplayers%` and `%serverslots%` placeholders for MOTD. The default MOTD message was also updated to use this. (@moisterrific, @bartico6) From 8ebecd9ff2e777adfebdffba07252959ba941f1b Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 17 Jul 2021 14:36:10 -0400 Subject: [PATCH 03/33] Add notify msg for online player group change This makes it more consistent with how /tempgroup works, since that tells the target player of their group change. Also added silent command support. --- TShockAPI/Commands.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index b6ba179f..ce0bf192 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1116,6 +1116,12 @@ namespace TShockAPI TShock.UserAccounts.SetUserGroup(account, args.Parameters[2]); TShock.Log.ConsoleInfo(args.Player.Name + " changed account " + account.Name + " to group " + args.Parameters[2] + "."); args.Player.SendSuccessMessage("Account " + account.Name + " has been changed to group " + args.Parameters[2] + "!"); + + var players = TSPlayer.FindByNameOrID(account.Name); + if (players.Count == 0) + return; + else if (!args.Silent) + players[0].SendSuccessMessage($"{args.Player.Name} has changed your group to {args.Parameters[2]}"); } catch (GroupNotExistsException) { From 96570bfcbdd09bf1fa3fab86aeb667381b43a83b Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 17 Jul 2021 14:43:52 -0400 Subject: [PATCH 04/33] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e55df643..d11a391a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added `summonboss` permission check for Prismatic Lacewing. Players who do not have said permission will be unable to kill this critter, as it will summon the Empress of Light. Also added support for the `AnonymousBossInvasions` config option, if this is set to `false` it will now broadcast the name of the player who summoned her. (@moisterrific) * Added `ForceTime` config setting check for Enchanted Sundial usage. If `ForceTime` is set to anything other than `normal`, Sundial use will be rejected as this would lead to very janky game behavior. Additionally, players with `cfgreload` permission will be advised to change it back to `normal` in order to use sundial. (@moisterrific, @bartico6) * Added `%onlineplayers%` and `%serverslots%` placeholders for MOTD. The default MOTD message was also updated to use this. (@moisterrific, @bartico6) +* Added a notification message and silent command support for permanently changing a target player's user group. Now players who received a group change will be notified of their new group if they are currently online. (@moisterrific) ## TShock 4.5.4 * Fixed ridiculous typo in `GetDataHandlers` which caused TShock to read the wrong field in the packet for `usingBiomeTorches`. (@hakusaro, @Arthri) From 1521c8b28e271272813bcde6f70187fb332d18d4 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:03:39 -0400 Subject: [PATCH 05/33] Improved login error messages and onboarding process Added config based checks so error messages only tell what is relevant to the user. Doesn't make any sense to tell them you can do /login when UUID is set to false because they will just get the same error message again. Also added an additional info message to the onboarding/password registration process so the next steps will be more obvious for first time users. --- TShockAPI/Commands.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index b6ba179f..a8a287b0 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -807,9 +807,17 @@ namespace TShockAPI } else { - args.Player.SendErrorMessage("Syntax: {0}login - Logs in using your UUID and character name", Specifier); - args.Player.SendErrorMessage(" {0}login - Logs in using your password and character name", Specifier); - args.Player.SendErrorMessage(" {0}login - Logs in using your username and password", Specifier); + if (TShock.Config.Settings.DisableUUIDLogin && !TShock.Config.Settings.AllowLoginAnyUsername) + args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); + else if (TShock.Config.Settings.DisableUUIDLogin && TShock.Config.Settings.AllowLoginAnyUsername) + { + args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); + args.Player.SendErrorMessage($" {Specifier}login - Logs in using your username and password"); + } + else + { + args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your UUID and character name"); + } args.Player.SendErrorMessage("If you forgot your password, there is no way to recover it."); return; } @@ -991,6 +999,14 @@ namespace TShockAPI { args.Player.SendSuccessMessage("Account \"{0}\" has been registered.", account.Name); args.Player.SendSuccessMessage("Your password is {0}.", echoPassword); + if (TShock.Config.Settings.DisableUUIDLogin && !TShock.Config.Settings.AllowLoginAnyUsername) + args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); + else if (TShock.Config.Settings.DisableUUIDLogin && TShock.Config.Settings.AllowLoginAnyUsername) + args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); + else + { + args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); + } TShock.UserAccounts.AddUserAccount(account); TShock.Log.ConsoleInfo("{0} registered an account: \"{1}\".", args.Player.Name, account.Name); } From cdafad1d5ab30404cca407e72ef02eaaae518432 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:10:11 -0400 Subject: [PATCH 06/33] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e55df643..53ffbb74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added `summonboss` permission check for Prismatic Lacewing. Players who do not have said permission will be unable to kill this critter, as it will summon the Empress of Light. Also added support for the `AnonymousBossInvasions` config option, if this is set to `false` it will now broadcast the name of the player who summoned her. (@moisterrific) * Added `ForceTime` config setting check for Enchanted Sundial usage. If `ForceTime` is set to anything other than `normal`, Sundial use will be rejected as this would lead to very janky game behavior. Additionally, players with `cfgreload` permission will be advised to change it back to `normal` in order to use sundial. (@moisterrific, @bartico6) * Added `%onlineplayers%` and `%serverslots%` placeholders for MOTD. The default MOTD message was also updated to use this. (@moisterrific, @bartico6) +* Improved `/login` related error messages and made the `/register` process more friendly for players new to TShock. (@moisterrific) ## TShock 4.5.4 * Fixed ridiculous typo in `GetDataHandlers` which caused TShock to read the wrong field in the packet for `usingBiomeTorches`. (@hakusaro, @Arthri) From 640c4ebdb50b601913d74d932bda7413ecf97809 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:25:20 -0400 Subject: [PATCH 07/33] Slightly even better idea I just realized --- TShockAPI/Commands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index a8a287b0..280c1cfb 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1000,9 +1000,9 @@ namespace TShockAPI args.Player.SendSuccessMessage("Account \"{0}\" has been registered.", account.Name); args.Player.SendSuccessMessage("Your password is {0}.", echoPassword); if (TShock.Config.Settings.DisableUUIDLogin && !TShock.Config.Settings.AllowLoginAnyUsername) - args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); + args.Player.SendInfoMessage($"Type {Specifier}login {echoPassword} to sign in to your account."); else if (TShock.Config.Settings.DisableUUIDLogin && TShock.Config.Settings.AllowLoginAnyUsername) - args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); + args.Player.SendInfoMessage($"Type {Specifier}login \"{account.Name}\" {echoPassword} to sign in to your account."); else { args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); From 7cf49b55d8fb0fa86b476533121086bf218d7fde Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 16:44:24 -0400 Subject: [PATCH 08/33] Update TShockAPI/Commands.cs Co-authored-by: Chris <2648373+QuiCM@users.noreply.github.com> --- TShockAPI/Commands.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ce0bf192..db92ca85 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1117,11 +1117,10 @@ namespace TShockAPI TShock.Log.ConsoleInfo(args.Player.Name + " changed account " + account.Name + " to group " + args.Parameters[2] + "."); args.Player.SendSuccessMessage("Account " + account.Name + " has been changed to group " + args.Parameters[2] + "!"); - var players = TSPlayer.FindByNameOrID(account.Name); - if (players.Count == 0) - return; - else if (!args.Silent) - players[0].SendSuccessMessage($"{args.Player.Name} has changed your group to {args.Parameters[2]}"); + //send message to player with matching account name + var player = TShock.Players.FirstOrDefault(p => p != null && p.Account?.Name == account.Name) + if (player != null && !args.Silent) + player.SendSuccessMessage($"{args.Player.Name} has changed your group to {args.Parameters[2]}"); } catch (GroupNotExistsException) { From 1d2cc0f7d3bc7f1e0401211113459e06ccd6a957 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 16:45:30 -0400 Subject: [PATCH 09/33] fix minor typo --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index db92ca85..86a99e31 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1118,7 +1118,7 @@ namespace TShockAPI args.Player.SendSuccessMessage("Account " + account.Name + " has been changed to group " + args.Parameters[2] + "!"); //send message to player with matching account name - var player = TShock.Players.FirstOrDefault(p => p != null && p.Account?.Name == account.Name) + var player = TShock.Players.FirstOrDefault(p => p != null && p.Account?.Name == account.Name); if (player != null && !args.Silent) player.SendSuccessMessage($"{args.Player.Name} has changed your group to {args.Parameters[2]}"); } From 88080b139c81816db64690a06e51eb952ce5021c Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 16:47:31 -0400 Subject: [PATCH 10/33] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3924f4..73e95489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. ## Upcoming changes -* Added a notification message and silent command support for permanently changing a target player's user group. Now players who received a group change will be notified of their new group if they are currently online. (@moisterrific) +* Added a notification message and silent command support for permanently changing a target player's user group. Now players who received a group change will be notified of their new group if they are currently online. (@moisterrific, @QuiCM) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From 11463930f38e0da2b59a0762375023fb6d57a20c Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 19:53:13 -0400 Subject: [PATCH 11/33] Add DisablePrimeBombs to OnProjectileSetDefaults --- TShockAPI/TShock.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 2114b469..92c8c8af 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1627,6 +1627,9 @@ namespace TShockAPI if (e.Info == 109) if (Config.Settings.DisableSnowBalls) e.Object.SetDefaults(0); + if (e.Info == ProjectileID.BombSkeletronPrime) + if (Config.Settings.DisablePrimeBombs) + e.Object.SetDefaults(0); } /// NetHooks_SendData - Fired when the server sends data. From 347a23a8bc65e6e5b53257f8610a9ce884b715d1 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 19:55:38 -0400 Subject: [PATCH 12/33] Add DisablePrimeBombs to World Settings --- TShockAPI/Configuration/TShockConfig.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index 801a4c5f..7fe74884 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -156,6 +156,12 @@ namespace TShockAPI.Configuration /// Disables tombstone dropping during death for all players. [Description("Disables tombstone dropping during death for all players.")] public bool DisableTombstones = true; + + /// + /// Disables Skeletron Prime Bombs from spawning, useful for preventing unwanted world destruction on for the worthy seed world. + /// + [Description("Disables Skeletron Prime Bombs from spawning, useful for preventing unwanted world destruction on for the worthy seed world.")] + public bool DisablePrimeBombs; /// Forces the world time to be normal, day, or night. [Description("Forces the world time to be normal, day, or night.")] From adeb7225e6df358153b285f67752b95362d05a96 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 20:01:21 -0400 Subject: [PATCH 13/33] Add DisablePrimeBombs to Upcoming changes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cba20d9..05f94143 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) +* Added a new `DisablePrimeBombs` config option (`false` by default). Highly recommended to set this to `true` in order to prevent griefing on servers doing a `for the worthy` play-through, since the prime bombs on this seed can destroy most tiles and bypass region protection. (@moisterrific) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From b5c1640058988d2da036da291c248b5365e1c351 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 20:08:51 -0400 Subject: [PATCH 14/33] Refactor: use more human-readable ProjectileID --- TShockAPI/TShock.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 92c8c8af..78c13a8d 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1618,13 +1618,13 @@ namespace TShockAPI private void OnProjectileSetDefaults(SetDefaultsEventArgs e) { //tombstone fix. - if (e.Info == 43 || (e.Info >= 201 && e.Info <= 205) || (e.Info >= 527 && e.Info <= 531)) + if (e.Info == ProjectileID.Tombstone || (e.Info >= ProjectileID.GraveMarker && e.Info <= ProjectileID.Obelisk) || (e.Info >= ProjectileID.RichGravestone1 && e.Info <= ProjectileID.RichGravestone5)) if (Config.Settings.DisableTombstones) e.Object.SetDefaults(0); - if (e.Info == 75) + if (e.Info == ProjectileID.HappyBomb) if (Config.Settings.DisableClownBombs) e.Object.SetDefaults(0); - if (e.Info == 109) + if (e.Info == ProjectileID.SnowBallHostile) if (Config.Settings.DisableSnowBalls) e.Object.SetDefaults(0); if (e.Info == ProjectileID.BombSkeletronPrime) From 5bce3b3492ff60526e3575d96444edeb5e35cbfd Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 20:13:11 -0400 Subject: [PATCH 15/33] Update CHANGELOG.md with suggested change Co-authored-by: Lucas Nicodemus --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff0dc50..e33eaf01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. ## Upcoming changes -* Improved `/login` related error messages and made the `/register` process more friendly for players new to TShock. (@moisterrific) +* Changed `/login` and `/register` provide login help depending on if UUID login is enabled or disabled, and whether or not a player can login via any username or not. (@moisterrific) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From bf5ba6e0f8e5e3a5c3ec488d84ed2cd581c44924 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 20:19:12 -0400 Subject: [PATCH 16/33] Add Lunatic Cultist summon permission check to Upcoming changes --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01cc4b86..2ac697e2 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) +* 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) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) @@ -32,7 +33,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Correct rejection message in LandGolfBallInCupHandler to output the proper expected player id. (@drunderscore) * Clarified the error mesage that the console is presented if a rate-limit is reached over REST to indicate that "tokens" actually refers to rate-limit tokens, and not auth tokens, and added a hint as to what config setting determines this. (@hakusaro, @patsore) * Fixed an issue where, when the console was redirected, input was disabled and commands didn't work, in TSAPI. You can now pass `-disable-commands` to disable the input thread, but by default, it will be enabled. Fixes [#1450](https://github.com/Pryaxis/TShock/issues/1450). (@DeathCradle, @QuiCM) -* Added `summonboss` permission check for Empress of Light and Lunatic Cultist. Players who do not have this permission will be unable to kill Prismatic Lacewings, Cultist Devotees, and Cultist Archers. Also added support for the `AnonymousBossInvasions` config option for summoning Empress of Light, if this is set to `false` it will now broadcast the name of the player who summoned her. (@moisterrific) +* Added `summonboss` permission check for Empress of Light. Players who do not have this permission will be unable to kill Prismatic Lacewings. Also added support for the `AnonymousBossInvasions` config option, if this is set to `false` it will now broadcast the name of the player who summoned her. (@moisterrific) * Added `ForceTime` config setting check for Enchanted Sundial usage. If `ForceTime` is set to anything other than `normal`, Sundial use will be rejected as this would lead to very janky game behavior. Additionally, players with `cfgreload` permission will be advised to change it back to `normal` in order to use sundial. (@moisterrific, @bartico6) * Added `%onlineplayers%` and `%serverslots%` placeholders for MOTD. The default MOTD message was also updated to use this. (@moisterrific, @bartico6) * Fixed Bouncer inconsistently using `TilePlacementValid` when validating tile coordinates, which could cause a DoS attack due to unexpectedly large world framing. The list below shows the corrected methods within Bouncer. This was assigned [GHSA-jq4j-v8pr-jv7j](https://github.com/Pryaxis/TShock/security/advisories/GHSA-jq4j-v8pr-jv7j). (@drunderscore) From a40effd55ecd0c53710499dc21eb518111a0fa8a Mon Sep 17 00:00:00 2001 From: James Puleo Date: Tue, 13 Jul 2021 21:49:22 -0400 Subject: [PATCH 17/33] 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"); From 86b5454854f44409cd872be97227ccaee6874290 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 20:37:09 -0400 Subject: [PATCH 18/33] Refactor for readability --- TShockAPI/Commands.cs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 280c1cfb..d2659c97 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -807,17 +807,18 @@ namespace TShockAPI } else { - if (TShock.Config.Settings.DisableUUIDLogin && !TShock.Config.Settings.AllowLoginAnyUsername) - args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); - else if (TShock.Config.Settings.DisableUUIDLogin && TShock.Config.Settings.AllowLoginAnyUsername) + if (TShock.Config.Settings.DisableUUIDLogin) { - args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); - args.Player.SendErrorMessage($" {Specifier}login - Logs in using your username and password"); + if (TShock.Config.Settings.AllowLoginAnyUsername) + { + args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); + args.Player.SendErrorMessage($" {Specifier}login - Logs in using your username and password"); + } + else + args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); } else - { args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your UUID and character name"); - } args.Player.SendErrorMessage("If you forgot your password, there is no way to recover it."); return; } @@ -999,14 +1000,17 @@ namespace TShockAPI { args.Player.SendSuccessMessage("Account \"{0}\" has been registered.", account.Name); args.Player.SendSuccessMessage("Your password is {0}.", echoPassword); - if (TShock.Config.Settings.DisableUUIDLogin && !TShock.Config.Settings.AllowLoginAnyUsername) - args.Player.SendInfoMessage($"Type {Specifier}login {echoPassword} to sign in to your account."); - else if (TShock.Config.Settings.DisableUUIDLogin && TShock.Config.Settings.AllowLoginAnyUsername) - args.Player.SendInfoMessage($"Type {Specifier}login \"{account.Name}\" {echoPassword} to sign in to your account."); - else + + if (TShock.Config.Settings.DisableUUIDLogin) { - args.Player.SendInfoMessage($"Type {Specifier}login to sign in to your account."); + if (TShock.Config.Settings.AllowLoginAnyUsername) + args.Player.SendInfoMessage($"Type {Specifier}login \"{account.Name}\" {echoPassword} to sign in to your account."); + else + args.Player.SendInfoMessage($"Type {Specifier}login {echoPassword} to sign in to your account."); } + else + args.Player.SendSuccessMessage($"Type {Specifier}login to sign in to your account."); + TShock.UserAccounts.AddUserAccount(account); TShock.Log.ConsoleInfo("{0} registered an account: \"{1}\".", args.Player.Name, account.Name); } From fc2330458e81fb871271b47336a3a6eac5471018 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 22:47:28 -0400 Subject: [PATCH 19/33] Change to independent checks and use colour differentiation --- TShockAPI/Commands.cs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 8ebea2b9..178c64b7 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -807,19 +807,15 @@ namespace TShockAPI } else { - if (TShock.Config.Settings.DisableUUIDLogin) - { - if (TShock.Config.Settings.AllowLoginAnyUsername) - { - args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); - args.Player.SendErrorMessage($" {Specifier}login - Logs in using your username and password"); - } - else - args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your password and character name"); - } + if (!TShock.Config.Settings.DisableUUIDLogin) + args.Player.SendMessage($"{Specifier}login - Logs in using your UUID and character name.", Color.White); + + if (TShock.Config.Settings.AllowLoginAnyUsername) + args.Player.SendMessage($"{Specifier}login {"username".Color(Utils.GreenHighlight)} {"password".Color(Utils.BoldHighlight)} - Logs in using your username and password.", Color.White); else - args.Player.SendErrorMessage($"Syntax: {Specifier}login - Logs in using your UUID and character name"); - args.Player.SendErrorMessage("If you forgot your password, there is no way to recover it."); + args.Player.SendMessage($"{Specifier}login {"password".Color(Utils.BoldHighlight)} - Logs in using your password and character name.", Color.White); + + args.Player.SendWarningMessage("If you forgot your password, there is no way to recover it."); return; } try @@ -1001,15 +997,13 @@ namespace TShockAPI args.Player.SendSuccessMessage("Account \"{0}\" has been registered.", account.Name); args.Player.SendSuccessMessage("Your password is {0}.", echoPassword); - if (TShock.Config.Settings.DisableUUIDLogin) - { - if (TShock.Config.Settings.AllowLoginAnyUsername) - args.Player.SendInfoMessage($"Type {Specifier}login \"{account.Name}\" {echoPassword} to sign in to your account."); - else - args.Player.SendInfoMessage($"Type {Specifier}login {echoPassword} to sign in to your account."); - } + if (!TShock.Config.Settings.DisableUUIDLogin) + args.Player.SendMessage($"Type {Specifier}login to sign in to your account.", Color.White); + + if (TShock.Config.Settings.AllowLoginAnyUsername) + args.Player.SendMessage($"Type {Specifier}login \"{account.Name.Color(Utils.GreenHighlight)}\" {echoPassword.Color(Utils.BoldHighlight)} to sign in to your account.", Color.White); else - args.Player.SendSuccessMessage($"Type {Specifier}login to sign in to your account."); + args.Player.SendMessage($"Type {Specifier}login {echoPassword.Color(Utils.BoldHighlight)} to sign in to your account.", Color.White); TShock.UserAccounts.AddUserAccount(account); TShock.Log.ConsoleInfo("{0} registered an account: \"{1}\".", args.Player.Name, account.Name); From ec4b21e78d431c0c13d30691bc7bbd4861420ccb Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 24 Jul 2021 22:51:38 -0400 Subject: [PATCH 20/33] Fix grammar typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c710e6..5d634545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,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) * Fix some typos that have been in the repository for over a lustrum. (@Killia0) -* Changed `/login` and `/register` provide login help depending on if UUID login is enabled or disabled, and whether or not a player can login via any username or not. (@moisterrific) +* Changed `/login` and `/register` to provide login help depending on if UUID login is enabled or disabled, and whether or not a player can login via any username or not. (@moisterrific) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From 838c03ce3f7f676d4ad8c37c95d91d5f11b840fc Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sun, 25 Jul 2021 15:45:43 -0400 Subject: [PATCH 21/33] Make UUID login help more descriptive Co-authored-by: Lucas Nicodemus --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 178c64b7..2633d237 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -998,7 +998,7 @@ namespace TShockAPI args.Player.SendSuccessMessage("Your password is {0}.", echoPassword); if (!TShock.Config.Settings.DisableUUIDLogin) - args.Player.SendMessage($"Type {Specifier}login to sign in to your account.", Color.White); + args.Player.SendMessage($"Type {Specifier}login to sign in to your account using your UUID.", Color.White); if (TShock.Config.Settings.AllowLoginAnyUsername) args.Player.SendMessage($"Type {Specifier}login \"{account.Name.Color(Utils.GreenHighlight)}\" {echoPassword.Color(Utils.BoldHighlight)} to sign in to your account.", Color.White); From 46865d2ad4ba5aa1c7727a34cc75ca632faafece Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sun, 25 Jul 2021 16:10:31 -0400 Subject: [PATCH 22/33] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d634545..54ef2466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,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) * Fix some typos that have been in the repository for over a lustrum. (@Killia0) -* Changed `/login` and `/register` to provide login help depending on if UUID login is enabled or disabled, and whether or not a player can login via any username or not. (@moisterrific) +* Changed `/login` and `/register` to provide login help depending on if UUID login is enabled or disabled, and whether or not a player can login via any username or not. In addition, the message parameters will now be differentiated by colour instead of `<>` (@moisterrific, @hakusaro) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From e1b78fe71f62a0302f75870f2908e1ba9ec527d8 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sun, 25 Jul 2021 22:20:59 -0400 Subject: [PATCH 23/33] Add ban usage examples + minor grammar & visual fixes for ban help Added usage examples for: - banning offline player by account - banning offline player by ip - banning online player by index Added ban help examples after ban help commands and fixed a few minor visual/grammar issues relating to ban help --- TShockAPI/Commands.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index cae1ebf3..88f44a27 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1303,7 +1303,7 @@ namespace TShockAPI args.Player.SendMessage($"ban {"list".Color(Utils.RedHighlight)}", Color.White); args.Player.SendMessage($"ban {"details".Color(Utils.RedHighlight)} ", Color.White); args.Player.SendMessage($"Quick usage: {"ban add".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} \"Griefing\"", Color.White); - args.Player.SendMessage($"For more info, use {"ban help".Color(Utils.BoldHighlight)} {"command".Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage($"For more info, use {"ban help".Color(Utils.BoldHighlight)} {"command".Color(Utils.RedHighlight)} or {"ban help".Color(Utils.BoldHighlight)} {"examples".Color(Utils.RedHighlight)}", Color.White); } void MoreHelp(string cmd) @@ -1327,7 +1327,7 @@ namespace TShockAPI args.Player.SendMessage("", Color.White); args.Player.SendMessage("Ban Del Syntax", Color.White); args.Player.SendMessage($"{"ban del".Color(Utils.BoldHighlight)} <{"Ticket Number".Color(Utils.RedHighlight)}>", Color.White); - args.Player.SendMessage($"- {"Ticket Number".Color(Utils.RedHighlight)}s are provided when you add a ban, and can also be viewed with the {"ban list".Color(Utils.BoldHighlight)} command.", Color.White); + args.Player.SendMessage($"- {"Ticket Numbers".Color(Utils.RedHighlight)} are provided when you add a ban, and can also be viewed with the {"ban list".Color(Utils.BoldHighlight)} command.", Color.White); args.Player.SendMessage($"Example usage: {"ban del".Color(Utils.BoldHighlight)} {"12345".Color(Utils.RedHighlight)}", Color.White); break; @@ -1343,14 +1343,14 @@ namespace TShockAPI args.Player.SendMessage("", Color.White); args.Player.SendMessage("Ban Details Syntax", Color.White); args.Player.SendMessage($"{"ban details".Color(Utils.BoldHighlight)} <{"Ticket Number".Color(Utils.RedHighlight)}>", Color.White); - args.Player.SendMessage($"- {"Ticket Number".Color(Utils.RedHighlight)}s are provided when you add a ban, and can be found with the {"ban list".Color(Utils.BoldHighlight)} command.", Color.White); + args.Player.SendMessage($"- {"Ticket Numbers".Color(Utils.RedHighlight)} are provided when you add a ban, and can be found with the {"ban list".Color(Utils.BoldHighlight)} command.", Color.White); args.Player.SendMessage($"Example usage: {"ban details".Color(Utils.BoldHighlight)} {"12345".Color(Utils.RedHighlight)}", Color.White); break; case "identifiers": if (!PaginationTools.TryParsePageNumber(args.Parameters, 2, args.Player, out int pageNumber)) { - args.Player.SendMessage($"Invalid page number. Page number should be numeric.", Color.White); + args.Player.SendMessage($"Invalid page number. Page number must be numeric.", Color.White); return; } @@ -1368,10 +1368,23 @@ namespace TShockAPI LineTextColor = Color.White }); break; + + case "examples": + args.Player.SendMessage("", Color.White); + args.Player.SendMessage("Ban Usage Examples", Color.White); + args.Player.SendMessage("- Ban an offline player by account name", Color.White); + args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)} {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} (Permanently bans this account name)", Color.White); + args.Player.SendMessage("- Ban an offline player by IP address", Color.White); + args.Player.SendMessage($" {Specifier}{"ai".Color(Utils.BoldHighlight)} \"{args.Player.Account.Color(Utils.RedHighlight)}\" (Find the IP associated with the offline target's account)", Color.White); + args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"ip:".Color(Utils.RedHighlight)}{args.Player.IP.Color(Utils.RedHighlight)} {"\"Griefing\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this IP address)", Color.White); + args.Player.SendMessage($"- Ban an online player by index (Useful for hard to type names)", Color.White); + args.Player.SendMessage($" {Specifier}{"who".Color(Utils.BoldHighlight)} {"-i".Color(Utils.GreenHighlight)} (Find the player index for the target)", Color.White); + args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"tsi:".Color(Utils.RedHighlight)}{args.Player.Index.Color(Utils.RedHighlight)} {"\"Trolling\"".Color(Utils.BoldHighlight)} {"-a -u -ip".Color(Utils.GreenHighlight)} (Permanently bans the online player by Account, UUID, and IP)", Color.White); + // Ban by account ID when? + break; default: - args.Player.SendMessage($"Unknown ban command. Try {"add".Color(Utils.RedHighlight)}, {"del".Color(Utils.RedHighlight)}, {"list".Color(Utils.RedHighlight)}, or {"details".Color(Utils.RedHighlight)}.", Color.White); - break; + args.Player.SendMessage($"Unknown ban command. Try {"ban help".Color(Utils.BoldHighlight)} {"add".Color(Utils.RedHighlight)}, {"del".Color(Utils.RedHighlight)}, {"list".Color(Utils.RedHighlight)}, {"details".Color(Utils.RedHighlight)}, {"identifiers".Color(Utils.RedHighlight)}, or {"examples".Color(Utils.RedHighlight)}.", Color.White); break; } } From da9076058567aef1092bf6e6b834c33841194b21 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sun, 25 Jul 2021 22:32:32 -0400 Subject: [PATCH 24/33] Add ban usage examples to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73eb4121..a49e14ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,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) * Fix some typos that have been in the repository for over a lustrum. (@Killia0) +* 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) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From da8d7d4e7018abb029f2eac683e96d1ec734a135 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Mon, 26 Jul 2021 08:35:30 -0400 Subject: [PATCH 25/33] Add "" for acc:account name https://github.com/Pryaxis/TShock/issues/2382#issuecomment-870062082 --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 88f44a27..af1a0693 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1373,7 +1373,7 @@ namespace TShockAPI args.Player.SendMessage("", Color.White); args.Player.SendMessage("Ban Usage Examples", Color.White); args.Player.SendMessage("- Ban an offline player by account name", Color.White); - args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)} {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} (Permanently bans this account name)", Color.White); + args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} \"{"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)}\" {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} (Permanently bans this account name)", Color.White); args.Player.SendMessage("- Ban an offline player by IP address", Color.White); args.Player.SendMessage($" {Specifier}{"ai".Color(Utils.BoldHighlight)} \"{args.Player.Account.Color(Utils.RedHighlight)}\" (Find the IP associated with the offline target's account)", Color.White); args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"ip:".Color(Utils.RedHighlight)}{args.Player.IP.Color(Utils.RedHighlight)} {"\"Griefing\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this IP address)", Color.White); From 818e9ce24bb55087a6d750340a633a8265e95d22 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 31 Jul 2021 13:59:24 -0400 Subject: [PATCH 26/33] Add new Respawn command --- TShockAPI/Commands.cs | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index cae1ebf3..501efe0f 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -599,6 +599,10 @@ namespace TShockAPI { HelpText = "Sends all tiles from the server to the player to resync the client with the actual world state." }); + add(new Command(Permissions.respawn, Respawn, "respawn") + { + HelpText = "Respawn yourself or another player." + }); #endregion add(new Command(Aliases, "aliases") @@ -5632,6 +5636,57 @@ namespace TShockAPI plr.SendErrorMessage("{0} just killed you!", args.Player.Name); } } + + private static void Respawn(CommandArgs args) + { + TSPlayer playerToRespawn; + if (args.Parameters.Count > 0) + { + if (!args.Player.HasPermission(Permissions.respawnother)) + { + args.Player.SendErrorMessage("You do not have permission to respawn another player."); + return; + } + string plStr = String.Join(" ", args.Parameters); + var players = TSPlayer.FindByNameOrID(plStr); + if (players.Count == 0) + { + args.Player.SendErrorMessage($"Could not find any player named \"{plStr}\""); + return; + } + else if (players.Count > 1) + { + args.Player.SendMultipleMatchError(players.Select(p => p.Name)); + return; + } + else + playerToRespawn = players[0]; + } + else if (!args.Player.RealPlayer) + { + args.Player.SendErrorMessage("You can't respawn the server console!"); + return; + } + else + playerToRespawn = args.Player; + + if (!playerToRespawn.Dead) + { + args.Player.SendErrorMessage($"{(playerToRespawn == args.Player ? "You" : playerToRespawn.Name)} {(playerToRespawn == args.Player ? "are" : "is")} not dead."); + return; + } + else + playerToRespawn.Spawn(PlayerSpawnContext.ReviveFromDeath); + + if (playerToRespawn != args.Player) + { + args.Player.SendSuccessMessage($"You have respawned {playerToRespawn.Name}"); + if (!args.Silent) + playerToRespawn.SendSuccessMessage($"{args.Player.Name} has respawned you."); + } + else + playerToRespawn.SendSuccessMessage("You have respawned yourself."); + } private static void Butcher(CommandArgs args) { From c1f14367e6b882cc282b66c9d1635b97551f941b Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 31 Jul 2021 14:01:17 -0400 Subject: [PATCH 27/33] Add respawn and respawnother permissions --- TShockAPI/Permissions.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 7df1ca83..7de195d2 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -436,6 +436,12 @@ namespace TShockAPI [Description("User can kill others.")] public static readonly string kill = "tshock.kill"; + + [Description("Player can respawn themselves.")] + public static readonly string respawn = "tshock.respawn"; + + [Description("Player can respawn others.")] + public static readonly string respawnother = "tshock.respawn.other"; [Description("Allows you to bypass the max slots for up to 5 slots above your max.")] public static readonly string reservedslot = "tshock.reservedslot"; From f53ba4309390930941df1e8d5b8599860a8e2562 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Sat, 31 Jul 2021 14:05:59 -0400 Subject: [PATCH 28/33] Add respawn command to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73eb4121..031cb686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,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) * Fix some typos that have been in the repository for over a lustrum. (@Killia0) +* Added a new `/respawn` command that lets you respawn yourself or another player. Respawning yourself requires the `tshock.respawn` permission and respawning others requires the `tshock.respawn.other` permission. The full command syntax is `/respawn [player]`. (@moisterrific) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From aa4b735163ebcb15c33937d4931cb343f71b69a9 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Mon, 2 Aug 2021 11:15:21 -0400 Subject: [PATCH 29/33] Refactor for fail fast approach --- TShockAPI/Commands.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index bdce7fb3..f464470f 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5666,6 +5666,11 @@ namespace TShockAPI private static void Respawn(CommandArgs args) { + if (!args.Player.RealPlayer) + { + args.Player.SendErrorMessage("You can't respawn the server console!"); + return; + } TSPlayer playerToRespawn; if (args.Parameters.Count > 0) { @@ -5681,20 +5686,14 @@ namespace TShockAPI args.Player.SendErrorMessage($"Could not find any player named \"{plStr}\""); return; } - else if (players.Count > 1) + if (players.Count > 1) { args.Player.SendMultipleMatchError(players.Select(p => p.Name)); return; } - else - playerToRespawn = players[0]; + playerToRespawn = players[0]; } - else if (!args.Player.RealPlayer) - { - args.Player.SendErrorMessage("You can't respawn the server console!"); - return; - } - else + else playerToRespawn = args.Player; if (!playerToRespawn.Dead) @@ -5702,8 +5701,7 @@ namespace TShockAPI args.Player.SendErrorMessage($"{(playerToRespawn == args.Player ? "You" : playerToRespawn.Name)} {(playerToRespawn == args.Player ? "are" : "is")} not dead."); return; } - else - playerToRespawn.Spawn(PlayerSpawnContext.ReviveFromDeath); + playerToRespawn.Spawn(PlayerSpawnContext.ReviveFromDeath); if (playerToRespawn != args.Player) { From ecec84ef09d0594b3a4bdd82629aac32b0eac24c Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Thu, 5 Aug 2021 14:09:45 -0400 Subject: [PATCH 30/33] Fix typo in ban usage examples --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 3961bf1f..55d281c3 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1396,7 +1396,7 @@ namespace TShockAPI args.Player.SendMessage("", Color.White); args.Player.SendMessage("Ban Usage Examples", Color.White); args.Player.SendMessage("- Ban an offline player by account name", Color.White); - args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} \"{"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)}\" {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} (Permanently bans this account name)", Color.White); + args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} \"{"acc:".Color(Utils.RedHighlight)}{args.Player.Account.Color(Utils.RedHighlight)}\" {"\"Multiple accounts are not allowed\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this account name)", Color.White); args.Player.SendMessage("- Ban an offline player by IP address", Color.White); args.Player.SendMessage($" {Specifier}{"ai".Color(Utils.BoldHighlight)} \"{args.Player.Account.Color(Utils.RedHighlight)}\" (Find the IP associated with the offline target's account)", Color.White); args.Player.SendMessage($" {Specifier}{"ban add".Color(Utils.BoldHighlight)} {"ip:".Color(Utils.RedHighlight)}{args.Player.IP.Color(Utils.RedHighlight)} {"\"Griefing\"".Color(Utils.BoldHighlight)} {"-e".Color(Utils.GreenHighlight)} (Permanently bans this IP address)", Color.White); From ccea7b7d576fac26d7ab878066b34b8ae8e5fa3d Mon Sep 17 00:00:00 2001 From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com> Date: Mon, 9 Aug 2021 01:32:17 +0200 Subject: [PATCH 31/33] Return loopback IP if RealPlayer is false --- TShockAPI/TSPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index afde7cef..ba789eea 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -892,7 +892,7 @@ namespace TShockAPI CacheIP = RealPlayer ? (Netplay.Clients[Index].Socket.IsConnected() ? TShock.Utils.GetRealIP(Netplay.Clients[Index].Socket.GetRemoteAddress().ToString()) : "") - : ""; + : "127.0.0.1"; else return CacheIP; } From 491c3ebb7690b7f013b3be7bf765ae1745c9a604 Mon Sep 17 00:00:00 2001 From: Armano den Boef <68127614+Rozen4334@users.noreply.github.com> Date: Mon, 9 Aug 2021 01:33:11 +0200 Subject: [PATCH 32/33] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9243d03..9e03b4fa 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 * Added a new `DisablePrimeBombs` config option (`false` by default). Highly recommended to set this to `true` in order to prevent griefing on servers doing a `for the worthy` play-through, since the prime bombs on this seed can destroy most tiles and bypass region protection. (@moisterrific) * Added a new `/respawn` command that lets you respawn yourself or another player. Respawning yourself requires the `tshock.respawn` permission and respawning others requires the `tshock.respawn.other` permission. The full command syntax is `/respawn [player]`. (@moisterrific) * Added a notification message and silent command support for permanently changing a target player's user group. Now players who received a group change will be notified of their new group if they are currently online. (@moisterrific, @QuiCM) +* Changed the TSPlayer IP method to return the loopback IP if RealPlayer is false. (@Rozen4334) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From 988c36e3ac3071510c26d889f592dbc93c1cb781 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 17 Aug 2021 13:05:17 -0700 Subject: [PATCH 33/33] Added warning about SSC config wipe in 4.5.3 land --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e03b4fa..62554a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * 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) * Fix oversight & exploit allowing specially crafted SendTileRectangle packets to perform large-scale world griefing. In addition, `NetTile.Slope` is now the native value (byte), and accessor methods `Slope1`, `Slope2`, and `Slope3` can be used to get the old style of values out. `HalfBrick` and `Actuator` were removed from `NetTile` because these were initialized to zero and never changed or used. (@bartico6) +* Warning: a bug introduced in a prior TShock release may cause your SSC config file to be reset after applying this update. Please backup your config file prior to installing TShock 4.5.3+ if you use SSC. (@cardinal-system) ## TShock 4.5.2 * Added preliminary support for Terraria 1.4.2.2. (@hakusaro)