diff --git a/src/main/java/com/alttd/hunger_games/config/Config.java b/src/main/java/com/alttd/hunger_games/config/Config.java index 5600844..5f6e104 100644 --- a/src/main/java/com/alttd/hunger_games/config/Config.java +++ b/src/main/java/com/alttd/hunger_games/config/Config.java @@ -2,7 +2,6 @@ package com.alttd.hunger_games.config; import com.alttd.hunger_games.data_objects.GameStage; import lombok.extern.slf4j.Slf4j; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; @@ -43,7 +42,7 @@ public class Config extends AbstractConfig { public static Duration COUNTDOWN = Duration.ofSeconds(10); public static Duration SAFE_PHASE = Duration.ofSeconds(30); - public static Duration KILL_PHASE = Duration.ofMinutes(5); + public static Duration TIME_TO_FINALE = Duration.ofMinutes(5); public static int INITIAL_BORDER_SIZE = 5000; public static List STAGES = List.of( GameStage.builder().duration(Duration.ofMinutes(5)).worldBorderSize(1000).build(), @@ -57,8 +56,8 @@ public class Config extends AbstractConfig { COUNTDOWN = Duration.ofSeconds(countdownSeconds); int safePhaseSeconds = config.getInt(prefix, "safe-phase-seconds", Math.toIntExact(SAFE_PHASE.toSeconds())); SAFE_PHASE = Duration.ofSeconds(safePhaseSeconds); - int killPhaseSeconds = config.getInt(prefix, "kill-phase-seconds", Math.toIntExact(KILL_PHASE.toSeconds())); - KILL_PHASE = Duration.ofSeconds(killPhaseSeconds); + int killPhaseSeconds = config.getInt(prefix, "time-to-finale-seconds", Math.toIntExact(TIME_TO_FINALE.toSeconds())); + TIME_TO_FINALE = Duration.ofSeconds(killPhaseSeconds); INITIAL_BORDER_SIZE = config.getInt(prefix, "initial-border-size", INITIAL_BORDER_SIZE); ConfigurationSection configurationSection = config.getConfigurationSection(prefix + "stages"); diff --git a/src/main/java/com/alttd/hunger_games/event_listeners/PlayerDamageListener.java b/src/main/java/com/alttd/hunger_games/event_listeners/PlayerDamageListener.java index 255ac0b..1f1800f 100644 --- a/src/main/java/com/alttd/hunger_games/event_listeners/PlayerDamageListener.java +++ b/src/main/java/com/alttd/hunger_games/event_listeners/PlayerDamageListener.java @@ -7,6 +7,7 @@ import com.alttd.hunger_games.services.StatService; import lombok.RequiredArgsConstructor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -39,7 +40,7 @@ public class PlayerDamageListener implements Listener { } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerDeath(PlayerDeathEvent event) { Player player = event.getPlayer(); event.setShowDeathMessages(false); diff --git a/src/main/java/com/alttd/hunger_games/services/PlayerService.java b/src/main/java/com/alttd/hunger_games/services/PlayerService.java index 55242e0..64d37bd 100644 --- a/src/main/java/com/alttd/hunger_games/services/PlayerService.java +++ b/src/main/java/com/alttd/hunger_games/services/PlayerService.java @@ -4,6 +4,7 @@ import com.alttd.hunger_games.config.Messages; import com.alttd.hunger_games.data_objects.DESTINATION; import com.alttd.hunger_games.data_objects.PLAYER_STATE; import com.alttd.hunger_games.data_objects.ROUND_STATE; +import lombok.extern.slf4j.Slf4j; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.Bukkit; @@ -13,6 +14,7 @@ import org.bukkit.event.player.PlayerRespawnEvent; import java.util.*; +@Slf4j public class PlayerService implements RoundListener { private static PlayerService instance = null; @@ -52,13 +54,14 @@ public class PlayerService implements RoundListener { } case FINALE -> { Set players = roundService.getPlayers(PLAYER_STATE.REGISTERED); + log.info("Teleporting players {} to finale area", players); Bukkit.getOnlinePlayers().stream() .filter(player -> players.contains(player.getUniqueId())) .forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.FINALE_AREA)); } case ENDED -> { roundService.clear(); - Bukkit.getOnlinePlayers().forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.START_AREA)); + Bukkit.getOnlinePlayers().forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.SPECTATOR_AREA)); } } } diff --git a/src/main/java/com/alttd/hunger_games/services/Round.java b/src/main/java/com/alttd/hunger_games/services/Round.java index 951e8d3..1536906 100644 --- a/src/main/java/com/alttd/hunger_games/services/Round.java +++ b/src/main/java/com/alttd/hunger_games/services/Round.java @@ -128,7 +128,7 @@ public class Round { } if (gameStageList.size() <= index) { - nextStage(); // Transition to FINALE + startCountdown(Config.ROUND.TIME_TO_FINALE, this::nextStage); return; } diff --git a/src/main/java/com/alttd/hunger_games/services/RoundService.java b/src/main/java/com/alttd/hunger_games/services/RoundService.java index ac1e3a9..3f6c3b3 100644 --- a/src/main/java/com/alttd/hunger_games/services/RoundService.java +++ b/src/main/java/com/alttd/hunger_games/services/RoundService.java @@ -3,7 +3,6 @@ package com.alttd.hunger_games.services; import com.alttd.hunger_games.Main; import com.alttd.hunger_games.config.Messages; 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.ROUND_STATE; import com.alttd.hunger_games.event_listeners.PlayerMovementListener; diff --git a/src/main/java/com/alttd/hunger_games/services/StatService.java b/src/main/java/com/alttd/hunger_games/services/StatService.java index 34913c3..a82ed4e 100644 --- a/src/main/java/com/alttd/hunger_games/services/StatService.java +++ b/src/main/java/com/alttd/hunger_games/services/StatService.java @@ -45,8 +45,10 @@ public class StatService implements RoundListener { @Override public void stateChange(ROUND_STATE roundState) { - if (roundState == ROUND_STATE.PLAYER_REGISTRATION) { + if (roundState.equals(ROUND_STATE.FINALE)) { saveRoundStats(); + } + if (roundState.equals(ROUND_STATE.PLAYER_REGISTRATION)) { currentRoundStats.clear(); } }