added pillars and block battle #10

Merged
jannis merged 7 commits from develop-pillars into develop 2026-02-02 19:09:44 +00:00
3 changed files with 25 additions and 21 deletions
Showing only changes of commit 05240660f2 - Show all commits

View File

@@ -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.Dimension;
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame; 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.events.FinalAttackEvent;
import io.github.togar2.pvp.feature.CombatFeatures; import io.github.togar2.pvp.feature.CombatFeatures;
import net.minestom.server.coordinate.Pos; import net.minestom.server.coordinate.Pos;
@@ -16,10 +16,9 @@ import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material; import net.minestom.server.item.Material;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
public class BlockBattle extends StatelessGame { 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), Team.Color.BLUE);
@@ -28,7 +27,7 @@ public class BlockBattle extends StatelessGame {
private final Map<Player, Team> teams = new WeakHashMap<>(); private final Map<Player, Team> teams = new WeakHashMap<>();
public BlockBattle() { public BlockBattle() {
super(Dimension.THE_END.key, "Block Battle", new NoScore()); super(Dimension.THE_END.key, "Block Battle", new FirstWinsScore());
this.eventNode().addChild( this.eventNode().addChild(
CombatFeatures.empty() CombatFeatures.empty()
@@ -55,10 +54,7 @@ public class BlockBattle extends StatelessGame {
Pos posGoldBlock = new Pos(playerBlockPlaceEvent.getBlockPosition()).sub(0, 1, 0); Pos posGoldBlock = new Pos(playerBlockPlaceEvent.getBlockPosition()).sub(0, 1, 0);
Block goldBlock = playerBlockPlaceEvent.getInstance().getBlock(posGoldBlock); Block goldBlock = playerBlockPlaceEvent.getInstance().getBlock(posGoldBlock);
if(goldBlock == Block.GOLD_BLOCK) playerBlockPlaceEvent.setCancelled(goldBlock != Block.GOLD_BLOCK);
playerBlockPlaceEvent.setCancelled(false);
else
playerBlockPlaceEvent.setCancelled(true);
playerBlockPlaceEvent.getInstance().scheduler().scheduleNextTick(() -> { playerBlockPlaceEvent.getInstance().scheduler().scheduleNextTick(() -> {
Pos middle = new Pos(0, 101, 0); Pos middle = new Pos(0, 101, 0);
@@ -87,15 +83,15 @@ public class BlockBattle extends StatelessGame {
break; break;
} }
if(validBlue) { if(!validBlue && !validRed) return;
super.stop(); var winningTeam = validBlue ? Team.Color.BLUE : Team.Color.RED;
System.out.println("blau"); var winningPlayers = this.teams.entrySet().stream()
} .filter(entry -> entry.getValue().getColor().equals(winningTeam))
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
if(validRed) { this.getScore().insertMultiple(winningPlayers);
super.stop(); super.stop();
System.out.println("rot");
}
}); });
} }
@@ -111,8 +107,8 @@ public class BlockBattle extends StatelessGame {
Block.RED_CONCRETE, Block.RED_CONCRETE,
Block.RED_STAINED_GLASS Block.RED_STAINED_GLASS
}; };
for(int i = 0; i < blockCantBreakList.length; i++) { for(Block block : blockCantBreakList) {
if(playerBlockBreakEvent.getBlock().equals(blockCantBreakList[i])) if(playerBlockBreakEvent.getBlock().equals(block))
playerBlockBreakEvent.setCancelled(true); playerBlockBreakEvent.setCancelled(true);
} }
} }
@@ -198,7 +194,8 @@ public class BlockBattle extends StatelessGame {
} }
private void setTeams() { private void setTeams() {
List<Player> players = this.getPlayers().stream().toList(); List<Player> players = new ArrayList<>(this.getPlayers());
Collections.shuffle(players);
int halfPlayers = players.size()/2; int halfPlayers = players.size()/2;
players.subList(0, halfPlayers).forEach(player -> this.teams.put(player, this.teamBlue)); 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)); players.subList(halfPlayers, players.size()).forEach(player -> this.teams.put(player, this.teamRed));

View File

@@ -30,6 +30,11 @@ public abstract class Score {
throw new NotImplementedException("This Score type is not able to process points"); throw new NotImplementedException("This Score type is not able to process points");
} }
public void insertMultiple(Set<Player> p) {
p.forEach(player -> this.insertResultProcessor(player, () -> {}));
this.insertResultImplementation(p);
}
public void insertResult(Player p) { public void insertResult(Player p) {
this.insertResultProcessor(p, () -> this.insertResultImplementation(Set.of(p))); this.insertResultProcessor(p, () -> this.insertResultImplementation(Set.of(p)));
} }

View File

@@ -177,6 +177,8 @@ description;;
;; ;;
ns:game_Pillars#;; ns:game_Pillars#;;
name;Pillars;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#;; ns:game_BlockBattle#;;
name;Block Battle;Block Battle 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!
jannis marked this conversation as resolved Outdated
Outdated
Review

Das Team, welches als erstes die Mitte mit seiner Farbe gefüllt hat, gewinnt!

Das Team, welches als erstes die Mitte mit seiner Farbe gefüllt hat, gewinnt!
1 map en_us de_de
177
178 ns:game_Pillars#
179 name Pillars Pillars
180 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!
181
182 ns:game_BlockBattle#
183 name Block Battle Block Battle Block Kampf
184 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!