diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index cea9fe57..d4bf0d93 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -631,6 +631,13 @@ public final class GameModeConfig { */ public final int MaxDispenserItems; + /** + * Maximal blast resistance for the blocks + * + * @implSpec {@code Double.MAX_VALUE} by default + */ + public final double MaxBlastResistance; + /** * Maximal blast resistance for the design blocks * @@ -663,6 +670,7 @@ public final class GameModeConfig { UnlimitedPrepare = loader.getBoolean("UnlimitedPrepare", false); MaxBlocks = loader.getInt("MaxBlocks", 0); MaxDispenserItems = loader.getInt("MaxDispenserItems", 128); + MaxBlastResistance = loader.getDouble("MaxBlastResistance", Double.MAX_VALUE); MaxDesignBlastResistance = loader.getDouble("MaxDesignBlastResistance", Double.MAX_VALUE); Map, Integer> Limited = new HashMap<>(); @@ -677,6 +685,9 @@ public final class GameModeConfig { Limited.put(Collections.unmodifiableSet(materials.stream().map(String::toUpperCase).map(loader.materialMapper).collect(Collectors.toSet())), amount); } } + SQLWrapper.impl.getMaterialWithGreaterBlastResistance(MaxBlastResistance).forEach(material -> { + Limited.put(Collections.singleton((M) material), 0); + }); this.Limited = Collections.unmodifiableMap(Limited); } diff --git a/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java b/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java index 4fbe2541..47331406 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java +++ b/CommonCore/SQL/src/de/steamwar/sql/SQLWrapper.java @@ -22,6 +22,8 @@ package de.steamwar.sql; import de.steamwar.ImplementationProvider; import java.io.File; +import java.util.Collections; +import java.util.List; public interface SQLWrapper { SQLWrapper impl = ImplementationProvider.getImpl("de.steamwar.sql.SQLWrapperImpl"); @@ -30,6 +32,10 @@ public interface SQLWrapper { GameModeConfig loadGameModeConfig(File file); + default List getMaterialWithGreaterBlastResistance(double maxBlastResistance) { + return Collections.emptyList(); + } + default void processSchematicType(GameModeConfig gameModeConfig) { } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java index 39e2cef6..69896ae1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java @@ -27,6 +27,9 @@ import org.bukkit.World; import org.bukkit.entity.Player; import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; public class SQLWrapperImpl implements SQLWrapper { @@ -40,6 +43,15 @@ public class SQLWrapperImpl implements SQLWrapper { return new GameModeConfig<>(file, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear, true); } + @Override + public List getMaterialWithGreaterBlastResistance(double maxBlastResistance) { + return Arrays.stream(Material.values()) + .filter(material -> !material.isLegacy()) + .filter(Material::isBlock) + .filter(material -> material.getBlastResistance() > maxBlastResistance) + .collect(Collectors.toList()); + } + private static final String SERVER_VERSION = Bukkit.getServer().getVersion(); @Override