@@ -490,20 +490,25 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Bu
490490 center = center .getRelative (-direction .getBlockZ (), 0 , direction .getBlockX ());
491491 }
492492
493- // log center
494- InventoryChangeListener .inventoryTransaction (player .getName (), center .getLocation (), null );
495-
496- if (center instanceof Shelf && ((Shelf )center .getBlockData ()).getSideChain () != ChainPart .CENTER ){
497- // if it's not the center it's just a chain of 2,
498- InventoryChangeListener .inventoryTransaction (player .getName (), block .getLocation (), null );
493+ BlockData centerBlockData = center .getBlockData ();
494+ if (centerBlockData instanceof Shelf ){
495+ // log center
496+ InventoryChangeListener .inventoryTransaction (player .getName (), center .getLocation (), null );
497+
498+ if (((Shelf )centerBlockData ).getSideChain () != ChainPart .CENTER ){
499+ // if it's not the center it's just a chain of 2
500+ InventoryChangeListener .inventoryTransaction (player .getName (), block .getLocation (), null );
501+ } else {
502+ Block left = center .getRelative (-direction .getBlockZ (), 0 , direction .getBlockX ());
503+ InventoryChangeListener .inventoryTransaction (player .getName (), left .getLocation (), null );
504+
505+ Block right = center .getRelative (direction .getBlockZ (), 0 , -direction .getBlockX ());
506+ InventoryChangeListener .inventoryTransaction (player .getName (), right .getLocation (), null );
507+ }
499508 } else {
500- Block left = center .getRelative (-direction .getBlockZ (), 0 , direction .getBlockX ());
501- InventoryChangeListener .inventoryTransaction (player .getName (), left .getLocation (), null );
502-
503- Block right = center .getRelative (direction .getBlockZ (), 0 , -direction .getBlockX ());
504- InventoryChangeListener .inventoryTransaction (player .getName (), right .getLocation (), null );
505- }
506-
509+ // fallback if invalid block is found just log clicked shelf
510+ InventoryChangeListener .inventoryTransaction (player .getName (), block .getLocation (), null );
511+ }
507512 }
508513 }
509514 }
0 commit comments