Program: 33991
Project: 33991
Buggy source:
/** 
 * This method pastes a schematic.
 * @param loc
 * @param player
 */
public void pasteSchematic(final Location loc,final Player player,boolean teleport){
  if (this.file == null) {
    if (Settings.GAMETYPE == GameType.ACIDISLAND) {
      generateIslandBlocks(loc,player);
    }
 else {
      loc.getBlock().setType(Material.BEDROCK);
      ASkyBlock.getPlugin().getLogger().severe("String_Node_Str");
    }
    return;
  }
  World world=loc.getWorld();
  Location blockLoc=new Location(world,loc.getX(),Settings.island_level,loc.getZ());
  blockLoc.subtract(bedrock);
  for (  IslandBlock b : islandBlocks) {
    b.paste(nms,blockLoc,this.usePhysics,biome);
  }
  if (pasteEntities) {
    for (    EntityObject ent : entitiesList) {
      if (ent.getTileX() != null && ent.getTileY() != null && ent.getTileZ() != null) {
        ent.setLocation(new BlockVector(ent.getTileX(),ent.getTileY(),ent.getTileZ()));
      }
      Location entitySpot=ent.getLocation().toLocation(blockLoc.getWorld()).add(blockLoc.toVector());
      entitySpot.setPitch(ent.getPitch());
      entitySpot.setYaw(ent.getYaw());
      if (ent.getType() == EntityType.PAINTING) {
        try {
          Painting painting=blockLoc.getWorld().spawn(entitySpot,Painting.class);
          if (painting != null) {
            if (paintingList.containsKey(ent.getMotive())) {
              painting.setArt(paintingList.get(ent.getMotive()),true);
            }
 else {
              painting.setArt(Art.ALBAN,true);
            }
            if (facingList.containsKey(ent.getFacing())) {
              painting.setFacingDirection(facingList.get(ent.getFacing()),true);
            }
 else {
              painting.setFacingDirection(BlockFace.NORTH,true);
            }
          }
        }
 catch (        IllegalArgumentException e) {
        }
      }
 else       if (ent.getType() == EntityType.ITEM_FRAME) {
        ItemFrame itemFrame=(ItemFrame)blockLoc.getWorld().spawnEntity(entitySpot,EntityType.ITEM_FRAME);
        if (itemFrame != null) {
          Material material=Material.matchMaterial(ent.getId().substring(10).toUpperCase());
          ;
          if (material == null && IslandBlock.WEtoM.containsKey(ent.getId().substring(10).toUpperCase())) {
            material=IslandBlock.WEtoM.get(ent.getId().substring(10).toUpperCase());
          }
          ItemStack item;
          if (material != null) {
            if (ent.getCount() != null) {
              if (ent.getDamage() != null) {
                item=new ItemStack(material,ent.getCount(),ent.getDamage());
              }
 else {
                item=new ItemStack(material,ent.getCount(),(short)0);
              }
            }
 else {
              if (ent.getDamage() != null) {
                item=new ItemStack(material,1,ent.getDamage());
              }
 else {
                item=new ItemStack(material,1,(short)0);
              }
            }
          }
 else {
            item=new ItemStack(Material.STONE,0,(short)4);
          }
          ItemMeta itemMeta=item.getItemMeta();
          item.setItemMeta(itemMeta);
          itemFrame.setItem(item);
          if (facingList.containsKey(ent.getFacing())) {
            itemFrame.setFacingDirection(facingList.get(ent.getFacing()),true);
          }
 else {
            itemFrame.setFacingDirection(BlockFace.NORTH,true);
          }
          if (rotationList.containsKey(ent.getItemRotation())) {
            itemFrame.setRotation(rotationList.get(ent.getItemRotation()));
          }
 else {
            itemFrame.setRotation(Rotation.NONE);
          }
        }
      }
 else {
        Entity spawned=blockLoc.getWorld().spawnEntity(entitySpot,ent.getType());
        if (spawned != null) {
          spawned.setVelocity(ent.getMotion());
          if (ent.getType() == EntityType.SHEEP) {
            Sheep sheep=(Sheep)spawned;
            if (ent.isSheared()) {
              sheep.setSheared(true);
            }
            DyeColor[] set=DyeColor.values();
            sheep.setColor(set[ent.getColor()]);
            sheep.setAge(ent.getAge());
          }
 else           if (ent.getType() == EntityType.HORSE) {
            Horse horse=(Horse)spawned;
            Horse.Color[] set=Horse.Color.values();
            horse.setColor(set[ent.getColor()]);
            horse.setAge(ent.getAge());
            horse.setCarryingChest(ent.isCarryingChest());
          }
 else           if (ent.getType() == EntityType.VILLAGER) {
            Villager villager=(Villager)spawned;
            villager.setAge(ent.getAge());
            Profession[] proffs=Profession.values();
            villager.setProfession(proffs[ent.getProfession()]);
          }
 else           if (!Bukkit.getServer().getVersion().contains("String_Node_Str") && ent.getType() == EntityType.RABBIT) {
            Rabbit rabbit=(Rabbit)spawned;
            Rabbit.Type[] set=Rabbit.Type.values();
            rabbit.setRabbitType(set[ent.getRabbitType()]);
            rabbit.setAge(ent.getAge());
          }
 else           if (ent.getType() == EntityType.OCELOT) {
            Ocelot cat=(Ocelot)spawned;
            if (ent.isOwned()) {
              cat.setTamed(true);
              cat.setOwner(player);
            }
            Ocelot.Type[] set=Ocelot.Type.values();
            cat.setCatType(set[ent.getCatType()]);
            cat.setAge(ent.getAge());
            cat.setSitting(ent.isSitting());
          }
 else           if (ent.getType() == EntityType.WOLF) {
            Wolf wolf=(Wolf)spawned;
            if (ent.isOwned()) {
              wolf.setTamed(true);
              wolf.setOwner(player);
            }
            wolf.setAge(ent.getAge());
            wolf.setSitting(ent.isSitting());
            DyeColor[] color=DyeColor.values();
            wolf.setCollarColor(color[ent.getCollarColor()]);
          }
        }
      }
    }
  }
  final Location grass;
  if (topGrass != null) {
    Location gr=topGrass.clone().toLocation(loc.getWorld()).subtract(bedrock);
    gr.add(loc.toVector());
    gr.add(new Vector(0.5D,1.1D,0.5D));
    grass=gr;
  }
 else {
    grass=null;
  }
  Block blockToChange=null;
  if (welcomeSign != null) {
    Vector ws=welcomeSign.clone().subtract(bedrock);
    ws.add(loc.toVector());
    blockToChange=ws.toLocation(world).getBlock();
    BlockState signState=blockToChange.getState();
    if (signState instanceof Sign) {
      Sign sign=(Sign)signState;
      if (sign.getLine(0).isEmpty()) {
        sign.setLine(0,plugin.myLocale(player.getUniqueId()).signLine1.replace("String_Node_Str",player.getName()));
      }
      if (sign.getLine(1).isEmpty()) {
        sign.setLine(1,plugin.myLocale(player.getUniqueId()).signLine2.replace("String_Node_Str",player.getName()));
      }
      if (sign.getLine(2).isEmpty()) {
        sign.setLine(2,plugin.myLocale(player.getUniqueId()).signLine3.replace("String_Node_Str",player.getName()));
      }
      if (sign.getLine(3).isEmpty()) {
        sign.setLine(3,plugin.myLocale(player.getUniqueId()).signLine4.replace("String_Node_Str",player.getName()));
      }
      sign.update();
    }
  }
  if (chest != null) {
    Vector ch=chest.clone().subtract(bedrock);
    ch.add(loc.toVector());
    blockToChange=ch.toLocation(world).getBlock();
    if (useDefaultChest) {
      if (blockToChange.getType() == Material.CHEST) {
        final Chest islandChest=(Chest)blockToChange.getState();
        DoubleChest doubleChest=null;
        InventoryHolder iH=islandChest.getInventory().getHolder();
        if (iH instanceof DoubleChest) {
          doubleChest=(DoubleChest)iH;
        }
        if (doubleChest != null) {
          Inventory inventory=doubleChest.getInventory();
          inventory.clear();
          inventory.setContents(defaultChestItems);
        }
 else {
          Inventory inventory=islandChest.getInventory();
          inventory.clear();
          inventory.setContents(defaultChestItems);
        }
      }
    }
  }
  if (teleport) {
    plugin.getPlayers().setInTeleport(player.getUniqueId(),true);
    player.teleport(world.getSpawnLocation());
    plugin.getServer().getScheduler().runTaskLater(plugin,new Runnable(){
      @Override public void run(){
        plugin.getGrid().homeTeleport(player);
        plugin.getPlayers().setInTeleport(player.getUniqueId(),false);
      }
    }
,10L);
  }
  if (!islandCompanion.isEmpty() && grass != null) {
    Bukkit.getServer().getScheduler().runTaskLater(ASkyBlock.getPlugin(),new Runnable(){
      @Override public void run(){
        spawnCompanion(player,grass);
      }
    }
,40L);
  }
}

