use of uk.co.oliwali.HawkEye.entry.BlockChangeEntry in project HawkEye by oliverwoodings.
the class MonitorBlockListener method onBlockPlace.
@HawkEvent(dataType = DataType.BLOCK_PLACE)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)
return;
DataManager.addEntry(new BlockChangeEntry(event.getPlayer(), DataType.BLOCK_PLACE, block.getLocation(), event.getBlockReplacedState(), block.getState()));
}
use of uk.co.oliwali.HawkEye.entry.BlockChangeEntry in project HawkEye by oliverwoodings.
the class MonitorBlockListener method onBlockFromTo.
@HawkEvent(dataType = { DataType.LAVA_FLOW, DataType.WATER_FLOW })
public void onBlockFromTo(BlockFromToEvent event) {
List<Integer> fluidBlocks = Arrays.asList(0, 27, 28, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 66, 69, 70, 75, 76, 78, 93, 94);
//Only interested in liquids flowing
if (!event.getBlock().isLiquid())
return;
Location loc = event.getToBlock().getLocation();
BlockState from = event.getBlock().getState();
BlockState to = event.getToBlock().getState();
MaterialData data = from.getData();
//Lava
if (from.getTypeId() == 10 || from.getTypeId() == 11) {
//Flowing into a normal block
if (fluidBlocks.contains(to.getTypeId())) {
data.setData((byte) (from.getRawData() + 1));
from.setData(data);
} else //Flowing into water
if (to.getTypeId() == 8 || to.getTypeId() == 9) {
from.setTypeId(event.getFace() == BlockFace.DOWN ? 10 : 4);
data.setData((byte) 0);
from.setData(data);
}
DataManager.addEntry(new BlockChangeEntry("Environment", DataType.LAVA_FLOW, loc, to, from));
} else //Water
if (from.getTypeId() == 8 || from.getTypeId() == 9) {
//Normal block
if (fluidBlocks.contains(to.getTypeId())) {
data.setData((byte) (from.getRawData() + 1));
from.setData(data);
DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, to, from));
}
//If we are flowing over lava, cobble or obsidian will form
BlockState lower = event.getToBlock().getRelative(BlockFace.DOWN).getState();
if (lower.getTypeId() == 10 || lower.getTypeId() == 11) {
from.setTypeId(lower.getData().getData() == 0 ? 49 : 4);
loc.setY(loc.getY() - 1);
DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, lower, from));
}
}
}
Aggregations