@HawkEvent(dataType = DataType.BLOCK_BREAK) public void onBlockBreak(BlockBreakEvent event) { Block block = event.getBlock(); if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) DataManager.addEntry(new SignEntry(event.getPlayer(), DataType.SIGN_BREAK, event.getBlock())); DataManager.addEntry(new BlockEntry(event.getPlayer(), DataType.BLOCK_BREAK, block)); }
@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); 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); } // Flowing into water else 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)); } // Water else 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)); } } }
@HawkEvent(dataType = DataType.BLOCK_FADE) public void onBlockFade(BlockFadeEvent event) { DataManager.addEntry( new BlockChangeEntry( "Environment", DataType.BLOCK_FADE, event.getBlock().getLocation(), event.getBlock().getState(), event.getNewState())); }
@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())); }
@HawkEvent(dataType = DataType.LEAF_DECAY) public void onLeavesDecay(LeavesDecayEvent event) { DataManager.addEntry( new SimpleRollbackEntry( "Environment", DataType.LEAF_DECAY, event.getBlock().getLocation(), "")); }
@HawkEvent(dataType = DataType.BLOCK_BURN) public void onBlockBurn(BlockBurnEvent event) { DataManager.addEntry(new BlockEntry("Environment", DataType.BLOCK_BURN, event.getBlock())); }
@HawkEvent(dataType = DataType.SIGN_PLACE) public void onSignChange(SignChangeEvent event) { DataManager.addEntry(new SignEntry(event.getPlayer(), DataType.SIGN_PLACE, event.getBlock())); }