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 1/5] 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 2/5] 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 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 3/5] 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 4/5] 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 5/5] 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)