8
8
import java .util .concurrent .CompletableFuture ;
9
9
import java .util .concurrent .ExecutionException ;
10
10
11
+ import javax .annotation .Nonnull ;
12
+
11
13
import org .bukkit .Bukkit ;
12
14
import org .bukkit .Chunk ;
13
15
import org .bukkit .Location ;
33
35
import org .bukkit .material .Colorable ;
34
36
import org .bukkit .scheduler .BukkitRunnable ;
35
37
import org .bukkit .util .BoundingBox ;
38
+ import org .eclipse .jdt .annotation .NonNull ;
36
39
import org .eclipse .jdt .annotation .Nullable ;
37
40
38
41
import io .papermc .lib .PaperLib ;
39
42
import world .bentobox .bentobox .BentoBox ;
40
43
import world .bentobox .bentobox .api .addons .GameModeAddon ;
44
+ import world .bentobox .bentobox .api .hooks .Hook ;
41
45
import world .bentobox .bentobox .database .objects .IslandDeletion ;
42
46
import world .bentobox .bentobox .hooks .ItemsAdderHook ;
43
47
import world .bentobox .bentobox .hooks .SlimefunHook ;
@@ -119,7 +123,8 @@ public CompletableFuture<Void> regenerateChunk(Chunk chunk) {
119
123
return regenerateChunk (null , chunk .getWorld (), chunk .getX (), chunk .getZ ());
120
124
}
121
125
122
- private CompletableFuture <Void > regenerateChunk (@ Nullable IslandDeletion di , World world , int chunkX , int chunkZ ) {
126
+ private CompletableFuture <Void > regenerateChunk (@ Nullable IslandDeletion di , @ NonNull World world , int chunkX ,
127
+ int chunkZ ) {
123
128
124
129
CompletableFuture <Chunk > seedWorldFuture = getSeedWorldChunk (world , chunkX , chunkZ );
125
130
@@ -201,10 +206,12 @@ private void copyChunkDataToChunk(Chunk toChunk, Chunk fromChunk, BoundingBox li
201
206
// Delete any 3rd party blocks
202
207
Location loc = new Location (toChunk .getWorld (), baseX + x , y , baseZ + z );
203
208
slimefunHook .ifPresent (hook -> hook .clearBlockInfo (loc , true ));
204
- itemsAdderHook . ifPresent ( hook -> hook . clearBlockInfo ( loc ));
209
+
205
210
}
206
211
}
207
212
}
213
+ // Items Adder
214
+ itemsAdderHook .ifPresent (hook -> ItemsAdderHook .deleteAllCustomBlocksInChunk (toChunk ));
208
215
// Entities
209
216
Arrays .stream (fromChunk .getEntities ()).forEach (e -> processEntity (e , e .getLocation ().toVector ().toLocation (toChunk .getWorld ())));
210
217
@@ -333,7 +340,8 @@ private boolean isEnded(int chunkX) {
333
340
}
334
341
335
342
@ SuppressWarnings ("deprecation" )
336
- private CompletableFuture <Void > regenerateChunk (GameModeAddon gm , IslandDeletion di , World world , int chunkX , int chunkZ ) {
343
+ private CompletableFuture <Void > regenerateChunk (GameModeAddon gm , IslandDeletion di , @ Nonnull World world ,
344
+ int chunkX , int chunkZ ) {
337
345
CompletableFuture <Chunk > chunkFuture = PaperLib .getChunkAtAsync (world , chunkX , chunkZ );
338
346
CompletableFuture <Void > invFuture = chunkFuture .thenAccept (chunk ->
339
347
Arrays .stream (chunk .getTileEntities ()).filter (InventoryHolder .class ::isInstance )
@@ -370,6 +378,7 @@ private void copyChunkDataToChunk(Chunk chunk, ChunkGenerator.ChunkData chunkDat
370
378
double baseZ = chunk .getZ () << 4 ;
371
379
int minHeight = chunk .getWorld ().getMinHeight ();
372
380
int maxHeight = chunk .getWorld ().getMaxHeight ();
381
+ Optional <Hook > slimefunHook = plugin .getHooks ().getHook ("Slimefun" );
373
382
for (int x = 0 ; x < 16 ; x ++) {
374
383
for (int z = 0 ; z < 16 ; z ++) {
375
384
if (!limitBox .contains (baseX + x , 0 , baseZ + z )) {
@@ -383,12 +392,11 @@ private void copyChunkDataToChunk(Chunk chunk, ChunkGenerator.ChunkData chunkDat
383
392
}
384
393
// Delete any 3rd party blocks
385
394
Location loc = new Location (chunk .getWorld (), baseX + x , y , baseZ + z );
386
- plugin .getHooks ().getHook ("Slimefun" )
387
- .ifPresent (sf -> ((SlimefunHook ) sf ).clearBlockInfo (loc , true ));
388
- plugin .getHooks ().getHook ("ItemsAdder" )
389
- .ifPresent (hook -> ((ItemsAdderHook ) hook ).clearBlockInfo (loc ));
395
+ slimefunHook .ifPresent (sf -> ((SlimefunHook ) sf ).clearBlockInfo (loc , true ));
390
396
}
391
397
}
392
398
}
399
+ // Items Adder
400
+ plugin .getHooks ().getHook ("ItemsAdder" ).ifPresent (hook -> ItemsAdderHook .deleteAllCustomBlocksInChunk (chunk ));
393
401
}
394
402
}
0 commit comments