From 9bdb98cdc91971553a55b3f25386daa2128f63c8 Mon Sep 17 00:00:00 2001 From: jannis_mg Date: Mon, 13 Jul 2026 16:34:07 +0200 Subject: [PATCH] other way for the effective-final --- .../stateless/types/colorJump/ColorJump.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/colorJump/ColorJump.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/colorJump/ColorJump.java index 7841c5e..6a14bf7 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/colorJump/ColorJump.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/colorJump/ColorJump.java @@ -14,6 +14,7 @@ import net.minestom.server.event.player.PlayerSwapItemEvent; import net.minestom.server.instance.batch.AbsoluteBlockBatch; import net.minestom.server.instance.block.Block; import net.minestom.server.item.ItemStack; +import net.minestom.server.timer.Scheduler; import net.minestom.server.timer.TaskSchedule; import org.jetbrains.annotations.NotNull; @@ -97,30 +98,29 @@ public class ColorJump extends StatelessGame { if(this.roundTime <= 1) this.roundTime = 1; long totalTicks = (long) (this.roundTime * 20); - final long[] remainingTicks = { totalTicks }; + this.scheduleExpUpdate(scheduler, totalTicks, totalTicks); + } - scheduler.scheduleTask(() -> { - - if (!this.isRunning) - return stop; - - if (remainingTicks[0] <= 0) { - this.getPlayers().forEach(player -> { - player.setExp(0f); - player.setLevel(0); - }); - return stop; - } - - float progress = (float) remainingTicks[0] / totalTicks; + private void scheduleExpUpdate(Scheduler scheduler, long remainingTicks, long totalTicks) { + if (!this.isRunning) return; + if (remainingTicks <= 0) { this.getPlayers().forEach(player -> { - player.setExp(progress); - player.setLevel((int) Math.ceil(remainingTicks[0] / 20.0)); + player.setExp(0f); + player.setLevel(0); }); + return; + } - remainingTicks[0]--; - return TaskSchedule.tick(1); + float progress = (float) remainingTicks / totalTicks; + + this.getPlayers().forEach(player -> { + player.setExp(progress); + player.setLevel((int) Math.ceil(remainingTicks / 20.0)); + }); + scheduler.scheduleTask(() -> { + this.scheduleExpUpdate(scheduler, remainingTicks -1, totalTicks); + return TaskSchedule.stop(); }, TaskSchedule.tick(1)); }