3636import org .bukkit .event .block .BlockPlaceEvent ;
3737import org .bukkit .event .block .SignChangeEvent ;
3838import org .bukkit .event .inventory .InventoryMoveItemEvent ;
39- import org .bukkit .inventory .Inventory ;
4039import org .jetbrains .annotations .NotNull ;
4140import org .jetbrains .annotations .Nullable ;
4241import org .maxgamer .quickshop .Cache ;
@@ -60,6 +59,7 @@ public class BlockListener extends AbstractProtectionListener {
6059
6160 public BlockListener (@ NotNull final QuickShop plugin , @ Nullable final Cache cache ) {
6261 super (plugin , cache );
62+ init ();
6363 }
6464
6565 private void init () {
@@ -169,20 +169,36 @@ private Shop getShopNextTo(@NotNull Location loc) {
169169 @ EventHandler (ignoreCancelled = true , priority = EventPriority .MONITOR )
170170 public void onInventoryMove (InventoryMoveItemEvent event ) {
171171 if (!this .update_sign_when_inventory_moving ) {
172+ Util .debugLog ("Sign update was disabled" );
172173 return ;
173174 }
174175
175- final Inventory inventory = event .getDestination ();
176- final Location location = inventory .getLocation ();
177-
178- if (location == null ) {
179- return ;
176+ Location destination = event .getDestination ().getLocation ();
177+ Location source = event .getSource ().getLocation ();
178+ Shop destShop = null ;
179+ Shop sourceShop = null ;
180+ if (destination != null ) {
181+ destination = Util .getBlockLocation (destination );
182+ Util .debugLog ("Destination found: " + destination );
183+ destShop = getShopPlayer (destination , true );
184+ }
185+ if (source != null ) {
186+ source = Util .getBlockLocation (source );
187+ Util .debugLog ("Source found: " + destination );
188+ sourceShop = getShopPlayer (source , true );
180189 }
181190
182- // Delayed task. Event triggers when item is moved, not when it is received.
183- final Shop shop = getShopRedstone (location , true );
184- if (shop != null ) {
185- super .getPlugin ().getSignUpdateWatcher ().scheduleSignUpdate (shop );
191+ if (destShop != null ) {
192+ Util .debugLog ("Destination shop found: " + destShop );
193+ super .getPlugin ().getSignUpdateWatcher ().scheduleSignUpdate (destShop );
194+ } else {
195+ Util .debugLog ("Destination shop not found." );
196+ }
197+ if (sourceShop != null ) {
198+ Util .debugLog ("Source shop found: " + sourceShop );
199+ super .getPlugin ().getSignUpdateWatcher ().scheduleSignUpdate (sourceShop );
200+ } else {
201+ Util .debugLog ("Source shop not found." );
186202 }
187203 }
188204
0 commit comments