From 12e085600eeb61b721d82bfce7c2be4c01aadfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Sp=C3=A4th?= Date: Fri, 24 Jul 2026 12:51:03 +0200 Subject: [PATCH] Move arena runtime configuration into GameCore - Replace FightSystem runtime properties with shared GameConfig - Update dependent modules, commands, states, and tests --- .../src/de/steamwar/fightsystem/Config.java | 36 ++-------- .../de/steamwar/fightsystem/FightSystem.java | 15 +++-- .../de/steamwar/fightsystem/ai/AIManager.java | 4 +- .../de/steamwar/fightsystem/commands/GUI.java | 15 +++-- .../fightsystem/commands/GamemodeCommand.java | 3 +- .../fightsystem/commands/SkipCommand.java | 4 +- .../commands/TechhiderbugCommand.java | 3 +- .../countdown/EventSpectateCountdown.java | 3 +- .../countdown/NoPlayersOnlineCountdown.java | 3 +- .../countdown/PostSchemCountdown.java | 5 +- .../countdown/PreRunningCountdown.java | 3 +- .../countdown/PreSchemCountdown.java | 3 +- .../countdown/SpectateOverCountdown.java | 5 +- .../fightsystem/event/PersistentDamage.java | 4 +- .../de/steamwar/fightsystem/fight/Fight.java | 7 +- .../fightsystem/fight/FightSchematic.java | 9 +-- .../steamwar/fightsystem/fight/FightTeam.java | 19 +++--- .../fightsystem/fight/FightWorld.java | 3 +- .../steamwar/fightsystem/listener/Check.java | 4 +- .../fightsystem/listener/Permanent.java | 3 +- .../fightsystem/listener/PistonListener.java | 3 +- .../fightsystem/listener/PrepareSchem.java | 3 +- .../fightsystem/listener/Shutdown.java | 5 +- .../fightsystem/listener/TestJoin.java | 4 +- .../fightsystem/record/FileRecorder.java | 3 +- .../fightsystem/record/FileSource.java | 8 +-- .../fightsystem/record/PacketProcessor.java | 5 +- .../steamwar/fightsystem/record/Recorder.java | 3 +- .../states/OneShotStateDependent.java | 3 +- .../fightsystem/states/StateDependent.java | 3 +- .../states/StateDependentCommand.java | 4 +- .../states/StateDependentListener.java | 3 +- .../states/StateDependentTask.java | 3 +- .../fightsystem/utils/FightStatistics.java | 3 +- .../fightsystem/utils/TechHiderWrapper.java | 3 +- GameCore/README.md | 2 +- .../src/de/steamwar/gamecore/ArenaMode.kt | 11 ---- .../src/de/steamwar/gamecore/GameConfig.kt | 65 +++++++++++++++++++ .../gamecore/config/GameRuntimeProperties.kt | 63 ------------------ .../de/steamwar/gamecore/ArenaModeTest.kt | 31 ++++----- .../de/steamwar/gamecore/GameConfigTest.kt | 22 +++++++ .../config/GameRuntimePropertiesTest.kt | 50 -------------- .../src/de/steamwar/misslewars/Config.java | 11 ++-- .../tntleague/config/TNTLeagueConfig.kt | 12 ++-- .../de/steamwar/towerrun/config/Config.java | 7 +- 45 files changed, 216 insertions(+), 265 deletions(-) create mode 100644 GameCore/src/de/steamwar/gamecore/GameConfig.kt delete mode 100644 GameCore/src/de/steamwar/gamecore/config/GameRuntimeProperties.kt create mode 100644 GameCore/testsrc/de/steamwar/gamecore/GameConfigTest.kt delete mode 100644 GameCore/testsrc/de/steamwar/gamecore/config/GameRuntimePropertiesTest.kt diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 144e5260..34ae6f7b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -22,8 +22,7 @@ package de.steamwar.fightsystem; import de.steamwar.data.GameModeConfigUtils; import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.winconditions.Winconditions; -import de.steamwar.gamecore.ArenaMode; -import de.steamwar.gamecore.config.GameRuntimeProperties; +import de.steamwar.gamecore.GameConfig; import de.steamwar.sql.*; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -37,7 +36,6 @@ import org.bukkit.util.Vector; import java.io.File; import java.util.Collections; import java.util.Set; -import java.util.UUID; import java.util.logging.Level; public class Config { @@ -46,7 +44,6 @@ public class Config { } public static final World world = Bukkit.getWorlds().get(0); - public static final GameRuntimeProperties RuntimeProperties = GameRuntimeProperties.load(); public static final GameModeConfig GameModeConfig; @@ -78,8 +75,6 @@ public class Config { public static final String TeamBlueName; public static final String TeamRedColor; public static final String TeamBlueColor; - public static final UUID BlueLeader; - public static final UUID RedLeader; //event parameter public static final EventFight EventKampf; @@ -90,23 +85,12 @@ public class Config { public static final int MaximumTeamMembers; public static final boolean LiveReplay; - //check parameter - public static final int CheckSchemID; - public static final int PrepareSchemID; - - public static final ArenaMode mode; - //replay system parameter public static final String spectateIP = "127.0.0.1"; public static final int SpectatePort; - public static final int ReplayID; static { - CheckSchemID = RuntimeProperties.getCheckSchematicId(); - PrepareSchemID = RuntimeProperties.getPrepareSchematicId(); - ReplayID = RuntimeProperties.getReplayId(); - - String configFile = RuntimeProperties.getConfigFile(); + String configFile = GameConfig.ConfigFile; if (!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) { FightSystem.getPlugin().saveDefaultConfig(); Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!"); @@ -212,7 +196,7 @@ public class Config { BlueInsetRegion = new Region(BluePasteRegion.getMinX() + GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMinY() + GameModeConfig.Schematic.Inset.bottom, BluePasteRegion.getMinZ() + GameModeConfig.Schematic.Inset.z, BluePasteRegion.getMaxX() - GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMaxY() - GameModeConfig.Schematic.Inset.top, BluePasteRegion.getMaxZ() - GameModeConfig.Schematic.Inset.z); - int eventKampfID = RuntimeProperties.getFightId(); + int eventKampfID = GameConfig.EventKampfID; if (eventKampfID >= 1) { EventKampf = EventFight.byId(eventKampfID); if (EventKampf == null) { @@ -264,20 +248,8 @@ public class Config { Referees = Collections.emptySet(); MaximumTeamMembers = Integer.MAX_VALUE; LiveReplay = false; - SpectatePort = -ReplayID; + SpectatePort = -GameConfig.ReplayID; } - - BlueLeader = RuntimeProperties.getBlueLeader(); - RedLeader = RuntimeProperties.getRedLeader(); - mode = ArenaMode.from(RuntimeProperties); - } - - public static boolean test() { - return ArenaMode.Test.contains(mode); - } - - public static boolean replayserver() { - return RuntimeProperties.isReplayServer(); } public static boolean blueNegZ() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index a512593e..c730e08d 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -37,6 +37,7 @@ import de.steamwar.fightsystem.utils.HullHider; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.TechHiderWrapper; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.linkage.AbstractLinker; import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; @@ -76,7 +77,7 @@ public class FightSystem extends JavaPlugin { } if (Config.SpectatePort != 0) { Core.setServerName("Spectate"); - } else if (Config.ReplayID != 0) { + } else if (GameConfig.ReplayID != 0) { Core.setServerName("Replay"); } @@ -110,7 +111,7 @@ public class FightSystem extends JavaPlugin { }); new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f)); new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new); - Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode)); + Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(GameConfig.mode)); hullHider = new HullHider(); techHider = new TechHiderWrapper(hullHider); @@ -119,10 +120,10 @@ public class FightSystem extends JavaPlugin { FileSource.startReplay(); - if (Config.mode == ArenaMode.EVENT) { + if (GameConfig.mode == ArenaMode.EVENT) { FightState.setFightState(FightState.PRE_SCHEM_SETUP); - } else if (Config.mode == ArenaMode.CHECK) { - SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID); + } else if (GameConfig.mode == ArenaMode.CHECK) { + SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(GameConfig.CheckSchemID); Fight.getBlueTeam().setSchem(checkSchematicNode); if (checkSchematicNode.isPrepared()) { @@ -130,8 +131,8 @@ public class FightSystem extends JavaPlugin { } new TechareaCommand(); - } else if (Config.mode == ArenaMode.PREPARE) { - Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID)); + } else if (GameConfig.mode == ArenaMode.PREPARE) { + Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(GameConfig.PrepareSchemID)); } Config.world.setGameRule(GameRule.LOCATOR_BAR, false); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java index 67fb8e12..660a0e29 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java @@ -20,7 +20,7 @@ package de.steamwar.fightsystem.ai; import de.steamwar.gamecore.ArenaMode; -import de.steamwar.fightsystem.Config; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.fight.FightTeam; import lombok.AllArgsConstructor; import lombok.Getter; @@ -35,7 +35,7 @@ import java.util.stream.Collectors; @AllArgsConstructor public class AIManager { private static final List AIs = Arrays.asList( - new AIManager("DummyAI", DummyAI::new, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)) + new AIManager("DummyAI", DummyAI::new, Material.STONE, () -> ArenaMode.Test.contains(GameConfig.mode)) ); public static List availableAIs() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java index 7ff85cd0..d0946229 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.commands; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.ai.AIManager; @@ -56,7 +57,7 @@ public class GUI { inv.setItem(pos, ColorConverter.chat2dye(team.getColor()), msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> { p.closeInventory(); - if (ArenaMode.ManualTeams.contains(Config.mode) && team.canbeLeader(p)) { + if (ArenaMode.ManualTeams.contains(GameConfig.mode) && team.canbeLeader(p)) { team.addMember(p); } else { JoinRequest.forPlayer(p, team); @@ -198,7 +199,7 @@ public class GUI { } public static void preSchemDialog(Player p) { - if (!Config.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP) { + if (!GameConfig.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP) { msg.sendPrefixless("SCHEM_NO_ENEMY", p, ChatMessageType.ACTION_BAR); return; } @@ -209,7 +210,7 @@ public class GUI { for (int i = 0; i < Config.GameModeConfig.Schematic.SubTypes.size(); i++) { setupSchemTypeRow(p, inv, Config.GameModeConfig.Schematic.SubTypes.get(i), i + 1); } - if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) { + if (!GameConfig.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) { SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameModeConfig.GameName, (Integer) null); if (node != null) { inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> { @@ -233,14 +234,14 @@ public class GUI { return; } - if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(Config.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) { + if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(GameConfig.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) { inv.setItem(row * 9 + 4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, type.name()), (ClickType click) -> { p.closeInventory(); schemDialog(p, type, false, true); }); } - if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !Config.test()) { + if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !GameConfig.test()) { inv.setItem(row * 9, Material.GRAY_DYE, (byte) 8, msg.parse("SCHEM_NO_PRIVATE", p, type.name()), (ClickType click) -> { }); return; @@ -253,7 +254,7 @@ public class GUI { } private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked) { - SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> { + SchematicSelector selector = new SchematicSelector(p, GameConfig.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> { schemSelect(p, node); }); selector.setPublicMode(publicSchems ? SchematicSelector.PublicMode.PUBLIC_ONLY : SchematicSelector.PublicMode.PRIVATE_ONLY); @@ -263,7 +264,7 @@ public class GUI { private static void schemSelect(Player p, SchematicNode node) { FightTeam fightTeam = Fight.getPlayerTeam(p); if (fightTeam == null) return; - if (Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) { + if (GameConfig.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) { fightTeam.pasteSchem(node); } p.closeInventory(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java index 1ac59065..f826140f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java @@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands; import com.google.common.collect.ImmutableList; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.gamecore.GameConfig; import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; @@ -65,7 +66,7 @@ public class GamemodeCommand extends BukkitCommand { Player p = (Player) sender; - if (!(Config.test() || Config.isReferee(p))) { + if (!(GameConfig.test() || Config.isReferee(p))) { FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR); return false; } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java index ab7d6fc7..50a8aee2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java @@ -20,7 +20,7 @@ package de.steamwar.fightsystem.commands; import de.steamwar.gamecore.ArenaMode; -import de.steamwar.fightsystem.Config; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.record.PacketProcessor; import de.steamwar.fightsystem.states.FightState; @@ -35,7 +35,7 @@ import org.bukkit.entity.Player; public class SkipCommand implements CommandExecutor { public SkipCommand() { - new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip", this); + new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(GameConfig.mode) ? FightState.All : FightState.TeamFix, "skip", this); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java index 58015a9e..754512f1 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.commands; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -49,7 +50,7 @@ public class TechhiderbugCommand implements CommandExecutor { StringWriter writer = new StringWriter(); try { - writer.append("ArenaMode: ").append(Config.mode.name()).append('\n'); + writer.append("ArenaMode: ").append(GameConfig.mode.name()).append('\n'); writer.append("FightState: ").append(FightState.getFightState().name()).append('\n'); writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n'); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java index 83e40f67..b5e5cfc7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.gamecore.countdown.StandardCountdown; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; @@ -34,7 +35,7 @@ public class EventSpectateCountdown extends StandardCountdown { public EventSpectateCountdown() { super(FightSystem.getPlugin(), Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false)); - new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this); + new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.NotRestartable.contains(GameConfig.mode) && !GameConfig.replayserver(), FightState.Spectate, this); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java index 190088b9..e185eede 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; @@ -36,7 +37,7 @@ public class NoPlayersOnlineCountdown extends StandardCountdown { super(FightSystem.getPlugin(), Config.GameModeConfig.Times.NoPlayersOnlineDuration, FightCountdownAdapter.presentation(new Message("SHUTDOWN_COUNTDOWN"), null, false)); if (!Config.GameModeConfig.Arena.Leaveable) { - new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(Config.mode), FightState.PreLeaderSetup, this); + new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(GameConfig.mode), FightState.PreLeaderSetup, this); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java index 732bfc44..54b800ed 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; @@ -33,11 +34,11 @@ public class PostSchemCountdown extends StandardCountdown { public PostSchemCountdown() { super(FightSystem.getPlugin(), Config.GameModeConfig.Times.SetupDuration, FightCountdownAdapter.presentation(new Message("POST_SCHEM_COUNTDOWN"), null, false)); - if (Config.mode == ArenaMode.PREPARE && Config.GameModeConfig.Schematic.UnlimitedPrepare) { + if (GameConfig.mode == ArenaMode.PREPARE && Config.GameModeConfig.Schematic.UnlimitedPrepare) { return; } - new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.SeriousFight.contains(Config.mode), FightState.PostSchemSetup, this); + new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.SeriousFight.contains(GameConfig.mode), FightState.PostSchemSetup, this); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index 25e3bf5e..c1a9d0bc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; @@ -34,7 +35,7 @@ public class PreRunningCountdown extends StandardCountdown { public PreRunningCountdown() { super(FightSystem.getPlugin(), Config.GameModeConfig.Times.PreFightDuration, FightCountdownAdapter.presentation(new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true)); - new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(Config.mode), FightState.PreRunning, this); + new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(GameConfig.mode), FightState.PreRunning, this); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java index 57ccb72c..bd638aef 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; @@ -34,7 +35,7 @@ public class PreSchemCountdown extends StandardCountdown { public PreSchemCountdown() { super(FightSystem.getPlugin(), Config.GameModeConfig.Times.PreSchemPasteDuration, FightCountdownAdapter.presentation(new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false)); - new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(Config.mode), FightState.PreSchemSetup, this); + new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(GameConfig.mode), FightState.PreSchemSetup, this); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java index a8d0fa9e..deacdaea 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; @@ -33,8 +34,8 @@ import de.steamwar.linkage.Linked; public class SpectateOverCountdown extends StandardCountdown { public SpectateOverCountdown() { - super(FightSystem.getPlugin(), Config.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false)); - new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this); + super(FightSystem.getPlugin(), GameConfig.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false)); + new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.Restartable.contains(GameConfig.mode) || GameConfig.replayserver(), FightState.Spectate, this); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java index b53bb152..63d908bc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java @@ -21,7 +21,7 @@ package de.steamwar.fightsystem.event; import com.sk89q.worldedit.WorldEditException; import de.steamwar.gamecore.ArenaMode; -import de.steamwar.fightsystem.Config; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; @@ -37,7 +37,7 @@ import java.util.logging.Level; public class PersistentDamage { public PersistentDamage() { - if (!ArenaMode.SeriousFight.contains(Config.mode)) return; + if (!ArenaMode.SeriousFight.contains(GameConfig.mode)) return; new OneShotStateDependent(Winconditions.PERSISTENT_DAMAGE, FightState.Spectate, () -> Fight.teams().forEach(team -> { try { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index 189db5cd..b63f4cf1 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.fight; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.gamecore.team.TeamRegistry; @@ -37,9 +38,9 @@ public class Fight { } @Getter - private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader); + private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, GameConfig.RedLeader); @Getter - private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader); + private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, GameConfig.BlueLeader); private static final TeamRegistry teamRegistry = new TeamRegistry<>(List.of(redTeam, blueTeam)); public static FightTeam getPlayerTeam(LivingEntity player) { @@ -90,7 +91,7 @@ public class Fight { if (Config.OnlyPublicSchematics) { return true; } - if (Config.GameModeConfig.Schematic.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) { + if (Config.GameModeConfig.Schematic.IgnorePublicOnly || ArenaMode.RankedEvent.contains(GameConfig.mode)) { return false; } if (redTeam.getLeader() == null || blueTeam.getLeader() == null) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java index bab8b805..166e2014 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.transform.AffineTransform; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.record.GlobalRecorder; @@ -130,7 +131,7 @@ public class FightSchematic extends StateDependent { setSchematic(publics.get(new Random().nextInt(publics.size()))); } - if (ArenaMode.AntiReplay.contains(Config.mode)) { + if (ArenaMode.AntiReplay.contains(GameConfig.mode)) { boolean changeRotation = false; if (Config.GameModeConfig.WinConditions.contains(Winconditions.RANDOM_ROTATE)) { changeRotation = new Random().nextBoolean(); @@ -148,7 +149,7 @@ public class FightSchematic extends StateDependent { private void replaceTeamColor(Clipboard clipboard) { try { - WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dyeColor(team.getColor()) : DyeColor.PINK); + WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(GameConfig.mode) ? ColorConverter.chat2dyeColor(team.getColor()) : DyeColor.PINK); } catch (WorldEditException e) { Bukkit.getLogger().log(Level.SEVERE, "Could not recolor schematic", e); } @@ -173,7 +174,7 @@ public class FightSchematic extends StateDependent { ); FightSystem.getHullHider().initialize(team); team.getPlayers().forEach(fightPlayer -> fightPlayer.ifAI(ai -> ai.schematic(clipboard))); - if (ArenaMode.Check.contains(Config.mode) && !team.isBlue()) { + if (ArenaMode.Check.contains(GameConfig.mode) && !team.isBlue()) { replaceSync(Material.TNT, Material.RED_WOOL); } @@ -182,7 +183,7 @@ public class FightSchematic extends StateDependent { @Override public void disable() { - if (Config.mode == ArenaMode.PREPARE) { + if (GameConfig.mode == ArenaMode.PREPARE) { return; } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 7e55967f..070541f5 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.ai.AIManager; @@ -79,14 +80,14 @@ public class FightTeam implements de.steamwar.gamecore.team.GameTeam Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset)); - new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset)); + new OneShotStateDependent(GameConfig.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset)); new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> { if (leader != null) leader.ifPlayer(notReadyKit::loadToPlayer); }); @@ -236,7 +237,7 @@ public class FightTeam implements de.steamwar.gamecore.team.GameTeam addMember(Bukkit.getPlayer(uuid), SteamwarUser.get(uuid), true)); - if (ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()) { + if (ArenaMode.VariableTeams.contains(GameConfig.mode) && isLeaderless()) { List onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers()); Collections.shuffle(onlinePlayers); for (Player player : onlinePlayers) { @@ -338,7 +339,7 @@ public class FightTeam implements de.steamwar.gamecore.team.GameTeam FightState.setFightState(FightState.PRE_LEADER_SETUP), 1); } } @@ -448,7 +449,7 @@ public class FightTeam implements de.steamwar.gamecore.team.GameTeam condition, Consumer leftAreaHandler) { this.leftAreaHandler = leftAreaHandler; - if (!condition.contains(Config.mode)) return; + if (!condition.contains(GameConfig.mode)) return; //Wenn Entern aktiv ist, sollen Raketen etc. entern können new StateDependentListener(!Config.GameModeConfig.Arena.AllowMissiles, FightState.All, this); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java index bc760eb1..6b51c45a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener; import com.sk89q.worldedit.WorldEditException; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -67,7 +68,7 @@ public class PrepareSchem implements Listener { SchematicNode schem; try { - schem = SchematicNode.getSchematicNode(Config.PrepareSchemID); + schem = SchematicNode.getSchematicNode(GameConfig.PrepareSchemID); } catch (SecurityException e) { FightSystem.getMessage().broadcast("PREPARE_SCHEM_DELETED"); Bukkit.shutdown(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java index 2aef208c..02759f5b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; @@ -33,12 +34,12 @@ import org.bukkit.event.player.PlayerQuitEvent; public class Shutdown implements Listener { public Shutdown() { - new StateDependentListener(ArenaMode.AntiEvent.contains(Config.mode) && !Config.replayserver(), FightState.All, this); + new StateDependentListener(ArenaMode.AntiEvent.contains(GameConfig.mode) && !GameConfig.replayserver(), FightState.All, this); } @EventHandler public void handlePlayerQuit(PlayerQuitEvent event) { - if (Config.replayserver() || Config.GameModeConfig.Arena.Leaveable) return; + if (GameConfig.replayserver() || Config.GameModeConfig.Arena.Leaveable) return; //Shutdown server if nobody online if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java index 63b37ba6..860b4445 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java @@ -20,7 +20,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.gamecore.ArenaMode; -import de.steamwar.fightsystem.Config; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; @@ -43,7 +43,7 @@ public class TestJoin implements Listener { public void handlePlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - if (Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) { + if (GameConfig.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) { FightSystem.getMessage().send("CHECK_JOIN_DENIED", player); player.kickPlayer(""); return; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java index d482913c..250b9d27 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java @@ -22,6 +22,7 @@ package de.steamwar.fightsystem.record; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.gamecore.GameConfig; import de.steamwar.linkage.Linked; import lombok.Getter; @@ -36,7 +37,7 @@ public class FileRecorder extends StateDependent implements Recorder { private DataOutputStream outputStream; public FileRecorder() { - super(Config.ReplayID == 0, FightState.Recording); + super(GameConfig.ReplayID == 0, FightState.Recording); register(); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java index 34e168ed..ff9f609d 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java @@ -19,7 +19,7 @@ package de.steamwar.fightsystem.record; -import de.steamwar.fightsystem.Config; +import de.steamwar.gamecore.GameConfig; import java.io.File; import java.io.IOException; @@ -33,7 +33,7 @@ public class FileSource extends PacketSource { } public static void startReplay() { - if (Config.replayserver()) { + if (GameConfig.replayserver()) { try { new LiveServer(); } catch (IOException e) { @@ -42,9 +42,9 @@ public class FileSource extends PacketSource { return; } - if (Config.ReplayID > 0) { + if (GameConfig.ReplayID > 0) { try { - new FileSource(replayFile(Config.ReplayID)); + new FileSource(replayFile(GameConfig.ReplayID)); } catch (IOException e) { throw new SecurityException("Could not start replay", e); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index badb430d..bd4d4478 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -25,6 +25,7 @@ import de.steamwar.entity.REntity; import de.steamwar.entity.REntityServer; import de.steamwar.entity.RPlayer; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.FightCountdownAdapter; @@ -255,7 +256,7 @@ public class PacketProcessor implements Listener { addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn)); team.addEntry(user.getUserName()); - if (ArenaMode.Test.contains(Config.mode)) { + if (ArenaMode.Test.contains(GameConfig.mode)) { entities.get(entityId).setGlowing(true); } }); @@ -633,7 +634,7 @@ public class PacketProcessor implements Listener { entities.clear(); freezer.disable(); - if (!Config.replayserver()) { + if (!GameConfig.replayserver()) { FightSystem.getMessage().broadcast("REPLAY_ENDS"); } if (FightSystem.getLastWinner() != null) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index 88a7a342..f9b739d0 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.record; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; @@ -51,7 +52,7 @@ public interface Recorder { default void enable() { GlobalRecorder.getInstance().add(this); - if (ArenaMode.Event.contains(Config.mode)) { + if (ArenaMode.Event.contains(GameConfig.mode)) { teamIds(Config.EventTeamBlueID, Config.EventTeamRedID); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java index d7acd724..00c5225b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java @@ -2,13 +2,14 @@ package de.steamwar.fightsystem.states; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.gamecore.GameConfig; import java.util.Set; @Deprecated public class OneShotStateDependent extends de.steamwar.gamecore.state.OneShotStateDependent implements IStateDependent { public OneShotStateDependent(Set modes, Set states, Runnable runnable) { - super(FightState.lifecycle, modes, Config.mode, states, runnable); + super(FightState.lifecycle, modes, GameConfig.mode, states, runnable); } public OneShotStateDependent(Winconditions wincondition, Set states, Runnable runnable) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java index 7b4c2e0a..432a1141 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java @@ -2,6 +2,7 @@ package de.steamwar.fightsystem.states; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.gamecore.GameConfig; import java.util.Set; @@ -12,7 +13,7 @@ public abstract class StateDependent extends de.steamwar.gamecore.state.StateDep } protected StateDependent(Set modes, Set states) { - super(FightState.lifecycle, modes, Config.mode, states); + super(FightState.lifecycle, modes, GameConfig.mode, states); } protected StateDependent(boolean enabled, Set states) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java index bd5a1da9..e9b26937 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java @@ -1,7 +1,7 @@ package de.steamwar.fightsystem.states; -import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.gamecore.GameConfig; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.CommandExecutor; @@ -15,6 +15,6 @@ public class StateDependentCommand extends de.steamwar.gamecore.state.StateDepen }; public StateDependentCommand(Set modes, Set states, String name, CommandExecutor executor) { - super(FightState.lifecycle, modes.contains(Config.mode), states, FightSystem.getPlugin(), name, executor, unavailable); + super(FightState.lifecycle, modes.contains(GameConfig.mode), states, FightSystem.getPlugin(), name, executor, unavailable); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java index 7f951ebf..8a7ab610 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java @@ -3,6 +3,7 @@ package de.steamwar.fightsystem.states; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.gamecore.GameConfig; import org.bukkit.event.Listener; import java.util.Set; @@ -18,6 +19,6 @@ public class StateDependentListener extends de.steamwar.gamecore.state.StateDepe } public StateDependentListener(Set modes, Set states, Listener listener) { - super(FightState.lifecycle, modes, Config.mode, states, FightSystem.getPlugin(), listener); + super(FightState.lifecycle, modes, GameConfig.mode, states, FightSystem.getPlugin(), listener); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java index abb7e578..42768467 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java @@ -3,6 +3,7 @@ package de.steamwar.fightsystem.states; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.gamecore.GameConfig; import java.util.Set; @@ -17,6 +18,6 @@ public class StateDependentTask extends de.steamwar.gamecore.state.StateDependen } public StateDependentTask(Set modes, Set states, Runnable runnable, long delay, long period) { - super(FightState.lifecycle, modes, Config.mode, states, FightSystem.getPlugin(), runnable, delay, period); + super(FightState.lifecycle, modes, GameConfig.mode, states, FightSystem.getPlugin(), runnable, delay, period); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java index 0253bbf3..128bb03e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.utils; import de.steamwar.gamecore.ArenaMode; +import de.steamwar.gamecore.GameConfig; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.gamecore.countdown.Countdown; @@ -125,7 +126,7 @@ public class FightStatistics { savePlayerStats(fp, fightId); } - if (ArenaMode.Event.contains(Config.mode)) { + if (ArenaMode.Event.contains(GameConfig.mode)) { Config.EventKampf.setFight(fightId); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHiderWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHiderWrapper.java index 7c4c9d77..7e2e5263 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHiderWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHiderWrapper.java @@ -29,6 +29,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.gamecore.GameConfig; import de.steamwar.techhider.AccessPrivilegeProvider; import de.steamwar.techhider.TechHider; import lombok.Getter; @@ -58,7 +59,7 @@ import java.util.stream.Stream; public class TechHiderWrapper extends StateDependent implements Listener { - public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.GameModeConfig.Techhider.Active; + public static final boolean ENABLED = !Config.OnlyPublicSchematics && !GameConfig.test() && Config.GameModeConfig.Techhider.Active; @Getter private final ConcurrentHashMap hiddenRegion = new ConcurrentHashMap<>(); diff --git a/GameCore/README.md b/GameCore/README.md index 87a19b49..2356c946 100644 --- a/GameCore/README.md +++ b/GameCore/README.md @@ -10,7 +10,7 @@ contains the mechanics that do not depend on a specific arena: - reusable winner/draw results and score/last-remaining evaluation; - the complete state-dependent lifecycle (one-shots, tasks, listeners, commands, and countdowns); -- the FightSystem arena modes and typed JVM runtime properties; +- the FightSystem arena modes and shared JVM runtime configuration; - observable, generic game-state transitions. GameCore intentionally does not define a game-state enum. Each consumer supplies diff --git a/GameCore/src/de/steamwar/gamecore/ArenaMode.kt b/GameCore/src/de/steamwar/gamecore/ArenaMode.kt index da01fa1d..44702496 100644 --- a/GameCore/src/de/steamwar/gamecore/ArenaMode.kt +++ b/GameCore/src/de/steamwar/gamecore/ArenaMode.kt @@ -11,7 +11,6 @@ package de.steamwar.gamecore -import de.steamwar.gamecore.config.GameRuntimeProperties import java.util.Collections import java.util.EnumSet @@ -50,16 +49,6 @@ enum class ArenaMode { @JvmField val NotOnBau: Set = complement(TEST, CHECK, PREPARE, REPLAY) @JvmField val SeriousFight: Set = complement(TEST, CHECK, REPLAY) - @JvmStatic - fun from(properties: GameRuntimeProperties): ArenaMode = when { - properties.checkSchematicId != 0 -> CHECK - properties.prepareSchematicId != 0 -> PREPARE - properties.fightId >= 1 -> EVENT - properties.fightId == -1 -> TEST - properties.replayId != 0 -> REPLAY - else -> NORMAL - } - private fun complement(vararg modes: ArenaMode): Set = immutable(EnumSet.complementOf(EnumSet.copyOf(modes.toSet()))) diff --git a/GameCore/src/de/steamwar/gamecore/GameConfig.kt b/GameCore/src/de/steamwar/gamecore/GameConfig.kt new file mode 100644 index 00000000..c9f414a3 --- /dev/null +++ b/GameCore/src/de/steamwar/gamecore/GameConfig.kt @@ -0,0 +1,65 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2026 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ + +package de.steamwar.gamecore + +import java.util.UUID + +/** + * Runtime configuration shared by all GameCore game modes. + * + * The values are supplied as JVM system properties by the game server launcher. + */ +object GameConfig { + @JvmField + val CheckSchemID: Int = System.getProperty("checkSchemID", "0").toInt() + + @JvmField + val PrepareSchemID: Int = System.getProperty("prepareSchemID", "0").toInt() + + @JvmField + val ReplayID: Int = System.getProperty("replay", "0").toInt() + + @JvmField + val ConfigFile: String = System.getProperty("config", "config.yml") + + @JvmField + val EventKampfID: Int = System.getProperty("fightID", "0").toInt() + + @JvmField + val BlueLeader: UUID? = System.getProperty("blueLeader")?.let(UUID::fromString) + + @JvmField + val RedLeader: UUID? = System.getProperty("redLeader")?.let(UUID::fromString) + + @JvmField + val mode: ArenaMode = resolveArenaMode(CheckSchemID, PrepareSchemID, EventKampfID, ReplayID) + + @JvmStatic + fun test(): Boolean = ArenaMode.Test.contains(mode) + + @JvmStatic + fun replayserver(): Boolean = ReplayID < 0 + + internal fun resolveArenaMode( + checkSchemID: Int, + prepareSchemID: Int, + eventKampfID: Int, + replayID: Int, + ): ArenaMode = when { + checkSchemID != 0 -> ArenaMode.CHECK + prepareSchemID != 0 -> ArenaMode.PREPARE + eventKampfID >= 1 -> ArenaMode.EVENT + eventKampfID == -1 -> ArenaMode.TEST + replayID != 0 -> ArenaMode.REPLAY + else -> ArenaMode.NORMAL + } +} diff --git a/GameCore/src/de/steamwar/gamecore/config/GameRuntimeProperties.kt b/GameCore/src/de/steamwar/gamecore/config/GameRuntimeProperties.kt deleted file mode 100644 index 56cac0e5..00000000 --- a/GameCore/src/de/steamwar/gamecore/config/GameRuntimeProperties.kt +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2026 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ - -package de.steamwar.gamecore.config - -import java.util.Properties -import java.util.UUID - -/** - * Typed view of every JVM system property historically consumed by FightSystem. - * - * Other game modes use the same names and parser, so launch behavior is - * consistent across the complete GameCore family. - */ -data class GameRuntimeProperties( - val checkSchematicId: Int, - val prepareSchematicId: Int, - val replayId: Int, - val configFile: String, - val fightId: Int, - val blueLeader: UUID?, - val redLeader: UUID?, -) { - val isReplayServer: Boolean - get() = replayId < 0 - - companion object { - const val CHECK_SCHEMATIC_ID = "checkSchemID" - const val PREPARE_SCHEMATIC_ID = "prepareSchemID" - const val REPLAY_ID = "replay" - const val CONFIG_FILE = "config" - const val FIGHT_ID = "fightID" - const val BLUE_LEADER = "blueLeader" - const val RED_LEADER = "redLeader" - - @JvmStatic - @JvmOverloads - fun load(properties: Properties = System.getProperties()): GameRuntimeProperties = - GameRuntimeProperties( - checkSchematicId = properties.int(CHECK_SCHEMATIC_ID), - prepareSchematicId = properties.int(PREPARE_SCHEMATIC_ID), - replayId = properties.int(REPLAY_ID), - configFile = properties.getProperty(CONFIG_FILE, "config.yml"), - fightId = properties.int(FIGHT_ID), - blueLeader = properties.uuid(BLUE_LEADER), - redLeader = properties.uuid(RED_LEADER), - ) - - private fun Properties.int(name: String): Int = - getProperty(name, "0").toInt() - - private fun Properties.uuid(name: String): UUID? = - getProperty(name)?.let(UUID::fromString) - } -} diff --git a/GameCore/testsrc/de/steamwar/gamecore/ArenaModeTest.kt b/GameCore/testsrc/de/steamwar/gamecore/ArenaModeTest.kt index 735f0ddb..e05e89ae 100644 --- a/GameCore/testsrc/de/steamwar/gamecore/ArenaModeTest.kt +++ b/GameCore/testsrc/de/steamwar/gamecore/ArenaModeTest.kt @@ -1,38 +1,31 @@ package de.steamwar.gamecore -import de.steamwar.gamecore.config.GameRuntimeProperties import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.Test -import java.util.Properties class ArenaModeTest { @Test fun resolvesEveryFightSystemArenaMode() { assertThat(mode(), equalTo(ArenaMode.NORMAL)) - assertThat(mode(GameRuntimeProperties.FIGHT_ID to "42"), equalTo(ArenaMode.EVENT)) - assertThat(mode(GameRuntimeProperties.FIGHT_ID to "-1"), equalTo(ArenaMode.TEST)) - assertThat(mode(GameRuntimeProperties.REPLAY_ID to "42"), equalTo(ArenaMode.REPLAY)) - assertThat(mode(GameRuntimeProperties.PREPARE_SCHEMATIC_ID to "42"), equalTo(ArenaMode.PREPARE)) - assertThat(mode(GameRuntimeProperties.CHECK_SCHEMATIC_ID to "42"), equalTo(ArenaMode.CHECK)) + assertThat(mode(eventKampfID = 42), equalTo(ArenaMode.EVENT)) + assertThat(mode(eventKampfID = -1), equalTo(ArenaMode.TEST)) + assertThat(mode(replayID = 42), equalTo(ArenaMode.REPLAY)) + assertThat(mode(prepareSchemID = 42), equalTo(ArenaMode.PREPARE)) + assertThat(mode(checkSchemID = 42), equalTo(ArenaMode.CHECK)) } @Test fun keepsFightSystemResolutionPrecedence() { - val resolved = mode( - GameRuntimeProperties.CHECK_SCHEMATIC_ID to "1", - GameRuntimeProperties.PREPARE_SCHEMATIC_ID to "2", - GameRuntimeProperties.FIGHT_ID to "3", - GameRuntimeProperties.REPLAY_ID to "4", - ) + val resolved = mode(checkSchemID = 1, prepareSchemID = 2, eventKampfID = 3, replayID = 4) assertThat(resolved, equalTo(ArenaMode.CHECK)) } - private fun mode(vararg values: Pair): ArenaMode { - val properties = Properties().apply { - values.forEach { (name, value) -> setProperty(name, value) } - } - return ArenaMode.from(GameRuntimeProperties.load(properties)) - } + private fun mode( + checkSchemID: Int = 0, + prepareSchemID: Int = 0, + eventKampfID: Int = 0, + replayID: Int = 0, + ): ArenaMode = GameConfig.resolveArenaMode(checkSchemID, prepareSchemID, eventKampfID, replayID) } diff --git a/GameCore/testsrc/de/steamwar/gamecore/GameConfigTest.kt b/GameCore/testsrc/de/steamwar/gamecore/GameConfigTest.kt new file mode 100644 index 00000000..f31d19c8 --- /dev/null +++ b/GameCore/testsrc/de/steamwar/gamecore/GameConfigTest.kt @@ -0,0 +1,22 @@ +package de.steamwar.gamecore + +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.nullValue +import org.junit.Test + +class GameConfigTest { + @Test + fun usesFightSystemDefaults() { + assertThat(GameConfig.CheckSchemID, equalTo(0)) + assertThat(GameConfig.PrepareSchemID, equalTo(0)) + assertThat(GameConfig.ReplayID, equalTo(0)) + assertThat(GameConfig.ConfigFile, equalTo("config.yml")) + assertThat(GameConfig.EventKampfID, equalTo(0)) + assertThat(GameConfig.BlueLeader, nullValue()) + assertThat(GameConfig.RedLeader, nullValue()) + assertThat(GameConfig.mode, equalTo(ArenaMode.NORMAL)) + assertThat(GameConfig.test(), equalTo(false)) + assertThat(GameConfig.replayserver(), equalTo(false)) + } +} diff --git a/GameCore/testsrc/de/steamwar/gamecore/config/GameRuntimePropertiesTest.kt b/GameCore/testsrc/de/steamwar/gamecore/config/GameRuntimePropertiesTest.kt deleted file mode 100644 index 7c0c972c..00000000 --- a/GameCore/testsrc/de/steamwar/gamecore/config/GameRuntimePropertiesTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -package de.steamwar.gamecore.config - -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.nullValue -import org.junit.Test -import java.util.Properties -import java.util.UUID - -class GameRuntimePropertiesTest { - @Test - fun loadsEveryFightSystemRuntimeProperty() { - val blueLeader = UUID.randomUUID() - val redLeader = UUID.randomUUID() - val properties = Properties().apply { - setProperty(GameRuntimeProperties.CHECK_SCHEMATIC_ID, "11") - setProperty(GameRuntimeProperties.PREPARE_SCHEMATIC_ID, "12") - setProperty(GameRuntimeProperties.REPLAY_ID, "-13") - setProperty(GameRuntimeProperties.CONFIG_FILE, "event.yml") - setProperty(GameRuntimeProperties.FIGHT_ID, "14") - setProperty(GameRuntimeProperties.BLUE_LEADER, blueLeader.toString()) - setProperty(GameRuntimeProperties.RED_LEADER, redLeader.toString()) - } - - val runtime = GameRuntimeProperties.load(properties) - - assertThat(runtime.checkSchematicId, equalTo(11)) - assertThat(runtime.prepareSchematicId, equalTo(12)) - assertThat(runtime.replayId, equalTo(-13)) - assertThat(runtime.configFile, equalTo("event.yml")) - assertThat(runtime.fightId, equalTo(14)) - assertThat(runtime.blueLeader, equalTo(blueLeader)) - assertThat(runtime.redLeader, equalTo(redLeader)) - assertThat(runtime.isReplayServer, equalTo(true)) - } - - @Test - fun usesFightSystemDefaults() { - val runtime = GameRuntimeProperties.load(Properties()) - - assertThat(runtime.checkSchematicId, equalTo(0)) - assertThat(runtime.prepareSchematicId, equalTo(0)) - assertThat(runtime.replayId, equalTo(0)) - assertThat(runtime.configFile, equalTo("config.yml")) - assertThat(runtime.fightId, equalTo(0)) - assertThat(runtime.blueLeader, nullValue()) - assertThat(runtime.redLeader, nullValue()) - assertThat(runtime.isReplayServer, equalTo(false)) - } -} diff --git a/MissileWars/src/de/steamwar/misslewars/Config.java b/MissileWars/src/de/steamwar/misslewars/Config.java index 8fa5d7bb..3840f924 100644 --- a/MissileWars/src/de/steamwar/misslewars/Config.java +++ b/MissileWars/src/de/steamwar/misslewars/Config.java @@ -20,7 +20,7 @@ package de.steamwar.misslewars; import de.steamwar.gamecore.ArenaMode; -import de.steamwar.gamecore.config.GameRuntimeProperties; +import de.steamwar.gamecore.GameConfig; import de.steamwar.sql.Event; import de.steamwar.sql.EventFight; import de.steamwar.sql.Team; @@ -38,8 +38,7 @@ public class Config { private Config() { } - public static final GameRuntimeProperties RuntimeProperties = GameRuntimeProperties.load(); - public static final ArenaMode mode = ArenaMode.from(RuntimeProperties); + public static final ArenaMode mode = GameConfig.mode; public static final int ArenaMinX; public static final int ArenaMaxX; @@ -113,13 +112,13 @@ public class Config { BluePortalZ = blue.getInt("PortalZ"); BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float) blue.getDouble("SpawnYaw"), (float) blue.getDouble("SpawnPitch")); - BlueLeader = RuntimeProperties.getBlueLeader(); - RedLeader = RuntimeProperties.getRedLeader(); + BlueLeader = GameConfig.BlueLeader; + RedLeader = GameConfig.RedLeader; Barrier = config.getBoolean("Barrier", false); Space = config.getBoolean("Space", false); - EventKampfID = RuntimeProperties.getFightId(); + EventKampfID = GameConfig.EventKampfID; if (EventKampfID >= 1) { EventKampf = EventFight.byId(EventKampfID); if (EventKampf == null) { diff --git a/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueConfig.kt b/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueConfig.kt index b4fcb643..8c40e0c5 100644 --- a/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueConfig.kt +++ b/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueConfig.kt @@ -20,7 +20,7 @@ package de.steamwar.tntleague.config import de.steamwar.gamecore.ArenaMode -import de.steamwar.gamecore.config.GameRuntimeProperties +import de.steamwar.gamecore.GameConfig import de.steamwar.message.SubMessage import de.steamwar.sql.Event import de.steamwar.sql.EventFight @@ -34,19 +34,17 @@ import org.bukkit.inventory.meta.Damageable import org.bukkit.inventory.meta.ItemMeta import java.util.* -private val runtimeProperties = GameRuntimeProperties.load() - data class TNTLeagueConfig( val startDelay: Int = 10, val gameTime: Int = 60 * 20, val prices: Map, - val blueLeader: UUID? = runtimeProperties.blueLeader, - val redLeader: UUID? = runtimeProperties.redLeader, + val blueLeader: UUID? = GameConfig.BlueLeader, + val redLeader: UUID? = GameConfig.RedLeader, - val eventFightId: Int? = runtimeProperties.fightId.takeIf { it != 0 }, - val arenaMode: ArenaMode = ArenaMode.from(runtimeProperties), + val eventFightId: Int? = GameConfig.EventKampfID.takeIf { it != 0 }, + val arenaMode: ArenaMode = GameConfig.mode, ) { lateinit var eventFight: EventFight lateinit var event: Event diff --git a/TowerRun/src/de/steamwar/towerrun/config/Config.java b/TowerRun/src/de/steamwar/towerrun/config/Config.java index 0fc4b88f..88f2a422 100644 --- a/TowerRun/src/de/steamwar/towerrun/config/Config.java +++ b/TowerRun/src/de/steamwar/towerrun/config/Config.java @@ -20,7 +20,7 @@ package de.steamwar.towerrun.config; import de.steamwar.gamecore.ArenaMode; -import de.steamwar.gamecore.config.GameRuntimeProperties; +import de.steamwar.gamecore.GameConfig; import de.steamwar.sql.Event; import de.steamwar.sql.EventFight; import de.steamwar.towerrun.TowerRun; @@ -37,8 +37,7 @@ import java.util.stream.Collectors; @UtilityClass public class Config { - public static final GameRuntimeProperties RUNTIME_PROPERTIES = GameRuntimeProperties.load(); - public static final ArenaMode MODE = ArenaMode.from(RUNTIME_PROPERTIES); + public static final ArenaMode MODE = GameConfig.mode; public static final int MIN_PLAYERS; public static final int LOBBY_TIMER; @@ -69,7 +68,7 @@ public class Config { GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60); DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet())); - EVENT_KAMPF_ID = RUNTIME_PROPERTIES.getFightId(); + EVENT_KAMPF_ID = GameConfig.EventKampfID; if (event()) { EVENT_FIGHT = EventFight.byId(EVENT_KAMPF_ID);