forked from SteamWar/SteamWar
Add GameModeConfig.Schematic.MaxBlastResistance
This commit is contained in:
@@ -631,6 +631,13 @@ public final class GameModeConfig<M, W> {
|
|||||||
*/
|
*/
|
||||||
public final int MaxDispenserItems;
|
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
|
* Maximal blast resistance for the design blocks
|
||||||
*
|
*
|
||||||
@@ -663,6 +670,7 @@ public final class GameModeConfig<M, W> {
|
|||||||
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);
|
||||||
|
MaxBlastResistance = loader.getDouble("MaxBlastResistance", Double.MAX_VALUE);
|
||||||
MaxDesignBlastResistance = loader.getDouble("MaxDesignBlastResistance", Double.MAX_VALUE);
|
MaxDesignBlastResistance = loader.getDouble("MaxDesignBlastResistance", Double.MAX_VALUE);
|
||||||
|
|
||||||
Map<Set<M>, Integer> Limited = new HashMap<>();
|
Map<Set<M>, Integer> Limited = new HashMap<>();
|
||||||
@@ -677,6 +685,9 @@ public final class GameModeConfig<M, W> {
|
|||||||
Limited.put(Collections.unmodifiableSet(materials.stream().map(String::toUpperCase).map(loader.materialMapper).collect(Collectors.toSet())), amount);
|
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);
|
this.Limited = Collections.unmodifiableMap(Limited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ package de.steamwar.sql;
|
|||||||
import de.steamwar.ImplementationProvider;
|
import de.steamwar.ImplementationProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface SQLWrapper<M> {
|
public interface SQLWrapper<M> {
|
||||||
SQLWrapper<?> impl = ImplementationProvider.getImpl("de.steamwar.sql.SQLWrapperImpl");
|
SQLWrapper<?> impl = ImplementationProvider.getImpl("de.steamwar.sql.SQLWrapperImpl");
|
||||||
@@ -30,6 +32,10 @@ public interface SQLWrapper<M> {
|
|||||||
|
|
||||||
GameModeConfig<M, String> loadGameModeConfig(File file);
|
GameModeConfig<M, String> loadGameModeConfig(File file);
|
||||||
|
|
||||||
|
default List<M> getMaterialWithGreaterBlastResistance(double maxBlastResistance) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
default void processSchematicType(GameModeConfig<?, String> gameModeConfig) {
|
default void processSchematicType(GameModeConfig<?, String> gameModeConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SQLWrapperImpl implements SQLWrapper<Material> {
|
public class SQLWrapperImpl implements SQLWrapper<Material> {
|
||||||
|
|
||||||
@@ -40,6 +43,15 @@ public class SQLWrapperImpl implements SQLWrapper<Material> {
|
|||||||
return new GameModeConfig<>(file, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear, true);
|
return new GameModeConfig<>(file, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Material> 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();
|
private static final String SERVER_VERSION = Bukkit.getServer().getVersion();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user