Prevent duplicate game end announcements and update RoundService initialization to include PlayerTeleporterService.

This commit is contained in:
akastijn 2026-06-27 22:17:50 +02:00
parent 29c46ba485
commit a3085ad4b4
2 changed files with 6 additions and 1 deletions

View File

@ -38,8 +38,8 @@ public final class Main extends JavaPlugin {
round = Round.createSingletonInstance(); round = Round.createSingletonInstance();
lootService = new LootService(); lootService = new LootService();
statService = new StatService(this, round); statService = new StatService(this, round);
roundService = RoundService.createSingletonInstance(round, this, lootService, statService);
playerTeleporterService = PlayerTeleporterService.createSingletonInstance(); playerTeleporterService = PlayerTeleporterService.createSingletonInstance();
roundService = RoundService.createSingletonInstance(round, this, lootService, statService, playerTeleporterService);
playerService = PlayerService.createSingletonInstance(round, roundService, playerTeleporterService); playerService = PlayerService.createSingletonInstance(round, roundService, playerTeleporterService);
bossBarService = BossBarService.createSingletonInstance(round, roundService); bossBarService = BossBarService.createSingletonInstance(round, roundService);

View File

@ -3,6 +3,7 @@ package com.alttd.hunger_games.services;
import com.alttd.hunger_games.Main; import com.alttd.hunger_games.Main;
import com.alttd.hunger_games.config.Messages; import com.alttd.hunger_games.config.Messages;
import com.alttd.hunger_games.data_objects.DESTINATION; import com.alttd.hunger_games.data_objects.DESTINATION;
import com.alttd.hunger_games.data_objects.GameStage;
import com.alttd.hunger_games.data_objects.PLAYER_STATE; import com.alttd.hunger_games.data_objects.PLAYER_STATE;
import com.alttd.hunger_games.data_objects.ROUND_STATE; import com.alttd.hunger_games.data_objects.ROUND_STATE;
import com.alttd.hunger_games.event_listeners.PlayerMovementListener; import com.alttd.hunger_games.event_listeners.PlayerMovementListener;
@ -127,6 +128,10 @@ public class RoundService implements RoundListener {
}); });
startFreeze(); startFreeze();
} }
if (roundState.equals(ROUND_STATE.ENDED)) {
//Don't announce the game ended since we already declare a winner
return;
}
Bukkit.broadcast(MiniMessage.miniMessage().deserialize(Messages.GAME.NEXT_STATE, Placeholder.parsed("round", roundState.getHumanReadableName()))); Bukkit.broadcast(MiniMessage.miniMessage().deserialize(Messages.GAME.NEXT_STATE, Placeholder.parsed("round", roundState.getHumanReadableName())));
} }