forked from LogBlock/LogBlock
Log BlockFormEvent by fluids
This commit is contained in:
@ -15,6 +15,7 @@ import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
||||
@ -95,9 +96,25 @@ public class FluidFlowLogging extends LoggingListener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockForm(BlockFormEvent event) {
|
||||
final WorldConfig wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
if (wcfg != null && (wcfg.isLogging(Logging.WATERFLOW) || wcfg.isLogging(Logging.LAVAFLOW))) {
|
||||
if (wcfg.isLogging(Logging.LAVAFLOW) && event.getBlock().getType() == Material.WATER && event.getNewState().getType() == Material.COBBLESTONE) {
|
||||
consumer.queueBlockReplace(new Actor("LavaFlow"), event.getBlock().getBlockData(), event.getNewState());
|
||||
}
|
||||
if (wcfg.isLogging(Logging.WATERFLOW) && event.getBlock().getType() == Material.LAVA) {
|
||||
consumer.queueBlockReplace(new Actor("WaterFlow"), event.getBlock().getBlockData(), event.getNewState());
|
||||
}
|
||||
if (wcfg.isLogging(Logging.WATERFLOW) && BukkitUtils.isConcreteBlock(event.getNewState().getType())) {
|
||||
consumer.queueBlockReplace(new Actor("WaterFlow"), event.getBlock().getBlockData(), event.getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSurroundedByWater(Block block) {
|
||||
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.WEST, BlockFace.EAST, BlockFace.SOUTH}) {
|
||||
if(block.getRelative(face).getType() == Material.WATER) {
|
||||
for (final BlockFace face : new BlockFace[] { BlockFace.NORTH, BlockFace.WEST, BlockFace.EAST, BlockFace.SOUTH }) {
|
||||
if (block.getRelative(face).getType() == Material.WATER) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class BukkitUtils {
|
||||
private static final EnumSet<Material> pressurePlates;
|
||||
private static final EnumSet<Material> woodenDoors;
|
||||
private static final EnumSet<Material> slabs;
|
||||
private static final EnumSet<Material> concreteBlocks;
|
||||
|
||||
static {
|
||||
pressurePlates = EnumSet.noneOf(Material.class);
|
||||
@ -352,6 +353,24 @@ public class BukkitUtils {
|
||||
bedBlocks.add(Material.RED_BED);
|
||||
bedBlocks.add(Material.WHITE_BED);
|
||||
bedBlocks.add(Material.YELLOW_BED);
|
||||
|
||||
concreteBlocks = EnumSet.noneOf(Material.class);
|
||||
concreteBlocks.add(Material.BLACK_CONCRETE);
|
||||
concreteBlocks.add(Material.BLUE_CONCRETE);
|
||||
concreteBlocks.add(Material.LIGHT_GRAY_CONCRETE);
|
||||
concreteBlocks.add(Material.BROWN_CONCRETE);
|
||||
concreteBlocks.add(Material.CYAN_CONCRETE);
|
||||
concreteBlocks.add(Material.GRAY_CONCRETE);
|
||||
concreteBlocks.add(Material.GREEN_CONCRETE);
|
||||
concreteBlocks.add(Material.LIGHT_BLUE_CONCRETE);
|
||||
concreteBlocks.add(Material.MAGENTA_CONCRETE);
|
||||
concreteBlocks.add(Material.LIME_CONCRETE);
|
||||
concreteBlocks.add(Material.ORANGE_CONCRETE);
|
||||
concreteBlocks.add(Material.PINK_CONCRETE);
|
||||
concreteBlocks.add(Material.PURPLE_CONCRETE);
|
||||
concreteBlocks.add(Material.RED_CONCRETE);
|
||||
concreteBlocks.add(Material.WHITE_CONCRETE);
|
||||
concreteBlocks.add(Material.YELLOW_CONCRETE);
|
||||
}
|
||||
|
||||
private static final BlockFace[] relativeBlockFaces = new BlockFace[]{
|
||||
@ -494,6 +513,10 @@ public class BukkitUtils {
|
||||
return containerBlocks;
|
||||
}
|
||||
|
||||
public static boolean isConcreteBlock(Material m) {
|
||||
return concreteBlocks.contains(m);
|
||||
}
|
||||
|
||||
public static String entityName(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
return ((Player) entity).getName();
|
||||
|
Reference in New Issue
Block a user