Remove TShock.CheckProjectilePermission
Add TSPlayer.HasProjectilePermission() and its inverse: TSPlayer.LacksProjectilePermission()
This commit is contained in:
parent
c5f9a51802
commit
ba851d3570
5 changed files with 54 additions and 37 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -789,6 +789,57 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Checks to see if this player object lacks access rights to a given projectile. Used by projectile bans.</summary>
|
||||
/// <param name="index">The projectile index from Main.projectiles (NOT from a packet directly).</param>
|
||||
/// <param name="type">The type of projectile, from Main.projectiles.</param>
|
||||
/// <returns>If the player has lacks access rights to the projectile.</returns>
|
||||
public bool LacksProjectilePermission(int index, int type)
|
||||
{
|
||||
return !HasProjectilePermission(index, type);
|
||||
}
|
||||
|
||||
/// <summary>Checks to see if this player object has access rights to a given projectile. Used by projectile bans.</summary>
|
||||
/// <param name="index">The projectile index from Main.projectiles (NOT from a packet directly).</param>
|
||||
/// <param name="type">The type of projectile, from Main.projectiles.</param>
|
||||
/// <returns>If the player has access rights to the projectile.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the projectile with the given index and owner.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1772,41 +1772,6 @@ namespace TShockAPI
|
|||
Main.StartInvasion(type);
|
||||
}
|
||||
|
||||
/// <summary>CheckProjectilePermission - Checks if a projectile is banned.</summary>
|
||||
/// <param name="player">player - The TSPlayer object that created the projectile.</param>
|
||||
/// <param name="index">index - The projectile index.</param>
|
||||
/// <param name="type">type - The projectile type.</param>
|
||||
/// <returns>bool - True if the player does not have permission to use a projectile.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>CheckRangePermission - Checks if a player has permission to modify a tile dependent on range checks.</summary>
|
||||
/// <param name="player">player - The TSPlayer object.</param>
|
||||
/// <param name="x">x - The x coordinate of the tile.</param>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue