From 8fb9aefbaae0c618df662c68fe4110b50bbd746d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 4 Feb 2021 08:51:12 +0100 Subject: [PATCH 1/2] Make config and kits path configurable Signed-off-by: Lixfel --- FightSystem_API/src/de/steamwar/fightsystem/Config.java | 5 ++++- .../src/de/steamwar/fightsystem/kit/KitManager.java | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index 8c175c2..3e05939 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -125,6 +125,7 @@ public class Config { public static final String LeaderDefault; public static final boolean PersonalKits; public static final List ForbiddenItems; + public static final String KitFile; //tech hider parameter public static final boolean TechhiderActive; @@ -155,7 +156,8 @@ public class Config { Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!"); IFightSystem.shutdown(null); } - if(!new File(IFightSystem.getPlugin().getDataFolder(), "config.yml").exists()) { + + if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) { IFightSystem.getPlugin().saveDefaultConfig(); Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!"); IFightSystem.shutdown(null); @@ -217,6 +219,7 @@ public class Config { EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages")); + KitFile = config.getString("Kits.File", "kits.data"); MemberDefault = config.getString("Kits.MemberDefault"); LeaderDefault = config.getString("Kits.LeaderDefault"); PersonalKits = config.getBoolean("Kits.PersonalKits"); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java b/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java index 3a95f18..bf58691 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/kit/KitManager.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.kit; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; @@ -34,7 +35,7 @@ import java.util.logging.Level; public class KitManager { private KitManager(){} - private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), "kits.data"); + private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), Config.KitFile); private static final FileConfiguration kitData = YamlConfiguration.loadConfiguration(kits); private static final ArrayList loadedKits = new ArrayList<>(); @@ -69,7 +70,7 @@ public class KitManager { public static void loadAllKits() { if(!kits.exists()) { saveAllKits(); - Bukkit.getLogger().log(Level.INFO, "kits.data erstellt!"); + Bukkit.getLogger().log(Level.SEVERE, "kit config fehlend!"); FightSystem.shutdown(null); return; } -- 2.39.5 From 0027c6c69ba20981e2b271043a66152f0184779d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 4 Feb 2021 09:16:22 +0100 Subject: [PATCH 2/2] Configurable world config Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/Config.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index 3e05939..d3f955d 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -151,18 +151,18 @@ public class Config { public static final int spectatePort = 2222; static{ - File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml"); - if(!worldConfigFile.exists()) { - Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!"); - IFightSystem.shutdown(null); - } - if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) { IFightSystem.getPlugin().saveDefaultConfig(); Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!"); IFightSystem.shutdown(null); } FileConfiguration config = IFightSystem.getPlugin().getConfig(); + + File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml")); + if(!worldConfigFile.exists()) { + Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!"); + IFightSystem.shutdown(null); + } FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile); NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration"); -- 2.39.5