added scores and translations

This commit is contained in:
2026-02-01 17:37:37 +01:00
parent d0031b4ea5
commit 05240660f2
3 changed files with 25 additions and 21 deletions

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.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<Player, Team> 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<Player> players = this.getPlayers().stream().toList();
List<Player> 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));

View File

@@ -30,6 +30,11 @@ public abstract class Score {
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) {
this.insertResultProcessor(p, () -> this.insertResultImplementation(Set.of(p)));
}

View File

@@ -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
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!
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!