From f00bd153fe89bc1023cb5cb77e19a9f30b940518 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 15 Mar 2026 12:49:13 +0100 Subject: [PATCH] Add GameModeConfig#Schematic#ReplacementsWithoutBlockUpdates Add GameModeConfig#Schematic#ReplacementsWithBlockUpdates --- .../src/de/steamwar/sql/GameModeConfig.java | 17 ++++++++------- .../SQL/src/de/steamwar/sql/YMLWrapper.java | 21 +++++++++++++++---- .../fightsystem/fight/FightSchematic.java | 21 ++++++++++++------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index e0b942ef..48989139 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -605,18 +605,18 @@ public final class GameModeConfig { public final boolean IgnorePublicOnly; /** - * If obsidian and bedrock should be replaced during PRE_RUNNING + * Replacements that should be done during PRE_RUNNING with no block updates * - * @implSpec {@code false} by default + * @implSpec {@code {}} by default */ - public final boolean ReplaceObsidianBedrock; + public final Map ReplacementsWithoutBlockUpdates; /** - * If the replacement should happen with block updates + * Replacements that should be done during PRE_RUNNING with block updates * - * @implSpec {@code false} by default + * @implSpec {@code {}} by default */ - public final boolean ReplaceWithBlockupdates; + public final Map ReplacementsWithBlockUpdates; /** * If the schematic perparation arena mode is time limited @@ -673,8 +673,6 @@ public final class GameModeConfig { PasteAligned = loader.getBoolean("PasteAligned", false); OnlyPublicSchematics = loader.getBoolean("OnlyPublicSchematics", false); IgnorePublicOnly = loader.getBoolean("IgnorePublicOnly", false); - ReplaceObsidianBedrock = loader.getBoolean("ReplaceObsidianBedrock", false); - ReplaceWithBlockupdates = loader.getBoolean("ReplaceWithBlockupdates", false); UnlimitedPrepare = loader.getBoolean("UnlimitedPrepare", false); MaxBlocks = loader.getInt("MaxBlocks", 0); MaxDispenserItems = loader.getInt("MaxDispenserItems", 128); @@ -698,6 +696,9 @@ public final class GameModeConfig { Limited.put(Collections.singleton((M) material), 0); }); this.Limited = Collections.unmodifiableMap(Limited); + + this.ReplacementsWithoutBlockUpdates = loader.getMap("ReplacementsWithoutBlockUpdates", loader.materialMapper, loader.materialMapper); + this.ReplacementsWithBlockUpdates = loader.getMap("ReplacementsWithBlockUpdates", loader.materialMapper, loader.materialMapper); } @ToString diff --git a/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java b/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java index 5a5f62aa..39eff9bb 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java +++ b/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java @@ -24,10 +24,7 @@ import org.yaml.snakeyaml.Yaml; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -160,6 +157,22 @@ final class YMLWrapper { } } + public Map getMap(String path, Function keyFunction, Function valueFunction) { + Object data = this.document.get(path); + if (data instanceof Map) { + Map result = new HashMap<>(); + ((Map) data).forEach((keyString, valueString) -> { + K key = keyFunction.apply(keyString.toUpperCase()); + V value = valueFunction.apply(valueString.toUpperCase()); + if (key == null || value == null) return; + result.put(key, value); + }); + return Collections.unmodifiableMap(result); + } else { + return Collections.emptyMap(); + } + } + public List> getMapList(String path) { Object value = this.document.get(path); if (value instanceof List) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java index 6345f888..7496f76a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -45,6 +45,7 @@ import org.bukkit.util.Vector; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.logging.Level; @@ -179,18 +180,24 @@ public class FightSchematic extends StateDependent { @Override public void disable() { - if(!Config.GameModeConfig.Schematic.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE) + if (Config.mode == ArenaMode.PREPARE) { return; + } FreezeWorld freezer = null; - if(!Config.GameModeConfig.Schematic.ReplaceWithBlockupdates) + if (!Config.GameModeConfig.Schematic.ReplacementsWithoutBlockUpdates.isEmpty()) { freezer = new FreezeWorld(); - - replaceSync(Material.OBSIDIAN, Material.TNT); - replaceSync(Material.BEDROCK, Material.SLIME_BLOCK); - - if(!Config.GameModeConfig.Schematic.ReplaceWithBlockupdates) + } + for (Map.Entry replacement : Config.GameModeConfig.Schematic.ReplacementsWithoutBlockUpdates.entrySet()) { + replaceSync(replacement.getKey(), replacement.getValue()); + } + if (freezer != null) { freezer.disable(); + } + + for (Map.Entry replacement : Config.GameModeConfig.Schematic.ReplacementsWithBlockUpdates.entrySet()) { + replaceSync(replacement.getKey(), replacement.getValue()); + } } public void pasteTeamName(){