@@ -78,8 +78,8 @@ public void handleCustomDigging(Player player, View view, DiggingAction actionTy
7878 }
7979 }
8080
81- // Block break functionality
82- if (actionType == DiggingAction .FINISHED_DIGGING && blockStages .get (view ).get (position ).getStage () >= 9 ) {
81+ // Block break functionality (CREATIVE)
82+ if (actionType == DiggingAction .FINISHED_DIGGING && blockStages .get (view ).get (position ).getStage () >= 9 && player . getGameMode () == GameMode . CREATIVE ) {
8383 breakCustomBlock (player , position , blockData , view );
8484 }
8585 }
@@ -98,10 +98,10 @@ public void handleNormalDigging(Player player, View view, DiggingAction actionTy
9898 if (actionType == DiggingAction .FINISHED_DIGGING || canInstantBreak (player , blockData )) {
9999 Bukkit .getScheduler ().runTask (Blockify .getInstance (), () -> {
100100 // Call BlockifyBreakEvent
101- BlockifyBreakEvent ghostBreakEvent = new BlockifyBreakEvent (player , position .toPosition (), blockData , view , view .getStage ());
102- ghostBreakEvent .callEvent ();
101+ BlockifyBreakEvent blockifyBreakEvent = new BlockifyBreakEvent (player , position .toPosition (), blockData , view , view .getStage ());
102+ blockifyBreakEvent .callEvent ();
103103 // If block is not cancelled, break the block, otherwise, revert the block
104- if (!ghostBreakEvent .isCancelled ()) {
104+ if (!blockifyBreakEvent .isCancelled ()) {
105105 Blockify .getInstance ().getBlockChangeManager ().sendBlockChange (view .getStage (), view .getStage ().getAudience (), position , Material .AIR .createBlockData ());
106106 view .setBlock (position , Material .AIR .createBlockData ());
107107 } else {
@@ -148,11 +148,13 @@ public void updateBlockStage(Player player, BlockifyPosition position, BlockData
148148 blockStage .setStage ((byte ) (blockStage .getStage () + 1 ));
149149 // Update last updated time to current time
150150 blockStage .setLastUpdated (System .currentTimeMillis ());
151- // If block stage is greater than or equal to 9, break the block
152- if (blockStage .getStage () > = 9 ) {
151+ // If block stage is 9, break the block
152+ if (blockStage .getStage () = = 9 ) {
153153 breakCustomBlock (player , position , blockData , view );
154- player .spawnParticle (Particle .BLOCK_CRACK , position .getX () + 0.5 , position .getY () + 0.5 , position .getZ () + 0.5 , 10 , 0 , 0 , 0 , blockData );
155- player .playSound (player .getLocation (), blockData .getSoundGroup ().getBreakSound (), 1 , 1 );
154+ Bukkit .getScheduler ().runTask (Blockify .getInstance (), () -> {
155+ player .spawnParticle (Particle .BLOCK_CRACK , position .getX () + 0.5 , position .getY () + 0.5 , position .getZ () + 0.5 , 10 , 0 , 0 , 0 , blockData );
156+ player .playSound (player .getLocation (), blockData .getSoundGroup ().getBreakSound (), 1 , 1 );
157+ });
156158 }
157159 }
158160 // Send block break animation packet
@@ -175,14 +177,14 @@ public void breakCustomBlock(Player player, BlockifyPosition position, BlockData
175177 // Run synchronously as using Spigot API
176178 Bukkit .getScheduler ().runTask (Blockify .getInstance (), () -> {
177179 // Call BlockifyBreakEvent
178- BlockifyBreakEvent ghostBreakEvent = new BlockifyBreakEvent (player , position .toPosition (), blockData , view , view .getStage ());
179- ghostBreakEvent .callEvent ();
180+ BlockifyBreakEvent blockifyBreakEvent = new BlockifyBreakEvent (player , position .toPosition (), blockData , view , view .getStage ());
181+ blockifyBreakEvent .callEvent ();
180182 // If block stage exists, cancel the task and remove it from the map
181183 resetViewBlockAnimation (view , Set .of (position ));
182184 // Remove mining fatigue effect
183185 player .removePotionEffect (PotionEffectType .SLOW_DIGGING );
184186 // If block is not cancelled, break the block, otherwise, revert the block
185- if (!ghostBreakEvent .isCancelled ()) {
187+ if (!blockifyBreakEvent .isCancelled ()) {
186188 Blockify .getInstance ().getBlockChangeManager ().sendBlockChange (view .getStage (), view .getStage ().getAudience (), position , Material .AIR .createBlockData ());
187189 view .setBlock (position , Material .AIR .createBlockData ());
188190 } else {
0 commit comments