From e1515200ab02b3cadae89b4a4212cb38d75919b7 Mon Sep 17 00:00:00 2001 From: jannis Date: Wed, 11 Feb 2026 20:56:26 +0100 Subject: [PATCH 1/6] stoped task at game end --- .../instance/game/stateless/types/colorJump/ColorJump.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 fef6c13..0f29bc1 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 @@ -33,6 +33,7 @@ public class ColorJump extends StatelessGame { ); private Block currentBlock; private double roundTime = 5; + private final double multiplierNextRoundTime = 0.9; public ColorJump() { super(Dimension.THE_END.key, "ColorJump", new LastWinsScore()); @@ -67,16 +68,17 @@ public class ColorJump extends StatelessGame { TaskSchedule stop = TaskSchedule.stop(); scheduler.scheduleTask(() -> { + if(!this.isRunning) return stop; this.destroyAllExcept(this.currentBlock); scheduler.scheduleTask(() -> { - this.nextRound(); + if(this.isRunning) this.nextRound(); return stop; }, TaskSchedule.seconds(3)); return stop; }, TaskSchedule.seconds((long) this.roundTime)); if(this.roundTime > 0.5) - this.roundTime = this.roundTime * 0.9; + this.roundTime = this.roundTime * this.multiplierNextRoundTime; long secondsLeft = Math.max(0, (long) this.roundTime); From 410f7b4027d574146db9c1a0812ab7661e7bfd1b Mon Sep 17 00:00:00 2001 From: jannis Date: Mon, 16 Feb 2026 21:07:30 +0100 Subject: [PATCH 2/6] perfekted colorjump --- .../stateless/types/colorJump/ColorJump.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 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 0f29bc1..51a9c5b 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 @@ -32,6 +32,7 @@ public class ColorJump extends StatelessGame { Block.PINK_CONCRETE ); private Block currentBlock; + private Block blockLastRound; private double roundTime = 5; private final double multiplierNextRoundTime = 0.9; @@ -56,6 +57,8 @@ public class ColorJump extends StatelessGame { this.generate(); this.currentBlock = this.blocks.get(ThreadLocalRandom.current().nextInt(this.blocks.size())); + if(this.currentBlock == this.blockLastRound) this.nextRound(); + this.blockLastRound = this.currentBlock; ItemStack item = ItemStack.of(Objects.requireNonNull(this.currentBlock.registry().material())); this.getPlayers().forEach(player -> { player.getInventory().clear(); @@ -80,15 +83,31 @@ public class ColorJump extends StatelessGame { if(this.roundTime > 0.5) this.roundTime = this.roundTime * this.multiplierNextRoundTime; - long secondsLeft = Math.max(0, (long) this.roundTime); + long totalMillis = (long) (this.roundTime * 1000); + long startTime = System.currentTimeMillis(); - for (int i = Math.min(3, (int) secondsLeft); i >= 0; i--) { - int level = i; - scheduler.scheduleTask(() -> { - this.getPlayers().forEach(player -> player.setLevel(level)); + scheduler.scheduleTask(() -> { + if (!this.isRunning) return stop; + + long elapsed = System.currentTimeMillis() - startTime; + long remaining = totalMillis - elapsed; + + if (remaining <= 0) { + this.getPlayers().forEach(player -> { + player.setExp(0f); + player.setLevel(0); + }); return stop; - }, TaskSchedule.seconds(secondsLeft-i)); - } + } + + float progress = (float) remaining / totalMillis; + + this.getPlayers().forEach(player -> { + player.setExp(progress); + player.setLevel((int) Math.ceil(remaining / 1000.0)); + }); + return TaskSchedule.millis(50); // 1 Tick (20 TPS) + }, TaskSchedule.millis(0)); } private void generate() { From ee7d434d7ee218f6d6327f10e147b52de012d790 Mon Sep 17 00:00:00 2001 From: jannis Date: Mon, 16 Feb 2026 22:28:32 +0100 Subject: [PATCH 3/6] perfectet colorjump timer, cancelled inventory movement --- .../stateless/types/colorJump/ColorJump.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 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 51a9c5b..4bed9a5 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 @@ -8,6 +8,7 @@ import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGen import net.minestom.server.MinecraftServer; import net.minestom.server.coordinate.Pos; import net.minestom.server.entity.GameMode; +import net.minestom.server.event.inventory.InventoryPreClickEvent; import net.minestom.server.event.player.PlayerMoveEvent; import net.minestom.server.instance.batch.AbsoluteBlockBatch; import net.minestom.server.instance.block.Block; @@ -41,6 +42,11 @@ public class ColorJump extends StatelessGame { this.getScore().setIgnoreLastPlayers(1); this.setGenerator(new CircularPlateTerrainGenerator(100)); + + this.eventNode().addListener( + InventoryPreClickEvent.class, + inventoryPreClickEvent -> inventoryPreClickEvent.setCancelled(true) + ); } @Override @@ -55,10 +61,11 @@ public class ColorJump extends StatelessGame { private void nextRound() { this.generate(); - - this.currentBlock = this.blocks.get(ThreadLocalRandom.current().nextInt(this.blocks.size())); - if(this.currentBlock == this.blockLastRound) this.nextRound(); + do { + this.currentBlock = this.blocks.get(ThreadLocalRandom.current().nextInt(this.blocks.size())); + } while(this.currentBlock == this.blockLastRound); this.blockLastRound = this.currentBlock; + ItemStack item = ItemStack.of(Objects.requireNonNull(this.currentBlock.registry().material())); this.getPlayers().forEach(player -> { player.getInventory().clear(); @@ -80,19 +87,18 @@ public class ColorJump extends StatelessGame { }, TaskSchedule.seconds(3)); return stop; }, TaskSchedule.seconds((long) this.roundTime)); - if(this.roundTime > 0.5) - this.roundTime = this.roundTime * this.multiplierNextRoundTime; + this.roundTime = this.roundTime * this.multiplierNextRoundTime; + if(this.roundTime <= 1) this.roundTime = 1; - long totalMillis = (long) (this.roundTime * 1000); - long startTime = System.currentTimeMillis(); + long totalTicks = (long) (this.roundTime * 20); + final long[] remainingTicks = { totalTicks }; scheduler.scheduleTask(() -> { - if (!this.isRunning) return stop; - long elapsed = System.currentTimeMillis() - startTime; - long remaining = totalMillis - elapsed; + if (!this.isRunning) + return stop; - if (remaining <= 0) { + if (remainingTicks[0] <= 0) { this.getPlayers().forEach(player -> { player.setExp(0f); player.setLevel(0); @@ -100,14 +106,16 @@ public class ColorJump extends StatelessGame { return stop; } - float progress = (float) remaining / totalMillis; + float progress = (float) remainingTicks[0] / totalTicks; this.getPlayers().forEach(player -> { player.setExp(progress); - player.setLevel((int) Math.ceil(remaining / 1000.0)); + player.setLevel((int) Math.ceil(remainingTicks[0] / 20.0)); }); - return TaskSchedule.millis(50); // 1 Tick (20 TPS) - }, TaskSchedule.millis(0)); + + remainingTicks[0]--; + return TaskSchedule.tick(1); + }, TaskSchedule.tick(1)); } private void generate() { From 58983be156786235ecb9993d85529da71da6e86c Mon Sep 17 00:00:00 2001 From: jannis_mg Date: Mon, 13 Jul 2026 10:30:34 +0200 Subject: [PATCH 4/6] removed off-hand swap in colorjump --- .../instance/game/stateless/types/colorJump/ColorJump.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 4bed9a5..7841c5e 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 @@ -10,6 +10,7 @@ import net.minestom.server.coordinate.Pos; import net.minestom.server.entity.GameMode; import net.minestom.server.event.inventory.InventoryPreClickEvent; import net.minestom.server.event.player.PlayerMoveEvent; +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; @@ -47,6 +48,11 @@ public class ColorJump extends StatelessGame { InventoryPreClickEvent.class, inventoryPreClickEvent -> inventoryPreClickEvent.setCancelled(true) ); + + this.eventNode().addListener( + PlayerSwapItemEvent.class, + playerSwapItemEvent -> playerSwapItemEvent.setCancelled(true) + ); } @Override From 6f0ebe4d12ce759f1b0caea7488fea7380cfc313 Mon Sep 17 00:00:00 2001 From: jannis_mg Date: Mon, 13 Jul 2026 10:40:58 +0200 Subject: [PATCH 5/6] moved colorjump from prototype to jumpnrun --- .../java/eu/mhsl/minenet/minigames/instance/game/GameList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/GameList.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/GameList.java index 328dcda..d160948 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/GameList.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/GameList.java @@ -52,7 +52,7 @@ public enum GameList { BOATRACE(new BoatRaceFactory(), GameType.OTHER), PILLARS(new PillarsFactory(), GameType.PROTOTYPE), BLOCKBATTLE(new BlockBattleFactory(), GameType.PVP), - COLORJUMP(new ColorJumpFactory(), GameType.PROTOTYPE); + COLORJUMP(new ColorJumpFactory(), GameType.JUMPNRUN); private final GameFactory factory; private final GameType type; From 9bdb98cdc91971553a55b3f25386daa2128f63c8 Mon Sep 17 00:00:00 2001 From: jannis_mg Date: Mon, 13 Jul 2026 16:34:07 +0200 Subject: [PATCH 6/6] 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)); }