Program: 178704
Project: 178704
Buggy source:
public void tryPlacingAutomatedPortal(V10Location b){
  Block rb=b.getHandle().getBlock();
  Wool wool=(Wool)Material.WOOL.getNewData(rb.getData());
  if (wool.getColor() != DyeColor.BLACK && wool.getColor() != DyeColor.BLUE && wool.getColor() != DyeColor.ORANGE)   return;
  Block firstIronBar=null;
  for (int i=0; i < 6; i++) {
    if (rb.getRelative(BlockFace.values()[i],2).getType() == Material.IRON_FENCE) {
      firstIronBar=rb.getRelative(BlockFace.values()[i],2);
      break;
    }
 else     if (rb.getRelative(BlockFace.values()[i]).getType() == Material.IRON_FENCE) {
      firstIronBar=rb.getRelative(BlockFace.values()[i]);
      break;
    }
  }
  if (firstIronBar == null)   return;
  ArrayList<Block> ironBars=new ArrayList<Block>();
  for (int i=0; i < 6; i++) {
    BlockFace face=BlockFace.values()[i];
    if (firstIronBar.getRelative(face).getType() == Material.IRON_FENCE) {
      while (firstIronBar.getRelative(face).getType() == Material.IRON_FENCE) {
        firstIronBar=firstIronBar.getRelative(face);
      }
      ironBars.add(firstIronBar);
      int counter=1;
      while (firstIronBar.getRelative(face.getOppositeFace(),counter).getType() == Material.IRON_FENCE) {
        ironBars.add(firstIronBar.getRelative(face.getOppositeFace(),counter));
        counter++;
      }
      break;
    }
  }
  int size=plugin.config.CompactPortal ? 2 : 4;
  BlockFace otherSide=null;
  for (int i=0; i < 6; i++) {
    BlockFace face=BlockFace.values()[i];
    if (firstIronBar.getRelative(face,size).getType() == Material.IRON_FENCE) {
      otherSide=face;
      break;
    }
  }
  if (otherSide == null)   return;
  for (  Block ironBar : ironBars.toArray(new Block[0])) {
    if (ironBar.getRelative(otherSide,size).getType() == Material.IRON_FENCE)     ironBars.add(ironBar.getRelative(otherSide,size));
  }
  BlockFace portalFace=null;
  Portal oldPortal=null;
  Region region=plugin.regionManager.getRegion(b);
  for (int i=0; i < 6; i++) {
    BlockFace face2=BlockFace.values()[i];
    if (face2 == otherSide || face2.getOppositeFace() == otherSide)     continue;
    Block firstPortalBlock=firstIronBar.getRelative(otherSide).getRelative(face2);
    if (region.getBoolean(RegionSetting.ALL_BLOCKS_PORTAL) && region.getList(RegionSetting.PORTAL_BLOCKS).contains(firstPortalBlock.getTypeId())) {
      portalFace=face2;
      break;
    }
 else {
      V10Location loc=new V10Location(firstPortalBlock);
      if (borderBlocks.containsKey(loc))       oldPortal=borderBlocks.get(loc);
 else       oldPortal=insideBlocks.get(loc);
      portalFace=face2;
      break;
    }
  }
  if (portalFace == null)   return;
  if ((!plugin.config.CompactPortal && (((portalFace == BlockFace.UP || portalFace == BlockFace.DOWN) && ironBars.size() != 6) || (portalFace != BlockFace.UP && portalFace != BlockFace.DOWN && ironBars.size() != 8))) || (plugin.config.CompactPortal && (((portalFace == BlockFace.UP || portalFace == BlockFace.DOWN) && ironBars.size() != 2) || (portalFace != BlockFace.UP && portalFace != BlockFace.DOWN && ironBars.size() != 4))))   return;
  if (wool.getColor() == DyeColor.BLACK) {
    if (oldPortal != null)     oldPortal.delete();
    return;
  }
  PortalCoord portalc=new PortalCoord();
  int c=0;
  for (int i=0; i < ironBars.size() / 2; i++) {
    portalc.border.add(new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,1)));
    portalc.border.add(new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,3)));
    if (i == 0 || i == (ironBars.size() / 2) - 1)     portalc.border.add(new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,2)));
 else     portalc.inside[c++]=new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,2));
  }
  portalc.vertical=portalFace == BlockFace.UP || portalFace == BlockFace.DOWN;
  portalc.block=portalc.inside[0];
  if (oldPortal != null)   oldPortal.delete();
  if (portalc.border.size() == 0 || portalc.inside[0] == null)   return;
  for (  V10Location tb : portalc.border)   if ((!region.getBoolean(RegionSetting.ALL_BLOCKS_PORTAL) && !region.getList(RegionSetting.PORTAL_BLOCKS).contains(tb.getHandle().getBlock().getTypeId())) || borderBlocks.containsKey(tb) || insideBlocks.containsKey(tb))   return;
  for (  V10Location tb : portalc.inside)   if (tb != null)   if ((!region.getBoolean(RegionSetting.ALL_BLOCKS_PORTAL) && !region.getList(RegionSetting.PORTAL_BLOCKS).contains(tb.getHandle().getBlock().getTypeId())) || borderBlocks.containsKey(tb) || insideBlocks.containsKey(tb))   return;
  if (portalc.vertical)   portalc.destLoc[0]=new V10Location(portalc.inside[0].getHandle().getBlock().getRelative(portalFace.getOppositeFace()));
 else {
    Block block=portalc.inside[0].getHandle().getBlock().getRelative(portalFace.getOppositeFace());
    portalc.destLoc[0]=new V10Location(block);
    block=block.getRelative(BlockFace.UP);
    portalc.destLoc[1]=new V10Location(block);
  }
  portalc.tpFace=portalFace;
  boolean orange=wool.getColor() == DyeColor.ORANGE;
  Portal portal=new Portal(plugin,portalc.destLoc,portalc.block,portalc.border,portalc.inside,portalc.behind,region,orange,portalc.vertical,portalc.tpFace);
  if (orange) {
    if (region.orangePortal != null)     region.orangePortal.delete();
    region.orangePortal=portal;
  }
 else {
    if (region.bluePortal != null)     region.bluePortal.delete();
    region.bluePortal=portal;
  }
  portals.add(portal);
  region.portals.add(portal);
  portal.create();
}

