forked from SteamWar/SteamWar
Remove CheckSchemTypeManager
This commit is contained in:
-55
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<SchematicType, GameModeConfig<Material, SchematicType, String>> 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<Material, SchematicType, String> 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<Material, SchematicType, String> get(SchematicType type){
|
||||
return types.get(type);
|
||||
}
|
||||
}
|
||||
+27
@@ -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<SchematicType, GameModeConfig<Material, SchematicType, String>> types = new HashMap<>();
|
||||
|
||||
public static GameModeConfig<Material, SchematicType, String> 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<Material, SchematicType, String> 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();
|
||||
|
||||
+1
-2
@@ -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<SchematicType> 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<SWListInv.SWListEntry<SchematicType>> items = types.stream()
|
||||
|
||||
+1
-2
@@ -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<Material, SchematicType, String> checkSchemType = CheckSchemTypeManager.get(type);
|
||||
GameModeConfig<Material, SchematicType, String> checkSchemType = SchematicSystem.getGameModeConfig(type);
|
||||
if (checkSchemType.isAfterDeadline()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.Deadline);
|
||||
return;
|
||||
|
||||
+3
-3
@@ -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<GameModeConfig<Material, SchematicType, String>>() {
|
||||
@Override
|
||||
public Collection<String> 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<Material, SchematicType, String> 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+1
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user