Skip to content

Commit

Permalink
use wool carpet tag
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed May 13, 2024
1 parent be4efba commit f01ec79
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.popcraft.bolt.matcher.block;

import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
Expand All @@ -10,17 +11,11 @@
import java.util.Set;

public class CarpetMatcher implements BlockMatcher {
// Future: Replace with Tag.WOOL_CARPETS
private static final Set<Material> WOOL_CARPETS = Set.of(Material.WHITE_CARPET, Material.ORANGE_CARPET,
Material.MAGENTA_CARPET, Material.LIGHT_BLUE_CARPET, Material.YELLOW_CARPET, Material.LIME_CARPET,
Material.PINK_CARPET, Material.GRAY_CARPET, Material.LIGHT_GRAY_CARPET, Material.CYAN_CARPET,
Material.PURPLE_CARPET, Material.BLUE_CARPET, Material.BROWN_CARPET, Material.GREEN_CARPET,
Material.RED_CARPET, Material.BLACK_CARPET);
private boolean enabled;

@Override
public void initialize(Set<Material> protectableBlocks, Set<EntityType> protectableEntities) {
enabled = protectableBlocks.stream().anyMatch(WOOL_CARPETS::contains);
enabled = protectableBlocks.stream().anyMatch(Tag.WOOL_CARPETS::isTagged);
}

@Override
Expand All @@ -36,7 +31,7 @@ public boolean canMatch(Block block) {
@Override
public Match findMatch(Block block) {
final Block above = block.getRelative(BlockFace.UP);
if (WOOL_CARPETS.contains(above.getType())) {
if (Tag.WOOL_CARPETS.isTagged(above.getType())) {
return Match.ofBlocks(Collections.singleton(above));
}
return null;
Expand Down

0 comments on commit f01ec79

Please sign in to comment.