Fixed version (ground truth):
public void tryPlacingAutomatedPortal(V10Location b){
  Block rb=b.getHandle().getBlock();
  Wool wool=(Wool)Material.WOOL.getNewData(rb.getData());
  if (wool.getColor() != DyeColor.BLACK && wool.getColor() != DyeColor.LIGHT_BLUE && wool.getColor() != DyeColor.ORANGE)   return;
  Block firstIronBar=null;
  for (int i=0; i < 6; i++) {
    if (rb.getRelative(BlockFace.values()[i],2).getType() == Material.IRON_FENCE) {
      firstIronBar=rb.getRelative(BlockFace.values()[i],2);
      break;
    }
 else     if (rb.getRelative(BlockFace.values()[i]).getType() == Material.IRON_FENCE) {
      firstIronBar=rb.getRelative(BlockFace.values()[i]);
      break;
    }
  }
  if (firstIronBar == null)   return;
  ArrayList<Block> ironBars=new ArrayList<Block>();
  for (int i=0; i < 6; i++) {
    BlockFace face=BlockFace.values()[i];
    if (firstIronBar.getRelative(face).getType() == Material.IRON_FENCE) {
      while (firstIronBar.getRelative(face).getType() == Material.IRON_FENCE) {
        firstIronBar=firstIronBar.getRelative(face);
      }
      ironBars.add(firstIronBar);
      int counter=1;
      while (firstIronBar.getRelative(face.getOppositeFace(),counter).getType() == Material.IRON_FENCE) {
        ironBars.add(firstIronBar.getRelative(face.getOppositeFace(),counter));
        counter++;
      }
      break;
    }
  }
  int size=plugin.config.CompactPortal ? 2 : 4;
  BlockFace otherSide=null;
  for (int i=0; i < 6; i++) {
    BlockFace face=BlockFace.values()[i];
    if (firstIronBar.getRelative(face,size).getType() == Material.IRON_FENCE) {
      otherSide=face;
      break;
    }
  }
  if (otherSide == null)   return;
  for (  Block ironBar : ironBars.toArray(new Block[0])) {
    if (ironBar.getRelative(otherSide,size).getType() == Material.IRON_FENCE)     ironBars.add(ironBar.getRelative(otherSide,size));
  }
  BlockFace portalFace=null;
  Portal oldPortal=null;
  Region region=plugin.regionManager.getRegion(b);
  for (int i=0; i < 6; i++) {
    BlockFace face2=BlockFace.values()[i];
    if (face2 == otherSide || face2.getOppositeFace() == otherSide)     continue;
    Block firstPortalBlock=firstIronBar.getRelative(otherSide).getRelative(face2);
    if (region.getBoolean(RegionSetting.ALL_BLOCKS_PORTAL) && region.getList(RegionSetting.PORTAL_BLOCKS).contains(firstPortalBlock.getTypeId())) {
      portalFace=face2;
      break;
    }
 else {
      V10Location loc=new V10Location(firstPortalBlock);
      if (borderBlocks.containsKey(loc))       oldPortal=borderBlocks.get(loc);
 else       oldPortal=insideBlocks.get(loc);
      portalFace=face2;
      break;
    }
  }
  if (portalFace == null)   return;
  if ((!plugin.config.CompactPortal && (((portalFace == BlockFace.UP || portalFace == BlockFace.DOWN) && ironBars.size() != 6) || (portalFace != BlockFace.UP && portalFace != BlockFace.DOWN && ironBars.size() != 8))) || (plugin.config.CompactPortal && (((portalFace == BlockFace.UP || portalFace == BlockFace.DOWN) && ironBars.size() != 2) || (portalFace != BlockFace.UP && portalFace != BlockFace.DOWN && ironBars.size() != 4))))   return;
  if (wool.getColor() == DyeColor.BLACK) {
    if (oldPortal != null)     oldPortal.delete();
    return;
  }
  PortalCoord portalc=new PortalCoord();
  int c=0;
  for (int i=0; i < ironBars.size() / 2; i++) {
    portalc.border.add(new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,1)));
    portalc.border.add(new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,3)));
    if (i == 0 || i == (ironBars.size() / 2) - 1)     portalc.border.add(new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,2)));
 else     portalc.inside[c++]=new V10Location(ironBars.get(i).getRelative(portalFace).getRelative(otherSide,2));
  }
  portalc.vertical=portalFace == BlockFace.UP || portalFace == BlockFace.DOWN;
  portalc.block=portalc.inside[0];
  if (oldPortal != null)   oldPortal.delete();
  if (portalc.border.size() == 0 || portalc.inside[0] == null)   return;
  for (  V10Location tb : portalc.border)   if ((!region.getBoolean(RegionSetting.ALL_BLOCKS_PORTAL) && !region.getList(RegionSetting.PORTAL_BLOCKS).contains(tb.getHandle().getBlock().getTypeId())) || borderBlocks.containsKey(tb) || insideBlocks.containsKey(tb))   return;
  for (  V10Location tb : portalc.inside)   if (tb != null)   if ((!region.getBoolean(RegionSetting.ALL_BLOCKS_PORTAL) && !region.getList(RegionSetting.PORTAL_BLOCKS).contains(tb.getHandle().getBlock().getTypeId())) || borderBlocks.containsKey(tb) || insideBlocks.containsKey(tb))   return;
  if (portalc.vertical)   portalc.destLoc[0]=new V10Location(portalc.inside[0].getHandle().getBlock().getRelative(portalFace.getOppositeFace()));
 else {
    Block block=portalc.inside[0].getHandle().getBlock().getRelative(portalFace.getOppositeFace());
    portalc.destLoc[0]=new V10Location(block);
    block=block.getRelative(BlockFace.UP);
    portalc.destLoc[1]=new V10Location(block);
  }
  portalc.tpFace=portalFace;
  boolean orange=wool.getColor() == DyeColor.ORANGE;
  Portal portal=new Portal(plugin,portalc.destLoc,portalc.block,portalc.border,portalc.inside,portalc.behind,region,orange,portalc.vertical,portalc.tpFace);
  if (orange) {
    if (region.orangePortal != null)     region.orangePortal.delete();
    region.orangePortal=portal;
  }
 else {
    if (region.bluePortal != null)     region.bluePortal.delete();
    region.bluePortal=portal;
  }
  portals.add(portal);
  region.portals.add(portal);
  portal.create();
}