From 32a9435e3063951a339c36dba4d47c7a02ffa463 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 15 Jun 2022 11:23:54 -0500 Subject: [PATCH] Fixed stream error when triggering OreVein effect --- .../java/io/github/simplex/luck/listener/OreVein.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/simplex/luck/listener/OreVein.java b/src/main/java/io/github/simplex/luck/listener/OreVein.java index 5c31544..a2242a4 100644 --- a/src/main/java/io/github/simplex/luck/listener/OreVein.java +++ b/src/main/java/io/github/simplex/luck/listener/OreVein.java @@ -12,6 +12,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; +import java.util.List; +import java.util.stream.Collectors; import java.util.stream.Stream; public class OreVein extends AbstractListener { @@ -31,22 +33,22 @@ public class OreVein extends AbstractListener { } } - public Stream getOresInArea(Block block) { + public List getOresInArea(Block block) { Stream.Builder streamBuilder = Stream.builder(); Location start = block.getLocation(); World world = block.getWorld(); - Stream> materialStream = Stream.of(Tag.COAL_ORES, Tag.COPPER_ORES, Tag.DIAMOND_ORES, Tag.GOLD_ORES, Tag.IRON_ORES, Tag.EMERALD_ORES, Tag.LAPIS_ORES, Tag.REDSTONE_ORES); + List> materialList = List.of(Tag.COAL_ORES, Tag.COPPER_ORES, Tag.DIAMOND_ORES, Tag.GOLD_ORES, Tag.IRON_ORES, Tag.EMERALD_ORES, Tag.LAPIS_ORES, Tag.REDSTONE_ORES); for (int x = start.getBlockX() - 15; x <= start.getBlockX() + 15; x++) { for (int y = start.getBlockY() - 15; y <= start.getBlockY() + 15; y++) { for (int z = start.getBlockZ() - 15; z <= start.getBlockZ() + 15; z++) { Location location = new Location(world, x, y, z); Material blockType = location.getBlock().getType(); - if (materialStream.anyMatch(o -> o.isTagged(blockType))) { + if (materialList.stream().anyMatch(o -> o.isTagged(blockType))) { streamBuilder.add(location.getBlock()); } } } } - return streamBuilder.build().filter(b -> b.getType().equals(block.getType())); + return streamBuilder.build().filter(b -> b.getType().equals(block.getType())).toList(); } }