コード例 #1
0
 @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));
 }
コード例 #2
0
  @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));
      }
    }
  }
コード例 #3
0
 @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()));
 }
コード例 #4
0
 @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()));
 }
コード例 #5
0
 @HawkEvent(dataType = DataType.LEAF_DECAY)
 public void onLeavesDecay(LeavesDecayEvent event) {
   DataManager.addEntry(
       new SimpleRollbackEntry(
           "Environment", DataType.LEAF_DECAY, event.getBlock().getLocation(), ""));
 }
コード例 #6
0
 @HawkEvent(dataType = DataType.BLOCK_BURN)
 public void onBlockBurn(BlockBurnEvent event) {
   DataManager.addEntry(new BlockEntry("Environment", DataType.BLOCK_BURN, event.getBlock()));
 }
コード例 #7
0
 @HawkEvent(dataType = DataType.SIGN_PLACE)
 public void onSignChange(SignChangeEvent event) {
   DataManager.addEntry(new SignEntry(event.getPlayer(), DataType.SIGN_PLACE, event.getBlock()));
 }