diff --git a/CHANGELOG.md b/CHANGELOG.md
index 92a4b919..80318d35 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
## Upcoming Changes
* API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ)
+* API: Added ItemForceIntoChest hook (@WhiteXZ)
* The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju)
* Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ)
* Fixed clients being able to remove other players' portals (@ProfessorXZ)
@@ -14,6 +15,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Fixed a bug involving Item Frames which allowed players to duplicate items (@ProfessorXZ)
* Fixed an issue allowing clients to teleport NPCs to arbitrary locations (@ProfessorXZ)
* Fixed a bug where players would get teleported to their previous location after dismounting the Unicorn Mount (@ProfessorXZ)
+* Players can no longer quick stack items into region protected chests (@ProfessorXZ)
## TShock 4.3.17
diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs
index 894f4a27..48e17c39 100755
--- a/TShockAPI/DB/RegionManager.cs
+++ b/TShockAPI/DB/RegionManager.cs
@@ -759,7 +759,7 @@ namespace TShockAPI.DB
return false;
}
- return AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
+ return ply.HasPermission(Permissions.editregion) || AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
}
///
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index e90576f5..8f48506c 100755
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -45,7 +45,7 @@ namespace TShockAPI
/// This is the TShock main class. TShock is a plugin on the TerrariaServerAPI, so it extends the base TerrariaPlugin.
/// TShock also complies with the API versioning system, and defines its required API version here.
///
- [ApiVersion(1, 23)]
+ [ApiVersion(1, 24)]
public class TShock : TerrariaPlugin
{
/// VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.
@@ -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,44 @@ namespace TShockAPI
}
}
+ /// OnItemForceIntoChest - Internal hook fired when a player quick stacks items into a chest.
+ /// The object.
+ 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 && !Regions.CanBuild((int)args.Position.X, (int)args.Position.Y, tsplr))
+ {
+ args.Handled = true;
+ return;
+ }
+
+ if (CheckRangePermission(tsplr, (int)args.Position.X, (int)args.Position.Y))
+ {
+ args.Handled = true;
+ return;
+ }
+ }
+ }
+
/// OnXmasCheck - Internal hook fired when the XMasCheck happens.
/// args - The ChristmasCheckEventArgs object.
private void OnXmasCheck(ChristmasCheckEventArgs args)
@@ -1700,8 +1740,7 @@ namespace TShockAPI
return true;
}
- if (!player.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
- Regions.InArea(tileX, tileY))
+ if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{
@@ -1768,8 +1807,7 @@ namespace TShockAPI
return true;
}
- if (!player.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
- Regions.InArea(tileX, tileY))
+ if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{