From c6dbece55056b21672327524fd1b753413a48d65 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 26 Oct 2025 12:34:16 +0100 Subject: [PATCH] Improve GameModeConfig --- .../de/steamwar/bausystem/region/Region.java | 4 +- .../region/fixed/FixedGlobalRegion.java | 5 +- .../bausystem/region/fixed/FixedRegion.java | 6 +- .../{data => sql}/GameModeConfig.java | 157 ++++++++++-------- .../SQL/src/de/steamwar/sql/SQLWrapper.java | 3 +- .../src/de/steamwar/sql/SchematicType.java | 30 ++-- .../de/steamwar/{data => sql}/YMLWrapper.java | 31 ++-- .../src/de/steamwar/fightsystem/Config.java | 6 +- .../autocheck/AutoChecker15.java | 6 +- .../schematiccommand/SchematicCommand15.java | 4 +- .../autocheck/AutoChecker8.java | 6 +- .../schematiccommand/SchematicCommand8.java | 4 +- .../schematicsystem/SchematicSystem.java | 8 +- .../autocheck/AutoChecker.java | 10 +- .../autocheck/AutoCheckerResult.java | 4 +- .../schematiccommand/SchematicCommand.java | 6 +- .../SchematicCommandUtils.java | 6 +- .../schematiccommand/SchematicMapper.java | 8 +- .../schematiccommand/parts/CheckPart.java | 10 +- .../src/de/steamwar/sql/SQLWrapperImpl.java | 4 +- .../de/steamwar/velocitycore/ArenaMode.java | 20 +-- .../steamwar/velocitycore/ServerStarter.java | 6 +- .../steamwar/velocitycore/ServerVersion.java | 4 +- .../velocitycore/commands/BauCommand.java | 4 +- .../commands/BuilderCloudCommand.java | 4 +- .../commands/ChallengeCommand.java | 5 +- .../velocitycore/commands/CheckCommand.java | 4 +- .../velocitycore/commands/FightCommand.java | 12 +- .../commands/HistoricCommand.java | 5 +- .../velocitycore/commands/RankCommand.java | 4 +- .../velocitycore/commands/ReplayCommand.java | 4 +- .../velocitycore/commands/TypeMappers.java | 10 +- .../velocitycore/listeners/ChatListener.java | 2 +- .../network/handlers/EloPlayerHandler.java | 4 +- .../network/handlers/EloSchemHandler.java | 4 +- .../network/handlers/PrepareSchemHandler.java | 4 +- 36 files changed, 212 insertions(+), 202 deletions(-) rename CommonCore/SQL/src/de/steamwar/{data => sql}/GameModeConfig.java (82%) rename CommonCore/SQL/src/de/steamwar/{data => sql}/YMLWrapper.java (84%) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 4b98caf1..0a022cfe 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import lombok.NonNull; import org.bukkit.Location; @@ -67,7 +67,7 @@ public interface Region { Area getTestblockArea(); @NonNull - GameModeConfig getGameModeConfig(); + GameModeConfig getGameModeConfig(); @NonNull RegionHistory getHistory(); 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 1bf07d5a..cac519e0 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 @@ -22,9 +22,8 @@ package de.steamwar.bausystem.region.fixed; 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.GameModeConfigUtils; -import de.steamwar.sql.SchematicType; +import de.steamwar.sql.GameModeConfig; import lombok.NonNull; import lombok.Setter; import org.bukkit.Location; @@ -94,7 +93,7 @@ public final class FixedGlobalRegion implements Region { } }; - private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig<>(null, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); + private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig<>(null, GameModeConfigUtils.ToMaterial, 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 1eb0ab62..ce48b5b6 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 @@ -28,8 +28,8 @@ import de.steamwar.bausystem.utils.FlatteningWrapper; 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.GameModeConfigUtils; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import lombok.NonNull; import org.bukkit.Bukkit; @@ -60,7 +60,7 @@ public class FixedRegion implements Region { private final Area testblock; private final int floorLevel; private final int waterLevel; - private final GameModeConfig gameModeConfig; + private final GameModeConfig gameModeConfig; private final RegionData regionData; private final RegionHistory regionHistory = new RegionHistory.Impl(20); @@ -339,7 +339,7 @@ public class FixedRegion implements Region { break; } } - this.gameModeConfig = new GameModeConfig<>(found, GameModeConfigUtils.ToMaterial, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); + this.gameModeConfig = new GameModeConfig<>(found, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); this.regionData = new RegionData.RegionDataImpl(regionData, WorldData::write); } diff --git a/CommonCore/SQL/src/de/steamwar/data/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java similarity index 82% rename from CommonCore/SQL/src/de/steamwar/data/GameModeConfig.java rename to CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index b9c8919b..942df6d1 100644 --- a/CommonCore/SQL/src/de/steamwar/data/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -17,12 +17,12 @@ * along with this program. If not, see . */ -package de.steamwar.data; +package de.steamwar.sql; -import de.steamwar.sql.SchematicType; import lombok.ToString; import java.io.File; +import java.lang.reflect.Field; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Instant; @@ -32,10 +32,9 @@ import java.util.function.Function; import java.util.stream.Collectors; @ToString -public final class GameModeConfig { +public final class GameModeConfig { 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"); @@ -44,10 +43,11 @@ public final class GameModeConfig { public final boolean loaded; public final File configFile; - public final Server Server; + public final ServerConfig Server; /** * Submission deadline for schematics in 'dd.MM.yyyy HH:mm' format + * * @implSpec {@code null} by default */ public final Date Deadline; @@ -58,9 +58,9 @@ public final class GameModeConfig { * @implSpec Disables check schem type if missing */ public final List CheckQuestions; - public final Times Times; - public final Arena Arena; - public final Schematic Schematic; + public final TimesConfig Times; + public final ArenaConfig Arena; + public final SchematicConfig Schematic; /** * The name of the game mode presented to the players @@ -83,28 +83,39 @@ public final class GameModeConfig { * @implSpec {@code +} by default */ public final String TeamChatPrefix; - public final Blue Blue; - public final Red Red; + public final BlueConfig Blue; + public final RedConfig Red; /** * The list of active win conditions */ public final List WinConditions; - public final WinConditionParams WinConditionParams; - public final Kits Kits; + public final WinConditionParamsConfig WinConditionParams; + public final KitsConfig Kits; /** * A list of integers containing the waiting time of this enter stage in the fight */ public final List EnterStages; - public final Techhider Techhider; + public final TechhiderConfig Techhider; - public GameModeConfig(File file, Function materialMapper, Function schematicTypeMapper, Function winconditionMapper, Function defaultGameName) { - YMLWrapper loader = new YMLWrapper<>(file, materialMapper, schematicTypeMapper, winconditionMapper); + private static final Field Schematic_TypeField; + + static { + try { + Schematic_TypeField = SchematicConfig.class.getDeclaredField("Type"); + Schematic_TypeField.setAccessible(true); + } catch (NoSuchFieldException e) { + throw new SecurityException(e.getMessage(), e); + } + } + + public GameModeConfig(File file, Function materialMapper, Function winconditionMapper, Function defaultGameName) { + YMLWrapper loader = new YMLWrapper<>(file, materialMapper, winconditionMapper); configFile = file; loaded = loader.canLoad(); - Server = new Server(loader.with("Server")); + Server = new ServerConfig(loader.with("Server")); String deadlineString = loader.getString("Deadline", null); if (deadlineString != null) { @@ -120,25 +131,44 @@ public final class GameModeConfig { } CheckQuestions = loader.getStringList("CheckQuestions"); - Times = new Times(loader.with("Times")); + Times = new TimesConfig(loader.with("Times")); // Arena would be here to be in config order but needs Schematic.Size and EnterStages loaded afterwards - Schematic = new Schematic<>(loader.with("Schematic")); + Schematic = new SchematicConfig<>(loader.with("Schematic")); GameName = loader.getString("GameName", defaultGameName.apply(file)); ActiveMonths = loader.getIntList("ActiveMonths"); TeamChatPrefix = loader.getString("TeamChatPrefix", "+"); - Blue = new Blue(loader.with("Blue")); - Red = new Red(loader.with("Red")); + Blue = new BlueConfig(loader.with("Blue")); + Red = new RedConfig(loader.with("Red")); WinConditions = Collections.unmodifiableList(loader.getStringList("WinConditions").stream().map(loader.winconditionMapper).collect(Collectors.toList())); - WinConditionParams = new WinConditionParams<>(loader.with("WinConditionParams")); - Kits = new Kits<>(loader.with("Kits")); + WinConditionParams = new WinConditionParamsConfig<>(loader.with("WinConditionParams")); + Kits = new KitsConfig<>(loader.with("Kits")); EnterStages = loader.getIntList("EnterStages"); - Techhider = new Techhider<>(loader.with("Techhider")); + Techhider = new TechhiderConfig<>(loader.with("Techhider")); - Arena = new Arena(loader.with("Arena"), Schematic.Size, EnterStages); + Arena = new ArenaConfig(loader.with("Arena"), Schematic.Size, EnterStages); + + if (Schematic.Type != null) return; + if (!Schematic.loaded) return; + String Schematic_Type = loader.with("Schematic").getString("Type", "Normal"); + if (Schematic_Type.equals("Normal")) return; + String Schematic_Shortcut = Schematic.Shortcut; + + SchematicType checktype = null; + String material = loader.with("Schematic").getString("Material", "STONE_BUTTON"); + + if (!CheckQuestions.isEmpty()) { + checktype = new SchematicType("C" + Schematic_Type, "C" + Schematic_Shortcut, SchematicType.Type.CHECK_TYPE, null, material, true); + } + SchematicType current = new SchematicType(Schematic_Type, Schematic_Shortcut, Server.loaded ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, Deadline, Schematic.ManualCheck); + try { + Schematic_TypeField.set(Schematic, current); + } catch (IllegalAccessException e) { + throw new SecurityException(e.getMessage(), e); + } } @ToString - public static final class Server { + public static final class ServerConfig { public final boolean loaded; @@ -183,7 +213,7 @@ public final class GameModeConfig { */ public final boolean Ranked; - private Server(YMLWrapper loader) { + private ServerConfig(YMLWrapper loader) { loaded = loader.canLoad(); Folder = loader.getString("Folder", null); ServerJar = loader.getString("ServerJar", null); @@ -196,7 +226,7 @@ public final class GameModeConfig { } @ToString - public static final class Times { + public static final class TimesConfig { public final boolean loaded; /** @@ -234,7 +264,7 @@ public final class GameModeConfig { */ public final int SpectatorDuration; - private Times(YMLWrapper loader) { + private TimesConfig(YMLWrapper loader) { loaded = loader.canLoad(); NoPlayersOnlineDuration = loader.getInt("NoPlayersOnlineDuration", 300); PreSchemPasteDuration = loader.getInt("PreSchemPasteDuration", 120); @@ -245,7 +275,7 @@ public final class GameModeConfig { } @ToString - public static final class Arena { + public static final class ArenaConfig { public final boolean loaded; @@ -259,12 +289,12 @@ public final class GameModeConfig { /** * The outer border of the arena, measured in blocks around the schematic areas */ - public final Schem2Border Schem2Border; + public final Schem2BorderConfig Schem2Border; /** * The offset the teams spawn relative to the center of their area */ - public final SpawnOffset SpawnOffset; + public final SpawnOffsetConfig SpawnOffset; /** * The size of the team areas are expanded around the schematics @@ -308,11 +338,11 @@ public final class GameModeConfig { */ public final boolean NoFloor; - private Arena(YMLWrapper loader, Schematic.Size Size, List EnterStages) { + private ArenaConfig(YMLWrapper loader, SchematicConfig.SizeConfig Size, List EnterStages) { loaded = loader.canLoad(); WaterDepth = loader.getInt("WaterDepth", 0); - Schem2Border = new Schem2Border(loader.with("Schem2Border")); - SpawnOffset = new SpawnOffset(loader.with("SpawnOffset"), Size); + Schem2Border = new Schem2BorderConfig(loader.with("Schem2Border")); + SpawnOffset = new SpawnOffsetConfig(loader.with("SpawnOffset"), Size); BorderFromSchematic = loader.getInt("BorderFromSchematic", 21); GroundWalkable = loader.getBoolean("GroundWalkable", true); DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false); @@ -322,7 +352,7 @@ public final class GameModeConfig { } @ToString - public static final class Schem2Border { + public static final class Schem2BorderConfig { public final boolean loaded; @@ -336,7 +366,7 @@ public final class GameModeConfig { */ public final int z; - private Schem2Border(YMLWrapper loader) { + private Schem2BorderConfig(YMLWrapper loader) { loaded = loader.canLoad(); x = loader.getInt("x", 24); z = loader.getInt("z", 24); @@ -344,7 +374,7 @@ public final class GameModeConfig { } @ToString - public static final class SpawnOffset { + public static final class SpawnOffsetConfig { public final boolean loaded; @@ -363,7 +393,7 @@ public final class GameModeConfig { */ public final double z; - private SpawnOffset(YMLWrapper loader, Schematic.Size Size) { + private SpawnOffsetConfig(YMLWrapper loader, SchematicConfig.SizeConfig Size) { loaded = loader.canLoad(); x = loader.getDouble("x", 0); y = loader.getDouble("y", Size.y); @@ -373,31 +403,31 @@ public final class GameModeConfig { } @ToString - public static final class Schematic { + public static final class SchematicConfig { public final boolean loaded; /** * The size of the schematics */ - public final Size Size; + public final SizeConfig Size; /** * Used for GameModes with a technic area */ - public final Inset Inset; + public final InsetConfig Inset; /** * The schematic type that can be chosen in this arena * * @implSpec {@code Normal} by default */ - public final ST Type; + public final SchematicType Type; /** * The schematic types that are also allowed to be chosen in this arena */ - public final List SubTypes; + public final List SubTypes; /** * Shortcut of the schematic type @@ -496,10 +526,10 @@ public final class GameModeConfig { */ public final Map, Integer> Limited; - private Schematic(YMLWrapper loader) { + private SchematicConfig(YMLWrapper loader) { loaded = loader.canLoad(); - Size = new Size(loader.with("Size")); - Inset = new Inset(loader.with("Inset")); + Size = new SizeConfig(loader.with("Size")); + Inset = new InsetConfig(loader.with("Inset")); Type = loader.getSchematicType("Type", "Normal"); SubTypes = loader.getSchematicTypeList("SubTypes"); Shortcut = loader.getString("Shortcut", ""); @@ -532,7 +562,7 @@ public final class GameModeConfig { } @ToString - public static final class Size { + public static final class SizeConfig { public final boolean loaded; @@ -551,7 +581,7 @@ public final class GameModeConfig { */ public final int z; - private Size(YMLWrapper loader) { + private SizeConfig(YMLWrapper loader) { loaded = loader.canLoad(); x = loader.getInt("x", 0); y = loader.getInt("y", 0); @@ -560,7 +590,7 @@ public final class GameModeConfig { } @ToString - public static final class Inset { + public static final class InsetConfig { public final boolean loaded; @@ -584,7 +614,7 @@ public final class GameModeConfig { */ public final int bottom; - private Inset(YMLWrapper loader) { + private InsetConfig(YMLWrapper loader) { loaded = loader.canLoad(); x = loader.getInt("x", 0); z = loader.getInt("z", 0); @@ -595,7 +625,7 @@ public final class GameModeConfig { } @ToString - public static final class Blue { + public static final class BlueConfig { public final boolean loaded; @@ -609,7 +639,7 @@ public final class GameModeConfig { */ public final String Prefix; - private Blue(YMLWrapper loader) { + private BlueConfig(YMLWrapper loader) { loaded = loader.canLoad(); Name = loader.getString("Name", "Blau"); Prefix = loader.getString("Prefix", "§3"); @@ -617,7 +647,7 @@ public final class GameModeConfig { } @ToString - public static final class Red { + public static final class RedConfig { public final boolean loaded; @@ -631,7 +661,7 @@ public final class GameModeConfig { */ public final String Prefix; - private Red(YMLWrapper loader) { + private RedConfig(YMLWrapper loader) { loaded = loader.canLoad(); Name = loader.getString("Name", "Rot"); Prefix = loader.getString("Prefix", "§c"); @@ -639,7 +669,7 @@ public final class GameModeConfig { } @ToString - public static final class WinConditionParams { + public static final class WinConditionParamsConfig { public final boolean loaded; @@ -683,7 +713,7 @@ public final class GameModeConfig { */ public final int TechKoTime; - private WinConditionParams(YMLWrapper loader) { + private WinConditionParamsConfig(YMLWrapper loader) { loaded = loader.canLoad(); TimeoutTime = loader.getInt("TimeoutTime", 1200); PercentWin = loader.getDouble("PercentWin", 7.0); @@ -695,7 +725,7 @@ public final class GameModeConfig { } @ToString - public static final class Kits { + public static final class KitsConfig { public final boolean loaded; @@ -732,7 +762,7 @@ public final class GameModeConfig { */ public final List ForbiddenItems; - private Kits(YMLWrapper loader) { + private KitsConfig(YMLWrapper loader) { loaded = loader.canLoad(); File = loader.getString("File", "kits.yml"); MemberDefault = loader.getString("MemberDefault", "default"); @@ -743,7 +773,7 @@ public final class GameModeConfig { } @ToString - public static final class Techhider { + public static final class TechhiderConfig { public final boolean loaded; @@ -771,7 +801,7 @@ public final class GameModeConfig { */ public final Set HiddenBlockEntities; - private Techhider(YMLWrapper loader) { + private TechhiderConfig(YMLWrapper loader) { loaded = loader.canLoad(); Active = loader.getBoolean("Active", false); ObfuscateWith = loader.getMaterial("ObfuscateWith", "end_stone"); @@ -816,12 +846,7 @@ public final class GameModeConfig { public String getSchemTypeOrInternalName() { if (Schematic.loaded) { - ST type = Schematic.Type; - if (type instanceof SchematicType) { - return ((SchematicType) type).toDB(); - } else if (type instanceof String) { - return (String) type; - } + return Schematic.Type.toDB(); } return configFile.getName().replace(".yml", ""); } diff --git a/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java b/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java index ac1424f0..0dbdde69 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java +++ b/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java @@ -20,7 +20,6 @@ package de.steamwar.sql; import de.steamwar.ImplementationProvider; -import de.steamwar.data.GameModeConfig; import java.io.File; @@ -29,7 +28,7 @@ public interface SQLWrapper { File getSchemTypesFolder(); - default void processSchematicType(GameModeConfig gameModeConfig, SchematicType type) { + default void processSchematicType(GameModeConfig gameModeConfig) { } void additionalExceptionMetadata(StringBuilder builder); diff --git a/CommonCore/SQL/src/de/steamwar/sql/SchematicType.java b/CommonCore/SQL/src/de/steamwar/sql/SchematicType.java index 3cab7f0a..04af18ef 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SchematicType.java +++ b/CommonCore/SQL/src/de/steamwar/sql/SchematicType.java @@ -19,7 +19,6 @@ package de.steamwar.sql; -import de.steamwar.data.GameModeConfig; import de.steamwar.sql.internal.SqlTypeMapper; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -47,28 +46,18 @@ public class SchematicType { File folder = SQLWrapper.impl.getSchemTypesFolder(); if (folder.exists()) { 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, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); - if (!gameModeConfig.Schematic.loaded) continue; - String type = gameModeConfig.Schematic.Type; - assert type != null; - String shortcut = gameModeConfig.Schematic.Shortcut; - if (tmpFromDB.containsKey(type.toLowerCase())) - continue; - - SchematicType checktype = null; - String material = gameModeConfig.Schematic.Material; - + GameModeConfig gameModeConfig = new GameModeConfig<>(configFile, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); + if (gameModeConfig.Schematic.Type == null) continue; + if (tmpFromDB.containsKey(gameModeConfig.Schematic.Type.toDB())) continue; + SchematicType current = gameModeConfig.Schematic.Type; if (!gameModeConfig.CheckQuestions.isEmpty()) { - checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true); - tmpTypes.add(checktype); - tmpFromDB.put(checktype.toDB(), checktype); + SchematicType checkType = current.checkType; + tmpTypes.add(checkType); + tmpFromDB.put(checkType.toDB(), checkType); } - - SchematicType current = new SchematicType(type, shortcut, gameModeConfig.Server.loaded ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, gameModeConfig.Deadline, gameModeConfig.Schematic.ManualCheck); tmpTypes.add(current); - tmpFromDB.put(type.toLowerCase(), current); - - SQLWrapper.impl.processSchematicType(gameModeConfig, current); + tmpFromDB.put(current.toDB(), current); + SQLWrapper.impl.processSchematicType(gameModeConfig); } } time = System.currentTimeMillis() - time; @@ -143,6 +132,7 @@ public class SchematicType { } public static SchematicType fromDB(String input) { + if (fromDB == null) return null; return fromDB.get(input.toLowerCase()); } diff --git a/CommonCore/SQL/src/de/steamwar/data/YMLWrapper.java b/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java similarity index 84% rename from CommonCore/SQL/src/de/steamwar/data/YMLWrapper.java rename to CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java index 30d6d9ae..d7afa5e6 100644 --- a/CommonCore/SQL/src/de/steamwar/data/YMLWrapper.java +++ b/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.data; +package de.steamwar.sql; import org.yaml.snakeyaml.Yaml; @@ -31,18 +31,16 @@ import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; -final class YMLWrapper { +final class YMLWrapper { final Function materialMapper; - final Function schematicTypeMapper; final Function winconditionMapper; private final boolean canLoad; private final Map document; - YMLWrapper(File file, Function materialMapper, Function schematicTypeMapper, Function winconditionMapper) { + YMLWrapper(File file, Function materialMapper, Function winconditionMapper) { this.materialMapper = materialMapper; - this.schematicTypeMapper = schematicTypeMapper; this.winconditionMapper = winconditionMapper; Yaml yaml = new Yaml(); @@ -60,9 +58,8 @@ final class YMLWrapper { this.canLoad = canLoad; } - private YMLWrapper(boolean canLoad, Map document, Function materialMapper, Function schematicTypeMapper, Function winconditionMapper) { + private YMLWrapper(boolean canLoad, Map document, Function materialMapper, Function winconditionMapper) { this.materialMapper = materialMapper; - this.schematicTypeMapper = schematicTypeMapper; this.winconditionMapper = winconditionMapper; this.canLoad = canLoad; this.document = document; @@ -72,24 +69,26 @@ final class YMLWrapper { return canLoad; } - public YMLWrapper with(String path) { + public YMLWrapper with(String path) { if (document.containsKey(path)) { Object value = document.get(path); if (value instanceof Map) { - return new YMLWrapper<>(true, (Map) value, materialMapper, schematicTypeMapper, winconditionMapper); + return new YMLWrapper<>(true, (Map) value, materialMapper, winconditionMapper); } } - return new YMLWrapper<>(false, Collections.emptyMap(), materialMapper, schematicTypeMapper, winconditionMapper); + return new YMLWrapper<>(false, Collections.emptyMap(), materialMapper, winconditionMapper); } public T get(String path, T defaultValue, Function mapper) { Object value = this.document.get(path); if (value == null) return defaultValue; try { - return mapper.apply(value); + T mapped = mapper.apply(value); + if (mapped != null) return mapped; } catch (ClassCastException e) { - return defaultValue; + // Ignore exception } + return defaultValue; } public String getString(String path, String defaultValue) { @@ -108,9 +107,9 @@ final class YMLWrapper { return get(path, defaultValue, Boolean.class::cast); } - public ST getSchematicType(String path, String defaultValue) { + public SchematicType getSchematicType(String path, String defaultValue) { String schematicType = getString(path, defaultValue); - return schematicTypeMapper.apply(schematicType); + return SchematicType.fromDB(schematicType); } public M getMaterial(String path, String defaultValue) { @@ -135,12 +134,12 @@ final class YMLWrapper { return get(path, o -> (List) o); } - public List getSchematicTypeList(String path) { + public List getSchematicTypeList(String path) { List list = getStringList(path); if (list.isEmpty()) { return Collections.emptyList(); } else { - return Collections.unmodifiableList(list.stream().map(schematicTypeMapper).collect(Collectors.toList())); + return Collections.unmodifiableList(list.stream().map(SchematicType::fromDB).collect(Collectors.toList())); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 93f263bb..3b8d2378 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -19,7 +19,7 @@ package de.steamwar.fightsystem; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.data.GameModeConfigUtils; import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.winconditions.Winconditions; @@ -45,7 +45,7 @@ public class Config { public static final World world = Bukkit.getWorlds().get(0); - public static final GameModeConfig GameModeConfig; + public static final GameModeConfig GameModeConfig; //arena parameter public static final Region BluePasteRegion; @@ -109,7 +109,7 @@ public class Config { Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!"); Bukkit.shutdown(); } - GameModeConfig = new GameModeConfig<>(new File(FightSystem.getPlugin().getDataFolder(), configFile), GameModeConfigUtils.ToMaterial, de.steamwar.data.GameModeConfig.ToSchematicType, Winconditions::valueOf, de.steamwar.data.GameModeConfig.ToStaticWarGear); + GameModeConfig = new GameModeConfig<>(new File(FightSystem.getPlugin().getDataFolder(), configFile), GameModeConfigUtils.ToMaterial, Winconditions::valueOf, de.steamwar.sql.GameModeConfig.ToStaticWarGear); File worldConfigFile = new File(world.getWorldFolder(), "config.yml"); if(!worldConfigFile.exists()) { diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java index d77f615c..97cf6de3 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java @@ -24,7 +24,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import org.bukkit.Material; @@ -119,7 +119,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { } @Override - public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { + public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { return AutoCheckerResult.builder() .type(type) .height(clipboard.getDimensions().getBlockY()) @@ -131,7 +131,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { } @Override - public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { + public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { return AutoCheckerResult.builder() .type(type) .height(clipboard.getDimensions().getBlockY()) diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java index 1a7f8a97..62fa611e 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java @@ -31,7 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.autocheck.BlockPos; import de.steamwar.sql.SchematicType; @@ -42,7 +42,7 @@ import java.util.stream.Collectors; public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { @Override - public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { + public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()); clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap()))); diff --git a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java b/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java index cf457f62..c98b136a 100644 --- a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java +++ b/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java @@ -25,7 +25,7 @@ import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.regions.Region; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import org.bukkit.Material; @@ -149,7 +149,7 @@ public class AutoChecker8 implements AutoChecker.IAutoChecker { } @Override - public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { + public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { AutoChecker.BlockScanResult blockScanResult = new AutoChecker.BlockScanResult(); scan(blockScanResult, clipboard); @@ -164,7 +164,7 @@ public class AutoChecker8 implements AutoChecker.IAutoChecker { } @Override - public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { + public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { return AutoCheckerResult.builder() .type(type) .height(clipboard.getDimensions().getBlockY()) diff --git a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java b/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java index 58c334cd..e873ea49 100644 --- a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java +++ b/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java @@ -24,7 +24,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.sql.SchematicType; import org.bukkit.Material; @@ -32,7 +32,7 @@ import org.bukkit.Material; public class SchematicCommand8 implements SchematicCommand.ISchematicCommand { @Override - public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { + public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { return null; } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java index a5826c70..b75ddbdf 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -19,7 +19,7 @@ package de.steamwar.schematicsystem; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.data.GameModeConfigUtils; import de.steamwar.linkage.AbstractLinker; import de.steamwar.linkage.SpigotLinker; @@ -38,9 +38,9 @@ public class SchematicSystem extends JavaPlugin { private static SchematicSystem instance; - private static final Map> types = new HashMap<>(); + private static final Map> types = new HashMap<>(); - public static GameModeConfig getGameModeConfig(SchematicType type){ + public static GameModeConfig getGameModeConfig(SchematicType type){ return types.get(type); } @@ -51,7 +51,7 @@ public class SchematicSystem extends JavaPlugin { 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); + GameModeConfig gameModeConfig = new GameModeConfig<>(configFile, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear); if (gameModeConfig.CheckQuestions.isEmpty() && gameModeConfig.Schematic.ManualCheck) continue; types.put(gameModeConfig.Schematic.Type, gameModeConfig); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java index ac4220fe..eb464553 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java @@ -21,7 +21,7 @@ package de.steamwar.schematicsystem.autocheck; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.core.VersionDependent; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.SchematicType; import lombok.Getter; @@ -32,19 +32,19 @@ import java.util.*; public class AutoChecker { - public static AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { + public static AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { return impl.check(clipboard, type); } - public static AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { + public static AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { return impl.sizeCheck(clipboard, type); } private static final IAutoChecker impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); public interface IAutoChecker { - AutoCheckerResult check(Clipboard clipboard, GameModeConfig type); - AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type); + AutoCheckerResult check(Clipboard clipboard, GameModeConfig type); + AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type); } @Getter diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java index 9aad0edb..60ab9070 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java @@ -20,7 +20,7 @@ package de.steamwar.schematicsystem.autocheck; import de.steamwar.core.Core; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.SchematicType; import lombok.Builder; @@ -38,7 +38,7 @@ import java.util.Map; @Getter @ToString public class AutoCheckerResult { - private final GameModeConfig type; + private final GameModeConfig type; private final int width; private final int height; private final int depth; diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java index 5b9add07..90c6d3c7 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java @@ -27,7 +27,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; import de.steamwar.core.VersionDependent; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; @@ -113,7 +113,7 @@ public class SchematicCommand extends SWCommand { } @ClassMapper(value = GameModeConfig.class, local = true) - public static TypeMapper> gameModeConfigTypeMapper() { + public static TypeMapper> gameModeConfigTypeMapper() { return SchematicMapper.gameModeConfigTypeMapper(); } @@ -150,7 +150,7 @@ public class SchematicCommand extends SWCommand { public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); public interface ISchematicCommand { - Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception; + Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception; void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException; } } 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 03f2f328..cea1122c 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 @@ -20,7 +20,7 @@ package de.steamwar.schematicsystem.commands.schematiccommand; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.network.NetworkSender; @@ -312,7 +312,7 @@ public class SchematicCommandUtils { } } - public static void check(Player player, Clipboard clipboard, GameModeConfig type, String schemName, boolean gui) { + public static void check(Player player, Clipboard clipboard, GameModeConfig type, String schemName, boolean gui) { AutoCheckerResult result = AutoChecker.check(clipboard, type); if(!result.isOk()) { result.sendErrorMessage(player, schemName); @@ -455,7 +455,7 @@ public class SchematicCommandUtils { return; } - GameModeConfig checkSchemType = SchematicSystem.getGameModeConfig(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 a7f50dd7..157e8d2d 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 @@ -20,7 +20,7 @@ package de.steamwar.schematicsystem.commands.schematiccommand; import de.steamwar.command.TypeMapper; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.NodeMember; import de.steamwar.sql.SchematicNode; @@ -177,15 +177,15 @@ public class SchematicMapper { }; } - public static TypeMapper> gameModeConfigTypeMapper() { - return new TypeMapper>() { + public static TypeMapper> gameModeConfigTypeMapper() { + return new TypeMapper>() { @Override public Collection tabCompletes(CommandSender commandSender, String[] strings, String s) { 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) { + public GameModeConfig map(CommandSender commandSender, String[] previousArguments, String s) { 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/CheckPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java index bf0f0c8e..9e3be830 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.session.ClipboardHolder; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoChecker; @@ -54,7 +54,7 @@ public class CheckPart extends SWCommand { } @Register("check") - public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, GameModeConfig type) { + public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, GameModeConfig type) { try { check(player, new SchematicData(node).load(), type, node.getName(), false); } catch (IOException e) { @@ -63,7 +63,7 @@ public class CheckPart extends SWCommand { } @Register(value = {"check", "clipboard"}) - public void checkClipboardCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { + public void checkClipboardCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { try { check(player, WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(), type, "clipboard", false); } catch (EmptyClipboardException e) { @@ -72,7 +72,7 @@ public class CheckPart extends SWCommand { } @Register(value = {"check", "selection"}) - public void checkSelectionCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { + public void checkSelectionCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { try { Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getSelection(new BukkitWorld(player.getWorld()))); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1); @@ -88,7 +88,7 @@ public class CheckPart extends SWCommand { } @Register("fix") - public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { + public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { if(Core.getVersion() < 15) { SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player); return; diff --git a/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java b/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java index 0c2aa004..1868fd9f 100644 --- a/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/VelocityCore/src/de/steamwar/sql/SQLWrapperImpl.java @@ -21,7 +21,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.velocitycore.VelocityCore; import de.steamwar.velocitycore.commands.CheckCommand; @@ -35,7 +34,8 @@ public class SQLWrapperImpl implements SQLWrapper { } @Override - public void processSchematicType(GameModeConfig gameModeConfig, SchematicType type) { + public void processSchematicType(GameModeConfig gameModeConfig) { + SchematicType type = gameModeConfig.Schematic.Type; if (type.checkType() != null) { CheckCommand.setCheckQuestions(type.checkType(), gameModeConfig.CheckQuestions); CheckCommand.addFightType(type.checkType(), type); diff --git a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java index 63c0187e..9707bdd9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java @@ -19,7 +19,7 @@ package de.steamwar.velocitycore; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import lombok.Getter; import lombok.experimental.UtilityClass; @@ -30,11 +30,11 @@ import java.util.*; @UtilityClass public class ArenaMode { - private static final Map> byChat = new HashMap<>(); - private static final Map> byInternal = new HashMap<>(); - private static final Map> bySchemType = new HashMap<>(); + private static final Map> byChat = new HashMap<>(); + private static final Map> byInternal = new HashMap<>(); + private static final Map> bySchemType = new HashMap<>(); @Getter - private static final List> allModes = new LinkedList<>(); + private static final List> allModes = new LinkedList<>(); static { init(); @@ -51,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, GameModeConfig.ToString, GameModeConfig.ToSchematicType, GameModeConfig.ToString, GameModeConfig.ToInternalName); + GameModeConfig gameModeConfig = new GameModeConfig<>(file, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToInternalName); if (!gameModeConfig.Server.loaded) continue; allModes.add(gameModeConfig); @@ -65,24 +65,24 @@ public class ArenaMode { } } - public static GameModeConfig getByChat(String name){ + public static GameModeConfig getByChat(String name){ return byChat.get(name.toLowerCase()); } - public static GameModeConfig getByInternal(String name){ + public static GameModeConfig getByInternal(String name){ return byInternal.get(name); } public static List getAllChatNames(boolean historic) { List chatNames = new LinkedList<>(); - for(GameModeConfig mode : byInternal.values()){ + for(GameModeConfig mode : byInternal.values()){ if(mode.isActive() && historic == mode.Server.Historic) chatNames.addAll(mode.Server.ChatNames); } return chatNames; } - public static GameModeConfig getBySchemType(SchematicType schemType){ + public static GameModeConfig getBySchemType(SchematicType schemType){ return bySchemType.get(schemType); } } diff --git a/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java b/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java index 31f73773..3b56256a 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java @@ -22,7 +22,7 @@ package de.steamwar.velocitycore; import com.velocitypowered.api.proxy.Player; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.velocity.platform.VelocityViaConfig; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.messages.Chatter; import de.steamwar.persistent.Arenaserver; import de.steamwar.persistent.Bauserver; @@ -80,7 +80,7 @@ public class ServerStarter { private final Set playersToSend = new HashSet<>(); private final Map arguments = new HashMap<>(); - public ServerStarter arena(GameModeConfig mode, String map) { + public ServerStarter arena(GameModeConfig mode, String map) { portrange = ARENA_PORTS; serverNameProvider = port -> mode.GameName + (port - portrange.start); version = ServerVersion.from(mode); @@ -116,7 +116,7 @@ public class ServerStarter { return this; } - public ServerStarter test(GameModeConfig mode, String map, Player owner) { + public ServerStarter test(GameModeConfig mode, String map, Player owner) { arena(mode, map); buildWithTemp(owner); portrange = BAU_PORTS; diff --git a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java index 260bbec6..5d3689f9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java @@ -20,7 +20,7 @@ package de.steamwar.velocitycore; import com.velocitypowered.api.network.ProtocolVersion; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import lombok.AllArgsConstructor; import lombok.Getter; @@ -115,7 +115,7 @@ public enum ServerVersion { private static final Pattern terminatingNumber = Pattern.compile("(\\d+)$"); - public static ServerVersion from(GameModeConfig type) { + public static ServerVersion from(GameModeConfig type) { Matcher matcher = terminatingNumber.matcher(type.Server.Folder); matcher.find(); return ServerVersion.valueOf((type.Server.Spigot ? "SPIGOT_" : "PAPER_") + matcher.group(1)); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java index 48ab4d05..0d679ca9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java @@ -23,7 +23,7 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.EventMode; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; @@ -240,7 +240,7 @@ public class BauCommand extends SWCommand { @Register("test") @Register("testarena") - public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { + public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { FightCommand.createArena(sender, "/bau testarena ", false, arenaMode, map, false, (chatter, mode, m) -> new ServerStarter().test(mode, m, sender.getPlayer()).start() ); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java index 6dc12264..5ae01fe7 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java @@ -19,7 +19,7 @@ package de.steamwar.velocitycore.commands; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicType; import de.steamwar.velocitycore.ArenaMode; @@ -87,7 +87,7 @@ public class BuilderCloudCommand extends SWCommand { } @Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE") - public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") GameModeConfig arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) { + public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") GameModeConfig arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) { if(!mapFile(version, map).exists()) { sender.system("BUILDERCLOUD_UNKNOWN_MAP"); return; diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java index 024d4de4..c9ab1f84 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java @@ -22,7 +22,7 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.EventMode; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; @@ -31,7 +31,6 @@ import de.steamwar.messages.PlayerChatter; import de.steamwar.persistent.Subserver; import de.steamwar.sql.IgnoreSystem; import de.steamwar.sql.SchematicType; -import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.ServerStarter; import net.kyori.adventure.text.event.ClickEvent; @@ -48,7 +47,7 @@ public class ChallengeCommand extends SWCommand { } @Register(description = "CHALLENGE_USAGE") - public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { + public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { FightCommand.createArena(sender, "/challenge " + target.getUsername() + " ", false, arenaMode, map, false, (chatter, mode, m) -> { Player p = sender.getPlayer(); if(challenges.containsKey(target) && challenges.get(target).contains(p)){ diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index 335e3201..218028bd 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -21,7 +21,7 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; @@ -221,7 +221,7 @@ public class CheckCommand extends SWCommand { this.startTime = Timestamp.from(Instant.now()); this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator(); - GameModeConfig mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype())); + GameModeConfig mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype())); new ServerStarter().test(mode, mode.getRandomMap(), checker.getPlayer()).check(schematic.getId()).callback(subserver -> { currentCheckers.put(checker.user().getUUID(), this); currentSchems.put(schematic.getId(), this); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java index 86ff28cd..1c1d8bd2 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java @@ -21,7 +21,7 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.EventMode; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; @@ -50,7 +50,7 @@ public class FightCommand extends SWCommand { private static void getModes(Chatter sender, String precommand, boolean historic){ Component start = Component.empty(); - for(GameModeConfig mode : ArenaMode.getAllModes()){ + for(GameModeConfig mode : ArenaMode.getAllModes()){ if (!mode.isActive() || mode.Server.Historic != historic) continue; @@ -66,7 +66,7 @@ public class FightCommand extends SWCommand { sender.sendMessage(start); } - static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, GameModeConfig arenaMode, String map, boolean historic, FightCallback callback) { + static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, GameModeConfig arenaMode, String map, boolean historic, FightCallback callback) { if (arenaMode == null) { getModes(sender, precommand, historic); return; @@ -82,7 +82,7 @@ public class FightCommand extends SWCommand { } } - private static void suggestMerging(PlayerChatter sender, GameModeConfig mode, String map, FightCallback declineMerge) { + private static void suggestMerging(PlayerChatter sender, GameModeConfig mode, String map, FightCallback declineMerge) { Arenaserver mergable = null; synchronized (Subserver.getServerList()) { for (Subserver subserver : Subserver.getServerList()) { @@ -120,7 +120,7 @@ public class FightCommand extends SWCommand { } @Register - public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { + public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { createArena(sender, "/fight ", true, arenaMode, map, false, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback( arena -> Chatter.broadcast().system("FIGHT_BROADCAST", new Message("FIGHT_BROADCAST_HOVER", p.getPlayer().getUsername()), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p.getPlayer().getUsername()) @@ -129,6 +129,6 @@ public class FightCommand extends SWCommand { } public interface FightCallback { - void run(PlayerChatter player, GameModeConfig mode, String map); + void run(PlayerChatter player, GameModeConfig mode, String map); } } diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java index cfee955d..639b25f5 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java @@ -20,14 +20,13 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.EventMode; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; import de.steamwar.sql.SchematicType; -import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.ServerStarter; import net.kyori.adventure.text.event.ClickEvent; @@ -39,7 +38,7 @@ public class HistoricCommand extends SWCommand { } @Register - public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { + public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull GameModeConfig arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback( arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", new Message("HISTORIC_BROADCAST_HOVER", p), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p.getPlayer()) ).start()); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java index 128cf5ea..b0b3e944 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java @@ -20,7 +20,7 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; @@ -48,7 +48,7 @@ public class RankCommand extends SWCommand { if (!sender.user().equals(user)) sender.prefixless("RANK_PLAYER_FOUND", user); - for(GameModeConfig mode : ArenaMode.getAllModes()) { + for(GameModeConfig mode : ArenaMode.getAllModes()) { if (!mode.Server.Ranked) continue; diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java index 72b12c4c..e4d8b3e0 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java @@ -20,7 +20,7 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.EventMode; import de.steamwar.linkage.Linked; import de.steamwar.messages.Message; @@ -69,7 +69,7 @@ public class ReplayCommand extends SWCommand { if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return; - GameModeConfig mode = ArenaMode.getBySchemType(fight.getSchemType()); + GameModeConfig mode = ArenaMode.getBySchemType(fight.getSchemType()); ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer()); String map = mode.getRandomMap(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java index 001b2b61..94c7f085 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TypeMappers.java @@ -23,7 +23,7 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.messages.Chatter; import de.steamwar.messages.PlayerChatter; import de.steamwar.sql.Punishment; @@ -47,11 +47,11 @@ public class TypeMappers { return (sender, player, messageSender) -> !PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer); } - private static TypeMapper> arenaModeTypeMapper(boolean historic) { + private static TypeMapper> arenaModeTypeMapper(boolean historic) { return new TypeMapper<>() { @Override - public GameModeConfig map(Chatter sender, PreviousArguments previousArguments, String s) { - GameModeConfig arenaMode = ArenaMode.getByChat(s); + public GameModeConfig map(Chatter sender, PreviousArguments previousArguments, String s) { + GameModeConfig arenaMode = ArenaMode.getByChat(s); if (arenaMode == null) return null; if (arenaMode.Server.Historic != historic) return null; if (!arenaMode.isActive()) return null; @@ -76,7 +76,7 @@ public class TypeMappers { @Override public Collection tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) { if (previousArguments.userArgs.length == 0) return null; - GameModeConfig arenaMode = ArenaMode.getByChat(previousArguments.userArgs[previousArguments.userArgs.length - 1]); + GameModeConfig arenaMode = ArenaMode.getByChat(previousArguments.userArgs[previousArguments.userArgs.length - 1]); if (arenaMode == null) return null; return arenaMode.Server.Maps; } diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java index 5b3ccff9..6b0c7059 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java @@ -29,7 +29,7 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.server.ServerInfo; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.ChatterGroup; diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java index 69b13b22..df2bcca8 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java @@ -20,7 +20,7 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.network.packets.PacketHandler; @@ -56,7 +56,7 @@ public class EloPlayerHandler extends PacketHandler { @Handler public void handle(FightEndsPacket fightEndsPacket) { SchematicType schematicType = SchematicType.fromDB(fightEndsPacket.getGameMode()); - GameModeConfig arenaMode; + GameModeConfig arenaMode; if (schematicType == null) { arenaMode = ArenaMode.getByInternal(fightEndsPacket.getGameMode()); } else { diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java index 036a6b2d..cd291de7 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java @@ -19,7 +19,7 @@ package de.steamwar.velocitycore.network.handlers; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightEndsPacket; @@ -46,7 +46,7 @@ public class EloSchemHandler extends PacketHandler { public void handle(FightEndsPacket fightEndsPacket) { SchematicType type = SchematicType.fromDB(fightEndsPacket.getGameMode()); if (type == null) return; - GameModeConfig arenaMode = ArenaMode.getBySchemType(type); + GameModeConfig arenaMode = ArenaMode.getBySchemType(type); if (!arenaMode.Server.Ranked) return; if (publicVsPrivate(fightEndsPacket)) diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java index da91ea50..e4c3c348 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java @@ -20,7 +20,7 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; -import de.steamwar.data.GameModeConfig; +import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.PrepareSchemPacket; @@ -37,7 +37,7 @@ public class PrepareSchemHandler extends PacketHandler { public void handle(PrepareSchemPacket packet) { Player player = VelocityCore.getProxy().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID()).orElse(null); int schematicID = packet.getSchem(); - GameModeConfig mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType())); + GameModeConfig mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType())); new ServerStarter().test(mode, mode.getRandomMap(), player).prepare(schematicID).start(); }