From d03f54594a5db26a37f6939de6dcefc0936b8d8d Mon Sep 17 00:00:00 2001 From: ZeroHD Date: Mon, 7 Sep 2020 00:19:45 +0200 Subject: [PATCH] Add blocks within a tnt or bed's blast to the cache (#10) Add blocks within a tnt or bed's blast to the cache + If TNT or bed is used for mining, those blocks should be placed in the cache + Beds are only tracked in the nether Co-authored-by: Joey Hines Reviewed-on: https://git.etztech.xyz/Minecraft/MineAlert/pulls/10 Reviewed-by: Etzelia --- .../minealert/listeners/OreAlertListener.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/etztech/minealert/listeners/OreAlertListener.java b/src/main/java/xyz/etztech/minealert/listeners/OreAlertListener.java index 1c8d3ae..dd547a5 100644 --- a/src/main/java/xyz/etztech/minealert/listeners/OreAlertListener.java +++ b/src/main/java/xyz/etztech/minealert/listeners/OreAlertListener.java @@ -7,6 +7,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -65,7 +66,18 @@ public class OreAlertListener implements Listener { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> { - if (isMaterialTracked(event.getBlock().getType())) cache.add(event.getBlock().getLocation()); + Block eventBlock = event.getBlock(); + if (isMaterialTracked(eventBlock.getType())) cache.add(eventBlock.getLocation()); + if (eventBlock.getType() == Material.TNT || (eventBlock.getType().toString().contains("_BED") && eventBlock.getWorld().getEnvironment() == World.Environment.NETHER)) { + for (int x = -4; x < 4; x++) { + for (int y = -4; y < 4; y++) { + for (int z = -4; z < 4; z++) { + Block block = eventBlock.getRelative(x, y, z); + cache.add(block.getLocation()); + } + } + } + } }); }