|
3 | 3 | import dev.pgm.events.EventsPlugin; |
4 | 4 | import dev.pgm.events.team.TournamentPlayer; |
5 | 5 | import dev.pgm.events.team.TournamentTeam; |
| 6 | +import dev.pgm.events.team.TournamentTeamManager; |
6 | 7 | import java.util.Collection; |
7 | 8 | import java.util.stream.Collectors; |
8 | 9 | import org.bukkit.Bukkit; |
|
11 | 12 | import org.bukkit.event.HandlerList; |
12 | 13 | import rip.bolt.ingame.Ingame; |
13 | 14 | import rip.bolt.ingame.api.definitions.BoltMatch; |
| 15 | +import rip.bolt.ingame.api.definitions.MatchStatus; |
14 | 16 | import rip.bolt.ingame.config.AppData; |
15 | 17 | import rip.bolt.ingame.events.BoltMatchResponseEvent; |
| 18 | +import rip.bolt.ingame.events.BoltMatchStatusChangeEvent; |
16 | 19 | import rip.bolt.ingame.managers.GameManager; |
17 | 20 | import rip.bolt.ingame.managers.MatchManager; |
18 | 21 | import rip.bolt.ingame.ranked.forfeit.PlayerWatcher; |
@@ -87,6 +90,24 @@ public void onBoltMatchResponse(BoltMatchResponseEvent event) { |
87 | 90 | } |
88 | 91 | } |
89 | 92 |
|
| 93 | + @EventHandler(priority = EventPriority.MONITOR) |
| 94 | + public void onBoltStatusChange(BoltMatchStatusChangeEvent event) { |
| 95 | + // Set the PGM teams to be same size as participant count |
| 96 | + if (event.getOldStatus() == MatchStatus.CREATED |
| 97 | + && event.getNewStatus().equals(MatchStatus.LOADED)) { |
| 98 | + TournamentTeamManager teamManager = EventsPlugin.get().getTeamManager(); |
| 99 | + event |
| 100 | + .getBoltMatch() |
| 101 | + .getTeams() |
| 102 | + .forEach( |
| 103 | + boltTeam -> |
| 104 | + teamManager |
| 105 | + .fromTournamentTeam(boltTeam) |
| 106 | + .ifPresent( |
| 107 | + team -> team.setMaxSize(boltTeam.getParticipations().size(), null))); |
| 108 | + } |
| 109 | + } |
| 110 | + |
90 | 111 | private void sendRequeueMessage(Match match) { |
91 | 112 | match.getCompetitors().stream() |
92 | 113 | .map(Competitor::getPlayers) |
|
0 commit comments