Add GameModeConfig#Schematic#ReplacementsWithoutBlockUpdates
Some checks failed
SteamWarCI Build failed

Add GameModeConfig#Schematic#ReplacementsWithBlockUpdates
This commit is contained in:
2026-03-15 12:49:13 +01:00
parent c1221e5cf5
commit f00bd153fe
3 changed files with 40 additions and 19 deletions

View File

@@ -605,18 +605,18 @@ public final class GameModeConfig<M, W> {
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<M, M> 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<M, M> ReplacementsWithBlockUpdates;
/**
* If the schematic perparation arena mode is time limited
@@ -673,8 +673,6 @@ public final class GameModeConfig<M, W> {
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<M, W> {
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

View File

@@ -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<M, W> {
}
}
public <K, V> Map<K, V> getMap(String path, Function<String, K> keyFunction, Function<String, V> valueFunction) {
Object data = this.document.get(path);
if (data instanceof Map) {
Map<K, V> result = new HashMap<>();
((Map<String, String>) 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<Map<?, ?>> getMapList(String path) {
Object value = this.document.get(path);
if (value instanceof List) {

View File

@@ -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<Material, Material> replacement : Config.GameModeConfig.Schematic.ReplacementsWithoutBlockUpdates.entrySet()) {
replaceSync(replacement.getKey(), replacement.getValue());
}
if (freezer != null) {
freezer.disable();
}
for (Map.Entry<Material, Material> replacement : Config.GameModeConfig.Schematic.ReplacementsWithBlockUpdates.entrySet()) {
replaceSync(replacement.getKey(), replacement.getValue());
}
}
public void pasteTeamName(){