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 <joey@ahines.net> Reviewed-on: https://git.etztech.xyz/Minecraft/MineAlert/pulls/10 Reviewed-by: Etzelia <etzelia@hotmail.com>master
parent
537e2fc237
commit
d03f54594a
|
@ -7,6 +7,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -65,7 +66,18 @@ public class OreAlertListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue