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
Joey Hines 2020-09-07 00:19:45 +02:00
parent 537e2fc237
commit d03f54594a
1 changed files with 13 additions and 1 deletions

View File

@ -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());
}
}
}
}
});
}