Ejemplo n.º 1
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();

    // Deny GameWorld Blocks
    GameWorld gworld = GameWorld.get(block.getWorld());
    if (gworld != null) {
      if (!GamePlaceableBlock.canBuildHere(
          block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gworld)) {

        // Workaround for a bug that would allow 3-Block-high jumping
        Location loc = event.getPlayer().getLocation();
        if (loc.getY() > block.getY() + 1.0 && loc.getY() <= block.getY() + 1.5) {
          if (loc.getX() >= block.getX() - 0.3 && loc.getX() <= block.getX() + 1.3) {
            if (loc.getZ() >= block.getZ() - 0.3 && loc.getZ() <= block.getZ() + 1.3) {
              loc.setX(block.getX() + 0.5);
              loc.setY(block.getY());
              loc.setZ(block.getZ() + 0.5);
              event.getPlayer().teleport(loc);
            }
          }
        }
        event.setCancelled(true);
      }
    }
  }
Ejemplo n.º 2
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onBlockBreak(BlockBreakEvent event) {
    Block block = event.getBlock();

    // Deny DPortal destroying
    if (block.getType() == Material.PORTAL) {
      if (DPortal.get(event.getBlock()) != null) {
        event.setCancelled(true);
      }
    }

    // Deny DGSignblocks destroying
    if (DGSign.isRelativeSign(block, 1, 0)
        || DGSign.isRelativeSign(block, -1, 0)
        || DGSign.isRelativeSign(block, 0, 1)
        || DGSign.isRelativeSign(block, 0, -1)) {
      event.setCancelled(true);
    }

    // DGSign destroying
    if (DGSign.getSign(block) != null) {
      DGSign.dgsigns.remove(DGSign.getSign(block));
    }

    // Deny LeaveSignblocks destroying
    if (LeaveSign.isRelativeSign(block, 1, 0)
        || LeaveSign.isRelativeSign(block, -1, 0)
        || LeaveSign.isRelativeSign(block, 0, 1)
        || LeaveSign.isRelativeSign(block, 0, -1)) {
      event.setCancelled(true);
    }

    // LeaveSign destroying
    if (LeaveSign.getSign(block) != null) {
      event.setCancelled(true);
      // LeaveSign.lsigns.remove(LeaveSign.getSign(block));
    }

    // Editworld Signs
    EditWorld eworld = EditWorld.get(block.getWorld());
    if (eworld != null) {
      eworld.sign.remove(event.getBlock());
    }

    // Deny GameWorld Blocks
    GameWorld gworld = GameWorld.get(block.getWorld());
    if (gworld != null) {
      event.setCancelled(true);
    }
  }
Ejemplo n.º 3
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onBlockSpread(BlockSpreadEvent event) {
    Block block = event.getBlock();
    // Block the Spread off Vines
    if (block.getType() == Material.VINE) {
      // Check GameWorlds
      GameWorld gworld = GameWorld.get(event.getBlock().getWorld());
      if (gworld != null) {
        event.setCancelled(true);
      }

      // Check EditWorlds
      EditWorld eworld = EditWorld.get(event.getBlock().getWorld());
      if (eworld != null) {
        event.setCancelled(true);
      }
    }
  }