Add logging to PlayerService for teleports, adjust ROUND_STATE handling, and use @Slf4j annotation for consistency. Update countdown logic in Round and refactor configuration keys for finale timing.
This commit is contained in:
parent
fe10d57978
commit
244f8f6df7
|
|
@ -2,7 +2,6 @@ package com.alttd.hunger_games.config;
|
||||||
|
|
||||||
import com.alttd.hunger_games.data_objects.GameStage;
|
import com.alttd.hunger_games.data_objects.GameStage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
|
@ -43,7 +42,7 @@ public class Config extends AbstractConfig {
|
||||||
|
|
||||||
public static Duration COUNTDOWN = Duration.ofSeconds(10);
|
public static Duration COUNTDOWN = Duration.ofSeconds(10);
|
||||||
public static Duration SAFE_PHASE = Duration.ofSeconds(30);
|
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 int INITIAL_BORDER_SIZE = 5000;
|
||||||
public static List<GameStage> STAGES = List.of(
|
public static List<GameStage> STAGES = List.of(
|
||||||
GameStage.builder().duration(Duration.ofMinutes(5)).worldBorderSize(1000).build(),
|
GameStage.builder().duration(Duration.ofMinutes(5)).worldBorderSize(1000).build(),
|
||||||
|
|
@ -57,8 +56,8 @@ public class Config extends AbstractConfig {
|
||||||
COUNTDOWN = Duration.ofSeconds(countdownSeconds);
|
COUNTDOWN = Duration.ofSeconds(countdownSeconds);
|
||||||
int safePhaseSeconds = config.getInt(prefix, "safe-phase-seconds", Math.toIntExact(SAFE_PHASE.toSeconds()));
|
int safePhaseSeconds = config.getInt(prefix, "safe-phase-seconds", Math.toIntExact(SAFE_PHASE.toSeconds()));
|
||||||
SAFE_PHASE = Duration.ofSeconds(safePhaseSeconds);
|
SAFE_PHASE = Duration.ofSeconds(safePhaseSeconds);
|
||||||
int killPhaseSeconds = config.getInt(prefix, "kill-phase-seconds", Math.toIntExact(KILL_PHASE.toSeconds()));
|
int killPhaseSeconds = config.getInt(prefix, "time-to-finale-seconds", Math.toIntExact(TIME_TO_FINALE.toSeconds()));
|
||||||
KILL_PHASE = Duration.ofSeconds(killPhaseSeconds);
|
TIME_TO_FINALE = Duration.ofSeconds(killPhaseSeconds);
|
||||||
INITIAL_BORDER_SIZE = config.getInt(prefix, "initial-border-size", INITIAL_BORDER_SIZE);
|
INITIAL_BORDER_SIZE = config.getInt(prefix, "initial-border-size", INITIAL_BORDER_SIZE);
|
||||||
|
|
||||||
ConfigurationSection configurationSection = config.getConfigurationSection(prefix + "stages");
|
ConfigurationSection configurationSection = config.getConfigurationSection(prefix + "stages");
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.alttd.hunger_games.services.StatService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
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) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
event.setShowDeathMessages(false);
|
event.setShowDeathMessages(false);
|
||||||
|
|
|
||||||
|
|
@ -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.DESTINATION;
|
||||||
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 lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -13,6 +14,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class PlayerService implements RoundListener {
|
public class PlayerService implements RoundListener {
|
||||||
|
|
||||||
private static PlayerService instance = null;
|
private static PlayerService instance = null;
|
||||||
|
|
@ -52,13 +54,14 @@ public class PlayerService implements RoundListener {
|
||||||
}
|
}
|
||||||
case FINALE -> {
|
case FINALE -> {
|
||||||
Set<UUID> players = roundService.getPlayers(PLAYER_STATE.REGISTERED);
|
Set<UUID> players = roundService.getPlayers(PLAYER_STATE.REGISTERED);
|
||||||
|
log.info("Teleporting players {} to finale area", players);
|
||||||
Bukkit.getOnlinePlayers().stream()
|
Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> players.contains(player.getUniqueId()))
|
.filter(player -> players.contains(player.getUniqueId()))
|
||||||
.forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.FINALE_AREA));
|
.forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.FINALE_AREA));
|
||||||
}
|
}
|
||||||
case ENDED -> {
|
case ENDED -> {
|
||||||
roundService.clear();
|
roundService.clear();
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.START_AREA));
|
Bukkit.getOnlinePlayers().forEach(player -> playerTeleporterService.teleportPlayer(player, DESTINATION.SPECTATOR_AREA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ public class Round {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameStageList.size() <= index) {
|
if (gameStageList.size() <= index) {
|
||||||
nextStage(); // Transition to FINALE
|
startCountdown(Config.ROUND.TIME_TO_FINALE, this::nextStage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ 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;
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,10 @@ public class StatService implements RoundListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChange(ROUND_STATE roundState) {
|
public void stateChange(ROUND_STATE roundState) {
|
||||||
if (roundState == ROUND_STATE.PLAYER_REGISTRATION) {
|
if (roundState.equals(ROUND_STATE.FINALE)) {
|
||||||
saveRoundStats();
|
saveRoundStats();
|
||||||
|
}
|
||||||
|
if (roundState.equals(ROUND_STATE.PLAYER_REGISTRATION)) {
|
||||||
currentRoundStats.clear();
|
currentRoundStats.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user