Refactor world border handling for game phases.

Removed world border size from `GamePhase` and centralized configuration in `GameConfig`. Updated logic to use `WorldBorderSettings` dynamically, ensuring all phases define valid world border behavior. Adjusted related methods to improve maintainability and clarity.
This commit is contained in:
2025-02-08 23:06:10 +01:00
parent 728e8b7486
commit 8718ca0918
4 changed files with 24 additions and 10 deletions
@@ -1,5 +1,8 @@
package com.alttd.ctf.team;
import com.alttd.ctf.config.GameConfig;
import com.alttd.ctf.config.WorldBorderSettings;
import com.alttd.ctf.config.WorldBorderType;
import com.alttd.ctf.game.GamePhase;
import com.alttd.ctf.game_class.GameClass;
import com.alttd.ctf.game_class.GameClassRetrieval;
@@ -48,12 +51,15 @@ public class TeamPlayer {
}
public void resetWorldBorder(Player player, WorldBorderApi worldBorderApi, GamePhase gamePhase, Location worldBorderCenter) {
double worldBorderSize = gamePhase.getWorldBorderSize();
if (worldBorderSize <= 0) {
WorldBorderSettings worldBorderSettings = GameConfig.WORLD_BORDER.getGAME_PHASE_WORLD_BORDER().get(gamePhase);
if (worldBorderSettings == null) {
throw new IllegalStateException("All phases need to have world border settings");
}
if (worldBorderSettings.type().equals(WorldBorderType.FLAG)) {
worldBorderApi.resetWorldBorderToGlobal(player);
return;
}
worldBorderApi.setBorder(player, worldBorderSize, worldBorderCenter);
worldBorderApi.setBorder(player, worldBorderSettings.size(), worldBorderCenter);
}
@Override