49
49
import world .bentobox .aoneblock .oneblocks .OneBlockObject ;
50
50
import world .bentobox .aoneblock .oneblocks .OneBlockPhase ;
51
51
import world .bentobox .aoneblock .oneblocks .OneBlocksManager ;
52
+ import world .bentobox .bentobox .BentoBox ;
52
53
import world .bentobox .bentobox .api .events .island .IslandCreatedEvent ;
53
54
import world .bentobox .bentobox .api .events .island .IslandDeleteEvent ;
54
55
import world .bentobox .bentobox .api .events .island .IslandResettedEvent ;
@@ -274,9 +275,9 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
274
275
// Save previous processing phase name
275
276
String prevPhaseName = is .getPhaseName ();
276
277
277
- // Check for a goto
278
- if (Objects .requireNonNull (phase ).getGotoBlock () != null ) {
279
- handleGoto (is , phase );
278
+ // Check if phase contains `gotoBlock`
279
+ if (Objects .requireNonNull (phase ).getGotoBlock () != null ){
280
+ phase = handleGoto (is , phase . getGotoBlock () );
280
281
}
281
282
282
283
// Get current phase name
@@ -285,9 +286,14 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
285
286
// Get the phase for next block number
286
287
OneBlockPhase nextPhase = oneBlocksManager .getPhase (is .getBlockNumber () + 1 );
287
288
289
+ // Check if nextPhase contains `gotoBlock` and override `nextPhase`
290
+ if (Objects .requireNonNull (nextPhase ).getGotoBlock () != null ) {
291
+ nextPhase = oneBlocksManager .getPhase (nextPhase .getGotoBlock ());
292
+ }
293
+
288
294
// Get next phase name
289
295
String nextPhaseName = nextPhase == null || nextPhase .getPhaseName () == null ? "" : nextPhase .getPhaseName ();
290
-
296
+
291
297
// If next phase is new, log break time of the last block of this phase
292
298
if (!currPhaseName .equalsIgnoreCase (nextPhaseName )) {
293
299
is .setLastPhaseChangeTime (System .currentTimeMillis ());
@@ -296,10 +302,11 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
296
302
boolean isCurrPhaseNew = !is .getPhaseName ().equalsIgnoreCase (currPhaseName );
297
303
298
304
if (isCurrPhaseNew ) {
305
+
299
306
// Check if requirements for new phase are met
300
307
if (check .phaseRequirementsFail (player , i , is , phase , world )) {
301
- e .setCancelled (true );
302
- return ;
308
+ e .setCancelled (true );
309
+ return ;
303
310
}
304
311
305
312
check .setNewPhase (player , i , is , phase );
@@ -379,13 +386,12 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
379
386
is .incrementBlockNumber ();
380
387
}
381
388
382
- private void handleGoto (OneBlockIslands is , OneBlockPhase phase ) {
383
- int gotoBlock = phase .getGotoBlock ();
384
- phase = oneBlocksManager .getPhase (gotoBlock );
385
- // Store lifetime
386
- is .setLifetime (is .getLifetime () + gotoBlock );
387
- // Set current block
388
- is .setBlockNumber (gotoBlock );
389
+ private OneBlockPhase handleGoto (OneBlockIslands is , int gotoBlock ) {
390
+ // Store lifetime
391
+ is .setLifetime (is .getLifetime () + gotoBlock );
392
+ // Set current block
393
+ is .setBlockNumber (gotoBlock );
394
+ return oneBlocksManager .getPhase (gotoBlock );
389
395
}
390
396
391
397
private void setBiome (@ NonNull Block block , @ Nullable Biome biome ) {
0 commit comments