Skip to content

Commit

Permalink
Bug fix for issue 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalton Caron committed Jun 29, 2022
1 parent 4b86036 commit 7eae62c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>xyz.dcaron.bridges</groupId>
<artifactId>RetractableBridges</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1-SNAPSHOT</version>

<name>RetractableBridges</name>
<!-- FIXME change it to the project's website -->
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/xyz/dcaron/bridges/BridgeOptions.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package xyz.dcaron.bridges;

import java.util.Set;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.stream.Collectors;

import org.bukkit.Material;
Expand All @@ -27,13 +29,22 @@ public class BridgeOptions {

public BridgeOptions(final FileConfiguration configuration) {

final Function<String, Material> warnForNullStringToMaterialFunc = (materialString) -> {
final Material material = Material.getMaterial(materialString);
if (material == null) {
BridgesPlugin.log("Failed to parse block " + materialString + " from the configuration", Level.WARNING);
}
return material;
};

moveEntitiesOnBridge = configuration.getBoolean("moveEntitiesOnBridge");

ticksPerBridgeMovement = configuration.getInt("ticksPerBridgeMovement");

bridgeMaterials = configuration.getStringList("bridgeMaterials")
.stream()
.map(material -> Material.getMaterial(material))
.map(warnForNullStringToMaterialFunc)
.filter(material -> material != null)
.collect(Collectors.toUnmodifiableSet());

maximumMultiplePowerBoost = configuration.getInt("maximumMultiplePowerBoost");
Expand All @@ -42,7 +53,8 @@ public BridgeOptions(final FileConfiguration configuration) {

bridgePowerBlocks = configuration.getStringList("bridgePowerBlocks")
.stream()
.map(material -> Material.getMaterial(material))
.map(warnForNullStringToMaterialFunc)
.filter(material -> material != null)
.collect(Collectors.toUnmodifiableSet());

allPowerBlocksAllowed = bridgePowerBlocks.isEmpty();
Expand Down

0 comments on commit 7eae62c

Please sign in to comment.