11package xyz .dcaron .bridges ;
22
33import java .util .Set ;
4+ import java .util .function .Function ;
5+ import java .util .logging .Level ;
46import java .util .stream .Collectors ;
57
68import org .bukkit .Material ;
@@ -27,13 +29,22 @@ public class BridgeOptions {
2729
2830 public BridgeOptions (final FileConfiguration configuration ) {
2931
32+ final Function <String , Material > warnForNullStringToMaterialFunc = (materialString ) -> {
33+ final Material material = Material .getMaterial (materialString );
34+ if (material == null ) {
35+ BridgesPlugin .log ("Failed to parse block " + materialString + " from the configuration" , Level .WARNING );
36+ }
37+ return material ;
38+ };
39+
3040 moveEntitiesOnBridge = configuration .getBoolean ("moveEntitiesOnBridge" );
3141
3242 ticksPerBridgeMovement = configuration .getInt ("ticksPerBridgeMovement" );
3343
3444 bridgeMaterials = configuration .getStringList ("bridgeMaterials" )
3545 .stream ()
36- .map (material -> Material .getMaterial (material ))
46+ .map (warnForNullStringToMaterialFunc )
47+ .filter (material -> material != null )
3748 .collect (Collectors .toUnmodifiableSet ());
3849
3950 maximumMultiplePowerBoost = configuration .getInt ("maximumMultiplePowerBoost" );
@@ -42,7 +53,8 @@ public BridgeOptions(final FileConfiguration configuration) {
4253
4354 bridgePowerBlocks = configuration .getStringList ("bridgePowerBlocks" )
4455 .stream ()
45- .map (material -> Material .getMaterial (material ))
56+ .map (warnForNullStringToMaterialFunc )
57+ .filter (material -> material != null )
4658 .collect (Collectors .toUnmodifiableSet ());
4759
4860 allPowerBlocksAllowed = bridgePowerBlocks .isEmpty ();
0 commit comments