diff --git a/src/main/java/net/slqmy/template_paper_plugin/custom_multiblock/AbstractCustomMultiblock.java b/src/main/java/net/slqmy/template_paper_plugin/custom_multiblock/AbstractCustomMultiblock.java index 4360bc9c..290fad69 100644 --- a/src/main/java/net/slqmy/template_paper_plugin/custom_multiblock/AbstractCustomMultiblock.java +++ b/src/main/java/net/slqmy/template_paper_plugin/custom_multiblock/AbstractCustomMultiblock.java @@ -1,27 +1,25 @@ package net.slqmy.template_paper_plugin.custom_multiblock; +import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.event.Listener; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; import net.slqmy.template_paper_plugin.TemplatePaperPlugin; +import net.slqmy.template_paper_plugin.util.types.BlockLocation; public abstract class AbstractCustomMultiblock implements Listener { - private final TemplatePaperPlugin plugin; + protected final TemplatePaperPlugin plugin; - private final CustomMultiblock multiblockId; + private final List> multiblocks = new ArrayList<>(); public AbstractCustomMultiblock(TemplatePaperPlugin plugin, CustomMultiblockManager customMultiblockManager, CustomMultiblock multiblockId) { this.plugin = plugin; - this.multiblockId = multiblockId; - Bukkit.getPluginManager().registerEvents(this, plugin); customMultiblockManager.addCustomMultiblock(multiblockId, this); @@ -32,20 +30,18 @@ public AbstractCustomMultiblock(TemplatePaperPlugin plugin, CustomMultiblockMana public List getCustomMultiblock(Location placeLocation) { List multiblock = generateCustomMultiblock(placeLocation); - for (Block block : multiblock) { - block.setMetadata(plugin.getCustomMultiblockIdKey(), new FixedMetadataValue(plugin, multiblockId.name())); - } + multiblocks.add(multiblock.stream().map((block) -> new BlockLocation(block)).toList()); return multiblock; } public boolean isBlock(Block block) { - List values = block.getMetadata(plugin.getCustomMultiblockIdKey()); - - if (values.size() == 0) { - return false; + for (List multiblock : multiblocks) { + if (multiblock.contains(new BlockLocation(block))) { + return true; + } } - return multiblockId.name().equals(values.get(0).asString()); + return false; } }