Program: 86505
Project: 86505
Buggy source:
/** 
 * Clears all LWC locks for the chunk at passed location except the locks that are of players in the same faction as passed fPlayer
 * @param facLocation the FLocation of the faction (chunk-coords basically)
 * @param fPlayer
 * @return number of protections removed,<br />0 or less means none were found/removed
 * @throws Exception if something failed (typically this won't happen)
 */
public static int clearLocks(PS facLocation,UPlayer fPlayer) throws Exception {
  World world=facLocation.asBukkitWorld();
  if (null == world) {
    throw new Exception("String_Node_Str");
  }
  Chunk chunk=world.getChunkAt(facLocation.getBlockX().intValue(),facLocation.getBlockZ().intValue());
  if (!world.isChunkLoaded(chunk)) {
    world.loadChunk(chunk);
    if (!chunk.isLoaded()) {
      throw new Exception("String_Node_Str");
    }
  }
  int numberOfRemovedProtections=0;
  for (int x=0; x < 16; x++) {
    for (int z=0; z < 16; z++) {
      for (int y=0; y < 256; y++) {
        Block block=chunk.getBlock(x,y,z);
        Material type=block.getType();
        if (type == Material.AIR) {
          continue;
        }
        if (isProtectionTypeToRemove(type)) {
          Protection protectedBlock=getLWC().findProtection(block);
          if (null != protectedBlock) {
            UPlayer fpOwner=UPlayer.get(protectedBlock.getOwner());
            if (!fPlayer.getFaction().getUPlayers().contains(fpOwner)) {
              protectedBlock.remove();
              numberOfRemovedProtections++;
            }
          }
        }
      }
    }
  }
  return numberOfRemovedProtections;
}

Fixed version (ground truth):
/** 
 * Clears all LWC locks for the chunk at passed location except the locks that are of players in the same faction as passed fPlayer
 * @param facLocation the FLocation of the faction (chunk-coords basically)
 * @param fPlayer
 * @return number of protections removed,<br />0 or less means none were found/removed
 * @throws Exception if something failed (typically this won't happen)
 */
public static int clearLocks(PS facLocation,UPlayer fPlayer) throws Exception {
  World world=facLocation.asBukkitWorld();
  if (null == world) {
    throw new Exception("String_Node_Str");
  }
  Chunk chunk=world.getChunkAt(facLocation.getBlock().asBukkitBlock().getX(),facLocation.getBlock().asBukkitBlock().getZ());
  if (!world.isChunkLoaded(chunk)) {
    world.loadChunk(chunk);
    if (!chunk.isLoaded()) {
      throw new Exception("String_Node_Str");
    }
  }
  int numberOfRemovedProtections=0;
  for (int x=0; x < 16; x++) {
    for (int z=0; z < 16; z++) {
      for (int y=0; y < 256; y++) {
        Block block=chunk.getBlock(x,y,z);
        Material type=block.getType();
        if (type == Material.AIR) {
          continue;
        }
        if (isProtectionTypeToRemove(type)) {
          Protection protectedBlock=getLWC().findProtection(block);
          if (null != protectedBlock) {
            UPlayer fpOwner=UPlayer.get(protectedBlock.getOwner());
            if (!fPlayer.getFaction().getUPlayers().contains(fpOwner)) {
              protectedBlock.remove();
              numberOfRemovedProtections++;
            }
          }
        }
      }
    }
  }
  return numberOfRemovedProtections;
}