diff --git a/TShockAPI/Hooks/PlayerHooks.cs b/TShockAPI/Hooks/PlayerHooks.cs index 43684387..062a78b8 100644 --- a/TShockAPI/Hooks/PlayerHooks.cs +++ b/TShockAPI/Hooks/PlayerHooks.cs @@ -18,6 +18,7 @@ along with this program. If not, see . using System.Collections.Generic; using System.ComponentModel; +using TShockAPI.DB; namespace TShockAPI.Hooks { @@ -166,6 +167,87 @@ namespace TShockAPI.Hooks } } + /// + /// EventArgs used for the event. + /// + public class PlayerItembanPermissionEventArgs : HandledEventArgs + { + /// + /// The player who fired the event. + /// + public TSPlayer Player { get; set; } + + /// + /// The banned item being checked. + /// + public ItemBan BannedItem { get; set; } + + /// + /// Initializes a new instance of the PlayerItembanPermissionEventArgs class. + /// + /// The player who fired the event. + /// The permission being checked. + public PlayerItembanPermissionEventArgs(TSPlayer player, ItemBan bannedItem) + { + Player = player; + BannedItem = bannedItem; + } + } + + /// + /// EventArgs used for the event. + /// + public class PlayerProjbanPermissionEventArgs : HandledEventArgs + { + /// + /// The player who fired the event. + /// + public TSPlayer Player { get; set; } + + /// + /// The banned projectile being checked. + /// + public ProjectileBan BannedProjectile { get; set; } + + /// + /// Initializes a new instance of the PlayerProjbanPermissionEventArgs class. + /// + /// The player who fired the event. + /// The banned projectile being checked. + public PlayerProjbanPermissionEventArgs(TSPlayer player, ProjectileBan checkedProjectile) + { + Player = player; + BannedProjectile = checkedProjectile; + } + } + + /// + /// EventArgs used for the event. + /// + public class PlayerTilebanPermissionEventArgs : HandledEventArgs + { + /// + /// The player who fired the event. + /// + public TSPlayer Player { get; set; } + + /// + /// The banned tile being checked. + /// + public TileBan BannedTile { get; set; } + + /// + /// Initializes a new instance of the PlayerTilebanPermissionEventArgs class. + /// + /// The player who fired the event. + /// The banned tile being checked. + public PlayerTilebanPermissionEventArgs(TSPlayer player, TileBan checkedTile) + { + Player = player; + BannedTile = checkedTile; + } + } + /// /// A collection of events fired by players that can be hooked to. /// @@ -232,6 +314,37 @@ namespace TShockAPI.Hooks /// public static event PlayerPermissionD PlayerPermission; + /// + /// The delegate of the event. + /// + /// The EventArgs for this event. + public delegate void PlayerItembanPermissionD(PlayerItembanPermissionEventArgs e); + /// + /// Fired by players every time a permission check on banned items involving them occurs. + /// + public static event PlayerItembanPermissionD PlayerItembanPermission; + + /// + /// The delegate of the event. + /// + /// The EventArgs for this event. + public delegate void PlayerProjbanPermissionD(PlayerProjbanPermissionEventArgs e); + /// + /// Fired by players every time a permission check on banned projectiles involving them occurs. + /// + public static event PlayerProjbanPermissionD PlayerProjbanPermission; + + /// + /// The delegate of the event. + /// + /// The EventArgs for this event. + public delegate void PlayerTilebanPermissionD(PlayerTilebanPermissionEventArgs e); + /// + /// Fired by players every time a permission check on banned tiles involving them occurs. + /// + public static event PlayerTilebanPermissionD PlayerTilebanPermission; + + /// /// Fires the event. /// @@ -336,5 +449,50 @@ namespace TShockAPI.Hooks PlayerPermission(args); return args.Handled; } + + /// + /// Fires the event. + /// + /// The player firing the event. + /// True if the event has been handled. + public static bool OnPlayerItembanPermission(TSPlayer player, ItemBan bannedItem) + { + if (PlayerItembanPermission == null) + return false; + + var args = new PlayerItembanPermissionEventArgs(player, bannedItem); + PlayerItembanPermission(args); + return args.Handled; + } + + /// + /// Fires the event. + /// + /// The player firing the event. + /// True if the event has been handled. + public static bool OnPlayerProjbanPermission(TSPlayer player, ProjectileBan bannedProj) + { + if (PlayerProjbanPermission == null) + return false; + + var args = new PlayerProjbanPermissionEventArgs(player, bannedProj); + PlayerProjbanPermission(args); + return args.Handled; + } + + /// + /// Fires the event. + /// + /// The player firing the event. + /// True if the event has been handled. + public static bool OnPlayerTilebanPermission(TSPlayer player, TileBan bannedTile) + { + if (PlayerTilebanPermission == null) + return false; + + var args = new PlayerTilebanPermissionEventArgs(player, bannedTile); + PlayerTilebanPermission(args); + return args.Handled; + } } }