Fixed version (ground truth):
/** 
 * This method pastes a schematic.
 * @param loc
 * @param player
 */
public void pasteSchematic(final Location loc,final Player player,boolean teleport){
  if (this.file == null) {
    if (Settings.GAMETYPE == GameType.ACIDISLAND) {
      generateIslandBlocks(loc,player);
    }
 else {
      loc.getBlock().setType(Material.BEDROCK);
      ASkyBlock.getPlugin().getLogger().severe("String_Node_Str");
    }
    return;
  }
  World world=loc.getWorld();
  Location blockLoc=new Location(world,loc.getX(),loc.getY(),loc.getZ());
  blockLoc.subtract(bedrock);
  for (  IslandBlock b : islandBlocks) {
    b.paste(nms,blockLoc,this.usePhysics,biome);
  }
  if (pasteEntities) {
    for (    EntityObject ent : entitiesList) {
      if (ent.getTileX() != null && ent.getTileY() != null && ent.getTileZ() != null) {
        ent.setLocation(new BlockVector(ent.getTileX(),ent.getTileY(),ent.getTileZ()));
      }
      Location entitySpot=ent.getLocation().toLocation(blockLoc.getWorld()).add(blockLoc.toVector());
      entitySpot.setPitch(ent.getPitch());
      entitySpot.setYaw(ent.getYaw());
      if (ent.getType() == EntityType.PAINTING) {
        try {
          Painting painting=blockLoc.getWorld().spawn(entitySpot,Painting.class);
          if (painting != null) {
            if (paintingList.containsKey(ent.getMotive())) {
              painting.setArt(paintingList.get(ent.getMotive()),true);
            }
 else {
              painting.setArt(Art.ALBAN,true);
            }
            if (facingList.containsKey(ent.getFacing())) {
              painting.setFacingDirection(facingList.get(ent.getFacing()),true);
            }
 else {
              painting.setFacingDirection(BlockFace.NORTH,true);
            }
          }
        }
 catch (        IllegalArgumentException e) {
        }
      }
 else       if (ent.getType() == EntityType.ITEM_FRAME) {
        ItemFrame itemFrame=(ItemFrame)blockLoc.getWorld().spawnEntity(entitySpot,EntityType.ITEM_FRAME);
        if (itemFrame != null) {
          Material material=Material.matchMaterial(ent.getId().substring(10).toUpperCase());
          ;
          if (material == null && IslandBlock.WEtoM.containsKey(ent.getId().substring(10).toUpperCase())) {
            material=IslandBlock.WEtoM.get(ent.getId().substring(10).toUpperCase());
          }
          ItemStack item;
          if (material != null) {
            if (ent.getCount() != null) {
              if (ent.getDamage() != null) {
                item=new ItemStack(material,ent.getCount(),ent.getDamage());
              }
 else {
                item=new ItemStack(material,ent.getCount(),(short)0);
              }
            }
 else {
              if (ent.getDamage() != null) {
                item=new ItemStack(material,1,ent.getDamage());
              }
 else {
                item=new ItemStack(material,1,(short)0);
              }
            }
          }
 else {
            item=new ItemStack(Material.STONE,0,(short)4);
          }
          ItemMeta itemMeta=item.getItemMeta();
          item.setItemMeta(itemMeta);
          itemFrame.setItem(item);
          if (facingList.containsKey(ent.getFacing())) {
            itemFrame.setFacingDirection(facingList.get(ent.getFacing()),true);
          }
 else {
            itemFrame.setFacingDirection(BlockFace.NORTH,true);
          }
          if (rotationList.containsKey(ent.getItemRotation())) {
            itemFrame.setRotation(rotationList.get(ent.getItemRotation()));
          }
 else {
            itemFrame.setRotation(Rotation.NONE);
          }
        }
      }
 else {
        Entity spawned=blockLoc.getWorld().spawnEntity(entitySpot,ent.getType());
        if (spawned != null) {
          spawned.setVelocity(ent.getMotion());
          if (ent.getType() == EntityType.SHEEP) {
            Sheep sheep=(Sheep)spawned;
            if (ent.isSheared()) {
              sheep.setSheared(true);
            }
            DyeColor[] set=DyeColor.values();
            sheep.setColor(set[ent.getColor()]);
            sheep.setAge(ent.getAge());
          }
 else           if (ent.getType() == EntityType.HORSE) {
            Horse horse=(Horse)spawned;
            Horse.Color[] set=Horse.Color.values();
            horse.setColor(set[ent.getColor()]);
            horse.setAge(ent.getAge());
            horse.setCarryingChest(ent.isCarryingChest());
          }
 else           if (ent.getType() == EntityType.VILLAGER) {
            Villager villager=(Villager)spawned;
            villager.setAge(ent.getAge());
            Profession[] proffs=Profession.values();
            villager.setProfession(proffs[ent.getProfession()]);
          }
 else           if (!Bukkit.getServer().getVersion().contains("String_Node_Str") && ent.getType() == EntityType.RABBIT) {
            Rabbit rabbit=(Rabbit)spawned;
            Rabbit.Type[] set=Rabbit.Type.values();
            rabbit.setRabbitType(set[ent.getRabbitType()]);
            rabbit.setAge(ent.getAge());
          }
 else           if (ent.getType() == EntityType.OCELOT) {
            Ocelot cat=(Ocelot)spawned;
            if (ent.isOwned()) {
              cat.setTamed(true);
              cat.setOwner(player);
            }
            Ocelot.Type[] set=Ocelot.Type.values();
            cat.setCatType(set[ent.getCatType()]);
            cat.setAge(ent.getAge());
            cat.setSitting(ent.isSitting());
          }
 else           if (ent.getType() == EntityType.WOLF) {
            Wolf wolf=(Wolf)spawned;
            if (ent.isOwned()) {
              wolf.setTamed(true);
              wolf.setOwner(player);
            }
            wolf.setAge(ent.getAge());
            wolf.setSitting(ent.isSitting());
            DyeColor[] color=DyeColor.values();
            wolf.setCollarColor(color[ent.getCollarColor()]);
          }
        }
      }
    }
  }
  final Location grass;
  if (topGrass != null) {
    Location gr=topGrass.clone().toLocation(loc.getWorld()).subtract(bedrock);
    gr.add(loc.toVector());
    gr.add(new Vector(0.5D,1.1D,0.5D));
    grass=gr;
  }
 else {
    grass=null;
  }
  Block blockToChange=null;
  if (welcomeSign != null) {
    Vector ws=welcomeSign.clone().subtract(bedrock);
    ws.add(loc.toVector());
    blockToChange=ws.toLocation(world).getBlock();
    BlockState signState=blockToChange.getState();
    if (signState instanceof Sign) {
      Sign sign=(Sign)signState;
      if (sign.getLine(0).isEmpty()) {
        sign.setLine(0,plugin.myLocale(player.getUniqueId()).signLine1.replace("String_Node_Str",player.getName()));
      }
      if (sign.getLine(1).isEmpty()) {
        sign.setLine(1,plugin.myLocale(player.getUniqueId()).signLine2.replace("String_Node_Str",player.getName()));
      }
      if (sign.getLine(2).isEmpty()) {
        sign.setLine(2,plugin.myLocale(player.getUniqueId()).signLine3.replace("String_Node_Str",player.getName()));
      }
      if (sign.getLine(3).isEmpty()) {
        sign.setLine(3,plugin.myLocale(player.getUniqueId()).signLine4.replace("String_Node_Str",player.getName()));
      }
      sign.update();
    }
  }
  if (chest != null) {
    Vector ch=chest.clone().subtract(bedrock);
    ch.add(loc.toVector());
    blockToChange=ch.toLocation(world).getBlock();
    if (useDefaultChest) {
      if (blockToChange.getType() == Material.CHEST) {
        final Chest islandChest=(Chest)blockToChange.getState();
        DoubleChest doubleChest=null;
        InventoryHolder iH=islandChest.getInventory().getHolder();
        if (iH instanceof DoubleChest) {
          doubleChest=(DoubleChest)iH;
        }
        if (doubleChest != null) {
          Inventory inventory=doubleChest.getInventory();
          inventory.clear();
          inventory.setContents(defaultChestItems);
        }
 else {
          Inventory inventory=islandChest.getInventory();
          inventory.clear();
          inventory.setContents(defaultChestItems);
        }
      }
    }
  }
  if (teleport) {
    plugin.getPlayers().setInTeleport(player.getUniqueId(),true);
    player.teleport(world.getSpawnLocation());
    plugin.getServer().getScheduler().runTaskLater(plugin,new Runnable(){
      @Override public void run(){
        plugin.getGrid().homeTeleport(player);
        plugin.getPlayers().setInTeleport(player.getUniqueId(),false);
      }
    }
,10L);
  }
  if (!islandCompanion.isEmpty() && grass != null) {
    Bukkit.getServer().getScheduler().runTaskLater(ASkyBlock.getPlugin(),new Runnable(){
      @Override public void run(){
        spawnCompanion(player,grass);
      }
    }
,40L);
  }
}