From 035e35a067cef1dc71d0a3482070edc64655e064 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Sep 2020 15:34:58 +0200 Subject: [PATCH] Implemented tags in more occurences --- .../items/androids/FisherAndroid.java | 4 ++-- .../electric/machines/ElectrifiedCrucible.java | 4 ++-- .../implementation/items/tools/LumberAxe.java | 3 +-- .../slimefun4/utils/tags/SlimefunTag.java | 13 ++++++++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java index 085895521..d2e9ce0c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java @@ -4,12 +4,12 @@ import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -25,7 +25,7 @@ public class FisherAndroid extends ProgrammableAndroid { super(category, tier, item, recipeType, recipe); // Fish - for (Material fish : MaterialCollections.getAllFishItems()) { + for (Material fish : Tag.ITEMS_FISHES.getValues()) { fishingLoot.add(new ItemStack(fish), 25); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java index 8bd212d00..f0d7c128d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java @@ -4,7 +4,7 @@ import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -22,7 +22,7 @@ public abstract class ElectrifiedCrucible extends AContainer { registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - for (Material terracotta : MaterialCollections.getAllTerracottaColors().getAsArray()) { + for (Material terracotta : SlimefunTag.TERRACOTTA.getValues()) { registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(terracotta, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java index 0e55e7ddb..084953de6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java @@ -12,7 +12,6 @@ import org.bukkit.block.data.Orientable; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.blocks.Vein; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; @@ -49,7 +48,7 @@ public class LumberAxe extends SimpleSlimefunItem implements Not private ToolUseHandler onBlockBreak() { return (e, tool, fortune, drops) -> { - if (MaterialCollections.getAllLogs().contains(e.getBlock().getType())) { + if (Tag.LOGS.isTagged(e.getBlock().getType())) { List logs = Vein.find(e.getBlock(), MAX_BROKEN, b -> Tag.LOGS.isTagged(b.getType())); if (logs.contains(e.getBlock())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 9b585f126..e78e3834e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.Set; +import java.util.stream.Stream; import javax.annotation.Nonnull; @@ -44,7 +45,7 @@ public enum SlimefunTag implements Tag { * Minecraft ores. */ ORES, - + /** * All variants of torches, normal, soulfire and redstone. */ @@ -199,4 +200,14 @@ public enum SlimefunTag implements Tag { return getValues().toArray(new Material[0]); } + /** + * This returns a {@link Stream} of {@link Material Materials} for this {@link SlimefunTag}. + * + * @return A {@link Stream} of {@link Material Materials} + */ + @Nonnull + public Stream stream() { + return getValues().stream(); + } + }