diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java deleted file mode 100644 index dc9c4ae4..00000000 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemTypeManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2025 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.schematicsystem; - -import de.steamwar.data.GameModeConfig; -import de.steamwar.data.GameModeConfigUtils; -import de.steamwar.sql.SchematicType; -import lombok.experimental.UtilityClass; -import org.bukkit.Material; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -@UtilityClass -public class CheckSchemTypeManager { - - private static final Map> types = new HashMap<>(); - - static { - 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, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); - if (gameModeConfig.CheckQuestions.isEmpty() && gameModeConfig.Schematic.ManualCheck) - continue; - types.put(gameModeConfig.Schematic.Type, gameModeConfig); - if (gameModeConfig.Schematic.Type.checkType() != null) { - types.put(gameModeConfig.Schematic.Type.checkType(), gameModeConfig); - } - } - } - } - - public static GameModeConfig get(SchematicType type){ - return types.get(type); - } -} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java index 8245209b..a5826c70 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -19,21 +19,48 @@ package de.steamwar.schematicsystem; +import de.steamwar.data.GameModeConfig; +import de.steamwar.data.GameModeConfigUtils; import de.steamwar.linkage.AbstractLinker; import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; +import de.steamwar.sql.SchematicType; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + public class SchematicSystem extends JavaPlugin { public static final Message MESSAGE = new Message("SchematicSystem", SchematicSystem.class.getClassLoader()); private static SchematicSystem instance; + private static final Map> types = new HashMap<>(); + + public static GameModeConfig getGameModeConfig(SchematicType type){ + return types.get(type); + } + @Override public void onEnable() { instance = this; + File folder = new File(this.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, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); + if (gameModeConfig.CheckQuestions.isEmpty() && gameModeConfig.Schematic.ManualCheck) + continue; + types.put(gameModeConfig.Schematic.Type, gameModeConfig); + if (gameModeConfig.Schematic.Type.checkType() != null) { + types.put(gameModeConfig.Schematic.Type.checkType(), gameModeConfig); + } + } + } + SpigotLinker spigotLinker = new SpigotLinker(this, MESSAGE); try { spigotLinker.link(); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java index ece48694..d5428118 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java @@ -23,7 +23,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.*; -import de.steamwar.schematicsystem.CheckSchemTypeManager; import de.steamwar.schematicsystem.SafeSchematicNode; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoChecker; @@ -245,7 +244,7 @@ public class GUI { Clipboard finalClipboard = clipboard; List types = SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) - .filter(type -> finalClipboard == null || CheckSchemTypeManager.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemTypeManager.get(type)).fastOk()) + .filter(type -> finalClipboard == null || SchematicSystem.getGameModeConfig(type) == null || AutoChecker.sizeCheck(finalClipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) .collect(Collectors.toList()); List> items = types.stream() diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java index 9cccc0b6..03f2f328 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java @@ -26,7 +26,6 @@ import de.steamwar.inventory.SWItem; import de.steamwar.network.NetworkSender; import de.steamwar.network.packets.client.PrepareSchemPacket; import de.steamwar.providers.BauServerInfo; -import de.steamwar.schematicsystem.CheckSchemTypeManager; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoChecker; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; @@ -456,7 +455,7 @@ public class SchematicCommandUtils { return; } - GameModeConfig checkSchemType = CheckSchemTypeManager.get(type); + GameModeConfig checkSchemType = SchematicSystem.getGameModeConfig(type); if (checkSchemType.isAfterDeadline()) { SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.Deadline); return; diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java index b3f23092..a7f50dd7 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java @@ -21,7 +21,7 @@ package de.steamwar.schematicsystem.commands.schematiccommand; import de.steamwar.command.TypeMapper; import de.steamwar.data.GameModeConfig; -import de.steamwar.schematicsystem.CheckSchemTypeManager; +import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.NodeMember; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; @@ -181,12 +181,12 @@ public class SchematicMapper { return new TypeMapper>() { @Override public Collection tabCompletes(CommandSender commandSender, String[] strings, String s) { - return SchematicType.values().stream().filter(type -> CheckSchemTypeManager.get(type) != null).map(SchematicType::name).collect(Collectors.toList()); + return SchematicType.values().stream().filter(type -> SchematicSystem.getGameModeConfig(type) != null).map(SchematicType::name).collect(Collectors.toList()); } @Override public GameModeConfig map(CommandSender commandSender, String[] previousArguments, String s) { - return SchematicType.values().stream().filter(type -> type.name().equalsIgnoreCase(s)).map(CheckSchemTypeManager::get).findAny().orElse(null); + return SchematicType.values().stream().filter(type -> type.name().equalsIgnoreCase(s)).map(SchematicSystem::getGameModeConfig).findAny().orElse(null); } }; } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java index 58645331..99006559 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java @@ -23,7 +23,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; -import de.steamwar.schematicsystem.CheckSchemTypeManager; import de.steamwar.schematicsystem.SafeSchematicNode; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoChecker; @@ -63,7 +62,7 @@ public class ModifyPart extends SWCommand { SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) - .filter(type -> finalClipboard == null || CheckSchemTypeManager.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemTypeManager.get(type)).fastOk()) + .filter(type -> finalClipboard == null || SchematicSystem.getGameModeConfig(type) == null || AutoChecker.sizeCheck(finalClipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) .forEach(type -> { TextComponent component = new TextComponent(type.name() + " "); component.setColor(ChatColor.GRAY);