From 360266339d30e94357f280ff897d9e4fd34d786b Mon Sep 17 00:00:00 2001 From: jannis Date: Fri, 23 Jan 2026 20:26:04 +0100 Subject: [PATCH 1/7] added pillars game --- .../minigames/instance/game/GameList.java | 4 +- .../game/stateless/types/pillars/Pillars.java | 100 ++++++++++++++++++ .../types/pillars/PillarsFactory.java | 27 +++++ .../mhsl/minenet/minigames/util/Position.java | 12 ++- src/main/resources/lang/locales.map.csv | 3 + 5 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java create mode 100644 src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java 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 29bad6a..97b5678 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 @@ -14,6 +14,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.fastbridge.Fastbr import eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround.HighGroundFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive.JumpDiveFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory; +import eu.mhsl.minenet.minigames.instance.game.stateless.types.pillars.PillarsFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.spaceSnake.SpaceSnakeFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.spleef.SpleefFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.stickfight.StickFightFactory; @@ -46,7 +47,8 @@ public enum GameList { FASTBRIDGE(new FastbridgeFactory(), GameType.OTHER), BLOCKBREAKRACE(new BlockBreakRaceFactory(), GameType.OTHER), SPACESNAKE(new SpaceSnakeFactory(), GameType.PVP), - BOATRACE(new BoatRaceFactory(), GameType.OTHER); + BOATRACE(new BoatRaceFactory(), GameType.OTHER), + PILLARS(new PillarsFactory(), GameType.PROTOTYPE); private final GameFactory factory; private final GameType type; diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java new file mode 100644 index 0000000..f621428 --- /dev/null +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java @@ -0,0 +1,100 @@ +package eu.mhsl.minenet.minigames.instance.game.stateless.types.pillars; + +import eu.mhsl.minenet.minigames.instance.Dimension; +import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame; +import eu.mhsl.minenet.minigames.score.LastWinsScore; +import eu.mhsl.minenet.minigames.util.Position; +import io.github.togar2.pvp.feature.CombatFeatures; +import net.minestom.server.MinecraftServer; +import net.minestom.server.coordinate.Pos; +import net.minestom.server.entity.GameMode; +import net.minestom.server.entity.Player; +import net.minestom.server.event.item.ItemDropEvent; +import net.minestom.server.event.player.PlayerBlockBreakEvent; +import net.minestom.server.event.player.PlayerBlockPlaceEvent; +import net.minestom.server.event.player.PlayerMoveEvent; +import net.minestom.server.instance.block.Block; +import net.minestom.server.item.ItemStack; +import net.minestom.server.item.Material; +import net.minestom.server.timer.TaskSchedule; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Random; + +class Pillars extends StatelessGame { + private int spawnPosx = 0; + private int spawnPosz = 0; + private final int pillarSpacing = 10; + private final int pillarRowCount = 5; + public Pillars() { + super(Dimension.THE_END.key, "Pillars", new LastWinsScore()); + this.getScore().setIgnoreLastPlayers(1); + + this.eventNode().addChild( + CombatFeatures.empty() + .add(CombatFeatures.VANILLA_ATTACK) + .add(CombatFeatures.VANILLA_DAMAGE) + .add(CombatFeatures.VANILLA_KNOCKBACK) + .build().createNode() + ); + } + + @Override + protected boolean onPlayerJoin(Player p) { + Pos pos = new Pos(this.spawnPosx * this.pillarSpacing, 100, this.spawnPosz * this.pillarSpacing); + this.setBlock(pos.sub(0, 1, 0), Block.BEDROCK); + + if(this.spawnPosx >= this.pillarRowCount) { + this.spawnPosx = 0; + this.spawnPosz++; + } + this.spawnPosx++; + MinecraftServer.getSchedulerManager().scheduleNextTick(() -> p.teleport(pos.add(0.5, 0, 0.5))); + + return super.onPlayerJoin(p); + } + + @Override + protected void onBlockPlace(@NotNull PlayerBlockPlaceEvent playerBlockPlaceEvent) {} + + @Override + protected void onBlockBreak(@NotNull PlayerBlockBreakEvent playerBlockBreakEvent) {} + + @Override + protected void onItemDrop(@NotNull ItemDropEvent itemDropEvent) {} + + @Override + public Pos getSpawn() { + return new Pos(0, 105, 0); + } + + @Override + protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) { + if(this.isBeforeBeginning && Position.hasPositionChanged(playerMoveEvent.getPlayer().getPosition(), playerMoveEvent.getNewPosition())) + playerMoveEvent.setCancelled(true); + + if(playerMoveEvent.getNewPosition().y() < 80) { + this.getScore().insertResult(playerMoveEvent.getPlayer()); + playerMoveEvent.getPlayer().teleport(this.getSpawn()); + playerMoveEvent.getPlayer().setGameMode(GameMode.SPECTATOR); + } + } + + @Override + protected void onStart() { + this.getPlayers().forEach(player -> player.setGameMode(GameMode.SURVIVAL)); + + MinecraftServer.getSchedulerManager().submitTask(() -> { + List materials = Material.values().stream() + .filter(material -> !material.equals(Material.AIR)) + .toList(); + this.getPlayers().forEach(player -> { + ItemStack item = ItemStack.of(materials.get(new Random().nextInt(Material.values().toArray().length))); + player.getInventory().addItemStack(item); + }); + + return TaskSchedule.seconds(5); + }); + } +} diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java new file mode 100644 index 0000000..c2afac6 --- /dev/null +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java @@ -0,0 +1,27 @@ +package eu.mhsl.minenet.minigames.instance.game.stateless.types.pillars; + +import eu.mhsl.minenet.minigames.instance.game.Game; +import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory; +import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option; +import eu.mhsl.minenet.minigames.instance.room.Room; +import eu.mhsl.minenet.minigames.message.component.TranslatedComponent; +import net.minestom.server.item.Material; + +import java.util.Map; + +public class PillarsFactory implements GameFactory { + @Override + public TranslatedComponent name() { + return TranslatedComponent.byId("game_Pillars#name"); + } + + @Override + public Material symbol() { + return Material.BEDROCK; + } + + @Override + public Game manufacture(Room parent, Map> configuration) throws Exception { + return new Pillars().setParent(parent); + } +} diff --git a/src/main/java/eu/mhsl/minenet/minigames/util/Position.java b/src/main/java/eu/mhsl/minenet/minigames/util/Position.java index 4dd189f..bb5dc2e 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/util/Position.java +++ b/src/main/java/eu/mhsl/minenet/minigames/util/Position.java @@ -33,9 +33,15 @@ public class Position { public static List blocksBelowPlayer(Instance instance, Player p) { Point playerPos = p.getPosition(); List blocks = new ArrayList<>(); - GeneratorUtils.foreachXZ(playerPos.sub(0.5, 1, 0.5), playerPos.add(0.5, -1, 0.5), point -> { - blocks.add(instance.getBlock(point)); - }); + GeneratorUtils.foreachXZ( + playerPos.sub(0.5, 1, 0.5), + playerPos.add(0.5, -1, 0.5), + point -> blocks.add(instance.getBlock(point)) + ); return blocks.stream().distinct().toList(); } + + public static boolean hasPositionChanged(Pos oldPos, Pos newPos) { + return !oldPos.withView(0, 0).equals(newPos.withView(0, 0)); + } } diff --git a/src/main/resources/lang/locales.map.csv b/src/main/resources/lang/locales.map.csv index 4d22dc4..46c7d6b 100644 --- a/src/main/resources/lang/locales.map.csv +++ b/src/main/resources/lang/locales.map.csv @@ -174,3 +174,6 @@ startSpeed;Start Speed;Startgeschwindigkeit ns:game_BoatRace#;; name;Boatrace;Bootrennen description;; +;; +ns:game_Pillars#;; +name;Pillars;Pillars \ No newline at end of file -- 2.30.2 From d0031b4ea59752010cff741e83dc8a33e8c49d04 Mon Sep 17 00:00:00 2001 From: jannis Date: Sun, 1 Feb 2026 14:13:08 +0100 Subject: [PATCH 2/7] added BlockBattle --- .../minigames/instance/game/GameList.java | 4 +- .../types/blockBattle/BlockBattle.java | 211 ++++++++++++++++++ .../types/blockBattle/BlockBattleFactory.java | 32 +++ .../stateless/types/blockBattle/Team.java | 25 +++ .../types/pillars/PillarsFactory.java | 7 +- src/main/resources/lang/locales.map.csv | 5 +- 6 files changed, 281 insertions(+), 3 deletions(-) create mode 100644 src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java create mode 100644 src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java create mode 100644 src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java 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 97b5678..0d846b6 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 @@ -5,6 +5,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.acidRain.AcidRain import eu.mhsl.minenet.minigames.instance.game.stateless.types.anvilRun.AnvilRunFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms.BackroomsFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory; +import eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle.BlockBattleFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBreakRace.BlockBreakRaceFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.boatRace.BoatRaceFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.types.bowSpleef.BowSpleefFactory; @@ -48,7 +49,8 @@ public enum GameList { BLOCKBREAKRACE(new BlockBreakRaceFactory(), GameType.OTHER), SPACESNAKE(new SpaceSnakeFactory(), GameType.PVP), BOATRACE(new BoatRaceFactory(), GameType.OTHER), - PILLARS(new PillarsFactory(), GameType.PROTOTYPE); + PILLARS(new PillarsFactory(), GameType.PROTOTYPE), + BLOCKBATTLE(new BlockBattleFactory(), GameType.PROTOTYPE); private final GameFactory factory; private final GameType type; diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java new file mode 100644 index 0000000..2e0efe1 --- /dev/null +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java @@ -0,0 +1,211 @@ +package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; + +import eu.mhsl.minenet.minigames.instance.Dimension; +import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame; +import eu.mhsl.minenet.minigames.score.NoScore; +import io.github.togar2.pvp.events.FinalAttackEvent; +import io.github.togar2.pvp.feature.CombatFeatures; +import net.minestom.server.coordinate.Pos; +import net.minestom.server.entity.GameMode; +import net.minestom.server.entity.Player; +import net.minestom.server.event.player.PlayerBlockBreakEvent; +import net.minestom.server.event.player.PlayerBlockPlaceEvent; +import net.minestom.server.event.player.PlayerMoveEvent; +import net.minestom.server.instance.block.Block; +import net.minestom.server.item.ItemStack; +import net.minestom.server.item.Material; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.concurrent.CompletableFuture; + +public class BlockBattle extends StatelessGame { + private final Team teamBlue = new Team(new Pos(0,101,20).add(0.5), Team.Color.BLUE); + private final Team teamRed = new Team(new Pos(0, 101, -20).add(0.5), Team.Color.RED); + + private final Map teams = new WeakHashMap<>(); + + public BlockBattle() { + super(Dimension.THE_END.key, "Block Battle", new NoScore()); + + this.eventNode().addChild( + CombatFeatures.empty() + .add(CombatFeatures.VANILLA_ATTACK) + .add(CombatFeatures.VANILLA_DAMAGE) + .add(CombatFeatures.VANILLA_KNOCKBACK) + .build().createNode() + ); + + this.eventNode().addListener(FinalAttackEvent.class, finalAttackEvent -> { + if(this.isBeforeBeginning) finalAttackEvent.setCancelled(true); + finalAttackEvent.setBaseDamage(0); + ((Player) finalAttackEvent.getTarget()).setHealth(20); + }); + } + + @Override + protected void onLoad(@NotNull CompletableFuture callback) { + this.generateWorld(); + } + + @Override + protected void onBlockPlace(@NotNull PlayerBlockPlaceEvent playerBlockPlaceEvent) { + Pos posGoldBlock = new Pos(playerBlockPlaceEvent.getBlockPosition()).sub(0, 1, 0); + Block goldBlock = playerBlockPlaceEvent.getInstance().getBlock(posGoldBlock); + + if(goldBlock == Block.GOLD_BLOCK) + playerBlockPlaceEvent.setCancelled(false); + else + playerBlockPlaceEvent.setCancelled(true); + + playerBlockPlaceEvent.getInstance().scheduler().scheduleNextTick(() -> { + Pos middle = new Pos(0, 101, 0); + boolean validBlue = true; + boolean validRed = true; + + for(int x = middle.blockX()-1; x < middle.blockX()+2; x++) { + for(int z = middle.blockZ()-1; z < middle.blockZ()+2; z++) { + if(playerBlockPlaceEvent.getInstance().getBlock(x, 101, z) != Block.BLUE_WOOL) { + validBlue = false; + break; + } + } + if(!validBlue) + break; + } + + for(int x = middle.blockX()-1; x < middle.blockX()+2; x++) { + for(int z = middle.blockZ()-1; z < middle.blockZ()+2; z++) { + if(playerBlockPlaceEvent.getInstance().getBlock(x, 101, z) != Block.RED_WOOL) { + validRed = false; + break; + } + } + if(!validRed) + break; + } + + if(validBlue) { + super.stop(); + System.out.println("blau"); + } + + if(validRed) { + super.stop(); + System.out.println("rot"); + } + }); + } + + @Override + protected void onBlockBreak(@NotNull PlayerBlockBreakEvent playerBlockBreakEvent) { + final Block[] blockCantBreakList = new Block[] { + Block.YELLOW_CONCRETE_POWDER, + Block.GOLD_BLOCK, + Block.BLUE_CONCRETE_POWDER, + Block.BLUE_CONCRETE, + Block.BLUE_STAINED_GLASS, + Block.RED_CONCRETE_POWDER, + Block.RED_CONCRETE, + Block.RED_STAINED_GLASS + }; + for(int i = 0; i < blockCantBreakList.length; i++) { + if(playerBlockBreakEvent.getBlock().equals(blockCantBreakList[i])) + playerBlockBreakEvent.setCancelled(true); + } + } + + @Override + protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) { + if(playerMoveEvent.getNewPosition().y() < 75) { + var player = playerMoveEvent.getPlayer(); + + if(this.isBeforeBeginning) { + player.teleport(this.getSpawn()); + } else { + player.teleport(this.teams.get(player).getSpawnPosition()); + } + + player.getInventory().clear(); + if(this.teams.get(player).getColor() == Team.Color.RED) { + ItemStack item = ItemStack.of(Material.RED_WOOL); + player.getInventory().addItemStack(item); + } + if(this.teams.get(player).getColor() == Team.Color.BLUE) { + ItemStack item = ItemStack.of(Material.BLUE_WOOL); + player.getInventory().addItemStack(item); + } + } + } + + @Override + protected void onStart() { + this.setTeams(); + this.getPlayers().forEach(player -> { + player.setGameMode(GameMode.SURVIVAL); + player.teleport(this.teams.get(player).getSpawnPosition()); + + if(this.teams.get(player).getColor() == Team.Color.RED) { + ItemStack item = ItemStack.of(Material.RED_WOOL); + player.getInventory().addItemStack(item); + } + if(this.teams.get(player).getColor() == Team.Color.BLUE) { + ItemStack item = ItemStack.of(Material.BLUE_WOOL); + player.getInventory().addItemStack(item); + } + }); + } + + private void generatePlatform(Pos center, Block inner, Block outer) { + for(int x = center.blockX()-2; x < center.blockX()+3; x++) { + for(int z = center.blockZ()-2; z < center.blockZ()+3; z++) { + this.setBlock(x, center.blockY(), z, outer); + } + } + + for(int x = center.blockX()-1; x < center.blockX()+2; x++) { + for(int z = center.blockZ()-1; z < center.blockZ()+2; z++) { + this.setBlock(x, center.blockY(), z, inner); + } + } + } + + private void generateWorld() { + this.generatePlatform(new Pos(0, 100, 0), Block.GOLD_BLOCK, Block.YELLOW_CONCRETE_POWDER); + this.generatePlatform(new Pos(0, 101, 0), Block.AIR, Block.YELLOW_CONCRETE_POWDER); + this.generatePlatform(new Pos(0, 100, 20), Block.BLUE_CONCRETE, Block.BLUE_CONCRETE_POWDER); + this.generatePlatform(new Pos(0, 100, -20), Block.RED_CONCRETE, Block.RED_CONCRETE_POWDER); + this.generatePlatform(new Pos(-5, 101, -14), Block.RED_STAINED_GLASS, Block.AIR); + this.generatePlatform(new Pos(5, 101, 14), Block.BLUE_STAINED_GLASS, Block.AIR); + + this.setBlock(new Pos(2, 102, -9), Block.RED_STAINED_GLASS); + this.setBlock(new Pos(-1, 103, -9), Block.RED_STAINED_GLASS); + this.setBlock(new Pos(-2, 104, -6), Block.RED_STAINED_GLASS); + this.setBlock(new Pos(-5, 103, -7), Block.RED_STAINED_GLASS); + this.setBlock(new Pos(-7, 102, -10), Block.RED_STAINED_GLASS); + this.setBlock(new Pos(3, 102, -12), Block.RED_STAINED_GLASS); + this.setBlock(new Pos(5, 101, -15), Block.RED_STAINED_GLASS); + + this.setBlock(new Pos(-5, 101, 15), Block.BLUE_STAINED_GLASS); + this.setBlock(new Pos(-3, 102, 12), Block.BLUE_STAINED_GLASS); + this.setBlock(new Pos(-2, 102, 9), Block.BLUE_STAINED_GLASS); + this.setBlock(new Pos(1, 103, 9), Block.BLUE_STAINED_GLASS); + this.setBlock(new Pos(2, 104, 6), Block.BLUE_STAINED_GLASS); + this.setBlock(new Pos(5, 103, 7), Block.BLUE_STAINED_GLASS); + this.setBlock(new Pos(7, 102, 10), Block.BLUE_STAINED_GLASS); + } + + private void setTeams() { + List players = this.getPlayers().stream().toList(); + int halfPlayers = players.size()/2; + players.subList(0, halfPlayers).forEach(player -> this.teams.put(player, this.teamBlue)); + players.subList(halfPlayers, players.size()).forEach(player -> this.teams.put(player, this.teamRed)); + } + + @Override + public Pos getSpawn() { + return new Pos(0, 101, 0).add(0.5); + } +} diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java new file mode 100644 index 0000000..d4b895f --- /dev/null +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java @@ -0,0 +1,32 @@ +package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; + +import eu.mhsl.minenet.minigames.instance.game.Game; +import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory; +import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option; +import eu.mhsl.minenet.minigames.instance.room.Room; +import eu.mhsl.minenet.minigames.message.component.TranslatedComponent; +import net.minestom.server.item.Material; + +import java.util.Map; + +public class BlockBattleFactory implements GameFactory { + @Override + public TranslatedComponent name() { + return TranslatedComponent.byId("game_BlockBattle#name"); + } + + @Override + public TranslatedComponent description() { + return TranslatedComponent.byId("game_BlockBattle#description"); + } + + @Override + public Material symbol() { + return Material.GREEN_CONCRETE; + } + + @Override + public Game manufacture(Room parent, Map> configuration) throws Exception { + return new BlockBattle().setParent(parent); + } +} diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java new file mode 100644 index 0000000..5dc8f81 --- /dev/null +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java @@ -0,0 +1,25 @@ +package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; + +import net.minestom.server.coordinate.Pos; + +public class Team { + public enum Color { + RED, + BLUE + } + private final Pos spawnPosition; + private final Color color; + + public Team(Pos spawnPosition, Color color) { + this.spawnPosition = spawnPosition; + this.color = color; + } + + public Pos getSpawnPosition() { + return this.spawnPosition; + } + + public Color getColor() { + return this.color; + } +} diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java index c2afac6..22e03a2 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/PillarsFactory.java @@ -15,9 +15,14 @@ public class PillarsFactory implements GameFactory { return TranslatedComponent.byId("game_Pillars#name"); } + @Override + public TranslatedComponent description() { + return TranslatedComponent.byId("game_Pillars#description"); + } + @Override public Material symbol() { - return Material.BEDROCK; + return Material.BEDROCK; } @Override diff --git a/src/main/resources/lang/locales.map.csv b/src/main/resources/lang/locales.map.csv index 46c7d6b..3c82743 100644 --- a/src/main/resources/lang/locales.map.csv +++ b/src/main/resources/lang/locales.map.csv @@ -176,4 +176,7 @@ name;Boatrace;Bootrennen description;; ;; ns:game_Pillars#;; -name;Pillars;Pillars \ No newline at end of file +name;Pillars;Pillars +;; +ns:game_BlockBattle#;; +name;Block Battle;Block Battle \ No newline at end of file -- 2.30.2 From 05240660f2ab9bd2ed20aff7f2bc49ba669aa358 Mon Sep 17 00:00:00 2001 From: jannis Date: Sun, 1 Feb 2026 17:37:37 +0100 Subject: [PATCH 3/7] added scores and translations --- .../types/blockBattle/BlockBattle.java | 37 +++++++++---------- .../mhsl/minenet/minigames/score/Score.java | 5 +++ src/main/resources/lang/locales.map.csv | 4 +- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java index 2e0efe1..b4878ab 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java @@ -2,7 +2,7 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; import eu.mhsl.minenet.minigames.instance.Dimension; import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame; -import eu.mhsl.minenet.minigames.score.NoScore; +import eu.mhsl.minenet.minigames.score.FirstWinsScore; import io.github.togar2.pvp.events.FinalAttackEvent; import io.github.togar2.pvp.feature.CombatFeatures; import net.minestom.server.coordinate.Pos; @@ -16,10 +16,9 @@ import net.minestom.server.item.ItemStack; import net.minestom.server.item.Material; import org.jetbrains.annotations.NotNull; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; +import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; public class BlockBattle extends StatelessGame { private final Team teamBlue = new Team(new Pos(0,101,20).add(0.5), Team.Color.BLUE); @@ -28,7 +27,7 @@ public class BlockBattle extends StatelessGame { private final Map teams = new WeakHashMap<>(); public BlockBattle() { - super(Dimension.THE_END.key, "Block Battle", new NoScore()); + super(Dimension.THE_END.key, "Block Battle", new FirstWinsScore()); this.eventNode().addChild( CombatFeatures.empty() @@ -55,10 +54,7 @@ public class BlockBattle extends StatelessGame { Pos posGoldBlock = new Pos(playerBlockPlaceEvent.getBlockPosition()).sub(0, 1, 0); Block goldBlock = playerBlockPlaceEvent.getInstance().getBlock(posGoldBlock); - if(goldBlock == Block.GOLD_BLOCK) - playerBlockPlaceEvent.setCancelled(false); - else - playerBlockPlaceEvent.setCancelled(true); + playerBlockPlaceEvent.setCancelled(goldBlock != Block.GOLD_BLOCK); playerBlockPlaceEvent.getInstance().scheduler().scheduleNextTick(() -> { Pos middle = new Pos(0, 101, 0); @@ -87,15 +83,15 @@ public class BlockBattle extends StatelessGame { break; } - if(validBlue) { - super.stop(); - System.out.println("blau"); - } + if(!validBlue && !validRed) return; + var winningTeam = validBlue ? Team.Color.BLUE : Team.Color.RED; + var winningPlayers = this.teams.entrySet().stream() + .filter(entry -> entry.getValue().getColor().equals(winningTeam)) + .map(Map.Entry::getKey) + .collect(Collectors.toSet()); - if(validRed) { - super.stop(); - System.out.println("rot"); - } + this.getScore().insertMultiple(winningPlayers); + super.stop(); }); } @@ -111,8 +107,8 @@ public class BlockBattle extends StatelessGame { Block.RED_CONCRETE, Block.RED_STAINED_GLASS }; - for(int i = 0; i < blockCantBreakList.length; i++) { - if(playerBlockBreakEvent.getBlock().equals(blockCantBreakList[i])) + for(Block block : blockCantBreakList) { + if(playerBlockBreakEvent.getBlock().equals(block)) playerBlockBreakEvent.setCancelled(true); } } @@ -198,7 +194,8 @@ public class BlockBattle extends StatelessGame { } private void setTeams() { - List players = this.getPlayers().stream().toList(); + List players = new ArrayList<>(this.getPlayers()); + Collections.shuffle(players); int halfPlayers = players.size()/2; players.subList(0, halfPlayers).forEach(player -> this.teams.put(player, this.teamBlue)); players.subList(halfPlayers, players.size()).forEach(player -> this.teams.put(player, this.teamRed)); diff --git a/src/main/java/eu/mhsl/minenet/minigames/score/Score.java b/src/main/java/eu/mhsl/minenet/minigames/score/Score.java index cd7982d..967cc0d 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/score/Score.java +++ b/src/main/java/eu/mhsl/minenet/minigames/score/Score.java @@ -30,6 +30,11 @@ public abstract class Score { throw new NotImplementedException("This Score type is not able to process points"); } + public void insertMultiple(Set p) { + p.forEach(player -> this.insertResultProcessor(player, () -> {})); + this.insertResultImplementation(p); + } + public void insertResult(Player p) { this.insertResultProcessor(p, () -> this.insertResultImplementation(Set.of(p))); } diff --git a/src/main/resources/lang/locales.map.csv b/src/main/resources/lang/locales.map.csv index 3c82743..d21bb24 100644 --- a/src/main/resources/lang/locales.map.csv +++ b/src/main/resources/lang/locales.map.csv @@ -177,6 +177,8 @@ description;; ;; ns:game_Pillars#;; name;Pillars;Pillars +description;Build yourself up with your random blocks to reach your opponents and push them down!;Baue dich mit deinen zufälligen Blöcken zu deinen Gegnern und schupse sie runter! ;; ns:game_BlockBattle#;; -name;Block Battle;Block Battle \ No newline at end of file +name;Block Battle;Block Kampf +description;The team that fills the center with their color first wins!;Das Team, welches als erstes die Mitte mit ihrer Farbe gefüllt hat, hat gewonnen! \ No newline at end of file -- 2.30.2 From 7d5fb025bdd53b9f27f1fa22f21a14fbfa429d8b Mon Sep 17 00:00:00 2001 From: jannis Date: Sun, 1 Feb 2026 18:24:36 +0100 Subject: [PATCH 4/7] added setting, refactored code --- .../types/blockBattle/BlockBattle.java | 71 ++++++++----------- .../types/blockBattle/BlockBattleFactory.java | 10 ++- .../stateless/types/blockBattle/Team.java | 14 +++- 3 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java index b4878ab..ec89496 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java @@ -23,12 +23,15 @@ import java.util.stream.Collectors; public class BlockBattle extends StatelessGame { private final Team teamBlue = new Team(new Pos(0,101,20).add(0.5), Team.Color.BLUE); private final Team teamRed = new Team(new Pos(0, 101, -20).add(0.5), Team.Color.RED); + private final int itemCount; private final Map teams = new WeakHashMap<>(); - public BlockBattle() { + public BlockBattle(int itemCount) { super(Dimension.THE_END.key, "Block Battle", new FirstWinsScore()); + this.itemCount = itemCount; + this.eventNode().addChild( CombatFeatures.empty() .add(CombatFeatures.VANILLA_ATTACK) @@ -97,42 +100,26 @@ public class BlockBattle extends StatelessGame { @Override protected void onBlockBreak(@NotNull PlayerBlockBreakEvent playerBlockBreakEvent) { - final Block[] blockCantBreakList = new Block[] { - Block.YELLOW_CONCRETE_POWDER, - Block.GOLD_BLOCK, - Block.BLUE_CONCRETE_POWDER, - Block.BLUE_CONCRETE, - Block.BLUE_STAINED_GLASS, - Block.RED_CONCRETE_POWDER, - Block.RED_CONCRETE, - Block.RED_STAINED_GLASS - }; - for(Block block : blockCantBreakList) { - if(playerBlockBreakEvent.getBlock().equals(block)) - playerBlockBreakEvent.setCancelled(true); - } + boolean isAllowed = Arrays.stream(Team.Color.values()) + .map(Team.Color::getMaterial) + .map(Material::block) + .toList() + .contains(playerBlockBreakEvent.getBlock()); + if(!isAllowed) playerBlockBreakEvent.setCancelled(true); } @Override protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) { - if(playerMoveEvent.getNewPosition().y() < 75) { + if(playerMoveEvent.getNewPosition().y() < 95) { var player = playerMoveEvent.getPlayer(); - if(this.isBeforeBeginning) { - player.teleport(this.getSpawn()); - } else { - player.teleport(this.teams.get(player).getSpawnPosition()); - } + player.teleport( + this.isBeforeBeginning + ? this.getSpawn() + : this.teams.get(player).getSpawnPosition() + ); - player.getInventory().clear(); - if(this.teams.get(player).getColor() == Team.Color.RED) { - ItemStack item = ItemStack.of(Material.RED_WOOL); - player.getInventory().addItemStack(item); - } - if(this.teams.get(player).getColor() == Team.Color.BLUE) { - ItemStack item = ItemStack.of(Material.BLUE_WOOL); - player.getInventory().addItemStack(item); - } + this.giveItems(player); } } @@ -140,17 +127,10 @@ public class BlockBattle extends StatelessGame { protected void onStart() { this.setTeams(); this.getPlayers().forEach(player -> { - player.setGameMode(GameMode.SURVIVAL); - player.teleport(this.teams.get(player).getSpawnPosition()); - - if(this.teams.get(player).getColor() == Team.Color.RED) { - ItemStack item = ItemStack.of(Material.RED_WOOL); - player.getInventory().addItemStack(item); - } - if(this.teams.get(player).getColor() == Team.Color.BLUE) { - ItemStack item = ItemStack.of(Material.BLUE_WOOL); - player.getInventory().addItemStack(item); - } + player.teleport(this.teams.get(player).getSpawnPosition()).thenRun(() -> { + this.giveItems(player); + player.setGameMode(GameMode.SURVIVAL); + }); }); } @@ -205,4 +185,13 @@ public class BlockBattle extends StatelessGame { public Pos getSpawn() { return new Pos(0, 101, 0).add(0.5); } + + private void giveItems(Player player) { + player.getInventory().clear(); + ItemStack item = ItemStack.of( + this.teams.get(player).getColor().getMaterial(), + this.itemCount + ); + player.getInventory().addItemStack(item); + } } diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java index d4b895f..8884337 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattleFactory.java @@ -1,8 +1,10 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; import eu.mhsl.minenet.minigames.instance.game.Game; +import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager; import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory; import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option; +import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption; import eu.mhsl.minenet.minigames.instance.room.Room; import eu.mhsl.minenet.minigames.message.component.TranslatedComponent; import net.minestom.server.item.Material; @@ -20,6 +22,12 @@ public class BlockBattleFactory implements GameFactory { return TranslatedComponent.byId("game_BlockBattle#description"); } + @Override + public ConfigManager configuration() { + return new ConfigManager() + .addOption(new NumericOption("itemCount", Material.WHITE_WOOL, TranslatedComponent.byId("game_BlockBattle#itemCount"), 1, 2, 3)); + } + @Override public Material symbol() { return Material.GREEN_CONCRETE; @@ -27,6 +35,6 @@ public class BlockBattleFactory implements GameFactory { @Override public Game manufacture(Room parent, Map> configuration) throws Exception { - return new BlockBattle().setParent(parent); + return new BlockBattle(configuration.get("itemCount").getAsInt()).setParent(parent); } } diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java index 5dc8f81..b7b7bc3 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java @@ -1,11 +1,21 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; import net.minestom.server.coordinate.Pos; +import net.minestom.server.item.Material; public class Team { public enum Color { - RED, - BLUE + RED(Material.RED_WOOL), + BLUE(Material.BLUE_WOOL); + + private final Material block; + Color(Material block) { + this.block = block; + } + + public Material getMaterial() { + return this.block; + } } private final Pos spawnPosition; private final Color color; -- 2.30.2 From 11ddd014707da365b656d3e7372fc7c52b5c1e70 Mon Sep 17 00:00:00 2001 From: jannis Date: Mon, 2 Feb 2026 19:15:46 +0100 Subject: [PATCH 5/7] pull requestest changes --- .../types/blockBattle/BlockBattle.java | 82 +++++++++++-------- .../stateless/types/blockBattle/Team.java | 18 +--- .../game/stateless/types/pillars/Pillars.java | 13 +-- src/main/resources/lang/locales.map.csv | 3 +- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java index ec89496..11018d6 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/BlockBattle.java @@ -3,6 +3,7 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; import eu.mhsl.minenet.minigames.instance.Dimension; import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame; import eu.mhsl.minenet.minigames.score.FirstWinsScore; +import eu.mhsl.minenet.minigames.util.BatchUtil; import io.github.togar2.pvp.events.FinalAttackEvent; import io.github.togar2.pvp.feature.CombatFeatures; import net.minestom.server.coordinate.Pos; @@ -11,6 +12,7 @@ import net.minestom.server.entity.Player; import net.minestom.server.event.player.PlayerBlockBreakEvent; import net.minestom.server.event.player.PlayerBlockPlaceEvent; import net.minestom.server.event.player.PlayerMoveEvent; +import net.minestom.server.instance.batch.AbsoluteBlockBatch; import net.minestom.server.instance.block.Block; import net.minestom.server.item.ItemStack; import net.minestom.server.item.Material; @@ -21,7 +23,7 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; public class BlockBattle extends StatelessGame { - private final Team teamBlue = new Team(new Pos(0,101,20).add(0.5), Team.Color.BLUE); + private final Team teamBlue = new Team(new Pos(0,101,20).add(0.5).withView(180, 0), Team.Color.BLUE); private final Team teamRed = new Team(new Pos(0, 101, -20).add(0.5), Team.Color.RED); private final int itemCount; @@ -49,7 +51,42 @@ public class BlockBattle extends StatelessGame { @Override protected void onLoad(@NotNull CompletableFuture callback) { - this.generateWorld(); + this.generatePlatform(new Pos(0, 100, 0), Block.GOLD_BLOCK, Block.YELLOW_CONCRETE_POWDER); + this.generatePlatform(new Pos(0, 101, 0), Block.AIR, Block.SANDSTONE_SLAB); + this.generatePlatform(new Pos(0, 100, 20), Block.BLUE_CONCRETE, Block.BLUE_CONCRETE_POWDER); + this.generatePlatform(new Pos(0, 100, -20), Block.RED_CONCRETE, Block.RED_CONCRETE_POWDER); + this.generatePlatform(new Pos(-5, 101, -14), Block.RED_STAINED_GLASS, Block.AIR); + this.generatePlatform(new Pos(5, 101, 14), Block.BLUE_STAINED_GLASS, Block.AIR); + + AbsoluteBlockBatch batch = new AbsoluteBlockBatch(); + + Pos[] positionsRedGlass = { + new Pos(2, 102, -9), + new Pos(-1, 103, -9), + new Pos(-2, 104, -6), + new Pos(-5, 103, -7), + new Pos(-7, 102, -10), + new Pos(3, 102, -12), + new Pos(5, 101, -15) + }; + + Pos[] positionsBlueGlass = { + new Pos(-5, 101, 15), + new Pos(-3, 102, 12), + new Pos(-2, 102, 9), + new Pos(1, 103, 9), + new Pos(2, 104, 6), + new Pos(5, 103, 7), + new Pos(7, 102, 10) + }; + + for(Pos pos : positionsRedGlass) + batch.setBlock(pos, Block.RED_STAINED_GLASS); + + for(Pos pos : positionsBlueGlass) + batch.setBlock(pos, Block.BLUE_STAINED_GLASS); + + BatchUtil.loadAndApplyBatch(batch, this, () -> {}); } @Override @@ -89,7 +126,7 @@ public class BlockBattle extends StatelessGame { if(!validBlue && !validRed) return; var winningTeam = validBlue ? Team.Color.BLUE : Team.Color.RED; var winningPlayers = this.teams.entrySet().stream() - .filter(entry -> entry.getValue().getColor().equals(winningTeam)) + .filter(entry -> entry.getValue().color().equals(winningTeam)) .map(Map.Entry::getKey) .collect(Collectors.toSet()); @@ -116,7 +153,7 @@ public class BlockBattle extends StatelessGame { player.teleport( this.isBeforeBeginning ? this.getSpawn() - : this.teams.get(player).getSpawnPosition() + : this.teams.get(player).spawnPosition() ); this.giveItems(player); @@ -126,12 +163,10 @@ public class BlockBattle extends StatelessGame { @Override protected void onStart() { this.setTeams(); - this.getPlayers().forEach(player -> { - player.teleport(this.teams.get(player).getSpawnPosition()).thenRun(() -> { - this.giveItems(player); - player.setGameMode(GameMode.SURVIVAL); - }); - }); + this.getPlayers().forEach(player -> player.teleport(this.teams.get(player).spawnPosition()).thenRun(() -> { + this.giveItems(player); + player.setGameMode(GameMode.SURVIVAL); + })); } private void generatePlatform(Pos center, Block inner, Block outer) { @@ -148,31 +183,6 @@ public class BlockBattle extends StatelessGame { } } - private void generateWorld() { - this.generatePlatform(new Pos(0, 100, 0), Block.GOLD_BLOCK, Block.YELLOW_CONCRETE_POWDER); - this.generatePlatform(new Pos(0, 101, 0), Block.AIR, Block.YELLOW_CONCRETE_POWDER); - this.generatePlatform(new Pos(0, 100, 20), Block.BLUE_CONCRETE, Block.BLUE_CONCRETE_POWDER); - this.generatePlatform(new Pos(0, 100, -20), Block.RED_CONCRETE, Block.RED_CONCRETE_POWDER); - this.generatePlatform(new Pos(-5, 101, -14), Block.RED_STAINED_GLASS, Block.AIR); - this.generatePlatform(new Pos(5, 101, 14), Block.BLUE_STAINED_GLASS, Block.AIR); - - this.setBlock(new Pos(2, 102, -9), Block.RED_STAINED_GLASS); - this.setBlock(new Pos(-1, 103, -9), Block.RED_STAINED_GLASS); - this.setBlock(new Pos(-2, 104, -6), Block.RED_STAINED_GLASS); - this.setBlock(new Pos(-5, 103, -7), Block.RED_STAINED_GLASS); - this.setBlock(new Pos(-7, 102, -10), Block.RED_STAINED_GLASS); - this.setBlock(new Pos(3, 102, -12), Block.RED_STAINED_GLASS); - this.setBlock(new Pos(5, 101, -15), Block.RED_STAINED_GLASS); - - this.setBlock(new Pos(-5, 101, 15), Block.BLUE_STAINED_GLASS); - this.setBlock(new Pos(-3, 102, 12), Block.BLUE_STAINED_GLASS); - this.setBlock(new Pos(-2, 102, 9), Block.BLUE_STAINED_GLASS); - this.setBlock(new Pos(1, 103, 9), Block.BLUE_STAINED_GLASS); - this.setBlock(new Pos(2, 104, 6), Block.BLUE_STAINED_GLASS); - this.setBlock(new Pos(5, 103, 7), Block.BLUE_STAINED_GLASS); - this.setBlock(new Pos(7, 102, 10), Block.BLUE_STAINED_GLASS); - } - private void setTeams() { List players = new ArrayList<>(this.getPlayers()); Collections.shuffle(players); @@ -189,7 +199,7 @@ public class BlockBattle extends StatelessGame { private void giveItems(Player player) { player.getInventory().clear(); ItemStack item = ItemStack.of( - this.teams.get(player).getColor().getMaterial(), + this.teams.get(player).color().getMaterial(), this.itemCount ); player.getInventory().addItemStack(item); diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java index b7b7bc3..fda428a 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/blockBattle/Team.java @@ -3,12 +3,13 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.blockBattle; import net.minestom.server.coordinate.Pos; import net.minestom.server.item.Material; -public class Team { +public record Team(Pos spawnPosition, Color color) { public enum Color { RED(Material.RED_WOOL), BLUE(Material.BLUE_WOOL); private final Material block; + Color(Material block) { this.block = block; } @@ -17,19 +18,4 @@ public class Team { return this.block; } } - private final Pos spawnPosition; - private final Color color; - - public Team(Pos spawnPosition, Color color) { - this.spawnPosition = spawnPosition; - this.color = color; - } - - public Pos getSpawnPosition() { - return this.spawnPosition; - } - - public Color getColor() { - return this.color; - } } diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java index f621428..d094416 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java @@ -20,13 +20,14 @@ import net.minestom.server.timer.TaskSchedule; import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; class Pillars extends StatelessGame { private int spawnPosx = 0; private int spawnPosz = 0; private final int pillarSpacing = 10; private final int pillarRowCount = 5; + public Pillars() { super(Dimension.THE_END.key, "Pillars", new LastWinsScore()); this.getScore().setIgnoreLastPlayers(1); @@ -71,13 +72,15 @@ class Pillars extends StatelessGame { @Override protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) { - if(this.isBeforeBeginning && Position.hasPositionChanged(playerMoveEvent.getPlayer().getPosition(), playerMoveEvent.getNewPosition())) + var player = playerMoveEvent.getPlayer(); + + if(this.isBeforeBeginning && Position.hasPositionChanged(player.getPosition(), playerMoveEvent.getNewPosition())) playerMoveEvent.setCancelled(true); if(playerMoveEvent.getNewPosition().y() < 80) { this.getScore().insertResult(playerMoveEvent.getPlayer()); - playerMoveEvent.getPlayer().teleport(this.getSpawn()); - playerMoveEvent.getPlayer().setGameMode(GameMode.SPECTATOR); + player.teleport(this.getSpawn()); + player.setGameMode(GameMode.SPECTATOR); } } @@ -90,7 +93,7 @@ class Pillars extends StatelessGame { .filter(material -> !material.equals(Material.AIR)) .toList(); this.getPlayers().forEach(player -> { - ItemStack item = ItemStack.of(materials.get(new Random().nextInt(Material.values().toArray().length))); + ItemStack item = ItemStack.of(materials.get(ThreadLocalRandom.current().nextInt(Material.values().toArray().length))); player.getInventory().addItemStack(item); }); diff --git a/src/main/resources/lang/locales.map.csv b/src/main/resources/lang/locales.map.csv index d21bb24..6cafdea 100644 --- a/src/main/resources/lang/locales.map.csv +++ b/src/main/resources/lang/locales.map.csv @@ -181,4 +181,5 @@ description;Build yourself up with your random blocks to reach your opponents an ;; ns:game_BlockBattle#;; name;Block Battle;Block Kampf -description;The team that fills the center with their color first wins!;Das Team, welches als erstes die Mitte mit ihrer Farbe gefüllt hat, hat gewonnen! \ No newline at end of file +description;The team that fills the center with their color first wins!;Das Team, welches als erstes die Mitte mit ihrer Farbe gefüllt hat, hat gewonnen! +itemCount;Block Count;Block Anzahl \ No newline at end of file -- 2.30.2 From 70fd5bafdb0c28f41a89b6eb19d07861f0f945ce Mon Sep 17 00:00:00 2001 From: jannis Date: Mon, 2 Feb 2026 18:19:45 +0000 Subject: [PATCH 6/7] updated Block Battle description --- src/main/resources/lang/locales.map.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang/locales.map.csv b/src/main/resources/lang/locales.map.csv index 6cafdea..9418927 100644 --- a/src/main/resources/lang/locales.map.csv +++ b/src/main/resources/lang/locales.map.csv @@ -181,5 +181,5 @@ description;Build yourself up with your random blocks to reach your opponents an ;; ns:game_BlockBattle#;; name;Block Battle;Block Kampf -description;The team that fills the center with their color first wins!;Das Team, welches als erstes die Mitte mit ihrer Farbe gefüllt hat, hat gewonnen! +description;The team that fills the center with their color first wins!;Das Team, welches als erstes die Mitte mit seiner Farbe gefüllt hat, gewinnt! itemCount;Block Count;Block Anzahl \ No newline at end of file -- 2.30.2 From 24d79d7a11e49ba3e0c1857e246d4bb8192c8484 Mon Sep 17 00:00:00 2001 From: jannis Date: Mon, 2 Feb 2026 20:04:55 +0100 Subject: [PATCH 7/7] pull requestest changes --- .../instance/game/stateless/types/pillars/Pillars.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java index d094416..7c3e68d 100644 --- a/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java +++ b/src/main/java/eu/mhsl/minenet/minigames/instance/game/stateless/types/pillars/Pillars.java @@ -78,7 +78,7 @@ class Pillars extends StatelessGame { playerMoveEvent.setCancelled(true); if(playerMoveEvent.getNewPosition().y() < 80) { - this.getScore().insertResult(playerMoveEvent.getPlayer()); + this.getScore().insertResult(player); player.teleport(this.getSpawn()); player.setGameMode(GameMode.SPECTATOR); } -- 2.30.2