From 196ce87669fe2ce43d8857347cb6427479bbb31e Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 14:24:06 -0400 Subject: [PATCH 01/16] add colours for GetVersion testing something --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 55d281c3..1e2a13b7 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5148,7 +5148,7 @@ namespace TShockAPI private static void GetVersion(CommandArgs args) { - args.Player.SendInfoMessage("TShock: {0} ({1}).", TShock.VersionNum, TShock.VersionCodename); + args.Player.SendMessage($"TShock: {TShock.VersionNum.Color(Utils.BoldHighlight)} {TShock.VersionCodename.Color(Utils.RedHighlight)}.", Color.White); } private static void ListConnectedPlayers(CommandArgs args) From d82a75836fcb714399f82fe6e9f38d637bd611f0 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 15:07:06 -0400 Subject: [PATCH 02/16] add colour for ListConnectedPlayers also various other minor improvements --- TShockAPI/Commands.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 1e2a13b7..93e021ab 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5176,16 +5176,24 @@ namespace TShockAPI } if (invalidUsage) { - args.Player.SendErrorMessage("Invalid usage, proper usage: {0}who [-i] [pagenumber]", Specifier); + args.Player.SendMessage($"List Online Players Syntax", Color.White); + args.Player.SendMessage($"{"playing".Color(Utils.BoldHighlight)} {"[-i]".Color(Utils.RedHighlight)} {"[page]".Color(Utils.GreenHighlight)}", Color.White); + args.Player.SendMessage($"Command aliases: {"playing".Color(Utils.GreenHighlight)}, {"online".Color(Utils.GreenHighlight)}, {"who".Color(Utils.GreenHighlight)}", Color.White); + args.Player.SendMessage($"Example usage: {"who".Color(Utils.BoldHighlight)} {"-i".Color(Utils.RedHighlight)}", Color.White); return; } if (displayIdsRequested && !args.Player.HasPermission(Permissions.seeids)) { - args.Player.SendErrorMessage("You do not have permission to list player ids."); + args.Player.SendErrorMessage("You do not have permission to see player IDs."); return; } - args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots); + if (TShock.Utils.GetActivePlayerCount() == 0) + { + args.Player.SendMessage("There are currently no players online.", Color.White); + return; + } + args.Player.SendMessage($"Online Players ({TShock.Utils.GetActivePlayerCount().Color(Utils.GreenHighlight)}/{TShock.Config.Settings.MaxSlots})", Color.White); var players = new List(); @@ -5194,13 +5202,9 @@ namespace TShockAPI if (ply != null && ply.Active) { if (displayIdsRequested) - { - players.Add(String.Format("{0} (Index: {1}{2})", ply.Name, ply.Index, ply.Account != null ? ", Account ID: " + ply.Account.ID : "")); - } + players.Add($"{ply.Name} (Index: {ply.Index}{(ply.Account != null ? ", Account ID: " + ply.Account.ID : "")})"); else - { players.Add(ply.Name); - } } } @@ -5209,7 +5213,7 @@ namespace TShockAPI new PaginationTools.Settings { IncludeHeader = false, - FooterFormat = string.Format("Type {0}who {1}{{0}} for more.", Specifier, displayIdsRequested ? "-i " : string.Empty) + FooterFormat = $"Type {Specifier}who {(displayIdsRequested ? "-i" : string.Empty)}{Specifier} for more." } ); } From 815fb9f3f8550c2e2d3ad325668248a9b4c3be65 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Fri, 6 Aug 2021 15:11:53 -0400 Subject: [PATCH 03/16] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9243d03..51cdb1b2 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) +* Added colours and usage examples (similiar to how the new ban system looks) for many more commands. (@moisterrific) ## TShock 4.5.5 * Changed the world autosave message so that it no longer warns of a "potential lag spike." (@hakusaro) From cb9740bda6fc4c5ec9411243ac45089eaeccedfe Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 15:34:14 -0400 Subject: [PATCH 04/16] add colours to Mute also added silent support --- TShockAPI/Commands.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 93e021ab..d6f08942 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5307,14 +5307,17 @@ namespace TShockAPI { if (args.Parameters.Count < 1) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}mute [reason]", Specifier); + args.Player.SendMessage("Mute Syntax", Color.White); + args.Player.SendMessage($"{"mute".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> [{"reason".Color(Utils.GreenHighlight)}]", Color.White); + args.Player.SendMessage($"Example usage: {"mute".Color(Utils.BoldHighlight)} \"{args.Player.Name.Color(Utils.RedHighlight)}\" \"{"No swearing on my Christian server".Color(Utils.GreenHighlight)}\"", Color.White); + args.Player.SendMessage($"To mute a player without broadcasting to chat, use the command with {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}", Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) { - args.Player.SendErrorMessage("Invalid player!"); + args.Player.SendErrorMessage($"Could not find any players named \"{args.Parameters[0]}\""); } else if (players.Count > 1) { @@ -5322,13 +5325,16 @@ namespace TShockAPI } else if (players[0].HasPermission(Permissions.mute)) { - args.Player.SendErrorMessage("You cannot mute this player."); + args.Player.SendErrorMessage($"You do not have permission to mute {players[0].Name}"); } else if (players[0].mute) { var plr = players[0]; plr.mute = false; - TSPlayer.All.SendInfoMessage("{0} has been unmuted by {1}.", plr.Name, args.Player.Name); + if (args.Silent) + args.Player.SendSuccessMessage($"You have unmuted {plr.Name}."); + else + TSPlayer.All.SendInfoMessage($"{args.Player.Name} has unmuted {plr.Name}."); } else { @@ -5337,7 +5343,10 @@ namespace TShockAPI reason = String.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); var plr = players[0]; plr.mute = true; - TSPlayer.All.SendInfoMessage("{0} has been muted by {1} for {2}.", plr.Name, args.Player.Name, reason); + if (args.Silent) + args.Player.SendSuccessMessage($"You have muted {plr.Name} for {reason}"); + else + TSPlayer.All.SendInfoMessage($"{args.Player.Name} has muted {plr.Name} for {reason}."); } } From 45e1e4288a8953804bc45d4a1a01a47311726a32 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 16:09:36 -0400 Subject: [PATCH 05/16] add colours to /w, /wallow, and /r and various minor improvements --- TShockAPI/Commands.cs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index d6f08942..79fb37c1 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -582,11 +582,11 @@ namespace TShockAPI { HelpText = "Teleports you to a warp point or manages warps." }); - add(new Command(Permissions.whisper, Whisper, "whisper", "w", "tell") + add(new Command(Permissions.whisper, Whisper, "whisper", "w", "tell", "pm", "dm") { HelpText = "Sends a PM to a player." }); - add(new Command(Permissions.whisper, Wallow, "wallow") + add(new Command(Permissions.whisper, Wallow, "wallow", "wa") { AllowServer = false, HelpText = "Toggles to either ignore or recieve whispers from other players." @@ -5364,13 +5364,15 @@ namespace TShockAPI { if (args.Parameters.Count < 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper usage: /whisper "); + args.Player.SendMessage("Whisper Syntax", Color.White); + args.Player.SendMessage($"{"whisper".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"message".Color(Utils.PinkHighlight)}>", Color.White); + args.Player.SendMessage($"Example usage: {"w".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)} {"We're no strangers to love, you know the rules, and so do I.".Color(Utils.PinkHighlight)}", Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) { - args.Player.SendErrorMessage("Invalid player!"); + args.Player.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); } else if (players.Count > 1) { @@ -5383,14 +5385,19 @@ namespace TShockAPI else { var plr = players[0]; + if (plr == args.Player) + { + args.Player.SendErrorMessage("You cannot whisper to yourself."); + return; + } if (!plr.AcceptingWhispers) { - args.Player.SendErrorMessage("This player is not accepting whispers."); + args.Player.SendErrorMessage($"{plr.Name} is not accepting whispers."); return; } var msg = string.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); - plr.SendMessage(String.Format(" {1}", args.Player.Name, msg), Color.MediumPurple); - args.Player.SendMessage(String.Format(" {1}", plr.Name, msg), Color.MediumPurple); + plr.SendMessage($" {msg}", Color.MediumPurple); + args.Player.SendMessage($" {msg}", Color.MediumPurple); plr.LastWhisper = args.Player; args.Player.LastWhisper = plr; } @@ -5400,7 +5407,7 @@ namespace TShockAPI { args.Player.AcceptingWhispers = !args.Player.AcceptingWhispers; args.Player.SendSuccessMessage($"You {(args.Player.AcceptingWhispers ? "may now" : "will no longer")} receive whispers from other players."); - args.Player.SendSuccessMessage($"You can toggle this with the '{Specifier}wallow' command."); + args.Player.SendMessage($"You can use {Specifier.Color(Utils.GreenHighlight)}{"wa".Color(Utils.GreenHighlight)} to toggle this setting.", Color.White); } private static void Reply(CommandArgs args) @@ -5413,20 +5420,21 @@ namespace TShockAPI { if (!args.Player.LastWhisper.AcceptingWhispers) { - args.Player.SendErrorMessage("This player is not accepting whispers."); + args.Player.SendErrorMessage($"{args.Player.LastWhisper.Name} is not accepting whispers."); return; } var msg = string.Join(" ", args.Parameters); - args.Player.LastWhisper.SendMessage(String.Format(" {1}", args.Player.Name, msg), Color.MediumPurple); - args.Player.SendMessage(String.Format(" {1}", args.Player.LastWhisper.Name, msg), Color.MediumPurple); + args.Player.LastWhisper.SendMessage($" {msg}", Color.MediumPurple); + args.Player.SendMessage($" {msg}", Color.MediumPurple); } else if (args.Player.LastWhisper != null) { - args.Player.SendErrorMessage("The player you're attempting to reply to is no longer online."); + args.Player.SendErrorMessage($"{args.Player.LastWhisper.Name} is offline and cannot receive your reply."); } else { - args.Player.SendErrorMessage("You haven't previously received any whispers. Please use {0}whisper to whisper to other people.", Specifier); + args.Player.SendErrorMessage("You haven't previously received any whispers."); + args.Player.SendMessage($"You can use {Specifier.Color(Utils.GreenHighlight)}{"w".Color(Utils.GreenHighlight)} to whisper to other players.", Color.White); } } From 7e4f05eb9c29f721fc79fd07f52f468d672ff865 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 16:29:20 -0400 Subject: [PATCH 06/16] add colours to annoy and add silent support --- TShockAPI/Commands.cs | 13 +++++++++---- TShockAPI/TSPlayer.cs | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 79fb37c1..a3360c95 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5442,7 +5442,10 @@ namespace TShockAPI { if (args.Parameters.Count != 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}annoy ", Specifier); + args.Player.SendMessage("Annoy Syntax", Color.White); + args.Player.SendMessage($"{"annoy".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"seconds".Color(Utils.PinkHighlight)}>", Color.White); + args.Player.SendMessage($"Example usage: {"annoy".Color(Utils.BoldHighlight)} <{args.Player.Name.Color(Utils.RedHighlight)}> <{"10".Color(Utils.PinkHighlight)}>", Color.White); + args.Player.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to annoy a player silently.", Color.White); return; } int annoy = 5; @@ -5450,14 +5453,16 @@ namespace TShockAPI var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) - args.Player.SendErrorMessage("Invalid player!"); + args.Player.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); else if (players.Count > 1) args.Player.SendMultipleMatchError(players.Select(p => p.Name)); else { var ply = players[0]; - args.Player.SendSuccessMessage("Annoying " + ply.Name + " for " + annoy + " seconds."); - (new Thread(ply.Whoopie)).Start(annoy); + args.Player.SendSuccessMessage($"Annoying {ply.Name} for {annoy} seconds."); + if (!args.Silent) + ply.SendMessage("You are now being annoyed.", Color.LightGoldenrodYellow); + new Thread(ply.Whoopie).Start(annoy); } } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index afde7cef..aadaf746 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1715,7 +1715,6 @@ namespace TShockAPI var time2 = (int)time; var launch = DateTime.UtcNow; var startname = Name; - SendInfoMessage("You are now being annoyed."); while ((DateTime.UtcNow - launch).TotalSeconds < time2 && startname == Name) { SendData(PacketTypes.NpcSpecial, number: Index, number2: 2f); From ca13b5011678ec7ee0f08c9612a1175e2cdb36a4 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 18:02:13 -0400 Subject: [PATCH 07/16] add colour and example for Rocket along with other minor improvements --- TShockAPI/Commands.cs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index a3360c95..fc0d9899 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5470,12 +5470,15 @@ namespace TShockAPI { if (args.Parameters.Count != 1) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}rocket ", Specifier); + args.Player.SendMessage("Rocket Syntax", Color.White); + args.Player.SendMessage($"{"rocket".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}>", Color.White); + args.Player.SendMessage($"Example usage: {"rocket".Color(Utils.BoldHighlight)} {args.Player.Name.Color(Utils.RedHighlight)}", Color.White); + args.Player.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to rocket a player silently.", Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) - args.Player.SendErrorMessage("Invalid player!"); + args.Player.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); else if (players.Count > 1) args.Player.SendMultipleMatchError(players.Select(p => p.Name)); else @@ -5486,11 +5489,24 @@ namespace TShockAPI { ply.TPlayer.velocity.Y = -50; TSPlayer.All.SendData(PacketTypes.PlayerUpdate, "", ply.Index); - args.Player.SendSuccessMessage("Rocketed {0}.", ply.Name); + + if (!args.Silent) + { + TSPlayer.All.SendInfoMessage($"{args.Player.Name} has launched {(ply == args.Player ? (args.Player.TPlayer.Male ? "himself" : "herself") : ply.Name)} into space."); + return; + } + + if (ply == args.Player) + args.Player.SendSuccessMessage("You have launched yourself into space."); + else + args.Player.SendSuccessMessage($"You have launched {ply.Name} into space."); } else { - args.Player.SendErrorMessage("Failed to rocket player: Not logged in or not SSC mode."); + if (!Main.ServerSideCharacter) + args.Player.SendErrorMessage("SSC must be enabled to use this command."); + else + args.Player.SendErrorMessage($"Unable to rocket {ply.Name} because {(ply.TPlayer.Male ? "he" : "she")} is not logged in."); } } } From e88ae85683673a2f298503315ce67d18a9d330bd Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 20:32:14 -0400 Subject: [PATCH 08/16] add colour msg for Rocket and example we do a lil refactoring, also added a cyan pastel coloured hex code and made various other little improvements --- TShockAPI/Commands.cs | 80 +++++++++++++++++++++++++++++++------------ TShockAPI/Utils.cs | 4 +++ 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index fc0d9899..2c895fd1 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5483,62 +5483,98 @@ namespace TShockAPI args.Player.SendMultipleMatchError(players.Select(p => p.Name)); else { - var ply = players[0]; + var target = players[0]; - if (ply.IsLoggedIn && Main.ServerSideCharacter) + if (target.IsLoggedIn && Main.ServerSideCharacter) { - ply.TPlayer.velocity.Y = -50; - TSPlayer.All.SendData(PacketTypes.PlayerUpdate, "", ply.Index); + target.TPlayer.velocity.Y = -50; + TSPlayer.All.SendData(PacketTypes.PlayerUpdate, "", target.Index); if (!args.Silent) { - TSPlayer.All.SendInfoMessage($"{args.Player.Name} has launched {(ply == args.Player ? (args.Player.TPlayer.Male ? "himself" : "herself") : ply.Name)} into space."); + TSPlayer.All.SendInfoMessage($"{args.Player.Name} has launched {(target == args.Player ? (args.Player.TPlayer.Male ? "himself" : "herself") : target.Name)} into space."); return; } - if (ply == args.Player) + if (target == args.Player) args.Player.SendSuccessMessage("You have launched yourself into space."); else - args.Player.SendSuccessMessage($"You have launched {ply.Name} into space."); + args.Player.SendSuccessMessage($"You have launched {target.Name} into space."); } else { if (!Main.ServerSideCharacter) args.Player.SendErrorMessage("SSC must be enabled to use this command."); else - args.Player.SendErrorMessage($"Unable to rocket {ply.Name} because {(ply.TPlayer.Male ? "he" : "she")} is not logged in."); + args.Player.SendErrorMessage($"Unable to rocket {target.Name} because {(target.TPlayer.Male ? "he" : "she")} is not logged in."); } } } private static void FireWork(CommandArgs args) { + var user = args.Player; if (args.Parameters.Count < 1) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}firework [red|green|blue|yellow]", Specifier); + // firework [R|G|B|Y] + user.SendMessage("Firework Syntax", Color.White); + user.SendMessage($"{"firework".Color(Utils.CyanHighlight)} <{"player".Color(Utils.PinkHighlight)}> [{"R".Color(Utils.RedHighlight)}|{"G".Color(Utils.GreenHighlight)}|{"B".Color(Utils.BoldHighlight)}|{"Y".Color(Utils.YellowHighlight)}]", Color.White); + user.SendMessage($"Example usage: {"firework".Color(Utils.CyanHighlight)} {user.Name.Color(Utils.PinkHighlight)} {"R".Color(Utils.RedHighlight)}", Color.White); + user.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to launch a firework silently.", Color.White); return; } var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) - args.Player.SendErrorMessage("Invalid player!"); + user.SendErrorMessage($"Could not find any player named \"{args.Parameters[0]}\""); else if (players.Count > 1) - args.Player.SendMultipleMatchError(players.Select(p => p.Name)); + user.SendMultipleMatchError(players.Select(p => p.Name)); else { - int type = 167; - if (args.Parameters.Count > 1) + int type = 0; + switch (args.Parameters[1].ToLower()) { - if (args.Parameters[1].ToLower() == "green") - type = 168; - else if (args.Parameters[1].ToLower() == "blue") - type = 169; - else if (args.Parameters[1].ToLower() == "yellow") - type = 170; + case "red": + case "r": + type = ProjectileID.RocketFireworkRed; + break; + case "green": + case "g": + type = ProjectileID.RocketFireworkGreen; + break; + case "blue": + case "b": + type = ProjectileID.RocketFireworkBlue; + break; + case "yellow": + case "y": + type = ProjectileID.RocketFireworkYellow; + break; + case "r2": + case "star": + type = ProjectileID.RocketFireworksBoxRed; + break; + case "g2": + case "spiral": + type = ProjectileID.RocketFireworksBoxGreen; + break; + case "b2": + case "rings": + type = ProjectileID.RocketFireworksBoxBlue; + break; + case "y2": + case "flower": + type = ProjectileID.RocketFireworksBoxYellow; + break; + default: + type = ProjectileID.RocketFireworkRed; + break; } - var ply = players[0]; - int p = Projectile.NewProjectile(Projectile.GetNoneSource(), ply.TPlayer.position.X, ply.TPlayer.position.Y - 64f, 0f, -8f, type, 0, (float)0); + var target = players[0]; + int p = Projectile.NewProjectile(Projectile.GetNoneSource(), target.TPlayer.position.X, target.TPlayer.position.Y - 64f, 0f, -8f, type, 0, 0); Main.projectile[p].Kill(); - args.Player.SendSuccessMessage("Launched Firework on {0}.", ply.Name); + args.Player.SendSuccessMessage($"You launched fireworks on {(target == user ? "yourself" : target.Name)}."); + if (!args.Silent && target != user) + target.SendSuccessMessage($"{user.Name} launched fireworks on you."); } } diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 92d45299..42f8ea96 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -62,6 +62,10 @@ namespace TShockAPI /// Hex code for a white highlight /// public const string WhiteHighlight = "FFFFFF"; + /// + /// Hex code for a cyan pastel color + /// + public const string CyanHighlight = "AAFFFF"; /// /// The lowest id for a prefix. From ded2e8544bb0c361cae2acf6435ec0e256f734cf Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 21:11:00 -0400 Subject: [PATCH 09/16] add examples for Clear + minor refactor --- TShockAPI/Commands.cs | 51 +++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2c895fd1..c4245fd0 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5636,18 +5636,25 @@ namespace TShockAPI private static void Clear(CommandArgs args) { + var user = args.Player; + var everyone = TSPlayer.All; + int radius = 50; + if (args.Parameters.Count != 1 && args.Parameters.Count != 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}clear [radius]", Specifier); + user.SendMessage("Clear Syntax", Color.White); + user.SendMessage($"{"clear".Color(Utils.BoldHighlight)} <{"item".Color(Utils.GreenHighlight)}|{"npc".Color(Utils.RedHighlight)}|{"projectile".Color(Utils.YellowHighlight)}> [{"radius".Color(Utils.PinkHighlight)}]", Color.White); + user.SendMessage($"Example usage: {"clear".Color(Utils.BoldHighlight)} {"i".Color(Utils.RedHighlight)} {"10000".Color(Utils.GreenHighlight)}", Color.White); user.SendMessage($"Example usage: {"clear".Color(Utils.BoldHighlight)} {"item".Color(Utils.RedHighlight)} {"10000".Color(Utils.GreenHighlight)}", Color.White); + user.SendMessage($"If you do not specify a radius, it will use a default radius of {radius} around your character.", Color.White); + user.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to execute this command silently.", Color.White); return; } - int radius = 50; if (args.Parameters.Count == 2) { if (!int.TryParse(args.Parameters[1], out radius) || radius <= 0) { - args.Player.SendErrorMessage("Invalid radius."); + user.SendErrorMessage($"\"{args.Parameters[1]}\" is not a valid radius."); return; } } @@ -5656,66 +5663,78 @@ namespace TShockAPI { case "item": case "items": + case "i": { int cleared = 0; for (int i = 0; i < Main.maxItems; i++) { - float dX = Main.item[i].position.X - args.Player.X; - float dY = Main.item[i].position.Y - args.Player.Y; + float dX = Main.item[i].position.X - user.X; + float dY = Main.item[i].position.Y - user.Y; if (Main.item[i].active && dX * dX + dY * dY <= radius * radius * 256f) { Main.item[i].active = false; - TSPlayer.All.SendData(PacketTypes.ItemDrop, "", i); + everyone.SendData(PacketTypes.ItemDrop, "", i); cleared++; } } - args.Player.SendSuccessMessage("Deleted {0} items within a radius of {1}.", cleared, radius); + if (args.Silent) + user.SendSuccessMessage($"You deleted {cleared} item{(cleared > 1 ? "s": "")} within a radius of {radius}."); + else + everyone.SendInfoMessage($"{user.Name} deleted {cleared} item{(cleared > 1 ? "s" : "")} within a radius of {radius}."); } break; case "npc": case "npcs": + case "n": { int cleared = 0; for (int i = 0; i < Main.maxNPCs; i++) { - float dX = Main.npc[i].position.X - args.Player.X; - float dY = Main.npc[i].position.Y - args.Player.Y; + float dX = Main.npc[i].position.X - user.X; + float dY = Main.npc[i].position.Y - user.Y; if (Main.npc[i].active && dX * dX + dY * dY <= radius * radius * 256f) { Main.npc[i].active = false; Main.npc[i].type = 0; - TSPlayer.All.SendData(PacketTypes.NpcUpdate, "", i); + everyone.SendData(PacketTypes.NpcUpdate, "", i); cleared++; } } - args.Player.SendSuccessMessage("Deleted {0} NPCs within a radius of {1}.", cleared, radius); + if (args.Silent) + user.SendSuccessMessage($"You deleted {cleared} NPC{(cleared > 1 ? "s" : "")} within a radius of {radius}."); + else + everyone.SendInfoMessage($"{user.Name} deleted {cleared} NPC{(cleared > 1 ? "s" : "")} within a radius of {radius}."); } break; case "proj": case "projectile": case "projectiles": + case "p": { int cleared = 0; for (int i = 0; i < Main.maxProjectiles; i++) { - float dX = Main.projectile[i].position.X - args.Player.X; - float dY = Main.projectile[i].position.Y - args.Player.Y; + float dX = Main.projectile[i].position.X - user.X; + float dY = Main.projectile[i].position.Y - user.Y; if (Main.projectile[i].active && dX * dX + dY * dY <= radius * radius * 256f) { Main.projectile[i].active = false; Main.projectile[i].type = 0; - TSPlayer.All.SendData(PacketTypes.ProjectileNew, "", i); + everyone.SendData(PacketTypes.ProjectileNew, "", i); cleared++; } } - args.Player.SendSuccessMessage("Deleted {0} projectiles within a radius of {1}.", cleared, radius); + if (args.Silent) + user.SendSuccessMessage($"You deleted {cleared} projectile{(cleared > 1 ? "s" : "")} within a radius of {radius}."); + else + everyone.SendInfoMessage($"{user.Name} deleted {cleared} projectile{(cleared > 1 ? "s" : "")} within a radius of {radius}"); } break; default: - args.Player.SendErrorMessage("Invalid clear option!"); + user.SendErrorMessage($"\"{args.Parameters[0]}\" is not a valid clear option."); break; } } From 57365a05348a38ac3df397f4e5c005b319232a36 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 22:22:18 -0400 Subject: [PATCH 10/16] add colours and examples for /kill also a bit of refactoring and other small improvements --- TShockAPI/Commands.cs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index c4245fd0..3eb31b0c 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5741,28 +5741,36 @@ namespace TShockAPI private static void Kill(CommandArgs args) { + // To-Do: separate kill self and kill other player into two permissions + var user = args.Player; if (args.Parameters.Count < 1) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}kill ", Specifier); + user.SendMessage("Kill syntax and example", Color.White); + user.SendMessage($"{"kill".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}>", Color.White); + user.SendMessage($"Example usage: {"kill".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)}", Color.White); + user.SendMessage($"You can use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)} to execute this command silently.", Color.White); return; } - string plStr = String.Join(" ", args.Parameters); - var players = TSPlayer.FindByNameOrID(plStr); + var players = TSPlayer.FindByNameOrID(String.Join(" ", args.Parameters)); + if (players.Count == 0) - { - args.Player.SendErrorMessage("Invalid player!"); - } + user.SendErrorMessage($"Could not find any player named \"{args.Parameters}\"."); else if (players.Count > 1) - { - args.Player.SendMultipleMatchError(players.Select(p => p.Name)); - } + user.SendMultipleMatchError(players.Select(p => p.Name)); else { - var plr = players[0]; - plr.KillPlayer(); - args.Player.SendSuccessMessage(string.Format("You just killed {0}!", plr.Name)); - plr.SendErrorMessage("{0} just killed you!", args.Player.Name); + var target = players[0]; + + if (target.Dead) + { + user.SendErrorMessage($"{(target == user ? "You" : target.Name)} {(target == user ? "are" : "is")} already dead!"); + return; + } + target.KillPlayer(); + user.SendSuccessMessage($"You just killed {(target == user ? "yourself" : target.Name)}!"); + if (!args.Silent && target != user) + target.SendErrorMessage($"{user.Name} just killed you!"); } } From a92e100836c3cf7a6aa57d9d40c6405b3c531620 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 22:34:13 -0400 Subject: [PATCH 11/16] Fix error msg error in /kill --- TShockAPI/Commands.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 3eb31b0c..ddc1b77a 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5752,10 +5752,11 @@ namespace TShockAPI return; } - var players = TSPlayer.FindByNameOrID(String.Join(" ", args.Parameters)); + string targetName = String.Join(" ", args.Parameters); + var players = TSPlayer.FindByNameOrID(targetName); if (players.Count == 0) - user.SendErrorMessage($"Could not find any player named \"{args.Parameters}\"."); + user.SendErrorMessage($"Could not find any player named \"{targetName}\"."); else if (players.Count > 1) user.SendMultipleMatchError(players.Select(p => p.Name)); else From 4c217bac65c0870183cbaa17704fe0dea55b0954 Mon Sep 17 00:00:00 2001 From: stacey Date: Fri, 6 Aug 2021 22:57:07 -0400 Subject: [PATCH 12/16] add colours + usage example for /butcher also added silent support --- TShockAPI/Commands.cs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ddc1b77a..fc1e4e31 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5826,9 +5826,15 @@ namespace TShockAPI private static void Butcher(CommandArgs args) { + var user = args.Player; if (args.Parameters.Count > 1) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}butcher [mob type]", Specifier); + user.SendMessage("Butcher Syntax and Example", Color.White); + user.SendMessage($"{"butcher".Color(Utils.BoldHighlight)} [{"NPC name".Color(Utils.RedHighlight)}|{"ID".Color(Utils.RedHighlight)}]", Color.White); + user.SendMessage($"Example usage: {"butcher".Color(Utils.BoldHighlight)} {"pigron".Color(Utils.RedHighlight)}", Color.White); + user.SendMessage("All alive NPCs (excluding town NPCs) on the server will be killed if you do not input a name or ID.", Color.White); + user.SendMessage($"To get rid of NPCs without making them drop items, use the {"clear".Color(Utils.BoldHighlight)} command instead.", Color.White); + user.SendMessage($"To execute this command silently, use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}", Color.White); return; } @@ -5839,18 +5845,16 @@ namespace TShockAPI var npcs = TShock.Utils.GetNPCByIdOrName(args.Parameters[0]); if (npcs.Count == 0) { - args.Player.SendErrorMessage("Invalid mob type!"); + user.SendErrorMessage($"\"{args.Parameters[0]}\" is not a valid NPC."); return; } - else if (npcs.Count > 1) + + if (npcs.Count > 1) { - args.Player.SendMultipleMatchError(npcs.Select(n => $"{n.FullName}({n.type})")); + user.SendMultipleMatchError(npcs.Select(n => $"{n.FullName}({n.type})")); return; } - else - { - npcId = npcs[0].netID; - } + npcId = npcs[0].netID; } int kills = 0; @@ -5862,7 +5866,11 @@ namespace TShockAPI kills++; } } - TSPlayer.All.SendInfoMessage("{0} butchered {1} NPCs.", args.Player.Name, kills); + + if (args.Silent) + user.SendSuccessMessage($"You butchered {kills} NPC{(kills > 1 ? "s": "")}."); + else + TSPlayer.All.SendInfoMessage($"{user.Name} butchered {kills} NPC{(kills > 1 ? "s" : "")}."); } private static void Item(CommandArgs args) From 72dab02a615a296377929dded12dd4f26a729e69 Mon Sep 17 00:00:00 2001 From: stacey Date: Sat, 7 Aug 2021 09:50:29 -0400 Subject: [PATCH 13/16] add example for /heal and custom heal amount code is mostly based from /slap, now users will be able to heal a target player by a custom HP amount. I deliberately changed the static 600 HP amount to statLifeMax2 so it would use whatever max HP the target player has, this should make it work better w/ plugins that allow you to set your max HP beyond the base game's 600. --- TShockAPI/Commands.cs | 68 +++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index fc1e4e31..41b69a36 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -6121,45 +6121,51 @@ namespace TShockAPI private static void Heal(CommandArgs args) { - TSPlayer playerToHeal; - if (args.Parameters.Count > 0) + // heal [amount] + // To-Do: break up heal self and heal other into two separate permissions + var user = args.Player; + if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - string plStr = String.Join(" ", args.Parameters); - var players = TSPlayer.FindByNameOrID(plStr); - if (players.Count == 0) - { - args.Player.SendErrorMessage("Invalid player!"); - return; - } - else if (players.Count > 1) - { - args.Player.SendMultipleMatchError(players.Select(p => p.Name)); - return; - } - else - { - playerToHeal = players[0]; - } - } - else if (!args.Player.RealPlayer) - { - args.Player.SendErrorMessage("You can't heal yourself!"); + user.SendMessage("Heal Syntax and Example", Color.White); + user.SendMessage($"{"heal".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> [{"amount".Color(Utils.GreenHighlight)}]", Color.White); + user.SendMessage($"Example usage: {"heal".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)} {"100".Color(Utils.GreenHighlight)}", Color.White); + user.SendMessage($"If no amount is specified, it will default to healing the target player by their max HP.", Color.White); + user.SendMessage($"To execute this command silently, use {SilentSpecifier.Color(Utils.GreenHighlight)} instead of {Specifier.Color(Utils.RedHighlight)}", Color.White); return; } - else + if (args.Parameters[0].Length == 0) { - playerToHeal = args.Player; + user.SendErrorMessage($"You didn't put a player name."); + return; } - playerToHeal.Heal(); - if (playerToHeal == args.Player) - { - args.Player.SendSuccessMessage("You just got healed!"); - } + string targetName = args.Parameters[0]; + var players = TSPlayer.FindByNameOrID(targetName); + if (players.Count == 0) + user.SendErrorMessage($"Unable to find any players named \"{targetName}\""); + else if (players.Count > 1) + user.SendMultipleMatchError(players.Select(p => p.Name)); else { - args.Player.SendSuccessMessage(string.Format("You just healed {0}", playerToHeal.Name)); - playerToHeal.SendSuccessMessage(string.Format("{0} just healed you!", args.Player.Name)); + var target = players[0]; + int amount = target.TPlayer.statLifeMax2; + + if (target.Dead) + { + user.SendErrorMessage("You can't heal a dead player!"); + return; + } + + if (args.Parameters.Count == 2) + { + int.TryParse(args.Parameters[1], out amount); + } + target.Heal(amount); + + if (args.Silent) + user.SendSuccessMessage($"You healed {(target == user ? "yourself" : target.Name)} for {amount} HP."); + else + TSPlayer.All.SendInfoMessage($"{user.Name} healed {(target == user ? (target.TPlayer.Male ? "himself" : "herself") : target.Name)} for {amount} HP."); } } From 6754cd48b4a4006045e38d9fc0ab1ec09cbec288 Mon Sep 17 00:00:00 2001 From: stacey Date: Sat, 7 Aug 2021 10:04:49 -0400 Subject: [PATCH 14/16] add examples for /buff --- TShockAPI/Commands.cs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 41b69a36..92b3abde 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -6171,42 +6171,53 @@ namespace TShockAPI private static void Buff(CommandArgs args) { + // buff [duration] + var user = args.Player; if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff [time in seconds]", Specifier); + user.SendMessage("Buff Syntax and Example", Color.White); + user.SendMessage($"buff [duration]", Color.White); + user.SendMessage($"Example usage: buff [seconds]", Color.White); + user.SendMessage("If you don't specify the duration, it will default to 60 seconds.", Color.White); + user.SendMessage("If you put -1 as the duration, it will use the max possible time of 415 days.", Color.White); return; } + int id = 0; int time = 60; var timeLimit = (int.MaxValue / 60) - 1; + if (!int.TryParse(args.Parameters[0], out id)) { var found = TShock.Utils.GetBuffByName(args.Parameters[0]); + if (found.Count == 0) { - args.Player.SendErrorMessage("Invalid buff name!"); + user.SendErrorMessage($"Unable to find any buffs named \"{args.Parameters[0]}\""); return; } - else if (found.Count > 1) + + if (found.Count > 1) { - args.Player.SendMultipleMatchError(found.Select(f => Lang.GetBuffName(f))); + user.SendMultipleMatchError(found.Select(f => Lang.GetBuffName(f))); return; } id = found[0]; } + if (args.Parameters.Count == 2) int.TryParse(args.Parameters[1], out time); + if (id > 0 && id < Main.maxBuffTypes) { - // Max possible buff duration as of 1.4.2.2 is 35791393 seconds (415 days). + // Max possible buff duration as of Terraria 1.4.2.3 is 35791393 seconds (415 days). if (time < 0 || time > timeLimit) time = timeLimit; - args.Player.SetBuff(id, time * 60); - args.Player.SendSuccessMessage(string.Format("You have buffed yourself with {0} ({1}) for {2} seconds!", - TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time))); + user.SetBuff(id, time * 60); + user.SendSuccessMessage($"You buffed yourself with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds."); } else - args.Player.SendErrorMessage("Invalid buff ID!"); + user.SendErrorMessage($"\"{id}\" is not a valid buff ID!"); } private static void GBuff(CommandArgs args) From de18c5d8dac25beae6a4032a9236df2a767fec42 Mon Sep 17 00:00:00 2001 From: stacey Date: Sat, 7 Aug 2021 10:45:35 -0400 Subject: [PATCH 15/16] forgot to add colours to /buff --- TShockAPI/Commands.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 92b3abde..6f6fae34 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -6171,15 +6171,15 @@ namespace TShockAPI private static void Buff(CommandArgs args) { - // buff [duration] + // buff <"buff name|ID"> [duration] var user = args.Player; if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { user.SendMessage("Buff Syntax and Example", Color.White); - user.SendMessage($"buff [duration]", Color.White); - user.SendMessage($"Example usage: buff [seconds]", Color.White); - user.SendMessage("If you don't specify the duration, it will default to 60 seconds.", Color.White); - user.SendMessage("If you put -1 as the duration, it will use the max possible time of 415 days.", Color.White); + user.SendMessage($"{"buff".Color(Utils.BoldHighlight)} <\"{"buff name".Color(Utils.RedHighlight)}|{"ID".Color(Utils.RedHighlight)}\"> [{"duration".Color(Utils.GreenHighlight)}]", Color.White); + user.SendMessage($"Example usage: {"buff".Color(Utils.BoldHighlight)} \"{"obsidian skin".Color(Utils.RedHighlight)}\" {"-1".Color(Utils.GreenHighlight)}", Color.White); + user.SendMessage($"If you don't specify the duration, it will default to {"60".Color(Utils.GreenHighlight)} seconds.", Color.White); + user.SendMessage($"If you put {"-1".Color(Utils.GreenHighlight)} as the duration, it will use the max possible time of 415 days.", Color.White); return; } From 855bdcb57f78b971ab7923c067a206ec79be2c1f Mon Sep 17 00:00:00 2001 From: stacey Date: Sun, 8 Aug 2021 21:08:49 -0400 Subject: [PATCH 16/16] add color and examples for /gbuff --- TShockAPI/Commands.cs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 6f6fae34..7fd52b01 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -6222,9 +6222,13 @@ namespace TShockAPI private static void GBuff(CommandArgs args) { + var user = args.Player; if (args.Parameters.Count < 2 || args.Parameters.Count > 3) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}gbuff [time in seconds]", Specifier); + user.SendMessage("Give Buff Syntax and Example", Color.White); + user.SendMessage($"{"gbuff".Color(Utils.BoldHighlight)} <{"player".Color(Utils.RedHighlight)}> <{"buff name".Color(Utils.PinkHighlight)}|{"ID".Color(Utils.PinkHighlight)}> [{"seconds".Color(Utils.GreenHighlight)}]", Color.White); + user.SendMessage($"Example usage: {"gbuff".Color(Utils.BoldHighlight)} {user.Name.Color(Utils.RedHighlight)} {"regen".Color(Utils.PinkHighlight)} {"-1".Color(Utils.GreenHighlight)}", Color.White); + user.SendMessage($"To buff a player without them knowing, use {SilentSpecifier.Color(Utils.RedHighlight)} instead of {Specifier.Color(Utils.GreenHighlight)}", Color.White); return; } int id = 0; @@ -6233,12 +6237,12 @@ namespace TShockAPI var foundplr = TSPlayer.FindByNameOrID(args.Parameters[0]); if (foundplr.Count == 0) { - args.Player.SendErrorMessage("Invalid player!"); + user.SendErrorMessage($"Unable to find any player named \"{args.Parameters[0]}\""); return; } else if (foundplr.Count > 1) { - args.Player.SendMultipleMatchError(foundplr.Select(p => p.Name)); + user.SendMultipleMatchError(foundplr.Select(p => p.Name)); return; } else @@ -6248,12 +6252,12 @@ namespace TShockAPI var found = TShock.Utils.GetBuffByName(args.Parameters[1]); if (found.Count == 0) { - args.Player.SendErrorMessage("Invalid buff name!"); + user.SendErrorMessage($"Unable to find any buff named \"{args.Parameters[1]}\""); return; } else if (found.Count > 1) { - args.Player.SendMultipleMatchError(found.Select(b => Lang.GetBuffName(b))); + user.SendMultipleMatchError(found.Select(b => Lang.GetBuffName(b))); return; } id = found[0]; @@ -6262,18 +6266,16 @@ namespace TShockAPI int.TryParse(args.Parameters[2], out time); if (id > 0 && id < Main.maxBuffTypes) { + var target = foundplr[0]; if (time < 0 || time > timeLimit) time = timeLimit; - foundplr[0].SetBuff(id, time * 60); - args.Player.SendSuccessMessage(string.Format("You have buffed {0} with {1} ({2}) for {3} seconds!", - foundplr[0].Name, TShock.Utils.GetBuffName(id), - TShock.Utils.GetBuffDescription(id), (time))); - foundplr[0].SendSuccessMessage(string.Format("{0} has buffed you with {1} ({2}) for {3} seconds!", - args.Player.Name, TShock.Utils.GetBuffName(id), - TShock.Utils.GetBuffDescription(id), (time))); + target.SetBuff(id, time * 60); + user.SendSuccessMessage($"You have buffed {(target == user ? "yourself" : target.Name)} with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!"); + if (!args.Silent && target != user) + target.SendSuccessMessage($"{user.Name} has buffed you with {TShock.Utils.GetBuffName(id)} ({TShock.Utils.GetBuffDescription(id)}) for {time} seconds!"); } else - args.Player.SendErrorMessage("Invalid buff ID!"); + user.SendErrorMessage("Invalid buff ID!"); } }