From 7310537cf604a950027b9218eeeffd279f2f1b64 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 23 Jul 2023 11:48:18 -0700 Subject: [PATCH] Small refactor to reduce complexity --- .../aoneblock/listeners/BlockListener.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java index ded058a6..bc11b62b 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java @@ -278,13 +278,7 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player String originalPhase = is.getPhaseName(); // Check for a goto if (Objects.requireNonNull(phase).getGotoBlock() != null) { - int gotoBlock = phase.getGotoBlock(); - phase = oneBlocksManager.getPhase(gotoBlock); - // Store lifetime - is.setLifetime(is.getLifetime() + gotoBlock); - // Set current block - is.setBlockNumber(gotoBlock); - + handleGoto(is, phase); } // Check for new phase and run commands if required boolean newPhase = check.checkPhase(player, i, is, Objects.requireNonNull(phase)); @@ -355,6 +349,15 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player is.incrementBlockNumber(); } + private void handleGoto(OneBlockIslands is, OneBlockPhase phase) { + int gotoBlock = phase.getGotoBlock(); + phase = oneBlocksManager.getPhase(gotoBlock); + // Store lifetime + is.setLifetime(is.getLifetime() + gotoBlock); + // Set current block + is.setBlockNumber(gotoBlock); + } + private void setBiome(@NonNull Block block, @Nullable Biome biome) { if (biome == null) { return;