Add ItemForceIntoChest hook. Fixes #1250
This commit is contained in:
parent
9e71284ff8
commit
e9d504afd4
1 changed files with 41 additions and 0 deletions
|
|
@ -317,6 +317,7 @@ namespace TShockAPI
|
|||
ServerApi.Hooks.WorldChristmasCheck.Register(this, OnXmasCheck);
|
||||
ServerApi.Hooks.WorldHalloweenCheck.Register(this, OnHalloweenCheck);
|
||||
ServerApi.Hooks.NetNameCollision.Register(this, NetHooks_NameCollision);
|
||||
ServerApi.Hooks.ItemForceIntoChest.Register(this, OnItemForceIntoChest);
|
||||
Hooks.PlayerHooks.PlayerPreLogin += OnPlayerPreLogin;
|
||||
Hooks.PlayerHooks.PlayerPostLogin += OnPlayerLogin;
|
||||
Hooks.AccountHooks.AccountDelete += OnAccountDelete;
|
||||
|
|
@ -384,6 +385,7 @@ namespace TShockAPI
|
|||
ServerApi.Hooks.WorldChristmasCheck.Deregister(this, OnXmasCheck);
|
||||
ServerApi.Hooks.WorldHalloweenCheck.Deregister(this, OnHalloweenCheck);
|
||||
ServerApi.Hooks.NetNameCollision.Deregister(this, NetHooks_NameCollision);
|
||||
ServerApi.Hooks.ItemForceIntoChest.Deregister(this, OnItemForceIntoChest);
|
||||
TShockAPI.Hooks.PlayerHooks.PlayerPostLogin -= OnPlayerLogin;
|
||||
|
||||
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
|
||||
|
|
@ -471,6 +473,45 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>OnItemForceIntoChest - Internal hook fired when a player quick stacks items into a chest.</summary>
|
||||
/// <param name="args">The <see cref="ForceItemIntoChestEventArgs"/> object.</param>
|
||||
private void OnItemForceIntoChest(ForceItemIntoChestEventArgs args)
|
||||
{
|
||||
if (args.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Player == null)
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
TSPlayer tsplr = Players[args.Player.whoAmI];
|
||||
if (tsplr == null)
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Chest != null)
|
||||
{
|
||||
if (Config.RegionProtectChests && !tsplr.HasPermission(Permissions.editregion)
|
||||
&& !Regions.CanBuild((int)args.Position.X, (int)args.Position.Y, tsplr) && Regions.InArea((int)args.Position.X, (int)args.Position.Y))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (CheckRangePermission(tsplr, (int)args.Position.X, (int)args.Position.Y))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>OnXmasCheck - Internal hook fired when the XMasCheck happens.</summary>
|
||||
/// <param name="args">args - The ChristmasCheckEventArgs object.</param>
|
||||
private void OnXmasCheck(ChristmasCheckEventArgs args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue