From 6cec7e71cd3b881d78157c4f8d397c730bf4e2b7 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 28 Nov 2021 15:35:50 +0700
Subject: [PATCH] Fixed the ability to spawn Zenith projectile with
non-original items.
---
CHANGELOG.md | 1 +
TShockAPI/Bouncer.cs | 8 +++++++-
TShockAPI/Configuration/TShockConfig.cs | 4 ++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc632514..ad559311 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Changed hook `GetDataHandlers.OnNewProjectile` so that it passes the projectile's AI (by updating `NewProjectileEventArgs` and parsing this during the TShock hook) to support processing projectile AI in bouncer. (@AgaSpace)
* Fixed an issue where certain projectiles could be sent to the server with uncapped size parameters, which resulted in large disruptive client artifacts that could be used to grief players. (@AgaSpace, @Arthri)
* Added the currently running value of `Main.GameMode` to `/worldmode` as "Mode". (@hakusaro)
+* Fixed the ability to spawn Zenith projectile with non-original items. (@AgaSpace)
## TShock 4.5.10
* Changed the server behavior when `SIGINT` is received. When `SIGINT` is trapped, the server will attempt to shut down safely. When it is trapped a second time in a session, it will immediately exit. (`SIGINT` is typically triggered via CTRL + C.) This means that it is possible to corrupt your world if you force shutdown at the wrong time (e.g., while the world is saving), but hopefully you expect this to happen if you hit CTRL + C twice in a session and you read the warning. (@hakusaro, @Onusai)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 7795ed64..bf7881e2 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1096,7 +1096,13 @@ namespace TShockAPI
return;
}
-
+ if (TShock.Config.Settings.DisableAnyZenith && type == ProjectileID.FinalFractal && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
+ {
+ TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified Zenith projectile from {0}.", args.Player.Name);
+ args.Player.RemoveProjectile(ident, owner);
+ args.Handled = true;
+ return;
+ }
if (!args.Player.HasPermission(Permissions.ignoreprojectiledetection))
{
diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs
index eeb658c1..8b1a31ea 100644
--- a/TShockAPI/Configuration/TShockConfig.cs
+++ b/TShockAPI/Configuration/TShockConfig.cs
@@ -456,6 +456,10 @@ namespace TShockAPI.Configuration
/// Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.
[Description("Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.")]
public bool SuppressPermissionFailureNotices = false;
+
+ /// Prohibit the use of Zenith projectile with different objects instead of weapons.
+ [Description("Prohibit the use of Zenith projectile with different objects instead of weapons.")]
+ public bool DisableAnyZenith = true;
#endregion