@EventHandler(priority = EventPriority.HIGHEST)
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled()) {
      return;
    }

    if (!War.isWarTime()) {
      return;
    }

    coord.setFromLocation(event.getBlock().getLocation());
    CultureChunk cc = CivGlobal.getCultureChunk(coord);

    if (cc == null) {
      return;
    }

    if (!cc.getCiv().getDiplomacyManager().isAtWar()) {
      return;
    }

    if (event.getBlock().getType().equals(Material.DIRT)
        || event.getBlock().getType().equals(Material.GRASS)
        || event.getBlock().getType().equals(Material.SAND)
        || event.getBlock().getType().equals(Material.GRAVEL)
        || event.getBlock().getType().equals(Material.TORCH)
        || event.getBlock().getType().equals(Material.REDSTONE_TORCH_OFF)
        || event.getBlock().getType().equals(Material.REDSTONE_TORCH_ON)
        || event.getBlock().getType().equals(Material.REDSTONE)
        || event.getBlock().getType().equals(Material.TNT)
        || event.getBlock().getType().equals(Material.LADDER)
        || event.getBlock().getType().equals(Material.VINE)
        || event.getBlock().getType().equals(Material.IRON_BLOCK)
        || event.getBlock().getType().equals(Material.GOLD_BLOCK)
        || event.getBlock().getType().equals(Material.DIAMOND_BLOCK)
        || event.getBlock().getType().equals(Material.EMERALD_BLOCK)
        || !event.getBlock().getType().isSolid()) {
      return;
    }

    CivMessage.sendError(event.getPlayer(), CivSettings.localize.localizedString("war_mustUseTNT"));
    event.setCancelled(true);
  }
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.HIGH)
  public void onBlockPlace(BlockPlaceEvent event) {
    if (event.isCancelled()) {
      return;
    }

    if (!War.isWarTime()) {
      return;
    }

    coord.setFromLocation(event.getBlock().getLocation());
    CultureChunk cc = CivGlobal.getCultureChunk(coord);

    if (cc == null) {
      return;
    }

    if (!cc.getCiv().getDiplomacyManager().isAtWar()) {
      return;
    }

    if (event.getBlock().getType().equals(Material.DIRT)
        || event.getBlock().getType().equals(Material.GRASS)
        || event.getBlock().getType().equals(Material.SAND)
        || event.getBlock().getType().equals(Material.GRAVEL)
        || event.getBlock().getType().equals(Material.TORCH)
        || event.getBlock().getType().equals(Material.REDSTONE_TORCH_OFF)
        || event.getBlock().getType().equals(Material.REDSTONE_TORCH_ON)
        || event.getBlock().getType().equals(Material.REDSTONE)
        || event.getBlock().getType().equals(Material.LADDER)
        || event.getBlock().getType().equals(Material.VINE)
        || event.getBlock().getType().equals(Material.TNT)) {

      if (event.getBlock().getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR) {
        return;
      }

      event
          .getBlock()
          .getWorld()
          .spawnFallingBlock(event.getBlock().getLocation(), event.getBlock().getType(), (byte) 0);
      event.getBlock().setType(Material.AIR);

      return;
    }

    if (event.getBlock().getType().equals(Material.IRON_BLOCK)
        || event.getBlock().getType().equals(Material.GOLD_BLOCK)
        || event.getBlock().getType().equals(Material.DIAMOND_BLOCK)
        || event.getBlock().getType().equals(Material.EMERALD_BLOCK)) {

      if (event.getBlock().getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR) {
        return;
      }

      return;
    }

    CivMessage.sendError(
        event.getPlayer(), CivSettings.localize.localizedString("war_onlyBuildCertainBlocks"));
    CivMessage.sendError(
        event.getPlayer(), CivSettings.localize.localizedString("war_canAlsoPlaceBridgeBlocks"));
    event.setCancelled(true);
  }
  @EventHandler(priority = EventPriority.HIGH)
  public void onEntityExplode(EntityExplodeEvent event) {

    if (War.isWarTime()) {
      event.setCancelled(false);
    } else {
      event.setCancelled(true);
      return;
    }

    if (event.isCancelled()) {
      return;
    }

    if (event.getEntity() == null) {
      return;
    }

    if (event.getEntityType().equals(EntityType.UNKNOWN)) {
      return;
    }

    if (event.getEntityType().equals(EntityType.PRIMED_TNT)
        || event.getEntityType().equals(EntityType.MINECART_TNT)) {

      HashSet<Buildable> structuresHit = new HashSet<Buildable>();

      for (int y = -yield; y <= yield; y++) {
        for (int x = -yield; x <= yield; x++) {
          for (int z = -yield; z <= yield; z++) {
            Location loc = event.getLocation().clone().add(new Vector(x, y, z));
            Block b = loc.getBlock();
            if (loc.distance(event.getLocation()) < yield) {

              BlockCoord bcoord = new BlockCoord();
              bcoord.setFromLocation(loc);
              //							StructureBlock sb = CivGlobal.getStructureBlock(bcoord);
              //							if (sb == null) {
              //							WarRegen.saveBlock(loc.getBlock(), Cannon.RESTORE_NAME, false);
              //							}
              //							if (sb.getTown() != null) {
              //							WarRegen.destroyThisBlock(loc.getBlock(), sb.getTown());
              //							} else {
              //							ItemManager.setTypeIdAndData(loc.getBlock(), CivData.AIR, 0, false);
              //							}

              StructureBlock sb = CivGlobal.getStructureBlock(bcoord);
              CampBlock cb = CivGlobal.getCampBlock(bcoord);

              if (sb == null && cb == null) {
                explodeBlock(b);
                continue;
              }

              if (sb != null) {

                if (!sb.isDamageable()) {
                  continue;
                }

                if (sb.getOwner() instanceof TownHall) {
                  TownHall th = (TownHall) sb.getOwner();
                  if (th.getControlPoints().containsKey(bcoord)) {
                    continue;
                  }
                }

                if (!sb.getOwner().isDestroyed()) {
                  if (!structuresHit.contains(sb.getOwner())) {

                    structuresHit.add(sb.getOwner());

                    if (sb.getOwner() instanceof TownHall) {
                      TownHall th = (TownHall) sb.getOwner();

                      if (th.getHitpoints() == 0) {
                        explodeBlock(b);
                      } else {
                        th.onTNTDamage(structureDamage);
                      }
                    } else {
                      sb.getOwner()
                          .onDamage(structureDamage, b.getWorld(), null, sb.getCoord(), sb);
                      CivMessage.sendCiv(
                          sb.getCiv(),
                          CivColor.Yellow
                              + CivSettings.localize.localizedString(
                                  "var_war_tntMsg",
                                  sb.getOwner().getDisplayName(),
                                  (sb.getOwner().getCenterLocation().getX()
                                      + ","
                                      + sb.getOwner().getCenterLocation().getY()
                                      + ","
                                      + sb.getOwner().getCenterLocation().getZ()
                                      + ")"),
                                  (sb.getOwner().getHitpoints()
                                      + "/"
                                      + sb.getOwner().getMaxHitPoints())));
                    }
                  }
                } else {
                  explodeBlock(b);
                }
                continue;
              }
            }
          }
        }
      }
      event.setCancelled(true);
    }
  }