@@ -137,6 +137,7 @@ internal Bouncer()
137137 GetDataHandlers . KillMe += OnKillMe ;
138138 GetDataHandlers . FishOutNPC += OnFishOutNPC ;
139139 GetDataHandlers . FoodPlatterTryPlacing += OnFoodPlatterTryPlacing ;
140+ GetDataHandlers . ForceItemIntoNearestChest += OnForceItemIntoNearestChest ;
140141
141142
142143 // The following section is based off Player.PlaceThing_Tiles_PlaceIt and Player.PlaceThing_Tiles_PlaceIt_GetLegacyTileStyle.
@@ -2505,7 +2506,7 @@ internal void OnPlaceItemFrame(object sender, GetDataHandlers.PlaceItemFrameEven
25052506 Main . item [ num ] . playerIndexTheItemIsReservedFor = args . Player . Index ;
25062507 NetMessage . SendData ( ( int ) PacketTypes . ItemDrop , args . Player . Index , - 1 , NetworkText . Empty , num , 1f ) ;
25072508 NetMessage . SendData ( ( int ) PacketTypes . ItemOwner , args . Player . Index , - 1 , NetworkText . Empty , num ) ;
2508-
2509+
25092510 TShock . Log . ConsoleDebug ( GetString ( "Bouncer / OnPlaceItemFrame rejected permissions from {0}" , args . Player . Name ) ) ;
25102511 NetMessage . SendData ( ( int ) PacketTypes . UpdateTileEntity , - 1 , - 1 , NetworkText . Empty , args . ItemFrame . ID , 0 , 1 ) ;
25112512 args . Handled = true ;
@@ -2871,6 +2872,44 @@ internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatter
28712872 }
28722873 }
28732874
2875+ /// <summary>
2876+ /// Called when a player is trying to put an item into chest through Quick Stack.
2877+ /// </summary>
2878+ /// <param name="sender"></param>
2879+ /// <param name="args"></param>
2880+ internal void OnForceItemIntoNearestChest ( object sender , ForceItemIntoNearestChestEventArgs args )
2881+ {
2882+ var slot = args . Slot ;
2883+
2884+ var id = Utils . LocateQuickStackChestIndex ( args . Player , slot ) ;
2885+
2886+ if ( id == - 1 )
2887+ return ;
2888+
2889+ if ( args . Player . IsBeingDisabled ( ) )
2890+ {
2891+ TShock . Log . ConsoleDebug ( GetString ( "Bouncer / OnForceItemIntoNearestChest rejected from disable from {0}" , args . Player . Name ) ) ;
2892+ args . Player . SendData ( PacketTypes . PlayerSlot , "" , args . Player . Index , slot , args . Player . TPlayer . inventory [ slot ] . prefix ) ;
2893+ args . Handled = true ;
2894+ return ;
2895+ }
2896+
2897+ if ( ! args . Player . HasBuildPermission ( Main . chest [ id ] . x , Main . chest [ id ] . y ) && TShock . Config . Settings . RegionProtectChests )
2898+ {
2899+ TShock . Log . ConsoleDebug ( GetString ( "Bouncer / OnForceItemIntoNearestChest rejected from region protection? from {0}" , args . Player . Name ) ) ;
2900+ args . Player . SendData ( PacketTypes . PlayerSlot , "" , args . Player . Index , slot , args . Player . TPlayer . inventory [ slot ] . prefix ) ;
2901+ args . Handled = true ;
2902+ return ;
2903+ }
2904+
2905+ if ( ! args . Player . IsInRange ( Main . chest [ id ] . x , Main . chest [ id ] . y ) )
2906+ {
2907+ TShock . Log . ConsoleDebug ( GetString ( "Bouncer / OnForceItemIntoNearestChest rejected from range check from {0}" , args . Player . Name ) ) ;
2908+ args . Handled = true ;
2909+ return ;
2910+ }
2911+ }
2912+
28742913 internal void OnSecondUpdate ( )
28752914 {
28762915 Task . Run ( ( ) =>
0 commit comments