nus-yam/ex-repair huggingface dataset:
Program: 10194
Project: 10194
Buggy source:
@Override public void adjust(Mechanism mechanism){
  if (mechanism.matches("String_Node_Str") && mechanism.requireInteger()) {
    if (entity.isCitizensNPC()) {
      if (entity.getDenizenNPC().getCitizen().hasTrait(HealthTrait.class))       entity.getDenizenNPC().getCitizen().getTrait(HealthTrait.class).setMaxhealth(mechanism.getValue().asInt());
 else       dB.echoError("String_Node_Str");
    }
 else     if (entity.isLivingEntity()) {
      entity.getLivingEntity().setMaxHealth(mechanism.getValue().asDouble());
    }
 else {
      dB.echoError("String_Node_Str");
    }
  }
  if (mechanism.matches("String_Node_Str") && mechanism.requireDouble()) {
    if (entity.isLivingEntity()) {
      entity.getLivingEntity().setHealth(mechanism.getValue().asDouble());
    }
 else {
      dB.echoError("String_Node_Str");
    }
  }
  if (mechanism.matches("String_Node_Str")) {
    if (entity.isLivingEntity()) {
      List<String> values=CoreUtilities.split(mechanism.getValue().asString(),'/');
      entity.getLivingEntity().setHealth(Double.valueOf(values.get(0)));
      entity.getLivingEntity().setMaxHealth(Double.valueOf(values.get(1)));
    }
 else {
      dB.echoError("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void adjust(Mechanism mechanism){
  if (mechanism.matches("String_Node_Str") && mechanism.requireInteger()) {
    if (entity.isCitizensNPC()) {
      if (entity.getDenizenNPC().getCitizen().hasTrait(HealthTrait.class))       entity.getDenizenNPC().getCitizen().getTrait(HealthTrait.class).setMaxhealth(mechanism.getValue().asInt());
 else       dB.echoError("String_Node_Str");
    }
 else     if (entity.isLivingEntity()) {
      entity.getLivingEntity().setMaxHealth(mechanism.getValue().asDouble());
    }
 else {
      dB.echoError("String_Node_Str");
    }
  }
  if (mechanism.matches("String_Node_Str") && mechanism.requireDouble()) {
    if (entity.isLivingEntity()) {
      entity.getLivingEntity().setHealth(mechanism.getValue().asDouble());
    }
 else {
      dB.echoError("String_Node_Str");
    }
  }
  if (mechanism.matches("String_Node_Str")) {
    if (entity.isLivingEntity()) {
      List<String> values=CoreUtilities.split(mechanism.getValue().asString(),'/');
      entity.getLivingEntity().setMaxHealth(Double.valueOf(values.get(1)));
      entity.getLivingEntity().setHealth(Double.valueOf(values.get(0)));
    }
 else {
      dB.echoError("String_Node_Str");
    }
  }
}
Program: 10195
Project: 10195
Buggy source:
private static byte[] imageToBytes(Image image,int width,int height){
  BufferedImage temp=new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
  Graphics2D graphics=temp.createGraphics();
  graphics.drawImage(image,0,0,width,height,null);
  graphics.dispose();
  int[] pixels=new int[width * height];
  temp.getRGB(0,0,width,height,pixels,0,width);
  byte[] result=new byte[width * height];
  for (int i=0; i < pixels.length; i++) {
    result[i]=matchColor(new Color(pixels[i]));
  }
  return result;
}

Fixed version (ground truth):
private static byte[] imageToBytes(Image image,int width,int height){
  BufferedImage temp=new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_ARGB);
  Graphics2D graphics=temp.createGraphics();
  graphics.drawImage(image,0,0,width,height,null);
  graphics.dispose();
  int[] pixels=new int[width * height];
  temp.getRGB(0,0,width,height,pixels,0,width);
  byte[] result=new byte[width * height];
  for (int i=0; i < pixels.length; i++) {
    result[i]=matchColor(new Color(pixels[i]));
  }
  return result;
}
Program: 10196
Project: 10196
Buggy source:
/** 
 * Get the eye location of this entity
 * @return  The location
 */
public dLocation getEyeLocation(){
  if (!isGeneric() && isLivingEntity()) {
    return new dLocation(getLivingEntity().getEyeLocation());
  }
 else   if (!isGeneric()) {
    return new dLocation(getBukkitEntity().getLocation());
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the eye location of this entity
 * @return  The location
 */
public dLocation getEyeLocation(){
  if (isPlayer()) {
    return new dLocation(getPlayer().getEyeLocation());
  }
 else   if (!isGeneric() && isLivingEntity()) {
    return new dLocation(getLivingEntity().getEyeLocation());
  }
 else   if (!isGeneric()) {
    return new dLocation(getBukkitEntity().getLocation());
  }
  return null;
}
Program: 10197
Project: 10197
Buggy source:
@EventHandler public void specialRecipeClick(InventoryClickEvent event){
  if (ItemScriptContainer.specialrecipesMap.isEmpty() && ItemScriptContainer.shapelessRecipesMap.isEmpty())   return;
  if (!(event.getInventory() instanceof CraftingInventory))   return;
  SlotType slotType=event.getSlotType();
  if (slotType.equals(InventoryType.SlotType.CRAFTING) || slotType.equals(InventoryType.SlotType.RESULT)) {
    CraftingInventory inventory=(CraftingInventory)event.getInventory();
    Player player=(Player)event.getWhoClicked();
    if (slotType.equals(InventoryType.SlotType.RESULT) && event.isShiftClick()) {
      emulateSpecialRecipeResultShiftClick(inventory,player);
    }
 else {
      processSpecialRecipes(inventory,player);
    }
    if (slotType.equals(SlotType.RESULT)) {
      removeOneFromEachSlot(inventory,player);
    }
  }
}

Fixed version (ground truth):
@EventHandler public void specialRecipeClick(InventoryClickEvent event){
  if (ItemScriptContainer.specialrecipesMap.isEmpty() && ItemScriptContainer.shapelessRecipesMap.isEmpty())   return;
  if (!(event.getInventory() instanceof CraftingInventory))   return;
  SlotType slotType=event.getSlotType();
  if (slotType.equals(InventoryType.SlotType.CRAFTING) || slotType.equals(InventoryType.SlotType.RESULT)) {
    CraftingInventory inventory=(CraftingInventory)event.getInventory();
    Player player=(Player)event.getWhoClicked();
    boolean clicked;
    if (slotType.equals(InventoryType.SlotType.RESULT) && event.isShiftClick()) {
      clicked=emulateSpecialRecipeResultShiftClick(inventory,player);
    }
 else {
      clicked=processSpecialRecipes(inventory,player);
    }
    if (clicked && slotType.equals(SlotType.RESULT)) {
      removeOneFromEachSlot(inventory,player);
    }
  }
}
Program: 10198
Project: 10198
Buggy source:
public void processSpecialRecipes(final CraftingInventory inventory,final Player player){
  Bukkit.getScheduler().scheduleSyncDelayedTask(DenizenAPI.getCurrentInstance(),new Runnable(){
    @Override public void run(){
      ItemStack[] matrix=inventory.getMatrix();
      dItem result=getSpecialRecipeResult(matrix);
      if (result != null) {
        Map<String,dObject> context=new HashMap<String,dObject>();
        context.put("String_Node_Str",new dInventory(inventory));
        context.put("String_Node_Str",result);
        dList recipeList=new dList();
        for (        ItemStack item : inventory.getMatrix()) {
          if (item != null)           recipeList.add(new dItem(item).identify());
 else           recipeList.add(new dItem(Material.AIR).identify());
        }
        context.put("String_Node_Str",recipeList);
        List<String> determinations=OldEventManager.doEvents(Arrays.asList("String_Node_Str",result.identifySimple() + "String_Node_Str",result.identifyMaterial() + "String_Node_Str"),new BukkitScriptEntryData(dEntity.getPlayerFrom(player),null),context);
        for (        String determination : determinations) {
          if (determination.toUpperCase().startsWith("String_Node_Str"))           return;
 else           if (dItem.matches(determination)) {
            result=dItem.valueOf(determination);
          }
        }
        inventory.setResult(result.getItemStack());
        player.updateInventory();
      }
    }
  }
,0);
}

Fixed version (ground truth):
public boolean processSpecialRecipes(final CraftingInventory inventory,final Player player){
  ItemStack[] matrix1=inventory.getMatrix();
  dItem result1=getSpecialRecipeResult(matrix1);
  boolean returnme=result1 != null;
  Bukkit.getScheduler().scheduleSyncDelayedTask(DenizenAPI.getCurrentInstance(),new Runnable(){
    @Override public void run(){
      ItemStack[] matrix=inventory.getMatrix();
      dItem result=getSpecialRecipeResult(matrix);
      if (result != null) {
        Map<String,dObject> context=new HashMap<String,dObject>();
        context.put("String_Node_Str",new dInventory(inventory));
        context.put("String_Node_Str",result);
        dList recipeList=new dList();
        for (        ItemStack item : inventory.getMatrix()) {
          if (item != null)           recipeList.add(new dItem(item).identify());
 else           recipeList.add(new dItem(Material.AIR).identify());
        }
        context.put("String_Node_Str",recipeList);
        List<String> determinations=OldEventManager.doEvents(Arrays.asList("String_Node_Str",result.identifySimple() + "String_Node_Str",result.identifyMaterial() + "String_Node_Str"),new BukkitScriptEntryData(dEntity.getPlayerFrom(player),null),context);
        for (        String determination : determinations) {
          if (determination.toUpperCase().startsWith("String_Node_Str"))           return;
 else           if (dItem.matches(determination)) {
            result=dItem.valueOf(determination);
          }
        }
        inventory.setResult(result.getItemStack());
        player.updateInventory();
      }
    }
  }
,0);
  return returnme;
}
Program: 10199
Project: 10199
Buggy source:
public void emulateSpecialRecipeResultShiftClick(CraftingInventory inventory,Player player){
  ItemStack[] matrix=inventory.getMatrix();
  dItem result=getSpecialRecipeResult(matrix);
  if (result != null) {
    int lowestAmount=0;
    for (int n=0; n < matrix.length - 1; n++) {
      if ((matrix[n].getAmount() > 0 && matrix[n].getAmount() < lowestAmount) || lowestAmount == 0) {
        lowestAmount=matrix[n].getAmount();
      }
    }
    for (int n=0; n < matrix.length - 1; n++) {
      if (matrix[n].getAmount() > 0) {
        matrix[n].setAmount(matrix[n].getAmount() - lowestAmount);
        if (matrix[n].getAmount() <= 0) {
          matrix[n]=null;
        }
      }
    }
    if (lowestAmount > 1) {
      ItemStack resultStack=result.getItemStack().clone();
      resultStack.setAmount(lowestAmount * resultStack.getAmount());
      inventory.setContents(matrix);
      inventory.setResult(resultStack);
      player.updateInventory();
    }
  }
}

Fixed version (ground truth):
public boolean emulateSpecialRecipeResultShiftClick(CraftingInventory inventory,Player player){
  ItemStack[] matrix=inventory.getMatrix();
  dItem result=getSpecialRecipeResult(matrix);
  if (result != null) {
    int lowestAmount=0;
    for (int n=0; n < matrix.length - 1; n++) {
      if ((matrix[n].getAmount() > 0 && matrix[n].getAmount() < lowestAmount) || lowestAmount == 0) {
        lowestAmount=matrix[n].getAmount();
      }
    }
    for (int n=0; n < matrix.length - 1; n++) {
      if (matrix[n].getAmount() > 0) {
        matrix[n].setAmount(matrix[n].getAmount() - lowestAmount);
        if (matrix[n].getAmount() <= 0) {
          matrix[n]=null;
        }
      }
    }
    if (lowestAmount > 1) {
      ItemStack resultStack=result.getItemStack().clone();
      resultStack.setAmount(lowestAmount * resultStack.getAmount());
      inventory.setContents(matrix);
      inventory.setResult(resultStack);
      player.updateInventory();
    }
    return true;
  }
  return false;
}
Program: 10203
Project: 10203
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
  List<dEntity> entities=(List<dEntity>)scriptEntry.getObject("String_Node_Str");
  dEntity target=(dEntity)scriptEntry.getObject("String_Node_Str");
  Boolean cancel=scriptEntry.hasObject("String_Node_Str");
  dB.report(scriptEntry,getName(),(cancel ? aH.debugObj("String_Node_Str",cancel) : "String_Node_Str") + aH.debugObj("String_Node_Str",entities.toString()) + (target != null ? aH.debugObj("String_Node_Str",target) : "String_Node_Str"));
  for (  dEntity entity : entities) {
    if (entity.isNPC()) {
      Navigator nav=entity.getDenizenNPC().getCitizen().getNavigator();
      if (cancel.equals(false)) {
        nav.setTarget(target.getBukkitEntity(),true);
      }
 else {
        if (nav.isNavigating() && nav.getTargetType().equals(TargetType.ENTITY) && nav.getEntityTarget().isAggressive()) {
          nav.cancelNavigation();
        }
      }
    }
 else {
      if (cancel.equals(false)) {
        entity.target(target.getLivingEntity());
      }
 else {
        entity.target(null);
      }
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
  List<dEntity> entities=(List<dEntity>)scriptEntry.getObject("String_Node_Str");
  dEntity target=(dEntity)scriptEntry.getObject("String_Node_Str");
  boolean cancel=scriptEntry.hasObject("String_Node_Str");
  dB.report(scriptEntry,getName(),(cancel ? aH.debugObj("String_Node_Str","String_Node_Str") : "String_Node_Str") + aH.debugObj("String_Node_Str",entities.toString()) + (target != null ? aH.debugObj("String_Node_Str",target) : "String_Node_Str"));
  for (  dEntity entity : entities) {
    if (entity.isNPC()) {
      Navigator nav=entity.getDenizenNPC().getCitizen().getNavigator();
      if (!cancel) {
        nav.setTarget(target.getBukkitEntity(),true);
      }
 else {
        if (nav.isNavigating() && nav.getTargetType().equals(TargetType.ENTITY) && nav.getEntityTarget().isAggressive()) {
          nav.cancelNavigation();
        }
      }
    }
 else {
      if (!cancel) {
        entity.target(target.getLivingEntity());
      }
 else {
        entity.target(null);
      }
    }
  }
}
Program: 10205
Project: 10205
Buggy source:
private void cancelBlock(){
  if (currentTask != null) {
    currentTask.cancel();
    currentTask=null;
  }
  cancelTime=-1;
  location.getBlock().getState().update();
}

Fixed version (ground truth):
private void cancelBlock(){
  if (currentTask != null) {
    currentTask.cancel();
    currentTask=null;
  }
  cancelTime=-1;
  material=null;
  location.getBlock().getState().update();
}
Program: 10209
Project: 10209
Buggy source:
@Override public void onBuild(List<aH.Argument> args){
  for (  aH.Argument arg : args) {
    if (arg.matchesEnum(KillType.values()) && type == null)     this.type=KillType.valueOf(arg.getValue().toUpperCase());
 else     if (arg.matchesPrefix("String_Node_Str") && arg.matchesPrimitive(aH.PrimitiveType.Integer))     this.required=aH.getIntegerFrom(arg.getValue());
 else     if (arg.matchesPrefix("String_Node_Str"))     this.region=arg.getValue();
 else     if (arg.matchesPrefix("String_Node_Str") && arg.matchesArgumentType(dCuboid.class))     this.cuboid=arg.asType(dCuboid.class);
 else     if (arg.matchesPrefix("String_Node_Str"))     targets=arg.asType(dList.class);
 else     if (arg.matchesPrefix("String_Node_Str")) {
      names=arg.asType(dList.class);
    }
  }
  if (targets == null)   targets=new dList("String_Node_Str");
  if (names == null) {
    names=new dList("String_Node_Str");
  }
  if (type == null) {
    dB.echoError("String_Node_Str");
    cancel();
  }
}

Fixed version (ground truth):
@Override public void onBuild(List<aH.Argument> args){
  for (  aH.Argument arg : args) {
    if (arg.matchesEnum(KillType.values()) && type == null)     this.type=KillType.valueOf(arg.getValue().toUpperCase());
 else     if (arg.matchesPrefix("String_Node_Str") && arg.matchesPrimitive(aH.PrimitiveType.Integer))     this.required=aH.getIntegerFrom(arg.getValue());
 else     if (arg.matchesPrefix("String_Node_Str"))     this.region=arg.getValue();
 else     if (arg.matchesPrefix("String_Node_Str") && arg.matchesArgumentType(dCuboid.class))     this.cuboid=arg.asType(dCuboid.class);
 else     if (arg.matchesPrefix("String_Node_Str"))     targets=arg.asType(dList.class);
 else     if (arg.matchesPrefix("String_Node_Str")) {
      names=arg.asType(dList.class);
    }
  }
  if (targets == null)   targets=new dList("String_Node_Str");
  if (names == null) {
    names=new dList("String_Node_Str");
  }
  if (type == null) {
    dB.echoError("String_Node_Str");
    cancel();
  }
 else   if (type == KillType.NPC && Depends.citizens == null) {
    dB.echoError("String_Node_Str");
    cancel();
  }
}
Program: 10215
Project: 10215
Buggy source:
@EventHandler public void onCombust(EntityCombustEvent event){
  Map<String,dObject> context=new HashMap<String,dObject>();
  dEntity entity=new dEntity(event.getEntity());
  Duration dura=new Duration((long)event.getDuration());
  context.put("String_Node_Str",entity);
  context.put("String_Node_Str",dura);
  dPlayer player=null;
  dNPC npc=null;
  if (CitizensAPI.getNPCRegistry().isNPC(entity.getBukkitEntity())) {
    npc=dNPC.mirrorCitizensNPC(CitizensAPI.getNPCRegistry().getNPC(entity.getBukkitEntity()));
  }
 else   if (entity.getBukkitEntity() instanceof Player) {
    player=new dPlayer((Player)entity.getBukkitEntity());
  }
  String determination=EventManager.doEvents(Arrays.asList("String_Node_Str",entity.identifySimple() + "String_Node_Str",entity.identifyType() + "String_Node_Str"),npc,player,context);
  if (determination.toUpperCase().startsWith("String_Node_Str"))   event.setCancelled(true);
 else   if (Duration.matches(determination))   event.setDuration(Duration.valueOf(determination).getTicksAsInt());
}

Fixed version (ground truth):
@EventHandler public void onCombust(EntityCombustEvent event){
  Map<String,dObject> context=new HashMap<String,dObject>();
  dEntity entity=new dEntity(event.getEntity());
  Duration dura=new Duration((long)event.getDuration());
  context.put("String_Node_Str",entity);
  context.put("String_Node_Str",dura);
  dPlayer player=null;
  dNPC npc=null;
  if (Depends.citizens != null && CitizensAPI.getNPCRegistry().isNPC(entity.getBukkitEntity())) {
    npc=dNPC.mirrorCitizensNPC(CitizensAPI.getNPCRegistry().getNPC(entity.getBukkitEntity()));
  }
 else   if (entity.getBukkitEntity() instanceof Player) {
    player=new dPlayer((Player)entity.getBukkitEntity());
  }
  String determination=EventManager.doEvents(Arrays.asList("String_Node_Str",entity.identifySimple() + "String_Node_Str",entity.identifyType() + "String_Node_Str"),npc,player,context);
  if (determination.toUpperCase().startsWith("String_Node_Str"))   event.setCancelled(true);
 else   if (Duration.matches(determination))   event.setDuration(Duration.valueOf(determination).getTicksAsInt());
}
Program: 10216
Project: 10216
Buggy source:
public void registerCoreTags(){
  new CuboidTags(denizen);
  new EntityTags(denizen);
  new ListTags(denizen);
  new LocationTags(denizen);
  if (Depends.citizens != null)   new NPCTags(denizen);
  new PlayerTags(denizen);
  new QueueTags(denizen);
  new ScriptTags(denizen);
  new UtilTags(denizen);
  new ProcedureScriptTag(denizen);
  new ContextTags(denizen);
  new TextTags(denizen);
  new EscapeTags(denizen);
  new DefinitionTags(denizen);
  new ParseTags(denizen);
  new AnchorTags(denizen);
  new FlagTags(denizen);
  new ConstantTags(denizen);
  new NotableLocationTags(denizen);
  denizen.getServer().getPluginManager().registerEvents(this,denizen);
}

Fixed version (ground truth):
public void registerCoreTags(){
  new CuboidTags(denizen);
  new EntityTags(denizen);
  new ListTags(denizen);
  new LocationTags(denizen);
  if (Depends.citizens != null)   new NPCTags(denizen);
  new PlayerTags(denizen);
  new QueueTags(denizen);
  new ScriptTags(denizen);
  new UtilTags(denizen);
  new ProcedureScriptTag(denizen);
  new ContextTags(denizen);
  new TextTags(denizen);
  new EscapeTags(denizen);
  new DefinitionTags(denizen);
  new ParseTags(denizen);
  if (Depends.citizens != null) {
    new AnchorTags(denizen);
    new ConstantTags(denizen);
  }
  new FlagTags(denizen);
  new NotableLocationTags(denizen);
  denizen.getServer().getPluginManager().registerEvents(this,denizen);
}
Program: 10218
Project: 10218
Buggy source:
public String getName(){
  if (isNPC())   return getDenizenNPC().getCitizen().getName();
  if (entity instanceof Player)   return ((Player)entity).getName();
  if (isLivingEntity()) {
    String customName=getLivingEntity().getCustomName();
    if (customName != null)     return customName;
  }
  return entity.getType().getName();
}

Fixed version (ground truth):
public String getName(){
  if (isNPC())   return getDenizenNPC().getCitizen().getName();
  if (entity instanceof Player)   return ((Player)entity).getName();
  if (isLivingEntity()) {
    String customName=getLivingEntity().getCustomName();
    if (customName != null)     return customName;
  }
  return entity_type.name();
}
Program: 10220
Project: 10220
Buggy source:
public void applyProperty(Mechanism mechanism){
  if (idType == null)   mechanisms.add(mechanism);
 else   if (idType.equals("String_Node_Str") || mechanism.matches("String_Node_Str"))   adjust(mechanism);
 else   dB.echoError("String_Node_Str");
}

Fixed version (ground truth):
public void applyProperty(Mechanism mechanism){
  if (idType == null)   mechanisms.add(mechanism);
 else   if (idType.equals("String_Node_Str") || mechanism.matches("String_Node_Str"))   adjust(mechanism);
 else   if (!(idType.equals("String_Node_Str") && mechanism.matches("String_Node_Str")))   dB.echoError("String_Node_Str");
}
Program: 10221
Project: 10221
Buggy source:
@Override public String getPropertyString(){
  return getTitle();
}

Fixed version (ground truth):
@Override public String getPropertyString(){
  if (inventory.isUnique() || inventory.getIdType().equals("String_Node_Str") || inventory.getIdType().equals("String_Node_Str"))   return getTitle();
 else   return null;
}
Program: 10222
Project: 10222
Buggy source:
public Argument(String string){
  raw_value=string;
  string=string.trim();
  int first_colon=string.indexOf(':');
  int first_space=string.indexOf(' ');
  if ((first_space > -1 && first_space < first_colon) || first_colon == -1) {
    value=string;
    lower_value=string.toLowerCase();
  }
 else {
    has_prefix=true;
    String[] split=StringUtils.split(string,"String_Node_Str",2);
    prefix=split[0];
    lower_prefix=prefix.toLowerCase();
    value=split[1];
    lower_value=value.toLowerCase();
  }
}

Fixed version (ground truth):
public Argument(String string){
  raw_value=string;
  string=string.trim();
  int first_colon=string.indexOf(':');
  int first_space=string.indexOf(' ');
  if ((first_space > -1 && first_space < first_colon) || first_colon == -1) {
    value=string;
    lower_value=string.toLowerCase();
  }
 else {
    has_prefix=true;
    String[] split=StringUtils.split(string,"String_Node_Str",2);
    prefix=split[0];
    lower_prefix=prefix.toLowerCase();
    if (split.length == 2)     value=split[1];
 else     value="String_Node_Str";
    lower_value=value.toLowerCase();
  }
}
Program: 10223
Project: 10223
Buggy source:
/** 
 * Notes that the player exists, for easy dPlayer valueOf handling.
 */
public static void notePlayer(OfflinePlayer player){
  if (!playerNames.containsKey(player.getName().toLowerCase())) {
    playerNames.put(player.getName().toLowerCase(),player.getUniqueId());
  }
}

Fixed version (ground truth):
/** 
 * Notes that the player exists, for easy dPlayer valueOf handling.
 */
public static void notePlayer(OfflinePlayer player){
  if (player.getName() == null) {
    dB.echoError("String_Node_Str" + player.toString());
    return;
  }
  if (!playerNames.containsKey(player.getName().toLowerCase())) {
    playerNames.put(player.getName().toLowerCase(),player.getUniqueId());
  }
}
Program: 10224
Project: 10224
Buggy source:
public void checkHeld(NavigationEvent e){
  for (int i=0; i < held.size(); i++) {
    ScriptEntry entry=held.get(i);
    List<dNPC> tally=(List<dNPC>)entry.getObject("String_Node_Str");
    tally.remove(dNPC.mirrorCitizensNPC(e.getNPC()));
    if (tally.isEmpty()) {
      entry.setFinished(true);
      held.remove(i);
      i--;
    }
  }
}

Fixed version (ground truth):
public void checkHeld(NavigationEvent e){
  if (e.getNPC() == null)   return;
  for (int i=0; i < held.size(); i++) {
    ScriptEntry entry=held.get(i);
    List<dNPC> tally=(List<dNPC>)entry.getObject("String_Node_Str");
    tally.remove(dNPC.mirrorCitizensNPC(e.getNPC()));
    if (tally.isEmpty()) {
      entry.setFinished(true);
      held.remove(i);
      i--;
    }
  }
}
Program: 10225
Project: 10225
Buggy source:
@Override public boolean shouldDebug() throws Exception {
  return script.getContainer().shouldDebug();
}

Fixed version (ground truth):
@Override public boolean shouldDebug() throws Exception {
  if (script != null && script.getContainer() != null)   return script.getContainer().shouldDebug();
 else   return true;
}
Program: 10226
Project: 10226
Buggy source:
private static void echo(String string,Debuggable caller){
  boolean should_send=true;
  if (caller != null)   try {
    if (filter.isEmpty())     should_send=caller.shouldDebug();
 else {
      should_send=false;
      for (      String criteria : filter)       if (caller.shouldFilter(criteria)) {
        should_send=true;
        break;
      }
    }
  }
 catch (  Exception e) {
    should_send=true;
  }
  if (should_send)   ConsoleSender.sendMessage(string);
}

Fixed version (ground truth):
private static void echo(String string,Debuggable caller){
  if (shouldDebug(caller))   ConsoleSender.sendMessage(string);
}
Program: 10227
Project: 10227
Buggy source:
@EventHandler public void playerJoin(PlayerJoinEvent event){
  Denizen denizen=DenizenAPI.getCurrentInstance();
  dPlayer player=new dPlayer(event.getPlayer());
  if (!denizen.getSaves().contains("String_Node_Str" + player.getSaveName()))   return;
  Set<String> inProgress=denizen.getSaves().getConfigurationSection("String_Node_Str" + event.getPlayer().getName()).getKeys(false);
  if (inProgress.isEmpty())   return;
  String path="String_Node_Str" + player.getSaveName() + "String_Node_Str";
  for (  String listenerId : inProgress) {
    try {
      String type=denizen.getSaves().getString(path + listenerId + "String_Node_Str");
      dNPC npc=null;
      if (denizen.getSaves().contains(path + listenerId + "String_Node_Str"))       npc=DenizenAPI.getDenizenNPC(CitizensAPI.getNPCRegistry().getById(denizen.getSaves().getInt(path + listenerId + "String_Node_Str")));
      if (get(type) == null)       return;
      dB.log(event.getPlayer().getName() + "String_Node_Str" + listenerId+ "String_Node_Str");
      get(type).createInstance(dPlayer.mirrorBukkitPlayer(event.getPlayer()),listenerId).load(dPlayer.mirrorBukkitPlayer(event.getPlayer()),npc,listenerId,type);
    }
 catch (    Exception e) {
      dB.log(event.getPlayer() + "String_Node_Str" + listenerId+ "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@EventHandler public void playerJoin(PlayerJoinEvent event){
  Denizen denizen=DenizenAPI.getCurrentInstance();
  dPlayer player=new dPlayer(event.getPlayer());
  if (!denizen.getSaves().contains("String_Node_Str" + player.getSaveName()))   return;
  Set<String> inProgress=denizen.getSaves().getConfigurationSection("String_Node_Str" + player.getSaveName()).getKeys(false);
  if (inProgress.isEmpty())   return;
  String path="String_Node_Str" + player.getSaveName() + "String_Node_Str";
  for (  String listenerId : inProgress) {
    try {
      String type=denizen.getSaves().getString(path + listenerId + "String_Node_Str");
      dNPC npc=null;
      if (denizen.getSaves().contains(path + listenerId + "String_Node_Str"))       npc=DenizenAPI.getDenizenNPC(CitizensAPI.getNPCRegistry().getById(denizen.getSaves().getInt(path + listenerId + "String_Node_Str")));
      if (get(type) == null)       return;
      dB.log(event.getPlayer().getName() + "String_Node_Str" + listenerId+ "String_Node_Str");
      get(type).createInstance(dPlayer.mirrorBukkitPlayer(event.getPlayer()),listenerId).load(dPlayer.mirrorBukkitPlayer(event.getPlayer()),npc,listenerId,type);
    }
 catch (    Exception e) {
      dB.log(event.getPlayer() + "String_Node_Str" + listenerId+ "String_Node_Str");
    }
  }
}
Program: 10228
Project: 10228
Buggy source:
@EventHandler public void signChange(final SignChangeEvent event){
  Map<String,dObject> context=new HashMap<String,dObject>();
  dPlayer player=new dPlayer(event.getPlayer());
  Block block=event.getBlock();
  if (block == null || !(block.getState() instanceof Sign)) {
    return;
  }
  Sign sign=(Sign)block.getState();
  dMaterial material=dMaterial.getMaterialFrom(block.getType(),block.getData());
  context.put("String_Node_Str",new dList(Arrays.asList(sign.getLines())));
  context.put("String_Node_Str",new dList(Arrays.asList(event.getLines())));
  dList old_escaped=new dList();
  for (  String str : sign.getLines()) {
    old_escaped.add(EscapeTags.Escape(str));
  }
  context.put("String_Node_Str",old_escaped);
  dList new_escaped=new dList();
  for (  String str : event.getLines()) {
    new_escaped.add(EscapeTags.Escape(str));
  }
  context.put("String_Node_Str",new_escaped);
  context.put("String_Node_Str",new dLocation(block.getLocation()));
  context.put("String_Node_Str",material);
  String determination=EventManager.doEvents(Arrays.asList("String_Node_Str","String_Node_Str" + material.identifySimple()),null,player,context,true);
  if (determination.toUpperCase().startsWith("String_Node_Str"))   event.setCancelled(true);
 else   if (determination.length() > 0 && !determination.equalsIgnoreCase("String_Node_Str")) {
    dList lines=new dList(determination);
    for (int i=0; i < 4 && i < lines.size(); i++) {
      event.setLine(i,EscapeTags.unEscape(lines.get(i)));
    }
  }
}

Fixed version (ground truth):
@EventHandler public void signChange(final SignChangeEvent event){
  Map<String,dObject> context=new HashMap<String,dObject>();
  dPlayer player=new dPlayer(event.getPlayer());
  Block block=event.getBlock();
  if (block == null || !(block.getState() instanceof Sign)) {
    return;
  }
  Sign sign=(Sign)block.getState();
  dMaterial material=dMaterial.getMaterialFrom(block.getType(),block.getData());
  context.put("String_Node_Str",new dList(Arrays.asList(sign.getLines())));
  context.put("String_Node_Str",new dList(Arrays.asList(event.getLines())));
  dList old_escaped=new dList();
  for (  String str : sign.getLines()) {
    old_escaped.add(EscapeTags.Escape(str));
  }
  context.put("String_Node_Str",old_escaped);
  dList new_escaped=new dList();
  for (  String str : event.getLines()) {
    new_escaped.add(EscapeTags.Escape(str));
  }
  context.put("String_Node_Str",new_escaped);
  context.put("String_Node_Str",new dLocation(block.getLocation()));
  context.put("String_Node_Str",material);
  String determination=EventManager.doEvents(Arrays.asList("String_Node_Str","String_Node_Str" + material.identifySimple()),null,player,context,true);
  if (determination.toUpperCase().startsWith("String_Node_Str"))   event.setCancelled(true);
 else   if (determination.length() > 0 && !determination.equalsIgnoreCase("String_Node_Str")) {
    dList lines=dList.valueOf(determination);
    for (int i=0; i < 4 && i < lines.size(); i++) {
      event.setLine(i,EscapeTags.unEscape(lines.get(i)));
    }
  }
}
Program: 10232
Project: 10232
Buggy source:
public void makeUnique(String id){
  String title=inventory.getTitle();
  if (title == null || title.startsWith("String_Node_Str"))   title=inventory.getType().getDefaultTitle();
  if (title.length() > 26)   title=title.substring(0,title.charAt(25) == '§' ? 25 : 26);
  String colors;
  while (true) {
    colors=Utilities.generateRandomColors(3);
    if (!InventoryScriptHelper.notableInventories.containsKey(title + colors)) {
      ItemStack[] contents=inventory.getContents();
      if (getInventoryType() == InventoryType.CHEST) {
        inventory=Bukkit.getServer().createInventory(null,inventory.getSize(),title + colors);
      }
 else {
        inventory=Bukkit.getServer().createInventory(null,inventory.getType(),title + colors);
      }
      inventory.setContents(contents);
      InventoryScriptHelper.notableInventories.put(title + colors,this);
      break;
    }
  }
  loadIdentifiers();
  NotableManager.saveAs(this,id);
}

Fixed version (ground truth):
public void makeUnique(String id){
  String title=inventory.getTitle();
  if (title == null || title.startsWith("String_Node_Str"))   title=inventory.getType().getDefaultTitle();
  if (title.length() > 26)   title=title.substring(0,title.charAt(25) == '§' ? 25 : 26);
  String colors;
  while (true) {
    colors=Utilities.generateRandomColors(3);
    if (!InventoryScriptHelper.notableInventories.containsKey(title + colors)) {
      ItemStack[] contents=inventory.getContents();
      if (getInventoryType() == InventoryType.CHEST) {
        inventory=Bukkit.getServer().createInventory(null,inventory.getSize(),title + colors);
      }
 else {
        inventory=Bukkit.getServer().createInventory(null,inventory.getType(),title + colors);
      }
      inventory.setContents(contents);
      InventoryScriptHelper.notableInventories.put(title + colors,this);
      break;
    }
  }
  idType=null;
  idHolder=null;
  loadIdentifiers();
  NotableManager.saveAs(this,id);
}
Program: 10234
Project: 10234
Buggy source:
@EventHandler(priority=EventPriority.MONITOR) public void onHit(EntityDamageByEntityEvent event){
  if (event.getDamager() != npc.getBukkitEntity()) {
    if (event.getDamager() instanceof Projectile) {
      if (((Projectile)event.getDamager()).getShooter() != npc.getBukkitEntity())       return;
    }
 else     return;
  }
  dPlayer player=null;
  if (event.getEntity() instanceof Player)   player=dPlayer.mirrorBukkitPlayer((Player)event.getEntity());
  DenizenAPI.getDenizenNPC(npc).action("String_Node_Str",player);
  DenizenAPI.getDenizenNPC(npc).action("String_Node_Str" + event.getEntityType().name(),player);
  if (event.getEntity() instanceof LivingEntity) {
    if (((LivingEntity)event.getEntity()).getHealth() - event.getDamage() <= 0) {
      DenizenAPI.getDenizenNPC(npc).action("String_Node_Str",player);
      DenizenAPI.getDenizenNPC(npc).action("String_Node_Str" + event.getEntityType().name(),player);
    }
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.MONITOR) public void onHit(EntityDamageByEntityEvent event){
  if (event.getDamager() != npc.getEntity()) {
    if (event.getDamager() instanceof Projectile) {
      if (((Projectile)event.getDamager()).getShooter() != npc.getEntity())       return;
    }
 else     return;
  }
  dPlayer player=null;
  if (event.getEntity() instanceof Player)   player=dPlayer.mirrorBukkitPlayer((Player)event.getEntity());
  DenizenAPI.getDenizenNPC(npc).action("String_Node_Str",player);
  DenizenAPI.getDenizenNPC(npc).action("String_Node_Str" + event.getEntityType().name(),player);
  if (event.getEntity() instanceof LivingEntity) {
    if (((LivingEntity)event.getEntity()).getHealth() - event.getDamage() <= 0) {
      DenizenAPI.getDenizenNPC(npc).action("String_Node_Str",player);
      DenizenAPI.getDenizenNPC(npc).action("String_Node_Str" + event.getEntityType().name(),player);
    }
  }
}
Program: 10239
Project: 10239
Buggy source:
@Override public ScriptEntry clone() throws CloneNotSupportedException {
  return (ScriptEntry)super.clone();
}

Fixed version (ground truth):
@Override public ScriptEntry clone() throws CloneNotSupportedException {
  ScriptEntry se=(ScriptEntry)super.clone();
  se.objects=new HashMap<String,Object>();
  return se;
}
Program: 10241
Project: 10241
Buggy source:
/** 
 * Gets a Location Object from a string form of id,x,y,z,world or a dScript argument (location:)x,y,z,world. If including an Id, this location will persist and can be recalled at any time.
 * @param string  the string or dScript argument String
 * @return  a Location, or null if incorrectly formatted
 */
@Fetchable("String_Node_Str") public static dCuboid valueOf(String string){
  if (string == null)   return null;
  String[] positions=string.replace("String_Node_Str","String_Node_Str").split("String_Node_Str");
  if (positions.length > 1 && dLocation.matches(positions[0]) && dLocation.matches(positions[1])) {
    if (positions.length % 2 != 0) {
      dB.echoError("String_Node_Str" + string + "String_Node_Str");
      return null;
    }
    dCuboid toReturn=new dCuboid();
    for (int i=0; i < positions.length; i+=2) {
      dLocation pos_1=dLocation.valueOf(positions[i]);
      dLocation pos_2=dLocation.valueOf(positions[i + 1]);
      if (pos_1 == null || pos_2 == null) {
        dB.echoError("String_Node_Str" + string + "String_Node_Str");
        return null;
      }
      toReturn.addPair(pos_1,pos_2);
    }
    if (toReturn.pairs.size() > 0)     return toReturn;
  }
  Matcher m;
  m=item_by_saved.matcher(string);
  if (m.matches() && NotableManager.isType(m.group(2),dCuboid.class))   return (dCuboid)NotableManager.getSavedObject(m.group(2));
  dB.echoError("String_Node_Str" + string);
  return null;
}

Fixed version (ground truth):
/** 
 * Gets a Location Object from a string form of id,x,y,z,world or a dScript argument (location:)x,y,z,world. If including an Id, this location will persist and can be recalled at any time.
 * @param string  the string or dScript argument String
 * @return  a Location, or null if incorrectly formatted
 */
@Fetchable("String_Node_Str") public static dCuboid valueOf(String string){
  if (string == null)   return null;
  dList positions=dList.valueOf(string.replace("String_Node_Str","String_Node_Str"));
  if (positions.size() > 1 && dLocation.matches(positions.get(0)) && dLocation.matches(positions.get(1))) {
    if (positions.size() % 2 != 0) {
      dB.echoError("String_Node_Str" + string + "String_Node_Str");
      return null;
    }
    dCuboid toReturn=new dCuboid();
    for (int i=0; i < positions.size(); i+=2) {
      dLocation pos_1=dLocation.valueOf(positions.get(i));
      dLocation pos_2=dLocation.valueOf(positions.get(i + 1));
      if (pos_1 == null || pos_2 == null) {
        dB.echoError("String_Node_Str" + string + "String_Node_Str");
        return null;
      }
      toReturn.addPair(pos_1,pos_2);
    }
    if (toReturn.pairs.size() > 0)     return toReturn;
  }
  Matcher m;
  m=item_by_saved.matcher(string);
  if (m.matches() && NotableManager.isType(m.group(2),dCuboid.class))   return (dCuboid)NotableManager.getSavedObject(m.group(2));
  dB.echoError("String_Node_Str" + string);
  return null;
}
Program: 10243
Project: 10243
Buggy source:
public TriggerContext trigger(AbstractTrigger triggerClass,dPlayer player,Map<String,dObject> context){
  String determination=DetermineCommand.DETERMINE_NONE;
  String trigger_type=triggerClass.getName();
  if (!DenizenAPI.getCurrentInstance().getTriggerRegistry().checkCooldown(npc,player,triggerClass,getCooldownType(trigger_type)))   return new TriggerContext(false);
  if (EngageCommand.getEngaged(npc)) {
    context.put("String_Node_Str",new Element(trigger_type));
    if (dNPCRegistry.getDenizen(npc).action("String_Node_Str",player,context).equalsIgnoreCase("String_Node_Str")) {
    }
 else     return new TriggerContext(false);
  }
  DenizenAPI.getCurrentInstance().getTriggerRegistry().setCooldown(npc,player,triggerClass,getCooldownDuration(trigger_type),getCooldownType(trigger_type));
  determination=dNPCRegistry.getDenizen(npc).action(trigger_type,player,context);
  return new TriggerContext(determination,true);
}

Fixed version (ground truth):
public TriggerContext trigger(AbstractTrigger triggerClass,dPlayer player,Map<String,dObject> context){
  String trigger_type=triggerClass.getName();
  if (!DenizenAPI.getCurrentInstance().getTriggerRegistry().checkCooldown(npc,player,triggerClass,getCooldownType(trigger_type)))   return new TriggerContext(false);
  if (context == null)   context=new HashMap<String,dObject>();
  if (EngageCommand.getEngaged(npc)) {
    context.put("String_Node_Str",new Element(trigger_type));
    if (dNPCRegistry.getDenizen(npc).action("String_Node_Str",player,context).equalsIgnoreCase("String_Node_Str")) {
    }
 else     return new TriggerContext(false);
  }
  DenizenAPI.getCurrentInstance().getTriggerRegistry().setCooldown(npc,player,triggerClass,getCooldownDuration(trigger_type),getCooldownType(trigger_type));
  String determination=dNPCRegistry.getDenizen(npc).action(trigger_type,player,context);
  return new TriggerContext(determination,true);
}
Program: 10245
Project: 10245
Buggy source:
int Compare(dLocation loc1,dLocation loc2){
  if (loc1 == null || loc1.equals(loc2))   return 0;
 else {
    double dist=distanceSquared(loc1) - distanceSquared(loc2);
    return dist == 0 ? 0 : (dist > 0 ? 1 : -1);
  }
}

Fixed version (ground truth):
int Compare(dLocation loc1,dLocation loc2){
  if (loc1 == null || loc2 == null || loc1.equals(loc2))   return 0;
 else {
    double dist=distanceSquared(loc1) - distanceSquared(loc2);
    return dist == 0 ? 0 : (dist > 0 ? 1 : -1);
  }
}
Program: 10246
Project: 10246
Buggy source:
/** 
 * Notes that the player exists, for easy dPlayer valueOf handling.
 */
public static void notePlayer(OfflinePlayer player){
  if (!playerNames.contains(player.getName().toLowerCase())) {
    playerNames.add(player.getName().toLowerCase());
  }
}

Fixed version (ground truth):
/** 
 * Notes that the player exists, for easy dPlayer valueOf handling.
 */
public static void notePlayer(OfflinePlayer player){
  if (!playerNames.containsKey(player.getName().toLowerCase())) {
    playerNames.put(player.getName().toLowerCase(),player.getUniqueId());
  }
}
Program: 10247
Project: 10247
Buggy source:
static dPlayer valueOfInternal(String string,boolean announce){
  if (string == null)   return null;
  string=string.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  if (string.indexOf('-') >= 0) {
    try {
      UUID uuid=UUID.fromString(string);
      if (uuid != null) {
        OfflinePlayer player=Bukkit.getOfflinePlayer(uuid);
        if (player != null) {
          return new dPlayer(player);
        }
      }
    }
 catch (    IllegalArgumentException e) {
    }
  }
  if (playerNameIsValid(string)) {
    OfflinePlayer player=Bukkit.getOfflinePlayer(string);
    if (player.hasPlayedBefore())     return new dPlayer(player);
  }
  if (announce)   dB.echoError("String_Node_Str" + string + "String_Node_Str");
  return null;
}

Fixed version (ground truth):
static dPlayer valueOfInternal(String string,boolean announce){
  if (string == null)   return null;
  string=string.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  if (string.indexOf('-') >= 0) {
    try {
      UUID uuid=UUID.fromString(string);
      if (uuid != null) {
        OfflinePlayer player=Bukkit.getOfflinePlayer(uuid);
        if (player != null) {
          return new dPlayer(player);
        }
      }
    }
 catch (    IllegalArgumentException e) {
    }
  }
  if (playerNames.containsKey(string.toLowerCase())) {
    OfflinePlayer player=Bukkit.getOfflinePlayer(playerNames.get(string.toLowerCase()));
    if (player.hasPlayedBefore())     return new dPlayer(player);
  }
  if (announce)   dB.echoError("String_Node_Str" + string + "String_Node_Str");
  return null;
}
Program: 10248
Project: 10248
Buggy source:
public static boolean matches(String arg){
  if (arg == null)   return false;
  if (arg.toLowerCase().startsWith("String_Node_Str"))   return true;
  arg=arg.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  if (arg.indexOf('-') >= 0) {
    try {
      UUID uuid=UUID.fromString(arg);
      if (uuid != null) {
        OfflinePlayer player=Bukkit.getOfflinePlayer(uuid);
        if (player != null) {
          return true;
        }
      }
    }
 catch (    IllegalArgumentException e) {
    }
  }
  arg=arg.toUpperCase();
  for (  String name : playerNames) {
    if (arg.equals(name)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean matches(String arg){
  if (arg == null)   return false;
  if (arg.toLowerCase().startsWith("String_Node_Str"))   return true;
  arg=arg.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  if (arg.indexOf('-') >= 0) {
    try {
      UUID uuid=UUID.fromString(arg);
      if (uuid != null) {
        OfflinePlayer player=Bukkit.getOfflinePlayer(uuid);
        if (player != null) {
          return true;
        }
      }
    }
 catch (    IllegalArgumentException e) {
    }
  }
  return playerNames.containsKey(arg.toLowerCase());
}
Program: 10249
Project: 10249
Buggy source:
public static boolean playerNameIsValid(String arg){
  arg=arg.toLowerCase();
  for (  String name : playerNames) {
    if (arg.equals(name)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean playerNameIsValid(String name){
  return playerNames.containsKey(name.toLowerCase());
}
Program: 10254
Project: 10254
Buggy source:
@Override public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
  Element name=(Element)scriptEntry.getObject("String_Node_Str");
  dB.report(scriptEntry,getName(),name.debug());
  NPC npc=scriptEntry.getNPC().getCitizen();
  Location prev=npc.isSpawned() ? npc.getEntity().getLocation() : null;
  npc.despawn(DespawnReason.PENDING_RESPAWN);
  npc.setName(name.asString().length() > 16 ? name.asString().substring(0,16) : name.asString());
  if (prev != null)   npc.spawn(prev);
}

Fixed version (ground truth):
@Override public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
  Element name=(Element)scriptEntry.getObject("String_Node_Str");
  dB.report(scriptEntry,getName(),name.debug());
  NPC npc=scriptEntry.getNPC().getCitizen();
  Location prev=npc.isSpawned() ? npc.getEntity().getLocation() : null;
  npc.despawn(DespawnReason.PENDING_RESPAWN);
  npc.setName(name.asString().length() > 100 ? name.asString().substring(0,100) : name.asString());
  if (prev != null)   npc.spawn(prev);
}