diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java index af08c4ae..1bf07d5a 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java @@ -23,8 +23,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; -import de.steamwar.data.YMLWrapperUtils; +import de.steamwar.data.GameModeConfigUtils; import de.steamwar.sql.SchematicType; import lombok.NonNull; import lombok.Setter; @@ -95,7 +94,7 @@ public final class FixedGlobalRegion implements Region { } }; - private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig<>(null, YMLWrapperUtils.ToMaterial, YMLWrapper.ToSchematicType, YMLWrapper.ToString, YMLWrapper.ToStaticWarGear); + private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig<>(null, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); private FixedGlobalRegion() { } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index 399c5aba..1eb0ab62 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -29,8 +29,7 @@ import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.core.Core; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; -import de.steamwar.data.YMLWrapperUtils; +import de.steamwar.data.GameModeConfigUtils; import de.steamwar.sql.SchematicType; import lombok.NonNull; import org.bukkit.Bukkit; @@ -340,7 +339,7 @@ public class FixedRegion implements Region { break; } } - this.gameModeConfig = new GameModeConfig<>(found, YMLWrapperUtils.ToMaterial, YMLWrapper.ToSchematicType, YMLWrapper.ToString, YMLWrapper.ToStaticWarGear); + this.gameModeConfig = new GameModeConfig<>(found, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); this.regionData = new RegionData.RegionDataImpl(regionData, WorldData::write); } diff --git a/CommonCore/Data/src/de/steamwar/data/GameModeConfig.java b/CommonCore/Data/src/de/steamwar/data/GameModeConfig.java index ed405522..b9c8919b 100644 --- a/CommonCore/Data/src/de/steamwar/data/GameModeConfig.java +++ b/CommonCore/Data/src/de/steamwar/data/GameModeConfig.java @@ -34,8 +34,12 @@ import java.util.stream.Collectors; @ToString public final class GameModeConfig { - private static final Random random = new Random(); + public static final Function ToString = Function.identity(); + public static final Function ToSchematicType = SchematicType::fromDB; + public static final Function ToStaticWarGear = __ -> "WarGear"; + public static final Function ToInternalName = file -> file.getName().replace(".yml", ""); public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm"); + private static final Random random = new Random(); public final boolean loaded; public final File configFile; diff --git a/CommonCore/Data/src/de/steamwar/data/YMLWrapper.java b/CommonCore/Data/src/de/steamwar/data/YMLWrapper.java index 644a8c13..30d6d9ae 100644 --- a/CommonCore/Data/src/de/steamwar/data/YMLWrapper.java +++ b/CommonCore/Data/src/de/steamwar/data/YMLWrapper.java @@ -19,7 +19,6 @@ package de.steamwar.data; -import de.steamwar.sql.SchematicType; import org.yaml.snakeyaml.Yaml; import java.io.File; @@ -32,15 +31,8 @@ import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; -public final class YMLWrapper { +final class YMLWrapper { - public static final Function ToString = Function.identity(); - public static final Function ToSchematicType = SchematicType::fromDB; - - public static final Function ToStaticWarGear = __ -> "WarGear"; - public static final Function ToInternalName = file -> file.getName().replace(".yml", ""); - - private final File file; final Function materialMapper; final Function schematicTypeMapper; final Function winconditionMapper; @@ -48,8 +40,7 @@ public final class YMLWrapper { private final boolean canLoad; private final Map document; - public YMLWrapper(File file, Function materialMapper, Function schematicTypeMapper, Function winconditionMapper) { - this.file = file; + YMLWrapper(File file, Function materialMapper, Function schematicTypeMapper, Function winconditionMapper) { this.materialMapper = materialMapper; this.schematicTypeMapper = schematicTypeMapper; this.winconditionMapper = winconditionMapper; @@ -70,7 +61,6 @@ public final class YMLWrapper { } private YMLWrapper(boolean canLoad, Map document, Function materialMapper, Function schematicTypeMapper, Function winconditionMapper) { - this.file = null; this.materialMapper = materialMapper; this.schematicTypeMapper = schematicTypeMapper; this.winconditionMapper = winconditionMapper; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index f8e18d4f..93f263bb 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -20,8 +20,7 @@ package de.steamwar.fightsystem; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; -import de.steamwar.data.YMLWrapperUtils; +import de.steamwar.data.GameModeConfigUtils; import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.winconditions.Winconditions; import de.steamwar.sql.*; @@ -110,7 +109,7 @@ public class Config { Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!"); Bukkit.shutdown(); } - GameModeConfig = new GameModeConfig<>(new File(FightSystem.getPlugin().getDataFolder(), configFile), YMLWrapperUtils.ToMaterial, YMLWrapper.ToSchematicType, Winconditions::valueOf, YMLWrapper.ToStaticWarGear); + GameModeConfig = new GameModeConfig<>(new File(FightSystem.getPlugin().getDataFolder(), configFile), GameModeConfigUtils.ToMaterial, de.steamwar.data.GameModeConfig.ToSchematicType, Winconditions::valueOf, de.steamwar.data.GameModeConfig.ToStaticWarGear); File worldConfigFile = new File(world.getWorldFolder(), "config.yml"); if(!worldConfigFile.exists()) { diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java index 48bd8859..dc9c4ae4 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java @@ -20,8 +20,7 @@ package de.steamwar.schematicsystem; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; -import de.steamwar.data.YMLWrapperUtils; +import de.steamwar.data.GameModeConfigUtils; import de.steamwar.sql.SchematicType; import lombok.experimental.UtilityClass; import org.bukkit.Material; @@ -39,7 +38,7 @@ public class CheckSchemTypeManager { File folder = new File(SchematicSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); if(folder.exists()) { for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) { - GameModeConfig gameModeConfig = new GameModeConfig<>(configFile, YMLWrapperUtils.ToMaterial, YMLWrapper.ToSchematicType, YMLWrapper.ToString, YMLWrapper.ToStaticWarGear); + GameModeConfig gameModeConfig = new GameModeConfig<>(configFile, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); if (gameModeConfig.CheckQuestions.isEmpty() && gameModeConfig.Schematic.ManualCheck) continue; types.put(gameModeConfig.Schematic.Type, gameModeConfig); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/data/YMLWrapperUtils.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/data/GameModeConfigUtils.java similarity index 97% rename from SpigotCore/SpigotCore_Main/src/de/steamwar/data/YMLWrapperUtils.java rename to SpigotCore/SpigotCore_Main/src/de/steamwar/data/GameModeConfigUtils.java index 15433cfc..a14aa31e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/data/YMLWrapperUtils.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/data/GameModeConfigUtils.java @@ -25,7 +25,7 @@ import org.bukkit.Material; import java.util.function.Function; @UtilityClass -public class YMLWrapperUtils { +public class GameModeConfigUtils { public static final Function ToMaterial = material -> { Material mat = Material.getMaterial(material); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java index 340daf47..e25e4bb6 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java @@ -21,7 +21,6 @@ package de.steamwar.sql; import de.steamwar.core.Core; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; @@ -39,7 +38,7 @@ public class SQLWrapperImpl implements SQLWrapper { File folder = new File(Core.getInstance().getDataFolder().getParentFile(), "FightSystem"); if (!folder.exists()) return; for (File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) { - GameModeConfig gameModeConfig = new GameModeConfig<>(configFile, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToStaticWarGear); + GameModeConfig gameModeConfig = new GameModeConfig<>(configFile, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); if (!gameModeConfig.Schematic.loaded) continue; String type = gameModeConfig.Schematic.Type; assert type != null; diff --git a/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java b/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java index cde15d01..156c45e9 100644 --- a/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java @@ -22,7 +22,6 @@ package de.steamwar.sql; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.commands.CheckCommand; @@ -40,7 +39,7 @@ public class SQLWrapperImpl implements SQLWrapper { return; for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) { - GameModeConfig gameModeConfig = new GameModeConfig<>(file, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToInternalName); + GameModeConfig gameModeConfig = new GameModeConfig<>(file, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToInternalName); if (!gameModeConfig.Schematic.loaded) continue; if (tmpFromDB.containsKey(gameModeConfig.Schematic.Type.toLowerCase())) continue; diff --git a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java index 53a2e0b0..63c0187e 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java @@ -20,7 +20,6 @@ package de.steamwar.velocitycore; import de.steamwar.data.GameModeConfig; -import de.steamwar.data.YMLWrapper; import de.steamwar.sql.SchematicType; import lombok.Getter; import lombok.experimental.UtilityClass; @@ -52,7 +51,7 @@ public class ArenaMode { return; for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) { - GameModeConfig gameModeConfig = new GameModeConfig<>(file, YMLWrapper.ToString, YMLWrapper.ToSchematicType, YMLWrapper.ToString, YMLWrapper.ToInternalName); + GameModeConfig gameModeConfig = new GameModeConfig<>(file, GameModeConfig.ToString, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToInternalName); if (!gameModeConfig.Server.loaded) continue; allModes.add(gameModeConfig); diff --git a/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt b/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt index 714e34d4..f00c4dbd 100644 --- a/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt +++ b/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt @@ -20,7 +20,6 @@ package de.steamwar.sql import de.steamwar.data.GameModeConfig -import de.steamwar.data.YMLWrapper import java.io.File import java.util.* import java.util.stream.Collectors @@ -30,7 +29,7 @@ fun loadSchematicTypes(tmpTypes: MutableList?, tmpFromDB: Mutable if (folder.exists()) { for (configFile in Arrays.stream(folder.listFiles { _, name -> name.endsWith(".yml") && !name.endsWith(".kits.yml") }) .sorted().collect(Collectors.toList())) { - val gameModeConfig = GameModeConfig(configFile, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToStaticWarGear) + val gameModeConfig = GameModeConfig(configFile, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear) if (!gameModeConfig.Schematic.loaded) continue val type = gameModeConfig.Schematic.Type