diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Xray.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Xray.java index d783f745..ba8bf651 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Xray.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Xray.java @@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.MetadataValue; import org.bukkit.scoreboard.Team; import org.jetbrains.annotations.NotNull; @@ -92,6 +93,7 @@ public class Xray extends Spell { shulker.setGravity(false); shulker.setGlowing(true); shulker.setInvisible(true); + shulker.setMetadata("xray-shulker", this.getPlugin().getMetadataValueFactory().create(true)); block1.setMetadata("xray-uuid", this.getPlugin().getMetadataValueFactory().create(shulker.getUniqueId())); @@ -115,14 +117,24 @@ public class Xray extends Spell { return; } - UUID uuid = (UUID) block.getMetadata("xray-uuid").get(0).value(); + for (MetadataValue meta : block.getMetadata("xray-uuid")) { + if (!(meta.value() instanceof UUID)) { + continue; + } - assert uuid != null; + UUID uuid = (UUID) meta.value(); - Entity entity = Bukkit.getServer().getEntity(uuid); + assert uuid != null; - if (entity != null) { - entity.remove(); + Entity entity = Bukkit.getServer().getEntity(uuid); + + if (entity != null) { + entity.remove(); + } + } + + for (Entity shulkerEntity : block.getLocation().getWorld().getNearbyEntities(block.getLocation(), 2, 2, 2, entity -> entity.hasMetadata("xray-shulker"))) { + shulkerEntity.remove(); } } } diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/xray.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/xray.yml index 5467a012..fa5d2ff3 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/spell/xray.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/xray.yml @@ -22,7 +22,7 @@ general-config: config: activation-sound: ENTITY_ENDERMAN_TELEPORT - cooldown: 30 # In seconds + cooldown: 40 # In seconds blocks: - coal_ore - iron_ore @@ -32,5 +32,5 @@ config: - ancient_debris - diamond_ore blocks-per-level: 3 # Blocks on all sides to scan per level - ticks: 20 + ticks: 60 color-glow: true # Color ore glow based on ore type. \ No newline at end of file