From 709997b72830487c32566a84d6b38b9bff9630c4 Mon Sep 17 00:00:00 2001 From: Nova4334 <68127614+Nova4334@users.noreply.github.com> Date: Sun, 21 Mar 2021 01:59:44 +0100 Subject: [PATCH 01/24] Rewriting /grow; Adding /wallow --- TShockAPI/Commands.cs | 359 ++++++++++++++++++++++++++++++++++++--- TShockAPI/Permissions.cs | 3 + 2 files changed, 336 insertions(+), 26 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 8d1217cf..6e8b1b95 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -585,6 +585,11 @@ namespace TShockAPI { HelpText = "Sends a PM to a player." }); + add(new Command(Permissions.whisper, Wallow, "wallow") + { + AllowServer = false, + HelpText = "Toggles to either ignore or recieve whispers from other players." + }); add(new Command(Permissions.createdumps, CreateDumps, "dump-reference-data") { HelpText = "Creates a reference tables for Terraria data types and the TShock permission system in the server folder." @@ -5283,14 +5288,15 @@ namespace TShockAPI args.Player.SendFileTextAsMessage(FileTools.RulesPath); } - private static void Whisper(CommandArgs args) + public static bool[] WDisabled { get; set; } = new bool[256]; + + public static void Whisper(CommandArgs args) { if (args.Parameters.Count < 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}whisper ", Specifier); + args.Player.SendErrorMessage("Invalid syntax! Proper usage: /whisper "); return; } - var players = TSPlayer.FindByNameOrID(args.Parameters[0]); if (players.Count == 0) { @@ -5308,6 +5314,11 @@ namespace TShockAPI { var plr = players[0]; var msg = string.Join(" ", args.Parameters.ToArray(), 1, args.Parameters.Count - 1); + if (WDisabled[players[0].Index]) + { + args.Player.SendErrorMessage("This player has disabled people from sending whispers!"); + return; + } plr.SendMessage(String.Format(" {1}", args.Player.Name, msg), Color.MediumPurple); args.Player.SendMessage(String.Format(" {1}", plr.Name, msg), Color.MediumPurple); plr.LastWhisper = args.Player; @@ -5315,6 +5326,19 @@ namespace TShockAPI } } + public static void Wallow(CommandArgs args) + { + int index = args.Player.Index; + if (WDisabled[index]) + { + args.Player.SendSuccessMessage("You will now recieve whispers from other players!"); + WDisabled[index] = !WDisabled[index]; + return; + } + WDisabled[index] = !WDisabled[index]; + args.Player.SendSuccessMessage("You will now not recieve whispers from other players, type '/wallow' to recieve them again!"); + } + private static void Reply(CommandArgs args) { if (args.Player.mute) @@ -6010,13 +6034,11 @@ namespace TShockAPI } } - private static void Grow(CommandArgs args) + public static void Grow(CommandArgs args) { - if (args.Parameters.Count != 1) - { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}grow ", Specifier); - return; - } + bool growevilAmb = args.Player.HasPermission(Permissions.growevil); + string subcmd = args.Parameters.Count == 0 ? "help" : args.Parameters[0].ToLower(); + var name = "Fail"; var x = args.Player.TileX; var y = args.Player.TileY + 3; @@ -6027,10 +6049,37 @@ namespace TShockAPI return; } - switch (args.Parameters[0].ToLower()) + switch (subcmd) { - case "tree": - for (int i = x - 1; i < x + 2; i++) + case "help": + { + if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out int pageNumber)) + return; + + var lines = new List + { + "- Default trees :", + " 'basic', 'sakura', 'willow', 'boreal', 'mahogany', 'ebonwood', 'shadewood', 'pearlwood'.", + "- Palm trees :", + " 'palm', 'corruptpalm', 'crimsonpalm', 'hallowpalm'.", + "- Gem trees :", + " 'topaz', 'amethyst', 'sapphire', 'emerald', 'ruby', 'diamond', 'amber'.", + "- Misc :", + " 'cactus', 'herb', 'mushroom'." + }; + + PaginationTools.SendPage(args.Player, pageNumber, lines, + new PaginationTools.Settings + { + HeaderFormat = "Trees types & misc available to use. ({0}/{1}):", + FooterFormat = "Type {0}grow help {{0}} for more sub-commands.".SFormat(Commands.Specifier) + } + ); + } + break; + + case "basic": + for (int i = x - 2; i < x + 3; i++) { Main.tile[i, y].active(true); Main.tile[i, y].type = 2; @@ -6038,37 +6087,279 @@ namespace TShockAPI } Main.tile[x, y - 1].wall = 0; WorldGen.GrowTree(x, y); - name = "Tree"; + name = "Basic Tree"; break; - case "epictree": - for (int i = x - 1; i < x + 2; i++) + + case "boreal": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 147; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowTree(x, y); + name = "Boreal Tree"; + break; + + case "mahogany": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 60; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowTree(x, y); + name = "Rich Mahogany"; + break; + + case "sakura": + for (int i = x - 2; i < x + 3; i++) { Main.tile[i, y].active(true); Main.tile[i, y].type = 2; Main.tile[i, y].wall = 0; } Main.tile[x, y - 1].wall = 0; - Main.tile[x, y - 1].liquid = 0; - Main.tile[x, y - 1].active(true); - WorldGen.GrowEpicTree(x, y); - name = "Epic Tree"; + WorldGen.TryGrowingTreeByType(596, x, y); + name = "Sakura Tree"; break; - case "mushroom": - for (int i = x - 1; i < x + 2; i++) + + case "willow": + for (int i = x - 2; i < x + 3; i++) { Main.tile[i, y].active(true); - Main.tile[i, y].type = 70; + Main.tile[i, y].type = 2; Main.tile[i, y].wall = 0; } Main.tile[x, y - 1].wall = 0; - WorldGen.GrowShroom(x, y); - name = "Mushroom"; + WorldGen.TryGrowingTreeByType(616, x, y); + name = "Willow Tree"; break; + + case "shadewood": + if (growevilAmb) + { + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 199; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowTree(x, y); + name = "Shadewood tree"; + } + else args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + break; + + case "ebonwood": + if (growevilAmb) + { + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 23; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowTree(x, y); + name = "Ebonwood Tree"; + } + else args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + break; + + case "pearlwood": + if (growevilAmb) + { + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 109; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowTree(x, y); + name = "Pearlwood Tree"; + } + else args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + break; + + case "palm": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 53; + Main.tile[i, y].wall = 0; + } + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y + 1].active(true); + Main.tile[i, y + 1].type = 397; + Main.tile[i, y + 1].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowPalmTree(x, y); + name = "Desert Palm"; + break; + + case "hallowpalm": + if (growevilAmb) + { + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 116; + Main.tile[i, y].wall = 0; + } + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y + 1].active(true); + Main.tile[i, y + 1].type = 402; + Main.tile[i, y + 1].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowPalmTree(x, y); + name = "Hallow Palm"; + } + else args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + break; + + case "crimsonpalm": + if (growevilAmb) + { + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 234; + Main.tile[i, y].wall = 0; + } + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y + 1].active(true); + Main.tile[i, y + 1].type = 399; + Main.tile[i, y + 1].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowPalmTree(x, y); + name = "Crimson Palm"; + } + else args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + break; + + case "corruptpalm": + if (growevilAmb) + { + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 112; + Main.tile[i, y].wall = 0; + } + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y + 1].active(true); + Main.tile[i, y + 1].type = 398; + Main.tile[i, y + 1].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowPalmTree(x, y); + name = "Corruption Palm"; + } + else args.Player.SendErrorMessage("You do not have permission to grow this tree type"); + break; + + case "topaz": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(583, x, y); + name = "Topaz Gemtree"; + break; + + case "amethyst": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(584, x, y); + name = "Amethust Gemtree"; + break; + + case "sapphire": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(585, x, y); + name = "Sapphire Gemtree"; + break; + + case "emerald": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(586, x, y); + name = "Emerald Gemtree"; + break; + + case "ruby": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(587, x, y); + name = "Ruby Gemtree"; + break; + + case "diamond": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(588, x, y); + name = "Diamond Gemtree"; + break; + + case "amber": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 1; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.TryGrowingTreeByType(589, x, y); + name = "Amber Gemtree"; + break; + case "cactus": Main.tile[x, y].type = 53; WorldGen.GrowCactus(x, y); name = "Cactus"; break; + case "herb": Main.tile[x, y].active(true); Main.tile[x, y].frameX = 36; @@ -6076,12 +6367,28 @@ namespace TShockAPI WorldGen.GrowAlch(x, y); name = "Herb"; break; + + case "mushroom": + for (int i = x - 2; i < x + 3; i++) + { + Main.tile[i, y].active(true); + Main.tile[i, y].type = 70; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowShroom(x, y); + name = "Glowing Mushroom Tree"; + break; + default: args.Player.SendErrorMessage("Unknown plant!"); return; } - args.Player.SendTileSquare(x, y); - args.Player.SendSuccessMessage("Tried to grow a " + name + "."); + if (args.Parameters.Count == 1) + { + args.Player.SendTileSquare(x - 2, y - 20, 25); + args.Player.SendSuccessMessage("Tried to grow a " + name + "."); + } } private static void ToggleGodMode(CommandArgs args) diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 600974a1..eb6b6925 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -319,6 +319,9 @@ namespace TShockAPI [Description("User can grow plants.")] public static readonly string grow = "tshock.world.grow"; + [Description("User can grow evil biome plants.")] + public static readonly string growevil = "tshock.world.growevil"; + [Description("User can change hardmode state.")] public static readonly string hardmode = "tshock.world.hardmode"; From 0edab1de834faf32a888c9ab6ffac55fa1ef39d1 Mon Sep 17 00:00:00 2001 From: Rozen / Nova <68127614+Nova4334@users.noreply.github.com> Date: Sun, 21 Mar 2021 02:08:53 +0100 Subject: [PATCH 02/24] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f34631c..d1a91f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Patched protocol issue. Thanks to Off (@tlworks) and @bartico6 for contributions, including packet captures, packet analysis, exploit proof-of-concept testing, patch testing, and detailed reproduction steps. (@hakusaro) * Disabled debug by default. (@hakusaro) * Changed "WinVer" field in `/serverinfo` to "Operating System". (@Terrabade) +* Rewritten `/grow`, added every default tree type & changed the default help response. (@Nova4334) + * Added a new permission: `tshock.world.growevil` to prevent players to grow evil biome trees, these trees spawn with evil biome blocks below them. (@Nova4334) +* Introduced `/wallow` to disable or enable recieving whispers from other players. (@Nova4334) ## TShock 4.4.0 (Pre-release 15) * Overhauled Bans system. Bans are now based on 'identifiers'. (@QuiCM) From 2b3b0273e3b7c2b7b99fd7fcdc03f3fe0718b81a Mon Sep 17 00:00:00 2001 From: Rozen / Nova <68127614+Nova4334@users.noreply.github.com> Date: Sun, 21 Mar 2021 02:09:23 +0100 Subject: [PATCH 03/24] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1a91f5b..a46e2ab5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Disabled debug by default. (@hakusaro) * Changed "WinVer" field in `/serverinfo` to "Operating System". (@Terrabade) * Rewritten `/grow`, added every default tree type & changed the default help response. (@Nova4334) - * Added a new permission: `tshock.world.growevil` to prevent players to grow evil biome trees, these trees spawn with evil biome blocks below them. (@Nova4334) + * Added a new permission: `tshock.world.growevil` to prevent players to grow evil biome trees, these trees spawn with evil biome blocks below them. * Introduced `/wallow` to disable or enable recieving whispers from other players. (@Nova4334) ## TShock 4.4.0 (Pre-release 15) From e23509de75dcbad34ed376395a74606651b796eb Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 23 Mar 2021 11:35:26 +1030 Subject: [PATCH 04/24] Removed stoned and frozen from disable --- TShockAPI/TSPlayer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 20977c8e..dc76e94c 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1557,8 +1557,6 @@ namespace TShockAPI public virtual void Disable(string reason = "", DisableFlags flags = DisableFlags.WriteToLog) { LastThreat = DateTime.UtcNow; - SetBuff(BuffID.Frozen, 330, true); - SetBuff(BuffID.Stoned, 330, true); SetBuff(BuffID.Webbed, 330, true); if (ActiveChest != -1) From 36b5d4e9f7decf889eceb89de5a676fc21b1f42b Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 23 Mar 2021 11:37:05 +1030 Subject: [PATCH 05/24] Updated changelog for stoned & webbed --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a46e2ab5..1e95cab2 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 * Rewritten `/grow`, added every default tree type & changed the default help response. (@Nova4334) * Added a new permission: `tshock.world.growevil` to prevent players to grow evil biome trees, these trees spawn with evil biome blocks below them. * Introduced `/wallow` to disable or enable recieving whispers from other players. (@Nova4334) +* Removed stoned & webbed from disabled status (@QuiCM) ## TShock 4.4.0 (Pre-release 15) * Overhauled Bans system. Bans are now based on 'identifiers'. (@QuiCM) From b4789607f60bf20b593ff7efa354f725b3956e78 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 23 Mar 2021 11:44:24 +1030 Subject: [PATCH 06/24] Implement suggestion for fixing forceupdate flag --- CHANGELOG.md | 1 + TShockAPI/TShock.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e95cab2..434c7ab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added a new permission: `tshock.world.growevil` to prevent players to grow evil biome trees, these trees spawn with evil biome blocks below them. * Introduced `/wallow` to disable or enable recieving whispers from other players. (@Nova4334) * Removed stoned & webbed from disabled status (@QuiCM) +* Fix -forceupdate flag not forcing updates (@Quake) ## TShock 4.4.0 (Pre-release 15) * Overhauled Bans system. Bans are now based on 'identifiers'. (@QuiCM) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 5f774f95..48fa7461 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -890,6 +890,13 @@ namespace TShockAPI /// args - EventArgs args private void OnUpdate(EventArgs args) { + // This forces Terraria to actually continue to update + // even if there are no clients connected + if (ServerApi.ForceUpdate) + { + Netplay.HasClients = true; + } + if (Backups.IsBackupTime) Backups.Backup(); //call these every second, not every update From 4159f6c1861311f4e06e13f4594d51df0142ceca Mon Sep 17 00:00:00 2001 From: Stealownz Date: Mon, 5 Apr 2021 09:45:39 +0800 Subject: [PATCH 07/24] Update firework command to include extra parameter in NewProjectile --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 6e8b1b95..cd2e6b2d 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5434,7 +5434,7 @@ namespace TShockAPI type = 170; } var ply = players[0]; - int p = Projectile.NewProjectile(ply.TPlayer.position.X, ply.TPlayer.position.Y - 64f, 0f, -8f, type, 0, (float)0); + int p = Projectile.NewProjectile(Projectile.GetNoneSource(), ply.TPlayer.position.X, ply.TPlayer.position.Y - 64f, 0f, -8f, type, 0, (float)0); Main.projectile[p].Kill(); args.Player.SendSuccessMessage("Launched Firework on {0}.", ply.Name); } From bc32eab4c82a00fe4295f30e20ba7627a343a9d2 Mon Sep 17 00:00:00 2001 From: Stealownz Date: Mon, 5 Apr 2021 10:45:41 +0800 Subject: [PATCH 08/24] Update GetDataHandler.HandleProjectileNew to include HasBannerIdToRespondTo --- TShockAPI/GetDataHandlers.cs | 1 + TShockAPI/Models/Projectiles/NewProjectileData.cs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 55ddaa05..deac632f 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2699,6 +2699,7 @@ namespace TShockAPI float[] ai = new float[Projectile.maxAI]; for (int i = 0; i < Projectile.maxAI; ++i) ai[i] = !bits.AI[i] ? 0.0f : args.Data.ReadSingle(); + ushort bannerId = bits.HasBannerIdToRespondTo ? args.Data.ReadUInt16() : (ushort)0; short dmg = bits.HasDamage ? args.Data.ReadInt16() : (short)0; float knockback = bits.HasKnockback ? args.Data.ReadSingle() : 0.0f; short origDmg = bits.HasOriginalDamage ? args.Data.ReadInt16() : (short)0; diff --git a/TShockAPI/Models/Projectiles/NewProjectileData.cs b/TShockAPI/Models/Projectiles/NewProjectileData.cs index 7caa057e..c76dbc65 100644 --- a/TShockAPI/Models/Projectiles/NewProjectileData.cs +++ b/TShockAPI/Models/Projectiles/NewProjectileData.cs @@ -38,6 +38,12 @@ namespace TShockAPI.Models.Projectiles } } + public bool HasBannerIdToRespondTo + { + get => bitsbyte[3]; + set => bitsbyte[3] = value; + } + /// /// Gets or Sets the Damage flag on the backing field /// From 5e64ecc45c4bfaff7870af97b04b04d086f518df Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 10 Apr 2021 19:54:21 -0700 Subject: [PATCH 09/24] Update submodule for 1.4.2.1 --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 2a0b338a..e0302513 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 2a0b338a3c4fb82e05946082ab31def771b783fb +Subproject commit e0302513009220a8d92ba12c867a401e7731d28a From 07a555eab9f53c6305ccc0ea7415533e15f8314e Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 10 Apr 2021 20:30:40 -0700 Subject: [PATCH 10/24] Update to TShock 4.5.0 --- TShockAPI/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index bf337820..11981016 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ using System.Runtime.InteropServices; // Also, be sure to release on github with the exact assembly version tag as below // so that the update manager works correctly (via the Github releases api and mimic) -[assembly: AssemblyVersion("4.4.0")] -[assembly: AssemblyFileVersion("4.4.0")] +[assembly: AssemblyVersion("4.5.0")] +[assembly: AssemblyFileVersion("4.5.0")] From 67a1a669a4c3a2b0cba984436d2aa16fb5d7ec89 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 10 Apr 2021 20:31:33 -0700 Subject: [PATCH 11/24] Update version codename --- TShockAPI/TShock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 48fa7461..6b0e36ad 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -57,7 +57,7 @@ namespace TShockAPI /// VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info. public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; /// VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions. - public static readonly string VersionCodename = "Now with less velocity, thanks to Off + Quake. Usual thanks to Chris/White <3"; + public static readonly string VersionCodename = "Stealownz + DeathCradle edition"; /// SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins). public static string SavePath = "tshock"; From c8bed97a21b0e5bae546329b1434d91cbd9e7b77 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 10 Apr 2021 20:34:39 -0700 Subject: [PATCH 12/24] Update changelog with latest changes --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 434c7ab1..19b4675b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## Upcoming changes * This could be you! +## TShock 4.5.0 +* Updated OTAPI and TSAPI to Terraria 1.4.2.1. (@Stealownz, @DeathCradle) +* Updated TShock with preliminary protocol support for Terraria 1.4.2.1. (@Stealownz) + ## TShock 4.4.0 (Pre-release 16) * Patched protocol issue. Thanks to Off (@tlworks) and @bartico6 for contributions, including packet captures, packet analysis, exploit proof-of-concept testing, patch testing, and detailed reproduction steps. (@hakusaro) * Disabled debug by default. (@hakusaro) From 78eab01904c00f892fd487730c5bcb1c4129c2ba Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 10 Apr 2021 23:59:47 -0700 Subject: [PATCH 13/24] Fix ban system conversion issue with MySQL DeathCradle spotted a typo in the ban converter and identified that the issue is likely because we used table_name in some, but not all, of the conversion SQL. Co-authored-by: DeathCradle --- CHANGELOG.md | 3 +++ TShockAPI/DB/BanManager.cs | 2 +- TShockAPI/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19b4675b..bf48f1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## Upcoming changes * This could be you! +## TShock 4.5.0.1 +* Fixed typo in conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle) + ## TShock 4.5.0 * Updated OTAPI and TSAPI to Terraria 1.4.2.1. (@Stealownz, @DeathCradle) * Updated TShock with preliminary protocol support for Terraria 1.4.2.1. (@Stealownz) diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs index 0edea2d0..7bbe013d 100644 --- a/TShockAPI/DB/BanManager.cs +++ b/TShockAPI/DB/BanManager.cs @@ -107,7 +107,7 @@ namespace TShockAPI.DB int res; if (database.GetSqlType() == SqlType.Mysql) { - res = database.QueryScalar("SELECT COUNT(name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.Settings.MySqlDbName); + res = database.QueryScalar("SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.Settings.MySqlDbName); } else { diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 11981016..1e1ba3db 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ using System.Runtime.InteropServices; // Also, be sure to release on github with the exact assembly version tag as below // so that the update manager works correctly (via the Github releases api and mimic) -[assembly: AssemblyVersion("4.5.0")] -[assembly: AssemblyFileVersion("4.5.0")] +[assembly: AssemblyVersion("4.5.0.1")] +[assembly: AssemblyFileVersion("4.5.0.1")] From 81b6872d6e2572e5f4343a8dbd2c35ddc3a3030b Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 11 Apr 2021 21:00:28 +1000 Subject: [PATCH 14/24] Fix OTAPI reference This now allows MonoDevelop to compile without receiving error while starting a build: System.IO.FileLoadException: The assembly name is invalid --- TShockAPI/TShockAPI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index cde1f86e..add34f1e 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -70,7 +70,7 @@ ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - + False ..\TerrariaServerAPI\TerrariaServerAPI\bin\$(ConfigurationName)\OTAPI.dll From d0ce5746ea8d2c4d8ef7d5d289aa2ca4acbb12bd Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 11 Apr 2021 21:18:37 +1000 Subject: [PATCH 15/24] Fix mysql & sqlite ban manager migration during init Tested with existing bans in both sqlite & mysql environments. This is in addition to the syntax fix from earlier. --- TShockAPI/DB/BanManager.cs | 75 ++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs index 7bbe013d..5777e84c 100644 --- a/TShockAPI/DB/BanManager.cs +++ b/TShockAPI/DB/BanManager.cs @@ -37,18 +37,7 @@ namespace TShockAPI.DB /// /// Readonly dictionary of Bans, keyed on ban ticket number. /// - public ReadOnlyDictionary Bans - { - get - { - if (_bans == null) - { - _bans = RetrieveAllBans().ToDictionary(b => b.TicketNumber); - } - - return new ReadOnlyDictionary(_bans); - } - } + public ReadOnlyDictionary Bans => new ReadOnlyDictionary(_bans); /// /// Event invoked when a ban is checked for validity @@ -93,12 +82,24 @@ namespace TShockAPI.DB throw new Exception("Could not find a database library (probably Sqlite3.dll)"); } + EnsureBansCollection(); TryConvertBans(); OnBanValidate += BanValidateCheck; OnBanPreAdd += BanAddedCheck; } + /// + /// Ensures the collection is ready to use. + /// + private void EnsureBansCollection() + { + if (_bans == null) + { + _bans = RetrieveAllBans().ToDictionary(b => b.TicketNumber); + } + } + /// /// Converts bans from the old ban system to the new. /// @@ -116,6 +117,7 @@ namespace TShockAPI.DB if (res != 0) { + var bans = new List(); using (var reader = database.QueryReader("SELECT * FROM Bans")) { while (reader.Read()) @@ -140,22 +142,46 @@ namespace TShockAPI.DB if (!string.IsNullOrWhiteSpace(ip)) { - InsertBan($"{Identifier.IP}{ip}", reason, banningUser, start, end); + bans.Add(new BanPreAddEventArgs + { + Identifier = $"{Identifier.IP}{ip}", + Reason = reason, + BanningUser = banningUser, + BanDateTime = start, + ExpirationDateTime = end + }); } if (!string.IsNullOrWhiteSpace(account)) { - InsertBan($"{Identifier.Account}{account}", reason, banningUser, start, end); + bans.Add(new BanPreAddEventArgs + { + Identifier = $"{Identifier.Account}{account}", + Reason = reason, + BanningUser = banningUser, + BanDateTime = start, + ExpirationDateTime = end + }); } if (!string.IsNullOrWhiteSpace(uuid)) { - InsertBan($"{Identifier.UUID}{uuid}", reason, banningUser, start, end); + bans.Add(new BanPreAddEventArgs + { + Identifier = $"{Identifier.UUID}{uuid}", + Reason = reason, + BanningUser = banningUser, + BanDateTime = start, + ExpirationDateTime = end + }); } } } - database.Query("DROP TABLE 'Bans'"); + foreach (var ban in bans) + InsertBan(ban); + + database.Query("DROP TABLE Bans"); } } @@ -232,7 +258,7 @@ namespace TShockAPI.DB args.Message = args.Valid ? null : "a current ban for this identifier already exists."; } } - + /// /// Adds a new ban for the given identifier. Returns a Ban object if the ban was added, else null /// @@ -252,7 +278,16 @@ namespace TShockAPI.DB BanDateTime = fromDate, ExpirationDateTime = toDate }; + return InsertBan(args); + } + /// + /// Adds a new ban for the given data. Returns a Ban object if the ban was added, else null + /// + /// A predefined instance of + /// + public AddBanResult InsertBan(BanPreAddEventArgs args) + { OnBanPreAdd?.Invoke(this, args); if (!args.Valid) @@ -265,21 +300,21 @@ namespace TShockAPI.DB if (database.GetSqlType() == SqlType.Mysql) { - query += "SELECT CAST(LAST_INSERT_ID() as INT);"; + query += "SELECT LAST_INSERT_ID();"; } else { query += "SELECT CAST(last_insert_rowid() as INT);"; } - int ticketId = database.QueryScalar(query, identifier, reason, banningUser, fromDate.Ticks, toDate.Ticks); + int ticketId = database.QueryScalar(query, args.Identifier, args.Reason, args.BanningUser, args.BanDateTime.Ticks, args.ExpirationDateTime.Ticks); if (ticketId == 0) { return new AddBanResult { Message = "Database insert failed." }; } - Ban b = new Ban(ticketId, identifier, reason, banningUser, fromDate, toDate); + Ban b = new Ban(ticketId, args.Identifier, args.Reason, args.BanningUser, args.BanDateTime, args.ExpirationDateTime); _bans.Add(ticketId, b); OnBanPostAdd?.Invoke(this, new BanEventArgs { Ban = b }); From 29e55a866d178cf4903bd14f42d5a03f17bd4662 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 11 Apr 2021 21:18:52 +1000 Subject: [PATCH 16/24] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf48f1aa..9a70062b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * This could be you! ## TShock 4.5.0.1 -* Fixed typo in conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle) +* Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle) ## TShock 4.5.0 * Updated OTAPI and TSAPI to Terraria 1.4.2.1. (@Stealownz, @DeathCradle) From 71e2ae1b316300da144a7cfd6a90bdbfe1bdce7c Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 12 Apr 2021 17:35:46 +1000 Subject: [PATCH 17/24] Corrected UUID InsertBan in TSPlayer Pointed out thanks to this discussion: https://github.com/Pryaxis/TShock/discussions/2268#discussioncomment-598331 --- TShockAPI/TSPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index dc76e94c..4c24468b 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1637,7 +1637,7 @@ namespace TShockAPI if (force) { TShock.Bans.InsertBan($"{Identifier.IP}{IP}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); - TShock.Bans.InsertBan($"{Identifier.IP}{UUID}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); + TShock.Bans.InsertBan($"{Identifier.UUID}{UUID}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); if (Account != null) { TShock.Bans.InsertBan($"{Identifier.Account}{Account.Name}", reason, adminUserName, DateTime.UtcNow, DateTime.MaxValue); From 099256bdba2ffdb6da52d7aa6c256b48de82bfc6 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 12 Apr 2021 11:09:58 -0700 Subject: [PATCH 18/24] Normalize changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a70062b..db4fd0d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * This could be you! ## TShock 4.5.0.1 -* Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle) +* Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle, @ATFGK) +* Fixed wrong identifier used for UUID bans. (@DeathCradle, @ATFGK) +* Fixed conversion from sqlite bans due to locking issue. (@DeathCradle, @Kojirremer) ## TShock 4.5.0 * Updated OTAPI and TSAPI to Terraria 1.4.2.1. (@Stealownz, @DeathCradle) From 32a0e2f1b6474632daaba3ccef757760c6e54576 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 13 Apr 2021 13:06:18 +0930 Subject: [PATCH 19/24] Resolve /v2/players/list generating a stack overflow --- TShockAPI/Rest/Rest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Rest/Rest.cs b/TShockAPI/Rest/Rest.cs index 51d783f5..40a908ef 100644 --- a/TShockAPI/Rest/Rest.cs +++ b/TShockAPI/Rest/Rest.cs @@ -94,17 +94,17 @@ namespace Rests /// /// public IEnumerator GetEnumerator() - { - return GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() { foreach (IParameter param in _collection) { yield return new EscapedParameter(param); } } + + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } } /// From 784a75b7c5e85e2f2945ffa743db16030a18904b Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 13 Apr 2021 13:14:56 +0930 Subject: [PATCH 20/24] Implement handled pattern on the PlayerChat hook --- TShockAPI/Hooks/PlayerHooks.cs | 6 ++++-- TShockAPI/TShock.cs | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 9056fe55..3114020b 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -449,14 +449,16 @@ namespace TShockAPI.Hooks /// The player firing the event. /// The raw chat text sent by the player. /// The chat text after being formatted. - public static void OnPlayerChat(TSPlayer ply, string rawtext, ref string tshockText) + public static bool OnPlayerChat(TSPlayer ply, string rawtext, ref string tshockText) { if (PlayerChat == null) - return; + return false; var args = new PlayerChatEventArgs {Player = ply, RawText = rawtext, TShockFormattedText = tshockText}; PlayerChat(args); tshockText = args.TShockFormattedText; + + return args.Handled; } /// diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 6b0e36ad..52bef011 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1330,9 +1330,17 @@ namespace TShockAPI { text = String.Format(Config.Settings.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, args.Text); - Hooks.PlayerHooks.OnPlayerChat(tsplr, args.Text, ref text); - Utils.Broadcast(text, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B); + + //Invoke the PlayerChat hook. If this hook event is handled then we need to prevent sending the chat message + bool cancelChat = PlayerHooks.OnPlayerChat(tsplr, args.Text, ref text); args.Handled = true; + + if (cancelChat) + { + return; + } + + Utils.Broadcast(text, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B); } else { @@ -1344,7 +1352,13 @@ namespace TShockAPI //Give that poor player their name back :'c ply.name = name; - PlayerHooks.OnPlayerChat(tsplr, args.Text, ref text); + + bool cancelChat = PlayerHooks.OnPlayerChat(tsplr, args.Text, ref text); + if (cancelChat) + { + args.Handled = true; + return; + } //This netpacket is used to send chat text from the server to clients, in this case on behalf of a client Terraria.Net.NetPacket packet = Terraria.GameContent.NetModules.NetTextModule.SerializeServerMessage( From 196a16c3210b817815af25e132b0d7012c4b4b69 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 13 Apr 2021 13:59:56 +0930 Subject: [PATCH 21/24] Changelog update --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db4fd0d1..9dac4b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ 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 -* This could be you! +* Fixed server crash from `/v2/players/list` & other parameterised REST endpoints. (@QuiCM) +* Added handling to the PlayerChat hook event. (@QuiCM - Thanks for the suggestion @Arthri) ## TShock 4.5.0.1 * Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle, @ATFGK) From c72e64fa5ee4ac35e21962d152517b2fe00b01f6 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 13 Apr 2021 15:15:49 +0930 Subject: [PATCH 22/24] Add silent command support to spawnboss --- TShockAPI/Commands.cs | 135 +++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 60 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index cd2e6b2d..20c21f26 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2426,6 +2426,8 @@ namespace TShockAPI return; } + string message = "{0} spawned {1} {2} time(s)"; + string spawnName; NPC npc = new NPC(); switch (args.Parameters[0].ToLower()) { @@ -2438,87 +2440,89 @@ namespace TShockAPI npc.SetDefaults(i); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); } - TSPlayer.All.SendSuccessMessage("{0} has spawned all bosses {1} time(s).", args.Player.Name, amount); - return; + spawnName = "all bosses"; + break; + case "brain": case "brain of cthulhu": case "boc": npc.SetDefaults(266); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Brain of Cthulhu {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Brain of Cthulhu"; + break; + case "destroyer": npc.SetDefaults(134); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Destroyer {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Destroyer"; + break; case "duke": case "duke fishron": case "fishron": npc.SetDefaults(370); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Duke Fishron {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Duke Fishron"; + break; case "eater": case "eater of worlds": case "eow": npc.SetDefaults(13); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Eater of Worlds {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Eater of Worlds"; + break; case "eye": case "eye of cthulhu": case "eoc": npc.SetDefaults(4); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Eye of Cthulhu {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Eye of Cthulhu"; + break; case "golem": npc.SetDefaults(245); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Golem {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Golem"; + break; case "king": case "king slime": case "ks": npc.SetDefaults(50); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned King Slime {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the King Slime"; + break; case "plantera": npc.SetDefaults(262); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Plantera {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Plantera"; + break; case "prime": case "skeletron prime": npc.SetDefaults(127); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Skeletron Prime {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Skeletron Prime"; + break; case "queen bee": case "qb": npc.SetDefaults(222); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Queen Bee {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Queen Bee"; + break; case "skeletron": npc.SetDefaults(35); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Skeletron {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Skeletron"; + break; case "twins": TSPlayer.Server.SetTime(false, 0.0); npc.SetDefaults(125); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); npc.SetDefaults(126); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Twins {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Twins"; + break; case "wof": case "wall of flesh": if (Main.wofNPCIndex != -1) @@ -2532,103 +2536,114 @@ namespace TShockAPI return; } NPC.SpawnWOF(new Vector2(args.Player.X, args.Player.Y)); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Wall of Flesh.", args.Player.Name); - return; + spawnName = "the Wall of Flesh"; + break; case "moon": case "moon lord": case "ml": npc.SetDefaults(398); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Moon Lord {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Moon Lord"; + break; case "empress": case "empress of light": case "eol": npc.SetDefaults(636); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Empress of Light {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Empress of Light"; + break; case "queen slime": case "qs": npc.SetDefaults(657); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Queen Slime {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Queen Slime"; + break; case "lunatic": case "lunatic cultist": case "cultist": case "lc": npc.SetDefaults(439); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Lunatic Cultist {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Lunatic Cultist"; + break; case "betsy": npc.SetDefaults(551); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Betsy {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Betsy"; + break; case "flying dutchman": case "flying": case "dutchman": npc.SetDefaults(491); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Flying Dutchman {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Flying Dutchman"; + break; case "mourning wood": npc.SetDefaults(325); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Mourning Wood {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Mourning Wood"; + break; case "pumpking": npc.SetDefaults(327); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Pumpking {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Pumpking"; + break; case "everscream": npc.SetDefaults(344); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Everscream {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Everscream"; + break; case "santa-nk1": case "santa": npc.SetDefaults(346); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned Santa-NK1 {1} time(s).", args.Player.Name, amount); - return; + spawnName = "Santa-NK1"; + break; case "ice queen": npc.SetDefaults(345); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Ice Queen {1} time(s).", args.Player.Name, amount); - return; + spawnName = "the Ice Queen"; + break; case "martian saucer": npc.SetDefaults(392); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Martian Saucer {1} time(s).", args.Player.Name, amount); - return; + spawnName = "a Martian Saucer"; + break; case "solar pillar": npc.SetDefaults(517); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Solar Pillar {1} time(s).", args.Player.Name, amount); - return; + spawnName = "a Solar Pillar"; + break; case "nebula pillar": npc.SetDefaults(507); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Nebula Pillar {1} time(s).", args.Player.Name, amount); - return; + spawnName = "a Nebula Pillar"; + break; case "vortex pillar": npc.SetDefaults(422); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Vortex Pillar {1} time(s).", args.Player.Name, amount); - return; + spawnName = "a Vortex Pillar"; + break; case "stardust pillar": npc.SetDefaults(493); TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY); - TSPlayer.All.SendSuccessMessage("{0} has spawned the Stardust Pillar {1} time(s).", args.Player.Name, amount); - return; + spawnName = "a Stardust Pillar"; + break; default: args.Player.SendErrorMessage("Invalid boss type!"); return; } + + if (args.Silent) + { + //"You spawned time(s)" + args.Player.SendSuccessMessage(message, "You", spawnName, amount); + } + else + { + //" spawned time(s)" + TSPlayer.All.SendSuccessMessage(message, args.Player.Name, spawnName, amount); + } } private static void SpawnMob(CommandArgs args) From 00b4eb677424715976062ebdbef0a3bbdf49a729 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 12 Apr 2021 23:20:10 -0700 Subject: [PATCH 23/24] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dac4b32..826059e3 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 server crash from `/v2/players/list` & other parameterised REST endpoints. (@QuiCM) * Added handling to the PlayerChat hook event. (@QuiCM - Thanks for the suggestion @Arthri) +* Changed the spawnboss command to support silent command specifiers. (@QuiCM, suggested by @nojomyth-dev). ## TShock 4.5.0.1 * Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle, @ATFGK) From 173d6f71f5eac97eebe653f63b588b5d1b5399a0 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 12 Apr 2021 23:21:51 -0700 Subject: [PATCH 24/24] Update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 826059e3..743141af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,9 @@ 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 -* Fixed server crash from `/v2/players/list` & other parameterised REST endpoints. (@QuiCM) +* Fixed server crash from `/v2/players/list` & other parameterised REST endpoints. (@QuiCM, reported by @ATFGK) * Added handling to the PlayerChat hook event. (@QuiCM - Thanks for the suggestion @Arthri) -* Changed the spawnboss command to support silent command specifiers. (@QuiCM, suggested by @nojomyth-dev). +* Changed the spawnboss command to support silent command specifiers. (@QuiCM, suggested by @nojomyth-dev) ## TShock 4.5.0.1 * Fixed conversion from old to new ban system for MySQL hosted ban databases. (@DeathCradle, @ATFGK)