diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7359fbfb..2327f753 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Added `GetDataHandlers.PlaceObject` hook. (@hakusaro)
* `GetDataHandlers.KillMe` now sends a `TSPlayer` and a `PlayerDeathReason`. (@hakusaro)
* Added `GetDataHandlers.ProjectileKill` hook. (@hakusaro)
+* Removed `TShock.CheckProjectilePermission` and replaced it with `TSPlayer.HasProjectilePermission` and `TSPlayer.LacksProjectilePermission` respectively. (@hakusaro)
## TShock 4.3.24
* Updated OpenTerraria API to 1.3.5.3 (@DeathCradle)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 87ea3c72..dd1257db 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -261,7 +261,7 @@ namespace TShockAPI
return;
}
- bool hasPermission = !TShock.CheckProjectilePermission(args.Player, index, type);
+ bool hasPermission = args.Player.HasProjectilePermission(index, type);
if (!TShock.Config.IgnoreProjUpdate && !hasPermission && !args.Player.HasPermission(Permissions.ignoreprojectiledetection))
{
if (type == ProjectileID.BlowupSmokeMoonlord
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index 3eb03926..2545a2f0 100644
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -2260,7 +2260,7 @@ namespace TShockAPI
var type = Main.projectile[index].type;
// TODO: This needs to be moved somewhere else.
- if (TShock.CheckProjectilePermission(args.Player, index, type) && type != 102 && type != 100 && !TShock.Config.IgnoreProjKill)
+ if (args.Player.LacksProjectilePermission(index, type) && type != 102 && type != 100 && !TShock.Config.IgnoreProjKill)
{
args.Player.Disable("Does not have projectile permission to kill projectile.", DisableFlags.WriteToLogAndConsole);
args.Player.RemoveProjectile(ident, owner);
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index 78d3ef74..73a2bce0 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -789,6 +789,57 @@ namespace TShockAPI
}
}
+ /// Checks to see if this player object lacks access rights to a given projectile. Used by projectile bans.
+ /// The projectile index from Main.projectiles (NOT from a packet directly).
+ /// The type of projectile, from Main.projectiles.
+ /// If the player has lacks access rights to the projectile.
+ public bool LacksProjectilePermission(int index, int type)
+ {
+ return !HasProjectilePermission(index, type);
+ }
+
+ /// Checks to see if this player object has access rights to a given projectile. Used by projectile bans.
+ /// The projectile index from Main.projectiles (NOT from a packet directly).
+ /// The type of projectile, from Main.projectiles.
+ /// If the player has access rights to the projectile.
+ public bool HasProjectilePermission(int index, int type)
+ {
+ // Players never have the rights to tombstones.
+ if (type == ProjectileID.Tombstone)
+ {
+ return false;
+ }
+
+ // Dirt balls are the projectiles from dirt rods.
+ // If the dirt rod item is banned, they probably shouldn't have this projectile.
+ if (type == ProjectileID.DirtBall && TShock.Itembans.ItemIsBanned("Dirt Rod", this))
+ {
+ return false;
+ }
+
+ // If the sandgun is banned, block sand bullets.
+ if (TShock.Itembans.ItemIsBanned("Sandgun", this))
+ {
+ if (type == ProjectileID.SandBallGun
+ || type == ProjectileID.EbonsandBallGun
+ || type == ProjectileID.PearlSandBallGun)
+ {
+ return false;
+ }
+ }
+
+ // If the projectile is hostile, block it?
+ Projectile tempProjectile = new Projectile();
+ tempProjectile.SetDefaults(type);
+
+ if (Main.projHostile[type])
+ {
+ return false;
+ }
+
+ return true;
+ }
+
///
/// Removes the projectile with the given index and owner.
///
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 40003217..a4245e09 100644
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -1772,41 +1772,6 @@ namespace TShockAPI
Main.StartInvasion(type);
}
- /// CheckProjectilePermission - Checks if a projectile is banned.
- /// player - The TSPlayer object that created the projectile.
- /// index - The projectile index.
- /// type - The projectile type.
- /// bool - True if the player does not have permission to use a projectile.
- public static bool CheckProjectilePermission(TSPlayer player, int index, int type)
- {
- if (type == 43)
- {
- return true;
- }
-
- if (type == 17 && Itembans.ItemIsBanned("Dirt Rod", player))
- //Dirt Rod Projectile
- {
- return true;
- }
-
- if ((type == 42 || type == 65 || type == 68) && Itembans.ItemIsBanned("Sandgun", player)) //Sandgun Projectiles
- {
- return true;
- }
-
- Projectile proj = new Projectile();
- proj.SetDefaults(type);
-
- if (Main.projHostile[type])
- {
- //player.SendMessage( proj.name, Color.Yellow);
- return true;
- }
-
- return false;
- }
-
/// CheckRangePermission - Checks if a player has permission to modify a tile dependent on range checks.
/// player - The TSPlayer object.
/// x - The x coordinate of the tile.