Add GameModeConfig#Schematic#ReplacementsWithoutBlockUpdates
Some checks failed
SteamWarCI Build failed
Some checks failed
SteamWarCI Build failed
Add GameModeConfig#Schematic#ReplacementsWithBlockUpdates
This commit is contained in:
@@ -605,18 +605,18 @@ public final class GameModeConfig<M, W> {
|
|||||||
public final boolean IgnorePublicOnly;
|
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
|
* If the schematic perparation arena mode is time limited
|
||||||
@@ -673,8 +673,6 @@ public final class GameModeConfig<M, W> {
|
|||||||
PasteAligned = loader.getBoolean("PasteAligned", false);
|
PasteAligned = loader.getBoolean("PasteAligned", false);
|
||||||
OnlyPublicSchematics = loader.getBoolean("OnlyPublicSchematics", false);
|
OnlyPublicSchematics = loader.getBoolean("OnlyPublicSchematics", false);
|
||||||
IgnorePublicOnly = loader.getBoolean("IgnorePublicOnly", false);
|
IgnorePublicOnly = loader.getBoolean("IgnorePublicOnly", false);
|
||||||
ReplaceObsidianBedrock = loader.getBoolean("ReplaceObsidianBedrock", false);
|
|
||||||
ReplaceWithBlockupdates = loader.getBoolean("ReplaceWithBlockupdates", false);
|
|
||||||
UnlimitedPrepare = loader.getBoolean("UnlimitedPrepare", false);
|
UnlimitedPrepare = loader.getBoolean("UnlimitedPrepare", false);
|
||||||
MaxBlocks = loader.getInt("MaxBlocks", 0);
|
MaxBlocks = loader.getInt("MaxBlocks", 0);
|
||||||
MaxDispenserItems = loader.getInt("MaxDispenserItems", 128);
|
MaxDispenserItems = loader.getInt("MaxDispenserItems", 128);
|
||||||
@@ -698,6 +696,9 @@ public final class GameModeConfig<M, W> {
|
|||||||
Limited.put(Collections.singleton((M) material), 0);
|
Limited.put(Collections.singleton((M) material), 0);
|
||||||
});
|
});
|
||||||
this.Limited = Collections.unmodifiableMap(Limited);
|
this.Limited = Collections.unmodifiableMap(Limited);
|
||||||
|
|
||||||
|
this.ReplacementsWithoutBlockUpdates = loader.getMap("ReplacementsWithoutBlockUpdates", loader.materialMapper, loader.materialMapper);
|
||||||
|
this.ReplacementsWithBlockUpdates = loader.getMap("ReplacementsWithBlockUpdates", loader.materialMapper, loader.materialMapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import org.yaml.snakeyaml.Yaml;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
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) {
|
public List<Map<?, ?>> getMapList(String path) {
|
||||||
Object value = this.document.get(path);
|
Object value = this.document.get(path);
|
||||||
if (value instanceof List) {
|
if (value instanceof List) {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@@ -179,18 +180,24 @@ public class FightSchematic extends StateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if(!Config.GameModeConfig.Schematic.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE)
|
if (Config.mode == ArenaMode.PREPARE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FreezeWorld freezer = null;
|
FreezeWorld freezer = null;
|
||||||
if(!Config.GameModeConfig.Schematic.ReplaceWithBlockupdates)
|
if (!Config.GameModeConfig.Schematic.ReplacementsWithoutBlockUpdates.isEmpty()) {
|
||||||
freezer = new FreezeWorld();
|
freezer = new FreezeWorld();
|
||||||
|
}
|
||||||
replaceSync(Material.OBSIDIAN, Material.TNT);
|
for (Map.Entry<Material, Material> replacement : Config.GameModeConfig.Schematic.ReplacementsWithoutBlockUpdates.entrySet()) {
|
||||||
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
|
replaceSync(replacement.getKey(), replacement.getValue());
|
||||||
|
}
|
||||||
if(!Config.GameModeConfig.Schematic.ReplaceWithBlockupdates)
|
if (freezer != null) {
|
||||||
freezer.disable();
|
freezer.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<Material, Material> replacement : Config.GameModeConfig.Schematic.ReplacementsWithBlockUpdates.entrySet()) {
|
||||||
|
replaceSync(replacement.getKey(), replacement.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pasteTeamName(){
|
public void pasteTeamName(){
|
||||||
|
|||||||
Reference in New Issue
Block a user