nus-yam/ex-repair huggingface dataset:
Program: 1922
Project: 1922
Buggy source:
@SuppressWarnings("String_Node_Str") private int generateUID(){
  boolean found=false;
  int UID=0;
  while (found != true) {
    UID=new Random().nextInt();
    if (!GlobalUIDs.containsKey(UID)) {
      found=true;
      break;
    }
  }
  return UID;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private int generateUID(){
  boolean found=false;
  int UID=0;
  while (!found) {
    UID=new Random().nextInt();
    if (!GlobalUIDs.containsKey(UID)) {
      found=true;
      break;
    }
  }
  return UID;
}
Program: 1923
Project: 1923
Buggy source:
/** 
 * Checks whether two locations are within a certain distance of each other.
 * @param loc
 * @param pLoc
 * @param range
 * @return
 */
public static boolean checkLocation(Location loc,Location pLoc,double range){
  if (!loc.getWorld().getName().equals(pLoc.getWorld().getName())) {
    return false;
  }
  double pX=pLoc.getX(), pY=pLoc.getY(), pZ=pLoc.getZ();
  double lX=loc.getX(), lY=loc.getY(), lZ=loc.getZ();
  if ((pX <= lX + range && pX >= lX - range) && (pY >= lY - range && pY <= lY + range) && (pZ >= lZ - range && pZ <= lZ + range)) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Checks whether two locations are within range of each other.
 * @param loc
 * @param pLoc
 * @param range
 * @return
 */
public static boolean checkLocation(Location loc,Location pLoc,double range){
  if (!loc.getWorld().getName().equals(pLoc.getWorld().getName())) {
    return false;
  }
  double pX=pLoc.getX(), pY=pLoc.getY(), pZ=pLoc.getZ();
  double lX=loc.getX(), lY=loc.getY(), lZ=loc.getZ();
  if ((pX <= lX + range && pX >= lX - range) && (pY >= lY - range && pY <= lY + range) && (pZ >= lZ - range && pZ <= lZ + range)) {
    return true;
  }
 else {
    return false;
  }
}
Program: 1924
Project: 1924
Buggy source:
/** 
 * Formats the not enough money message for an operation.
 * @param op
 * @param player
 * @return
 */
public static String getNoMoneyMessage(Operation op,Player player){
  String message="String_Node_Str";
  message=ChatColor.RED + "String_Node_Str" + StringUtils.wrap(EconomyHandler.getPaymentType(op,EconomyHandler.getRemainder(op,player),ChatColor.RED),ChatColor.RED)+ "String_Node_Str";
  return message;
}

Fixed version (ground truth):
/** 
 * Formats the not enough money message for an operation.
 * @param op
 * @param player
 * @return
 */
public static String getNoMoneyMessage(Operation op,Player player){
  String message="String_Node_Str";
  message=ChatColor.RED + "String_Node_Str" + StringUtils.wrap(EconomyHandler.getPaymentType(op,EconomyHandler.getRemainder(op,player)),ChatColor.RED)+ "String_Node_Str";
  return message;
}
Program: 1925
Project: 1925
Buggy source:
/** 
 * Pulls a random message from a string of messages split by a semi-colon
 * @param messages
 * @return
 */
public static String getRandomMessage(String messages){
  String[] split=messages.split("String_Node_Str");
  String text="String_Node_Str";
  text=split[new Random().nextInt(split.length)];
  if (text.equals(Constants.defaultText)) {
    return text.replace('&','�');
  }
  return text;
}

Fixed version (ground truth):
/** 
 * Pulls a random message from a string of messages split by a semi-colon
 * @param messages
 * @return
 */
public static String getRandomMessage(String messages){
  String[] split=messages.split("String_Node_Str");
  String text=split[new Random().nextInt(split.length)];
  if (text.equals(Constants.defaultText)) {
    return text.replace('&','�');
  }
  return text;
}
Program: 1926
Project: 1926
Buggy source:
/** 
 * Gets the text to be said for a basic npc.
 * @param npc
 * @param player
 * @param plugin
 * @return
 */
public static String getText(HumanNPC npc,Player player){
  String name=StringUtils.stripColour(npc.getStrippedName());
  ArrayDeque<String> array=NPCManager.getText(npc.getUID());
  String text="String_Node_Str";
  if (array != null && array.size() > 0) {
    text=array.pop();
    array.addLast(text);
    NPCManager.setText(npc.getUID(),array);
  }
  if (text.isEmpty()) {
    text=getRandomMessage(Constants.defaultText);
  }
  if (!text.isEmpty()) {
    if (Constants.useNPCColours) {
      text=Constants.chatFormat.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str",npc.getStrippedName()) + text;
    }
 else {
      text=Constants.chatFormat.replace("String_Node_Str",Constants.npcColour + name + ChatColor.WHITE).replace("String_Node_Str","String_Node_Str") + text;
    }
    return text;
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Gets the text to be said for a basic NPC
 * @param npc
 * @param player
 * @return
 */
public static String getText(HumanNPC npc,Player player){
  String name=StringUtils.stripColour(npc.getStrippedName());
  ArrayDeque<String> array=NPCManager.getText(npc.getUID());
  String text="String_Node_Str";
  if (array != null && array.size() > 0) {
    text=array.pop();
    array.addLast(text);
    NPCManager.setText(npc.getUID(),array);
  }
  if (text.isEmpty()) {
    text=getRandomMessage(Constants.defaultText);
  }
  if (!text.isEmpty()) {
    if (Constants.useNPCColours) {
      text=Constants.chatFormat.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str",npc.getStrippedName()) + text;
    }
 else {
      text=Constants.chatFormat.replace("String_Node_Str",Constants.npcColour + name + ChatColor.WHITE).replace("String_Node_Str","String_Node_Str") + text;
    }
    return text;
  }
  return "String_Node_Str";
}
Program: 1927
Project: 1927
Buggy source:
/** 
 * Formats the paid message for an operation.
 * @param op
 * @param paid
 * @param npcName
 * @param type
 * @param useType
 * @return
 */
public static String getPaidMessage(Operation op,double paid,String npcName,String type,boolean useType){
  String message="String_Node_Str";
  message=ChatColor.GREEN + "String_Node_Str" + StringUtils.wrap(EconomyHandler.getPaymentType(op,"String_Node_Str" + paid,ChatColor.GREEN))+ "String_Node_Str";
  if (useType) {
    message+=StringUtils.wrap(npcName) + "String_Node_Str" + StringUtils.wrap(type)+ "String_Node_Str";
  }
 else {
    message+=StringUtils.wrap(npcName) + "String_Node_Str";
  }
  return message;
}

Fixed version (ground truth):
/** 
 * Formats the paid message for an operation.
 * @param op
 * @param paid
 * @param npcName
 * @param type
 * @param useType
 * @return
 */
public static String getPaidMessage(Operation op,double paid,String npcName,String type,boolean useType){
  String message="String_Node_Str";
  message=ChatColor.GREEN + "String_Node_Str" + StringUtils.wrap(EconomyHandler.getPaymentType(op,"String_Node_Str" + paid))+ "String_Node_Str";
  if (useType) {
    message+=StringUtils.wrap(npcName) + "String_Node_Str" + StringUtils.wrap(type)+ "String_Node_Str";
  }
 else {
    message+=StringUtils.wrap(npcName) + "String_Node_Str";
  }
  return message;
}
Program: 1930
Project: 1930
Buggy source:
private void saveStockables(int UID,ConcurrentHashMap<Check,Stockable> stockables){
  String string="String_Node_Str";
  setStockables(UID,string);
  int count=0;
  for (  Stockable entry : stockables.values()) {
    if (!string.contains(entry.toString()))     string+=entry.toString();
    count+=1;
  }
  setStockables(UID,string);
}

Fixed version (ground truth):
private void saveStockables(int UID,ConcurrentHashMap<Check,Stockable> stockables){
  String string="String_Node_Str";
  setStockables(UID,string);
  int count=0;
  for (  Stockable entry : stockables.values()) {
    if (!string.contains(entry.toString()))     string+=(entry.toString() + "String_Node_Str");
    count+=1;
  }
  setStockables(UID,string);
}
Program: 1931
Project: 1931
Buggy source:
public static HumanNPC spawnBasicHumanNpc(int UID,String name,World world,double x,double y,double z,float yaw,float pitch){
  try {
    WorldServer ws=getWorldServer(world);
    MinecraftServer ms=getMinecraftServer(ws.getServer());
    CraftNPC eh=new CraftNPC(ms,ws,name,new ItemInWorldManager(ws));
    eh.setPositionRotation(x,y,z,yaw,pitch);
    ws.addEntity(eh);
    ws.players.remove(eh);
    return new HumanNPC(eh,UID,name);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
public static HumanNPC spawnBasicHumanNpc(int UID,String name,World world,double x,double y,double z,float yaw,float pitch){
  try {
    WorldServer ws=getWorldServer(world);
    MinecraftServer ms=getMinecraftServer(ws.getServer());
    CraftNPC eh=new CraftNPC(ms,ws,name,new ItemInWorldManager(ws));
    eh.setLocation(x,y,z,yaw,pitch);
    ws.addEntity(eh);
    ws.players.remove(eh);
    return new HumanNPC(eh,UID,name);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}
Program: 1932
Project: 1932
Buggy source:
@Override public synchronized void save(){
  try {
    this.properties.store(new FileOutputStream(this.fileName),"String_Node_Str");
  }
 catch (  IOException ex) {
    Messaging.log("String_Node_Str" + this.fileName,Level.SEVERE);
  }
}

Fixed version (ground truth):
@Override public synchronized void save(){
  FileOutputStream stream=null;
  try {
    stream=new FileOutputStream(this.fileName);
    this.properties.store(stream,"String_Node_Str");
  }
 catch (  IOException ex) {
    Messaging.log("String_Node_Str" + this.fileName,Level.SEVERE);
  }
 finally {
    try {
      if (stream != null)       stream.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}
Program: 1933
Project: 1933
Buggy source:
@Override public synchronized void load(){
  try {
    this.properties.load(new FileInputStream(this.fileName));
  }
 catch (  Exception ex) {
    Messaging.log("String_Node_Str" + this.fileName,Level.SEVERE);
  }
}

Fixed version (ground truth):
@Override public synchronized void load(){
  FileInputStream stream=null;
  try {
    stream=new FileInputStream(this.fileName);
    this.properties.load(stream);
  }
 catch (  Exception ex) {
    Messaging.log("String_Node_Str" + this.fileName,Level.SEVERE);
  }
 finally {
    try {
      if (stream != null)       stream.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}
Program: 1934
Project: 1934
Buggy source:
/** 
 * Checks the inventory of a player for having enough for a payment.
 * @param payment
 * @param player
 * @return
 */
public static boolean hasEnough(Payment payment,Player player){
  int current=0;
  if (payment.getPrice() <= 0)   return true;
  for (  ItemStack i : player.getInventory().getContents()) {
    if (i != null && i.getTypeId() == payment.getItem().getTypeId()) {
      current+=i.getAmount();
      if (current >= payment.getPrice()) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks the inventory of a player for having enough for a payment.
 * @param payment
 * @param player
 * @return
 */
public static boolean hasEnough(Payment payment,Player player){
  int current=0;
  if (payment.getItem().getAmount() <= 0 || payment.getItem().getTypeId() == 0) {
    return true;
  }
  for (  ItemStack i : player.getInventory().getContents()) {
    if (i != null && i.getTypeId() == payment.getItem().getTypeId()) {
      current+=i.getAmount();
      if (current >= payment.getPrice()) {
        return true;
      }
    }
  }
  return false;
}
Program: 1935
Project: 1935
Buggy source:
/** 
 * Pays for a payment from the player's inventory.
 * @param player
 * @param payment
 * @param slot
 * @return
 */
public static double pay(Player player,Payment payment,int slot){
  int currencyID=payment.getItem().getTypeId();
  double current=payment.getPrice();
  if (current <= 0)   return payment.getPrice();
  int count=0;
  if (slot != -1) {
    current=decreaseItemStack(player,currencyID,current,slot);
  }
  if (current <= 0)   return payment.getPrice();
  for (  ItemStack item : player.getInventory().getContents()) {
    if (item != null) {
      current=decreaseItemStack(player,currencyID,current,count);
      if (current <= 0)       break;
    }
    count+=1;
  }
  return payment.getPrice();
}

Fixed version (ground truth):
/** 
 * Pays for a payment from the player's inventory.
 * @param player
 * @param payment
 * @param slot
 * @return
 */
public static double pay(Player player,Payment payment,int slot){
  int currencyID=payment.getItem().getTypeId();
  double current=payment.getPrice();
  if (current <= 0)   return current;
  int count=0;
  if (slot != -1) {
    current=decreaseItemStack(player,currencyID,current,slot);
  }
  if (current <= 0)   return payment.getPrice();
  for (  ItemStack item : player.getInventory().getContents()) {
    if (item != null) {
      current=decreaseItemStack(player,currencyID,current,count);
      if (current <= 0)       break;
    }
    count+=1;
  }
  return payment.getPrice();
}
Program: 1936
Project: 1936
Buggy source:
/** 
 * Get the price for repairing an item
 * @param player
 * @param item
 * @param op
 * @return
 */
public static int getBlacksmithPrice(Player player,ItemStack item,Operation op){
  short maxDurability=Material.getMaterial(item.getTypeId()).getMaxDurability();
  double percentage=((double)maxDurability - item.getDurability()) / maxDurability;
  price=(1.0 - percentage) * UtilityProperties.getPrice(Operation.getString(op,addendum));
  if (price < 1.0) {
    price+=1;
  }
  return (int)price;
}

Fixed version (ground truth):
/** 
 * Get the price for repairing an item
 * @param player
 * @param item
 * @param op
 * @return
 */
public static int getBlacksmithPrice(Player player,ItemStack item,Operation op){
  short maxDurability=Material.getMaterial(item.getTypeId()).getMaxDurability();
  double percentage=((double)maxDurability - item.getDurability()) / maxDurability;
  blacksmithPrice=(1.0 - percentage) * UtilityProperties.getPrice(Operation.getString(op,addendum));
  if (blacksmithPrice < 1.0) {
    blacksmithPrice+=1;
  }
  return (int)blacksmithPrice;
}
Program: 1937
Project: 1937
Buggy source:
/** 
 * Pays for a blacksmith operation
 * @param player
 * @param item
 * @param op
 * @return
 */
public static double payBlacksmith(Player player,ItemStack item,Operation op){
  int currencyID=UtilityProperties.getCurrencyID(Operation.getString(op,currencyAddendum));
  double current=getBlacksmithPrice(player,item,op);
  int count=0;
  for (  ItemStack i : player.getInventory().getContents()) {
    if (i != null) {
      current=decreaseItemStack(player,currencyID,current,count);
      if (current <= 0)       break;
    }
    count+=1;
  }
  return price;
}

Fixed version (ground truth):
/** 
 * Pays for a blacksmith operation
 * @param player
 * @param item
 * @param op
 * @return
 */
public static double payBlacksmith(Player player,ItemStack item,Operation op){
  int currencyID=UtilityProperties.getCurrencyID(Operation.getString(op,currencyAddendum));
  double current=getBlacksmithPrice(player,item,op);
  if (current <= 0 || currencyID == 0) {
    return blacksmithPrice;
  }
  int count=0;
  for (  ItemStack i : player.getInventory().getContents()) {
    if (i != null) {
      current=decreaseItemStack(player,currencyID,current,count);
      if (current <= 0)       break;
    }
    count+=1;
  }
  return blacksmithPrice;
}
Program: 1938
Project: 1938
Buggy source:
@Override public boolean onCommand(CommandSender sender,Command command,String commandLabel,String[] args){
  if (!(sender instanceof Player)) {
    sender.sendMessage(MessageUtils.mustBeIngameMessage);
    return true;
  }
  Player player=(Player)sender;
  HumanNPC npc=null;
  boolean returnval=false;
  if (NPCManager.validateSelected((Player)sender)) {
    npc=NPCManager.get(NPCManager.selectedNPCs.get(player.getName()));
  }
 else {
    sender.sendMessage(ChatColor.RED + MessageUtils.mustHaveNPCSelectedMessage);
    return true;
  }
  if (!NPCManager.validateOwnership(player,npc.getUID())) {
    sender.sendMessage(MessageUtils.notOwnerMessage);
    return true;
  }
  if (!npc.isBandit()) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str");
    return true;
  }
 else {
    if (args.length == 1 && args[0].equalsIgnoreCase("String_Node_Str")) {
      if (Permission.canUse(player,npc,"String_Node_Str")) {
        HelpUtils.sendBanditHelp(sender);
      }
 else {
        sender.sendMessage(MessageUtils.noPermissionsMessage);
      }
      return true;
    }
 else     if (args.length == 2 && args[0].equalsIgnoreCase("String_Node_Str")) {
      if (Permission.canModify(player,npc,"String_Node_Str")) {
        addStealableItem(player,npc,args[1]);
      }
 else {
        sender.sendMessage(MessageUtils.noPermissionsMessage);
      }
      returnval=true;
    }
  }
  return returnval;
}

Fixed version (ground truth):
@Override public boolean onCommand(CommandSender sender,Command command,String commandLabel,String[] args){
  if (!(sender instanceof Player)) {
    sender.sendMessage(MessageUtils.mustBeIngameMessage);
    return true;
  }
  Player player=(Player)sender;
  HumanNPC npc=null;
  boolean returnval=false;
  if (NPCManager.validateSelected((Player)sender)) {
    npc=NPCManager.get(NPCManager.selectedNPCs.get(player.getName()));
  }
 else {
    sender.sendMessage(ChatColor.RED + MessageUtils.mustHaveNPCSelectedMessage);
    return true;
  }
  if (!NPCManager.validateOwnership(player,npc.getUID())) {
    sender.sendMessage(MessageUtils.notOwnerMessage);
    return true;
  }
  if (!npc.isBandit()) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str");
    return true;
  }
 else {
    if (args.length == 1 && args[0].equalsIgnoreCase("String_Node_Str")) {
      if (Permission.canUse(player,npc,"String_Node_Str")) {
        HelpUtils.sendBanditHelp(sender);
      }
 else {
        sender.sendMessage(MessageUtils.noPermissionsMessage);
      }
      return true;
    }
 else     if (args.length == 3 && args[0].equalsIgnoreCase("String_Node_Str")) {
      if (Permission.canModify(player,npc,"String_Node_Str")) {
        if (args[1].equalsIgnoreCase("String_Node_Str")) {
          changeStealable(player,npc,args[2],true);
        }
 else         if (args[1].equalsIgnoreCase("String_Node_Str")) {
          changeStealable(player,npc,args[2],false);
        }
      }
 else {
        sender.sendMessage(MessageUtils.noPermissionsMessage);
      }
      returnval=true;
    }
  }
  return returnval;
}
Program: 1940
Project: 1940
Buggy source:
@Override public void onRightClick(Player player,HumanNPC npc){
  if (Permission.canUse(player,npc,getType())) {
    Operation op=null;
    if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_TOOLREPAIR;
    }
 else     if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_ARMORREPAIR;
    }
    if (op != null)     npc.getBlacksmith().buyItemRepair(player,npc,player.getItemInHand(),op);
  }
 else {
    player.sendMessage(MessageUtils.noPermissionsMessage);
  }
}

Fixed version (ground truth):
@Override public void onRightClick(Player player,HumanNPC npc){
  if (Permission.canUse(player,npc,getType())) {
    Operation op=null;
    if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_TOOLREPAIR;
    }
 else     if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_ARMORREPAIR;
    }
    if (op != null) {
      npc.getBlacksmith().buyItemRepair(player,npc,player.getItemInHand(),op);
    }
  }
 else {
    player.sendMessage(MessageUtils.noPermissionsMessage);
  }
}
Program: 1941
Project: 1941
Buggy source:
/** 
 * Validate that the item to repair is armor
 * @param armor
 * @return
 */
public boolean validateArmor(ItemStack armor){
  int id=armor.getTypeId();
  if (id >= 298 && id <= 317) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Validate that the item to repair is armor
 * @param armor
 * @return
 */
public boolean validateArmor(ItemStack armor){
  int id=armor.getTypeId();
  if (id >= 298 && id <= 317) {
    return true;
  }
  return false;
}
Program: 1942
Project: 1942
Buggy source:
/** 
 * Validate that an item has a durability and can be repaired
 * @param item
 * @return
 */
public boolean validateTool(ItemStack item){
  int id=item.getTypeId();
  if (id >= 256 && id <= 259 || id >= 267 && id <= 279 || id >= 283 && id <= 286 || id >= 290 && id <= 294 || id == 346) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Validate that an item has a durability and can be repaired
 * @param item
 * @return
 */
public boolean validateTool(ItemStack item){
  int id=item.getTypeId();
  if ((id >= 256 && id <= 259) || (id >= 267 && id <= 279) || (id >= 283 && id <= 286)|| (id >= 290 && id <= 294)|| id == 346) {
    return true;
  }
  return false;
}
Program: 1943
Project: 1943
Buggy source:
private CreatureType getMob(int UID){
  return CreatureType.valueOf(mob.getString(UID));
}

Fixed version (ground truth):
private CreatureType getMob(int UID){
  if (CreatureType.fromName(mob.getString(UID)) != null) {
    return CreatureType.fromName(mob.getString(UID));
  }
  System.out.println("String_Node_Str");
  return CreatureType.CREEPER;
}
Program: 1944
Project: 1944
Buggy source:
/** 
 * Moves the selected NPC to the current location of a player.
 * @param sender
 * @param name
 * @param npc
 */
private void move(Player player,String name,HumanNPC npc){
  Location loc=npc.getNPCData().getLocation();
  player.sendMessage(StringUtils.wrap(name) + "String_Node_Str");
  npc.getNPCData().setLocation(loc);
  npc.moveTo(player.getLocation());
}

Fixed version (ground truth):
/** 
 * Moves the selected NPC to the current location of a player.
 * @param sender
 * @param name
 * @param npc
 */
private void move(Player player,String name,HumanNPC npc){
  Location loc=npc.getNPCData().getLocation();
  player.sendMessage(StringUtils.wrap(name) + "String_Node_Str");
  npc.getNPCData().setLocation(loc);
  npc.teleport(player.getLocation());
}
Program: 1945
Project: 1945
Buggy source:
/** 
 * Copies an npc's data and position to another npc.
 * @param npc
 * @param p
 */
private void copy(int UID,String name,Player p){
  int newUID=NPCManager.register(name,p.getLocation(),p.getName());
  HumanNPC newNPC=NPCManager.get(newUID);
  newNPC.moveTo(p.getLocation());
  newNPC.getNPCData().setLocation(p.getLocation());
  PropertyManager.copy(UID,newUID);
  NPCManager.removeForRespawn(newUID);
  NPCManager.register(name,newUID,newNPC.getOwner());
}

Fixed version (ground truth):
/** 
 * Copies an npc's data and position to another npc.
 * @param npc
 * @param p
 */
private void copy(int UID,String name,Player p){
  int newUID=NPCManager.register(name,p.getLocation(),p.getName());
  HumanNPC newNPC=NPCManager.get(newUID);
  newNPC.teleport(p.getLocation());
  newNPC.getNPCData().setLocation(p.getLocation());
  PropertyManager.copy(UID,newUID);
  NPCManager.removeForRespawn(newUID);
  NPCManager.register(name,newUID,newNPC.getOwner());
}
Program: 1946
Project: 1946
Buggy source:
@Override public void onRightClick(Player player,HumanNPC npc){
  if (Permission.canUse(player,npc,getType())) {
    Operation op=null;
    if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_TOOLREPAIR;
    }
 else     if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_ARMORREPAIR;
    }
    npc.getBlacksmith().buyItemRepair(player,npc,player.getItemInHand(),op);
  }
 else {
    player.sendMessage(MessageUtils.noPermissionsMessage);
  }
}

Fixed version (ground truth):
@Override public void onRightClick(Player player,HumanNPC npc){
  if (Permission.canUse(player,npc,getType())) {
    Operation op=null;
    if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_TOOLREPAIR;
    }
 else     if (npc.getBlacksmith().getToolType(player.getItemInHand()).equals("String_Node_Str")) {
      op=Operation.BLACKSMITH_ARMORREPAIR;
    }
    if (op != null)     npc.getBlacksmith().buyItemRepair(player,npc,player.getItemInHand(),op);
  }
 else {
    player.sendMessage(MessageUtils.noPermissionsMessage);
  }
}
Program: 1947
Project: 1947
Buggy source:
/** 
 * Validate that an item has a durability and can be repaired
 * @param item
 * @return
 */
public boolean validateTool(ItemStack item){
  int id=item.getTypeId();
  if (id == 256 || id == 257 || id == 258 || id == 259 || id == 267 || id == 268 || id == 269 || id == 270 || id == 271 || id == 272 || id == 273 || id == 274 || id == 275 || id == 276 || id == 277 || id == 278 || id == 279 || id == 283 || id == 284 || id == 285 || id == 286 || id == 290 || id == 291 || id == 292 || id == 293 || id == 294 || id == 346) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Validate that an item has a durability and can be repaired
 * @param item
 * @return
 */
public boolean validateTool(ItemStack item){
  int id=item.getTypeId();
  if (id >= 256 && id <= 259 || id >= 267 && id <= 279 || id >= 283 && id <= 286 || id >= 290 && id <= 294 || id == 346) {
    return true;
  }
 else {
    return false;
  }
}
Program: 1949
Project: 1949
Buggy source:
@Override public void onRightClick(Player player,HumanNPC npc){
  if (npc.getTrader().isFree()) {
    Mode mode;
    if (NPCManager.validateOwnership(player,npc.getUID())) {
      if (!Permission.canModify(player,npc,"String_Node_Str")) {
        return;
      }
      mode=Mode.STOCK;
    }
 else     if (npc.getTrader().isUnlimited()) {
      mode=Mode.INFINITE;
      if (!Permission.canUse(player,npc,"String_Node_Str")) {
        return;
      }
    }
 else {
      mode=Mode.NORMAL;
      if (!Permission.canUse(player,npc,"String_Node_Str")) {
        return;
      }
    }
    TraderTask task=new TraderTask(npc,player,Citizens.plugin,mode);
    int id=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Citizens.plugin,task,2,0);
    TraderManager.tasks.add(id);
    task.addID(id);
    npc.getTrader().setFree(false);
    NPCManager.showInventory(npc,player);
  }
 else {
    player.sendMessage(ChatColor.RED + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void onRightClick(Player player,HumanNPC npc){
  if (npc.getTrader().isFree()) {
    Mode mode;
    if (NPCManager.validateOwnership(player,npc.getUID())) {
      if (!Permission.canModify(player,npc,"String_Node_Str")) {
        return;
      }
      mode=Mode.STOCK;
    }
 else     if (npc.getTrader().isUnlimited()) {
      mode=Mode.INFINITE;
      if (!Permission.canUse(player,npc,"String_Node_Str")) {
        return;
      }
    }
 else {
      mode=Mode.NORMAL;
      if (!Permission.canUse(player,npc,"String_Node_Str")) {
        return;
      }
    }
    TraderTask task=new TraderTask(npc,player,mode);
    int id=Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Citizens.plugin,task,2,0);
    TraderManager.tasks.add(id);
    task.addID(id);
    npc.getTrader().setFree(false);
    NPCManager.showInventory(npc,player);
  }
 else {
    player.sendMessage(ChatColor.RED + "String_Node_Str");
  }
}
Program: 1950
Project: 1950
Buggy source:
/** 
 * Gets run every tick, checks the inventory for changes.
 * @param npc
 * @param player
 * @param plugin
 * @param mode
 */
public TraderTask(HumanNPC npc,Player player,Citizens plugin,Mode mode){
  this.npc=npc;
  this.player=(CraftPlayer)player;
  this.mcPlayer=this.player.getHandle();
  this.plugin=plugin;
  this.previousTraderInv=new CraftInventoryPlayer(new InventoryPlayer(null));
  this.previousPlayerInv=new CraftInventoryPlayer(new InventoryPlayer(null));
  clonePlayerInventory(npc.getInventory(),this.previousTraderInv);
  clonePlayerInventory(player.getInventory(),this.previousPlayerInv);
  this.mode=mode;
  sendJoinMessage();
}

Fixed version (ground truth):
/** 
 * Gets run every tick, checks the inventory for changes.
 * @param npc
 * @param player
 * @param plugin
 * @param mode
 */
public TraderTask(HumanNPC npc,Player player,Mode mode){
  this.npc=npc;
  this.player=(CraftPlayer)player;
  this.mcPlayer=this.player.getHandle();
  this.previousTraderInv=new CraftInventoryPlayer(new InventoryPlayer(null));
  this.previousPlayerInv=new CraftInventoryPlayer(new InventoryPlayer(null));
  clonePlayerInventory(npc.getInventory(),this.previousTraderInv);
  clonePlayerInventory(player.getInventory(),this.previousPlayerInv);
  this.mode=mode;
  sendJoinMessage();
}
Program: 1952
Project: 1952
Buggy source:
public void kill(){
  stop=true;
  this.npc.getTrader().setFree(true);
  sendLeaveMessage();
  int index=TraderManager.tasks.indexOf(taskID);
  if (index != -1) {
    TraderManager.tasks.remove(TraderManager.tasks.indexOf(taskID));
  }
  plugin.getServer().getScheduler().cancelTask(taskID);
}

Fixed version (ground truth):
public void kill(){
  stop=true;
  this.npc.getTrader().setFree(true);
  sendLeaveMessage();
  int index=TraderManager.tasks.indexOf(taskID);
  if (index != -1) {
    TraderManager.tasks.remove(TraderManager.tasks.indexOf(taskID));
  }
  Bukkit.getServer().getScheduler().cancelTask(taskID);
}
Program: 1953
Project: 1953
Buggy source:
/** 
 * Rotates an npc.
 * @param npc
 * @param player
 */
public static void facePlayer(HumanNPC npc,Player player){
  Location loc=npc.getLocation();
  double xDiff=player.getLocation().getX() - loc.getX();
  double yDiff=player.getLocation().getY() - loc.getY();
  double zDiff=player.getLocation().getZ() - loc.getZ();
  double DistanceXZ=Math.sqrt(xDiff * xDiff + zDiff * zDiff);
  double DistanceY=Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
  double yaw=(Math.acos(xDiff / DistanceXZ) * 180 / Math.PI);
  double pitch=(Math.acos(yDiff / DistanceY) * 180 / Math.PI) - 90;
  if (zDiff < 0.0) {
    yaw=yaw + (Math.abs(180 - yaw) * 2);
  }
  npc.moveTo(loc.getX(),loc.getY(),loc.getZ(),(float)yaw - 90,(float)pitch);
}

Fixed version (ground truth):
/** 
 * Rotates an npc.
 * @param npc
 * @param player
 */
public static void facePlayer(HumanNPC npc,Player player){
  Location loc=npc.getLocation();
  double xDiff=player.getLocation().getX() - loc.getX();
  double yDiff=player.getLocation().getY() - loc.getY();
  double zDiff=player.getLocation().getZ() - loc.getZ();
  double DistanceXZ=Math.sqrt(xDiff * xDiff + zDiff * zDiff);
  double DistanceY=Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
  double yaw=(Math.acos(xDiff / DistanceXZ) * 180 / Math.PI);
  double pitch=(Math.acos(yDiff / DistanceY) * 180 / Math.PI) - 90;
  if (zDiff < 0.0) {
    yaw=yaw + (Math.abs(180 - yaw) * 2);
  }
  npc.teleport(loc.getX(),loc.getY(),loc.getZ(),(float)yaw - 90,(float)pitch);
}
Program: 1954
Project: 1954
Buggy source:
public Location getActualLocationFromName(int UID){
  String[] values=locations.getString(UID).split("String_Node_Str");
  if (values.length != 6) {
    log.info("String_Node_Str" + values.length);
    return null;
  }
 else {
    Location loc=new Location(Bukkit.getServer().getWorld(values[0]),NPCManager.get(UID).getX(),NPCManager.get(UID).getY(),NPCManager.get(UID).getZ(),Float.parseFloat(values[4]),Float.parseFloat(values[5]));
    return loc;
  }
}

Fixed version (ground truth):
public Location getActualLocationFromName(int UID){
  String[] values=locations.getString(UID).split("String_Node_Str");
  if (values.length != 6) {
    log.info("String_Node_Str" + values.length);
    return null;
  }
 else {
    Location loc=new Location(Bukkit.getServer().getWorld(values[0]),NPCManager.get(UID).getLocation().getX(),NPCManager.get(UID).getLocation().getY(),NPCManager.get(UID).getLocation().getZ(),Float.parseFloat(values[4]),Float.parseFloat(values[5]));
    return loc;
  }
}
Program: 1955
Project: 1955
Buggy source:
public static void saveFiles(){
  for (  Saveable saveable : properties.values()) {
    saveable.saveFiles();
  }
  QuestProperties.save();
}

Fixed version (ground truth):
public static void saveFiles(){
  for (  Saveable saveable : properties.values()) {
    saveable.saveFiles();
  }
}
Program: 1956
Project: 1956
Buggy source:
/** 
 * Gets the text to be said for a basic npc.
 * @param npc
 * @param player
 * @param plugin
 * @return
 */
public static String getText(HumanNPC npc,Player player){
  String name=StringUtils.stripColour(npc.getStrippedName());
  ArrayDeque<String> array=NPCManager.getText(npc.getUID());
  String text="String_Node_Str";
  if (array != null && array.size() > 0) {
    text=array.getLast();
    array.push(array.pop());
    NPCManager.setText(npc.getUID(),array);
  }
  if (text.isEmpty()) {
    text=UtilityProperties.getDefaultText();
  }
  if (!text.isEmpty()) {
    if (Constants.useNPCColours) {
      text=Constants.chatFormat.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str",npc.getStrippedName()) + text;
    }
 else {
      text=Constants.chatFormat.replace("String_Node_Str",Constants.npcColour + name + ChatColor.WHITE).replace("String_Node_Str","String_Node_Str") + text;
    }
    return text;
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Gets the text to be said for a basic npc.
 * @param npc
 * @param player
 * @param plugin
 * @return
 */
public static String getText(HumanNPC npc,Player player){
  String name=StringUtils.stripColour(npc.getStrippedName());
  ArrayDeque<String> array=NPCManager.getText(npc.getUID());
  String text="String_Node_Str";
  if (array != null && array.size() > 0) {
    text=array.pop();
    array.addLast(text);
    NPCManager.setText(npc.getUID(),array);
  }
  if (text.isEmpty()) {
    text=UtilityProperties.getDefaultText();
  }
  if (!text.isEmpty()) {
    if (Constants.useNPCColours) {
      text=Constants.chatFormat.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str",npc.getStrippedName()) + text;
    }
 else {
      text=Constants.chatFormat.replace("String_Node_Str",Constants.npcColour + name + ChatColor.WHITE).replace("String_Node_Str","String_Node_Str") + text;
    }
    return text;
  }
  return "String_Node_Str";
}
Program: 1957
Project: 1957
Buggy source:
public static boolean pathFinished(HumanNPC npc){
  return npc.pathFinished();
}

Fixed version (ground truth):
public static boolean pathFinished(HumanNPC npc){
  return npc.getHandle().pathFinished();
}
Program: 1958
Project: 1958
Buggy source:
public static void cancelTarget(HumanNPC npc){
  npc.cancelTarget();
}

Fixed version (ground truth):
public static void cancelTarget(HumanNPC npc){
  npc.getHandle().cancelTarget();
}
Program: 1959
Project: 1959
Buggy source:
public static void cancelPath(HumanNPC npc){
  npc.cancelPath();
}

Fixed version (ground truth):
public static void cancelPath(HumanNPC npc){
  npc.getHandle().cancelPath();
}
Program: 1960
Project: 1960
Buggy source:
public void applyGravity(){
  if (this.motY > 0)   this.motY-=Constants.GRAVITY;
}

Fixed version (ground truth):
public void applyGravity(){
  this.motY-=Constants.GRAVITY;
}
Program: 1961
Project: 1961
Buggy source:
public void updateMovement(){
  this.moveNPCTowardsTarget();
  this.applyGravity();
}

Fixed version (ground truth):
public void updateMovement(){
  this.mcEntity.updateMove();
  this.mcEntity.applyGravity();
}
Program: 1962
Project: 1962
Buggy source:
/** 
 * Returns whether the given item ID is usable as a tool.
 * @param key , type
 * @return Whether the ID is used for a tool.
 */
public boolean validateTool(String key,int type,boolean sneaking){
  if (Constants.useItemList) {
    String[] items=UtilityProperties.settings.getString(key).split("String_Node_Str");
    List<String> item=Arrays.asList(items);
    if (item.contains("String_Node_Str"))     return true;
    boolean isShift=false;
    for (    String s : item) {
      isShift=false;
      if (s.contains("String_Node_Str")) {
        s=s.replace("String_Node_Str","String_Node_Str");
        isShift=true;
      }
      if (Integer.parseInt(s) == type && isShift == sneaking)       return true;
    }
    return false;
  }
 else   return true;
}

Fixed version (ground truth):
/** 
 * Returns whether the given item ID is usable as a tool.
 * @param key , type
 * @return Whether the ID is used for a tool.
 */
public boolean validateTool(String key,int type,boolean sneaking){
  if (Constants.useItemList) {
    String[] items=UtilityProperties.settings.getString(key).split("String_Node_Str");
    List<String> item=Arrays.asList(items);
    if (item.contains("String_Node_Str")) {
      return true;
    }
    boolean isShift=false;
    for (    String s : item) {
      isShift=false;
      if (s.contains("String_Node_Str")) {
        s=s.replace("String_Node_Str","String_Node_Str");
        isShift=true;
      }
      if (Integer.parseInt(s) == type && isShift == sneaking) {
        return true;
      }
    }
    return false;
  }
 else {
    return true;
  }
}
Program: 1966
Project: 1966
Buggy source:
private void levelUp(Player player,HumanNPC npc,int multiple){
  if (EconomyHandler.useEconomy()) {
    int level=npc.getHealer().getLevel();
    double paid=EconomyHandler.pay(Operation.HEALER_LEVEL_UP,player,multiple);
    if (paid > 0) {
      if (level < 10) {
        npc.getHealer().setLevel(level + multiple);
        player.sendMessage(getLevelUpPaidMessage(Operation.HEALER_LEVEL_UP,npc,paid,level + multiple,multiple));
      }
 else {
        player.sendMessage(StringUtils.wrap(npc.getStrippedName()) + "String_Node_Str");
      }
    }
  }
 else {
    player.sendMessage(ChatColor.GRAY + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void levelUp(Player player,HumanNPC npc,int multiple){
  if (EconomyHandler.useEconomy()) {
    int level=npc.getHealer().getLevel();
    double paid=EconomyHandler.pay(Operation.HEALER_LEVELUP,player,multiple);
    if (paid > 0) {
      if (level < 10) {
        npc.getHealer().setLevel(level + multiple);
        player.sendMessage(getLevelUpPaidMessage(Operation.HEALER_LEVELUP,npc,paid,level + multiple,multiple));
      }
 else {
        player.sendMessage(StringUtils.wrap(npc.getStrippedName()) + "String_Node_Str");
      }
    }
  }
 else {
    player.sendMessage(ChatColor.GRAY + "String_Node_Str");
  }
}
Program: 1968
Project: 1968
Buggy source:
/** 
 * Changes an operation enum to a string value for use in settings retrieval.
 * @param op
 * @param addendum
 * @return
 */
public static String getString(Operation op,String addendum){
  return op.toString().toLowerCase().replace("String_Node_Str","String_Node_Str") + addendum;
}

Fixed version (ground truth):
/** 
 * Changes an operation enum to a string value for use in settings retrieval.
 * @param op
 * @param addendum
 * @return
 */
public static String getString(Operation op,String addendum){
  return prefix + op.toString().toLowerCase().replace("String_Node_Str","String_Node_Str") + addendum;
}
Program: 1970
Project: 1970
Buggy source:
public static String getDefaultText(){
  String[] split=settings.getString("String_Node_Str").split("String_Node_Str");
  String text;
  if (split != null) {
    text=split[new Random(System.currentTimeMillis()).nextInt(split.length)];
    if (text == null)     text="String_Node_Str";
  }
 else   text="String_Node_Str";
  return text.replace('&','�');
}

Fixed version (ground truth):
public static String getDefaultText(){
  String[] split=settings.getString("String_Node_Str").split("String_Node_Str");
  String text;
  if (split != null) {
    text=split[new Random(System.currentTimeMillis()).nextInt(split.length)];
    if (text == null) {
      text="String_Node_Str";
    }
  }
 else {
    text="String_Node_Str";
  }
  return text.replace('&','�');
}
Program: 1971
Project: 1971
Buggy source:
public boolean setMethod(Plugin method){
  PluginManager loader=method.getServer().getPluginManager();
  if (method.isEnabled()) {
    PluginDescriptionFile info=method.getDescription();
    String name=info.getName();
    if (name.equalsIgnoreCase("String_Node_Str")) {
      if (method.getClass().getName().equals("String_Node_Str"))       Method=new MethodiCo5((iConomy)method);
 else {
        Method=new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method);
      }
    }
 else     if (name.equalsIgnoreCase("String_Node_Str")) {
      Method=new MethodBOSEconomy((BOSEconomy)method);
    }
 else     if (name.equalsIgnoreCase("String_Node_Str")) {
      if (!((Essentials)method).isIConomyFallbackEnabled())       Method=new MethodEEco((Essentials)method);
    }
  }
  if (!hasMethod()) {
    if (loader.getPlugin("String_Node_Str") != null) {
      method=loader.getPlugin("String_Node_Str");
      if (method.getClass().getName().equals("String_Node_Str"))       Method=new MethodiCo5((iConomy)method);
 else {
        Method=new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method);
      }
    }
 else     if (loader.getPlugin("String_Node_Str") != null) {
      method=loader.getPlugin("String_Node_Str");
      Method=new MethodBOSEconomy((BOSEconomy)method);
    }
 else     if (loader.getPlugin("String_Node_Str") != null) {
      method=loader.getPlugin("String_Node_Str");
      if (!((Essentials)method).isIConomyFallbackEnabled())       Method=new MethodEEco((Essentials)method);
    }
  }
  return hasMethod();
}

Fixed version (ground truth):
public boolean setMethod(Plugin method){
  PluginManager loader=method.getServer().getPluginManager();
  if (method.isEnabled()) {
    PluginDescriptionFile info=method.getDescription();
    String name=info.getName();
    if (name.equalsIgnoreCase("String_Node_Str")) {
      if (method.getClass().getName().equals("String_Node_Str"))       Method=new MethodiCo5((iConomy)method);
 else {
        Method=new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method);
      }
    }
 else     if (name.equalsIgnoreCase("String_Node_Str")) {
      Method=new MethodBOSEconomy((BOSEconomy)method);
    }
 else     if (name.equalsIgnoreCase("String_Node_Str")) {
      Method=new MethodEEco((Essentials)method);
    }
  }
  if (!hasMethod()) {
    if (loader.getPlugin("String_Node_Str") != null) {
      method=loader.getPlugin("String_Node_Str");
      if (method.getClass().getName().equals("String_Node_Str"))       Method=new MethodiCo5((iConomy)method);
 else {
        Method=new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method);
      }
    }
 else     if (loader.getPlugin("String_Node_Str") != null) {
      method=loader.getPlugin("String_Node_Str");
      Method=new MethodBOSEconomy((BOSEconomy)method);
    }
 else     if (loader.getPlugin("String_Node_Str") != null) {
      method=loader.getPlugin("String_Node_Str");
      Method=new MethodEEco((Essentials)method);
    }
  }
  return hasMethod();
}
Program: 1973
Project: 1973
Buggy source:
/** 
 * Creates an ItemStack from the given string ItemStack format.
 * @param split
 * @return
 */
private ItemStack createItemStack(String[] split){
  try {
    int amount=1;
    int data=0;
    Material mat=StringUtils.parseMaterial(split[0]);
    if (mat == null) {
      return null;
    }
    if (split.length > 1)     amount=Integer.parseInt(split[1]);
    if (split.length > 2)     data=Integer.parseInt(split[2]);
    ItemStack stack=new ItemStack(mat,amount);
    if (data > 0) {
      MaterialData mdata=new MaterialData(data);
      stack.setData(mdata);
    }
    return stack;
  }
 catch (  NumberFormatException ex) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Creates an ItemStack from the given string ItemStack format.
 * @param split
 * @return
 */
private ItemStack createItemStack(String[] split){
  try {
    int amount=1;
    byte data=Citizens.MAGIC_DATA_VALUE;
    Material mat=StringUtils.parseMaterial(split[0]);
    if (mat == null) {
      return null;
    }
    if (split.length >= 2)     amount=Integer.parseInt(split[1]);
    if (split.length >= 3)     data=Byte.parseByte(split[2]);
    ItemStack stack=new ItemStack(mat,amount);
    if (data != 0) {
      MaterialData mdata=new MaterialData(mat,data);
      stack.setData(mdata);
    }
    return stack;
  }
 catch (  NumberFormatException ex) {
    return null;
  }
}
Program: 1974
Project: 1974
Buggy source:
@Override public void run(){
  for (  Entry<Integer,HumanNPC> entry : NPCManager.getNPCList().entrySet()) {
{
      HumanNPC npc=entry.getValue();
      npc.updateMovement();
      int UID=npc.getUID();
      int entityID=entry.getKey();
      for (      Player p : plugin.getServer().getOnlinePlayers()) {
        String name=p.getName();
        if (PropertyPool.getLookWhenClose(UID) || PropertyPool.getTalkWhenClose(UID)) {
          if (checkLocation(npc.getLocation(),p.getLocation())) {
            if (PropertyPool.getLookWhenClose(UID)) {
              NPCManager.rotateNPCToPlayer(npc,p);
            }
            if (PropertyPool.getTalkWhenClose(UID) && (hasSaidText.get(entityID) == null || (hasSaidText.get(entityID).get(name) == null || hasSaidText.get(entityID).get(name) == false))) {
              MessageUtils.sendText(npc,p,plugin);
              HashMap<String,Boolean> players=new HashMap<String,Boolean>();
              if (hasSaidText.get(entityID) != null)               players=hasSaidText.get(entityID);
              players.put(name,true);
              hasSaidText.put(entityID,players);
            }
          }
        }
 else         if (PropertyPool.getTalkWhenClose(UID) && hasSaidText.get(entityID) != null && hasSaidText.get(entityID).get(name) != null && hasSaidText.get(entityID).get(name) == true) {
          hasSaidText.get(entityID).put(name,false);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  for (  Entry<Integer,HumanNPC> entry : NPCManager.getNPCList().entrySet()) {
{
      HumanNPC npc=entry.getValue();
      npc.updateMovement();
      int entityID=entry.getKey();
      for (      Player p : plugin.getServer().getOnlinePlayers()) {
        String name=p.getName();
        if (npc.getNPCData().isLookClose() || npc.getNPCData().isTalkClose()) {
          if (checkLocation(npc.getLocation(),p.getLocation())) {
            if (npc.getNPCData().isLookClose()) {
              NPCManager.rotateNPCToPlayer(npc,p);
            }
            if (npc.getNPCData().isTalkClose() && (hasSaidText.get(entityID) == null || (hasSaidText.get(entityID).get(name) == null || hasSaidText.get(entityID).get(name) == false))) {
              MessageUtils.sendText(npc,p,plugin);
              HashMap<String,Boolean> players=new HashMap<String,Boolean>();
              if (hasSaidText.get(entityID) != null)               players=hasSaidText.get(entityID);
              players.put(name,true);
              hasSaidText.put(entityID,players);
            }
          }
        }
 else         if (npc.getNPCData().isTalkClose() && hasSaidText.get(entityID) != null && hasSaidText.get(entityID).get(name) != null && hasSaidText.get(entityID).get(name) == true) {
          hasSaidText.get(entityID).put(name,false);
        }
      }
    }
  }
}
Program: 1975
Project: 1975
Buggy source:
public ItemStack getItemStack(){
  ItemStack item=new ItemStack(itemID,amount);
  item.setData(new MaterialData(data));
  return item;
}

Fixed version (ground truth):
public ItemStack getItemStack(){
  ItemStack item=new ItemStack(itemID,amount);
  item.setData(new MaterialData(itemID,(byte)data));
  return item;
}
Program: 1976
Project: 1976
Buggy source:
private boolean checkData(MaterialData first,MaterialData second){
  int data=0;
  int data2=0;
  if (first != null)   data=first.getData();
  if (second != null)   data2=second.getData();
  if (data == data2 || data == Citizens.MAGIC_DATA_VALUE)   return true;
  return false;
}

Fixed version (ground truth):
private boolean checkData(MaterialData first,MaterialData second){
  int data=0;
  int data2=0;
  if (first != null)   data=first.getData();
  if (second != null)   data2=second.getData();
  Citizens.log.info("String_Node_Str" + data + "String_Node_Str"+ data2);
  if (data == data2 || data == Citizens.MAGIC_DATA_VALUE)   return true;
  return false;
}
Program: 1977
Project: 1977
Buggy source:
public void addStockable(Stockable s){
  stocking.put(new Check(s.getStockingId(),s.isSelling()),s);
  TraderPropertyPool.saveStockables(npc.getUID(),getStocking());
}

Fixed version (ground truth):
public void addStockable(Stockable s){
  stocking.put(new Check(s.getStockingId(),s.isSelling()),s);
  TraderPropertyPool.saveStockables(npc.getUID(),stocking);
}
Program: 1978
Project: 1978
Buggy source:
public boolean isStocked(Stockable s){
  return isStocked(s.getStockingId(),s.getStocking().getData(),s.isSelling());
}

Fixed version (ground truth):
public boolean isStocked(Stockable s){
  return isStocked(s.getStockingId(),s.getPrice().getMaterialData(),s.isSelling());
}