Make addToScoreboard public and reset team scores.
Changed addToScoreboard visibility to public for external usage, allowing it to be called when a player joins a team. Added a reset for team scores in the Flag class to ensure scores are cleared when resetting the game state.
This commit is contained in:
parent
57f2898451
commit
409a1aa596
|
|
@ -64,6 +64,7 @@ public class OnPlayerOnlineStatus implements Listener {
|
||||||
teamPlayer = min.get().addPlayer(player);
|
teamPlayer = min.get().addPlayer(player);
|
||||||
} else {
|
} else {
|
||||||
teamPlayer = optionalTeamPlayer.get();
|
teamPlayer = optionalTeamPlayer.get();
|
||||||
|
teamPlayer.getTeam().addToScoreboard(player);
|
||||||
}
|
}
|
||||||
FighterCreator.createFighter(teamPlayer.getTeam().getColor())
|
FighterCreator.createFighter(teamPlayer.getTeam().getColor())
|
||||||
.apply(teamPlayer, worldBorderApi, gamePhase, true);
|
.apply(teamPlayer, worldBorderApi, gamePhase, true);
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,7 @@ public class Flag implements Runnable {
|
||||||
resetFlagCarrier();
|
resetFlagCarrier();
|
||||||
resetFlag();
|
resetFlag();
|
||||||
wins.clear();
|
wins.clear();
|
||||||
|
gameManager.getTeams().forEach(team -> team.setScore(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCarrierDeathOrDisconnect(Player player) {
|
public void handleCarrierDeathOrDisconnect(Player player) {
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ public class Team {
|
||||||
log.debug("Removed player {} from team with id {}", player.getName(), id);
|
log.debug("Removed player {} from team with id {}", player.getName(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToScoreboard(Player player) {
|
public void addToScoreboard(Player player) {
|
||||||
org.bukkit.scoreboard.Team team = scoreboard.getTeam("ctf_" + id);
|
org.bukkit.scoreboard.Team team = scoreboard.getTeam("ctf_" + id);
|
||||||
if (team == null) {
|
if (team == null) {
|
||||||
team = scoreboard.registerNewTeam("ctf_" + id);
|
team = scoreboard.registerNewTeam("ctf_" + id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user