From b78d4d175a32edcf70f9b576256ef9dcf54db224 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 23 Nov 2021 19:49:46 +0100 Subject: [PATCH] push --- src/main/java/rip/tilly/bedwars/game/Game.java | 4 ++++ .../providers/scoreboard/ScoreboardProvider.java | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/rip/tilly/bedwars/game/Game.java b/src/main/java/rip/tilly/bedwars/game/Game.java index cb58f4a..6588c46 100644 --- a/src/main/java/rip/tilly/bedwars/game/Game.java +++ b/src/main/java/rip/tilly/bedwars/game/Game.java @@ -103,6 +103,10 @@ public class Game { })); } + public void broadcastToOneTeam(String message, GameTeam gameTeam) { + this.teams.stream().filter(team -> team == gameTeam).forEach(team -> team.playingPlayers().forEach(player -> player.sendMessage(CC.translate(message)))); + } + public int decrementCountdown() { return --this.countdown; } diff --git a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java index f57ac66..20247ba 100644 --- a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java +++ b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java @@ -80,7 +80,7 @@ public class ScoreboardProvider implements BoardAdapter { green.setPrefix(String.valueOf(ChatColor.GREEN)); PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId()); - if (playerData.getPlayerState() != PlayerState.PLAYING) { + if (playerData.getPlayerState() != PlayerState.PLAYING && playerData.getPlayerState() != PlayerState.RESPAWNING) { Objective objective = player.getScoreboard().getObjective(DisplaySlot.BELOW_NAME); if (objective != null) { objective.unregister(); @@ -134,6 +134,7 @@ public class ScoreboardProvider implements BoardAdapter { for (UUID teamUUID : team.getPlayingPlayers()) { Player teamPlayer = this.plugin.getServer().getPlayer(teamUUID); if (teamPlayer != null) { + String teamPlayerName = teamPlayer.getName(); if (team.getId() == 1) { if (green.hasEntry(teamPlayerName)) { @@ -266,11 +267,14 @@ public class ScoreboardProvider implements BoardAdapter { lines.add("&7[" + opposingTeam.getPlayerTeam().getChatColor() + opposingTeam.getPlayerTeam().getSmallName() + "&7] &c&l✗"); } lines.add(" "); - Player teamAplayer = yourTeam.playingPlayers().collect(Collectors.toList()).get(0); - lines.add(yourTeam.getPlayerTeam().getChatColor() + (teamAplayer != null ? teamAplayer.getName() : "None")); + + List teamAplayers = yourTeam.playingPlayers().collect(Collectors.toList()); + List teamBplayers = opposingTeam.playingPlayers().collect(Collectors.toList()); + + lines.add(yourTeam.getPlayerTeam().getChatColor() + (teamAplayers.size() > 0 ? teamAplayers.get(0).getName() : "None")); lines.add("&7VS"); - Player teamBplayer = opposingTeam.playingPlayers().collect(Collectors.toList()).get(0); - lines.add(opposingTeam.getPlayerTeam().getChatColor() + (teamBplayer != null ? teamBplayer.getName() : "None")); + + lines.add(opposingTeam.getPlayerTeam().getChatColor() + (teamBplayers.size() > 0 ? teamBplayers.get(0).getName() : "None")); lines.add(" "); lines.add("&dtilly.rip"); lines.add(CC.scoreboardBar);