nus-yam/ex-repair huggingface dataset:
Program: 17094
Project: 17094
Buggy source:
/** 
 * Gives you an ItemStack from a String
 * @param itemName Item name
 * @return ItemStack
 */
public static ItemStack getItem(String itemName){
  ItemStack itemStack=Odd.getFromString(itemName);
  if (itemStack != null) {
    return itemStack;
  }
  String[] split=itemName.split("String_Node_Str");
  for (int i=0; i < split.length; i++) {
    split[i]=split[i].trim();
  }
  Material material=getMaterial(split[0]);
  short durability=getDurability(itemName);
  MaterialData data=null;
  if (material == null) {
    if (!split[0].contains("String_Node_Str")) {
      return null;
    }
    for (int index=split[0].indexOf(' '); index >= 0 && index + 1 < split[0].length(); index=split[0].indexOf(' ',index + 1)) {
      material=getMaterial(split[0].substring(index + 1));
      if (material != null) {
        data=DataValue.getData(split[0].substring(0,index),material);
        break;
      }
    }
    if (material == null) {
      return null;
    }
  }
  itemStack=new ItemStack(material);
  if (data != null) {
    itemStack.setData(data);
    durability=data.getData();
  }
  itemStack.setDurability(durability);
  ItemMeta meta=getMetadata(itemName);
  if (meta != null) {
    itemStack.setItemMeta(meta);
  }
  return itemStack;
}

Fixed version (ground truth):
/** 
 * Gives you an ItemStack from a String
 * @param itemName Item name
 * @return ItemStack
 */
public static ItemStack getItem(String itemName){
  ItemStack itemStack=Odd.getFromString(itemName);
  if (itemStack != null) {
    return itemStack;
  }
  String[] split=itemName.split("String_Node_Str");
  for (int i=0; i < split.length; i++) {
    split[i]=split[i].trim();
  }
  Material material=getMaterial(split[0]);
  short durability=getDurability(itemName);
  MaterialData data=null;
  if (material == null) {
    if (!split[0].contains("String_Node_Str")) {
      return null;
    }
    for (int index=split[0].indexOf(' '); index >= 0 && index + 1 < split[0].length(); index=split[0].indexOf(' ',index + 1)) {
      material=getMaterial(split[0].substring(index + 1));
      if (material != null) {
        data=DataValue.getData(split[0].substring(0,index),material);
        material=data.getItemType();
        break;
      }
    }
    if (material == null) {
      return null;
    }
  }
  itemStack=new ItemStack(material);
  if (data != null) {
    itemStack.setData(data);
    durability=data.getData();
  }
  itemStack.setDurability(durability);
  ItemMeta meta=getMetadata(itemName);
  if (meta != null) {
    itemStack.setItemMeta(meta);
  }
  return itemStack;
}
Program: 17096
Project: 17096
Buggy source:
/** 
 * Returns item's name, with a maximum length
 * @param itemStack ItemStack to name
 * @param maxLength The max length that the name should have; 0 or below if it should be unlimited
 * @return ItemStack's name
 */
public static String getName(ItemStack itemStack,int maxLength){
  String alias=Odd.getAlias(itemStack);
  String itemName=alias != null ? alias : itemStack.getType().toString();
  String data=DataValue.name(itemStack);
  String durability="String_Node_Str";
  if (data == null) {
    if (itemStack.getDurability() != 0) {
      durability="String_Node_Str" + itemStack.getDurability();
    }
  }
  data=data != null ? data + "String_Node_Str" : "String_Node_Str";
  String metaData="String_Node_Str";
  if (itemStack.hasItemMeta()) {
    metaData="String_Node_Str" + Metadata.getItemCode(itemStack);
  }
  String code=data + itemName + durability+ metaData;
  if (maxLength > 0 && code.length() > maxLength) {
    int exceeding=code.length() - maxLength;
    code=data + getShortenedName(itemName,itemName.length() - exceeding) + durability+ metaData;
  }
  code=StringUtil.capitalizeFirstLetter(code,'_');
  ItemStack codeItem=getItem(code);
  if (!equals(itemStack,codeItem)) {
    throw new IllegalArgumentException("String_Node_Str" + itemStack + "String_Node_Str"+ maxLength);
  }
  return code;
}

Fixed version (ground truth):
/** 
 * Returns item's name, with a maximum length
 * @param itemStack ItemStack to name
 * @param maxLength The max length that the name should have; 0 or below if it should be unlimited
 * @return ItemStack's name
 */
public static String getName(ItemStack itemStack,int maxLength){
  String alias=Odd.getAlias(itemStack);
  String itemName=alias != null ? alias : itemStack.getType().toString();
  String data=DataValue.name(itemStack);
  String durability="String_Node_Str";
  if (data == null) {
    if (itemStack.getDurability() != 0) {
      durability="String_Node_Str" + itemStack.getDurability();
    }
  }
  data=data != null ? data + "String_Node_Str" : "String_Node_Str";
  String metaData="String_Node_Str";
  if (itemStack.hasItemMeta()) {
    metaData="String_Node_Str" + Metadata.getItemCode(itemStack);
  }
  String code=data + itemName + durability+ metaData;
  if (maxLength > 0 && code.length() > maxLength) {
    int exceeding=code.length() - maxLength;
    code=data + getShortenedName(itemName,itemName.length() - exceeding) + durability+ metaData;
  }
  code=StringUtil.capitalizeFirstLetter(code,'_');
  ItemStack codeItem=getItem(code);
  if (!equals(itemStack,codeItem)) {
    throw new IllegalArgumentException("String_Node_Str" + itemStack + "String_Node_Str"+ maxLength+ "String_Node_Str"+ code);
  }
  return code;
}
Program: 17097
Project: 17097
Buggy source:
/** 
 * Gives you an ItemStack from a String
 * @param itemName Item name
 * @return ItemStack
 */
public static ItemStack getItem(String itemName){
  ItemStack itemStack=Odd.getFromString(itemName);
  if (itemStack != null) {
    return itemStack;
  }
  String[] split=itemName.split("String_Node_Str");
  for (int i=0; i < split.length; i++) {
    split[i]=split[i].trim();
  }
  Material material=getMaterial(split[0]);
  short durability=getDurability(itemName);
  if (material == null) {
    if (!split[0].contains("String_Node_Str")) {
      return null;
    }
    for (int index=split[0].indexOf(' '); index >= 0 && index + 1 < split[0].length(); index=split[0].indexOf(' ',index + 1)) {
      material=getMaterial(split[0].substring(index + 1));
      if (material != null) {
        if (durability == 0) {
          durability=DataValue.get(split[0].substring(0,index),material);
        }
        break;
      }
    }
    if (material == null) {
      return null;
    }
  }
  itemStack=new ItemStack(material);
  itemStack.setDurability(durability);
  ItemMeta meta=getMetadata(itemName);
  if (meta != null) {
    itemStack.setItemMeta(meta);
  }
  return itemStack;
}

Fixed version (ground truth):
/** 
 * Gives you an ItemStack from a String
 * @param itemName Item name
 * @return ItemStack
 */
public static ItemStack getItem(String itemName){
  ItemStack itemStack=Odd.getFromString(itemName);
  if (itemStack != null) {
    return itemStack;
  }
  String[] split=itemName.split("String_Node_Str");
  for (int i=0; i < split.length; i++) {
    split[i]=split[i].trim();
  }
  Material material=getMaterial(split[0]);
  short durability=getDurability(itemName);
  byte data=-1;
  if (material == null) {
    if (!split[0].contains("String_Node_Str")) {
      return null;
    }
    for (int index=split[0].indexOf(' '); index >= 0 && index + 1 < split[0].length(); index=split[0].indexOf(' ',index + 1)) {
      material=getMaterial(split[0].substring(index + 1));
      if (material != null) {
        if (durability == 0) {
          durability=data=DataValue.get(split[0].substring(0,index),material);
        }
        break;
      }
    }
    if (material == null) {
      return null;
    }
  }
  itemStack=new ItemStack(material);
  itemStack.setDurability(durability);
  if (data > -1) {
    itemStack.getData().setData(data);
  }
  ItemMeta meta=getMetadata(itemName);
  if (meta != null) {
    itemStack.setItemMeta(meta);
  }
  return itemStack;
}
Program: 17098
Project: 17098
Buggy source:
/** 
 * Checks if the itemStacks are equal, ignoring their amount
 * @param one first itemStack
 * @param two second itemStack
 * @return Are they equal?
 */
public static boolean equals(ItemStack one,ItemStack two){
  if (one == null || two == null) {
    return one == two;
  }
  if (one.isSimilar(two)) {
    return true;
  }
  return one.getType() == two.getType() && one.getDurability() == two.getDurability() && one.getData().equals(two.getData()) && one.hasItemMeta() && two.hasItemMeta() && one.getItemMeta() instanceof BookMeta && two.getItemMeta() instanceof BookMeta && one.getItemMeta().serialize().equals(two.getItemMeta().serialize());
}

Fixed version (ground truth):
/** 
 * Checks if the itemStacks are equal, ignoring their amount
 * @param one first itemStack
 * @param two second itemStack
 * @return Are they equal?
 */
public static boolean equals(ItemStack one,ItemStack two){
  if (one == null || two == null) {
    return one == two;
  }
  if (one.isSimilar(two)) {
    return true;
  }
  if (one.getType() == two.getType() && one.getType() == Material.BANNER && one.getDurability() == two.getDurability()) {
    Map<String,Object> m1=new HashMap<>(one.getItemMeta().serialize());
    Map<String,Object> m2=new HashMap<>(two.getItemMeta().serialize());
    Object c1=m1.remove("String_Node_Str");
    Object c2=m2.remove("String_Node_Str");
    return (one.getData().equals(two.getData()) || c1.equals(c2)) && m1.equals(m2);
  }
  return one.getType() == two.getType() && one.getDurability() == two.getDurability() && one.getData().equals(two.getData()) && one.hasItemMeta() && two.hasItemMeta() && one.getItemMeta() instanceof BookMeta && two.getItemMeta() instanceof BookMeta && one.getItemMeta().serialize().equals(two.getItemMeta().serialize());
}
Program: 17100
Project: 17100
Buggy source:
/** 
 * Returns a string with the DataValue
 * @param itemStack ItemStack to describe
 * @return Data value string
 */
public static String name(ItemStack itemStack){
  MaterialData data=itemStack.getData();
  if (data == null) {
    return null;
  }
  if (data instanceof TexturedMaterial) {
    return ((TexturedMaterial)data).getMaterial().name();
  }
 else   if (data instanceof Colorable) {
    DyeColor color=((Colorable)data).getColor();
    return (color != null ? color.name() : null);
  }
 else   if (data instanceof Tree) {
    TreeSpecies specie=((Tree)data).getSpecies();
    return (specie != null && specie != TreeSpecies.GENERIC ? specie.name() : null);
  }
 else   if (data instanceof SpawnEgg) {
    EntityType type=((SpawnEgg)data).getSpawnedType();
    return (type != null ? type.name() : null);
  }
 else   if (data instanceof Coal) {
    CoalType coal=((Coal)data).getType();
    return (coal != null && coal != CoalType.COAL ? coal.name() : null);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Returns a string with the DataValue
 * @param itemStack ItemStack to describe
 * @return Data value string
 */
public static String name(ItemStack itemStack){
  MaterialData data=itemStack.getData();
  if (data == null) {
    return null;
  }
  if (data.getItemType() == Material.BANNER && data.getData() < 16) {
    return DyeColor.getByDyeData(data.getData()).name();
  }
  if (data instanceof TexturedMaterial) {
    return ((TexturedMaterial)data).getMaterial().name();
  }
 else   if (data instanceof Colorable) {
    DyeColor color=((Colorable)data).getColor();
    return (color != null ? color.name() : null);
  }
 else   if (data instanceof Tree) {
    TreeSpecies specie=((Tree)data).getSpecies();
    return (specie != null && specie != TreeSpecies.GENERIC ? specie.name() : null);
  }
 else   if (data instanceof SpawnEgg) {
    EntityType type=((SpawnEgg)data).getSpawnedType();
    return (type != null ? type.name() : null);
  }
 else   if (data instanceof Coal) {
    CoalType coal=((Coal)data).getType();
    return (coal != null && coal != CoalType.COAL ? coal.name() : null);
  }
 else {
    return null;
  }
}
Program: 17101
Project: 17101
Buggy source:
/** 
 * Returns item's name, with a maximum length
 * @param itemStack ItemStack to name
 * @param maxLength The max length that the name should have; 0 or below if it should be unlimited
 * @return ItemStack's name
 */
public static String getName(ItemStack itemStack,int maxLength){
  String alias=Odd.getAlias(itemStack);
  String itemName=alias != null ? alias : itemStack.getType().toString();
  String data=DataValue.name(itemStack);
  String durability="String_Node_Str";
  if (data == null) {
    if (itemStack.getDurability() != 0) {
      durability="String_Node_Str" + itemStack.getDurability();
    }
  }
  data=data != null ? data + "String_Node_Str" : "String_Node_Str";
  String metaData="String_Node_Str";
  if (itemStack.hasItemMeta()) {
    metaData="String_Node_Str" + Metadata.getItemCode(itemStack);
  }
  String code=data + itemName + durability+ metaData;
  if (maxLength > 0 && code.length() > maxLength) {
    int exceeding=code.length() - maxLength;
    code=data + getShortenedName(itemName,itemName.length() - exceeding) + durability+ metaData;
  }
  code=StringUtil.capitalizeFirstLetter(code,'_');
  ItemStack codeItem=getItem(code);
  if (!equals(itemStack,codeItem)) {
    throw new IllegalArgumentException("String_Node_Str" + itemStack + "String_Node_Str"+ maxLength+ "String_Node_Str"+ code);
  }
  return code;
}

Fixed version (ground truth):
/** 
 * Returns item's name, with a maximum length
 * @param itemStack ItemStack to name
 * @param maxLength The max length that the name should have; 0 or below if it should be unlimited
 * @return ItemStack's name
 */
public static String getName(ItemStack itemStack,int maxLength){
  String alias=Odd.getAlias(itemStack);
  String itemName=alias != null ? alias : itemStack.getType().toString();
  String data=DataValue.name(itemStack);
  String durability="String_Node_Str";
  if (data == null) {
    if (itemStack.getDurability() != 0) {
      durability="String_Node_Str" + itemStack.getDurability();
    }
  }
  data=data != null ? data + "String_Node_Str" : "String_Node_Str";
  String metaData="String_Node_Str";
  if (itemStack.hasItemMeta()) {
    metaData="String_Node_Str" + Metadata.getItemCode(itemStack);
  }
  int codeLength=(data + itemName + durability+ metaData).length();
  String code=data + itemName;
  if (maxLength > 0 && codeLength > maxLength) {
    int exceeding=codeLength - maxLength;
    code=getShortenedName(code,code.length() - exceeding);
  }
  code=StringUtil.capitalizeFirstLetter(code,'_') + durability + metaData;
  ItemStack codeItem=getItem(code);
  if (!equals(itemStack,codeItem)) {
    throw new IllegalArgumentException("String_Node_Str" + itemStack + "String_Node_Str"+ maxLength+ "String_Node_Str"+ code+ "String_Node_Str"+ codeItem+ "String_Node_Str");
  }
  return code;
}
Program: 17102
Project: 17102
Buggy source:
public boolean onCommand(CommandSender sender,Command cmd,String label,String[] args){
  ItemStack item;
  if (args.length == 0) {
    if (!(sender instanceof HumanEntity)) {
      return false;
    }
    item=((HumanEntity)sender).getItemInHand();
  }
 else {
    item=MaterialUtil.getItem(StringUtil.joinArray(args));
  }
  if (MaterialUtil.isEmpty(item)) {
    return false;
  }
  sender.sendMessage(Messages.prefix(iteminfo));
  sender.sendMessage(ChatColor.WHITE + "String_Node_Str" + ChatColor.GRAY+ MaterialUtil.getName(item));
  sender.sendMessage(ChatColor.WHITE + "String_Node_Str" + ChatColor.GRAY+ MaterialUtil.getSignName(item));
  ItemInfoEvent event=new ItemInfoEvent(sender,item);
  ChestShop.callEvent(event);
  return true;
}

Fixed version (ground truth):
public boolean onCommand(CommandSender sender,Command cmd,String label,String[] args){
  ItemStack item;
  if (args.length == 0) {
    if (!(sender instanceof HumanEntity)) {
      return false;
    }
    item=((HumanEntity)sender).getItemInHand();
  }
 else {
    item=MaterialUtil.getItem(StringUtil.joinArray(args));
  }
  if (MaterialUtil.isEmpty(item)) {
    return false;
  }
  sender.sendMessage(Messages.prefix(iteminfo));
  try {
    sender.sendMessage(ChatColor.WHITE + "String_Node_Str" + ChatColor.GRAY+ MaterialUtil.getName(item));
  }
 catch (  IllegalArgumentException e) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str" + e.getMessage());
  }
  try {
    sender.sendMessage(ChatColor.WHITE + "String_Node_Str" + ChatColor.GRAY+ MaterialUtil.getSignName(item));
  }
 catch (  IllegalArgumentException e) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str" + e.getMessage());
  }
  ItemInfoEvent event=new ItemInfoEvent(sender,item);
  ChestShop.callEvent(event);
  return true;
}
Program: 17103
Project: 17103
Buggy source:
public static String getServerAccountName(){
  return Properties.SERVER_ECONOMY_ACCOUNT;
}

Fixed version (ground truth):
/** 
 * Get the name of the server conomy account
 * @return The username of te server economy account
 * @deprecated Use {@link NameManager#getServerEconomyAccount()} or {@link Properties#SERVER_ECONOMY_ACCOUNT}
 */
@Deprecated public static String getServerAccountName(){
  return Properties.SERVER_ECONOMY_ACCOUNT;
}
Program: 17104
Project: 17104
Buggy source:
public static boolean isOwnerEconomicallyActive(Inventory inventory){
  return !ChestShopSign.isAdminShop(inventory) || !getServerAccountName().isEmpty();
}

Fixed version (ground truth):
public static boolean isOwnerEconomicallyActive(Inventory inventory){
  return !ChestShopSign.isAdminShop(inventory) || NameManager.getServerEconomyAccount() != null;
}
Program: 17105
Project: 17105
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onBalanceCheck(CurrencyAmountEvent event){
  UUID target=event.getAccount();
  if (!NameManager.isAdminShop(target) || NameManager.isServerEconomyAccount(target)) {
    return;
  }
  if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
    event.setAmount(BigDecimal.valueOf(Double.MAX_VALUE));
    return;
  }
 else {
    Account account=NameManager.getAccount(SERVER_ECONOMY_ACCOUNT);
    if (account == null || account.getUuid() == null) {
      return;
    }
    target=account.getUuid();
  }
  CurrencyAmountEvent currencyAmountEvent=new CurrencyAmountEvent(target,event.getWorld());
  ChestShop.callEvent(currencyAmountEvent);
  event.setAmount(currencyAmountEvent.getAmount());
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onBalanceCheck(CurrencyAmountEvent event){
  UUID target=event.getAccount();
  if (!NameManager.isAdminShop(target) || NameManager.isServerEconomyAccount(target)) {
    return;
  }
  Account account=NameManager.getServerEconomyAccount();
  target=account != null ? account.getUuid() : null;
  if (target == null) {
    event.setAmount(BigDecimal.valueOf(Double.MAX_VALUE));
    return;
  }
  CurrencyAmountEvent currencyAmountEvent=new CurrencyAmountEvent(target,event.getWorld());
  ChestShop.callEvent(currencyAmountEvent);
  event.setAmount(currencyAmountEvent.getAmount());
}
Program: 17106
Project: 17106
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencySubtract(CurrencySubtractEvent event){
  UUID target=event.getTarget();
  if (!NameManager.isAdminShop(target) || SERVER_ECONOMY_ACCOUNT.equals(NameManager.getUsername(target))) {
    return;
  }
  if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
    event.setSubtracted(true);
    return;
  }
 else {
    Account account=NameManager.getAccount(SERVER_ECONOMY_ACCOUNT);
    if (account != null) {
      target=account.getUuid();
    }
 else {
      target=null;
    }
  }
  event.setSubtracted(true);
  if (target == null) {
    return;
  }
  CurrencySubtractEvent currencySubtractEvent=new CurrencySubtractEvent(event.getAmount(),target,event.getWorld());
  ChestShop.callEvent(currencySubtractEvent);
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencySubtract(CurrencySubtractEvent event){
  UUID target=event.getTarget();
  if (!NameManager.isAdminShop(target) || NameManager.isServerEconomyAccount(target)) {
    return;
  }
  Account account=NameManager.getServerEconomyAccount();
  target=account != null ? account.getUuid() : null;
  event.setSubtracted(true);
  if (target == null) {
    return;
  }
  CurrencySubtractEvent currencySubtractEvent=new CurrencySubtractEvent(event.getAmount(),target,event.getWorld());
  ChestShop.callEvent(currencySubtractEvent);
}
Program: 17107
Project: 17107
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencyAdd(CurrencyAddEvent event){
  UUID target=event.getTarget();
  if (!NameManager.isAdminShop(target) || SERVER_ECONOMY_ACCOUNT.equals(NameManager.getUsername(target))) {
    return;
  }
  if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
    event.setAdded(true);
    return;
  }
 else {
    Account account=NameManager.getAccount(SERVER_ECONOMY_ACCOUNT);
    if (account == null || account.getUuid() == null) {
      return;
    }
    target=account.getUuid();
  }
  event.setAdded(true);
  if (target == null) {
    return;
  }
  CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(event.getAmount(),target,event.getWorld());
  ChestShop.callEvent(currencyAddEvent);
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencyAdd(CurrencyAddEvent event){
  UUID target=event.getTarget();
  if (!NameManager.isAdminShop(target) || NameManager.isServerEconomyAccount(target)) {
    return;
  }
  Account account=NameManager.getServerEconomyAccount();
  target=account != null ? account.getUuid() : null;
  event.setAdded(true);
  if (target == null) {
    return;
  }
  CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(event.getAmount(),target,event.getWorld());
  ChestShop.callEvent(currencyAddEvent);
}
Program: 17108
Project: 17108
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencyCheck(CurrencyCheckEvent event){
  UUID target=event.getAccount();
  if (!NameManager.isAdminShop(target) || SERVER_ECONOMY_ACCOUNT.equals(NameManager.getUsername(target))) {
    return;
  }
  if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
    event.hasEnough(true);
    return;
  }
 else {
    Account account=NameManager.getAccount(SERVER_ECONOMY_ACCOUNT);
    if (account == null || account.getUuid() == null) {
      event.hasEnough(true);
      return;
    }
    target=account.getUuid();
  }
  CurrencyCheckEvent currencyCheckEvent=new CurrencyCheckEvent(event.getAmount(),target,event.getWorld());
  ChestShop.callEvent(currencyCheckEvent);
  event.hasEnough(currencyCheckEvent.hasEnough());
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencyCheck(CurrencyCheckEvent event){
  UUID target=event.getAccount();
  if (!NameManager.isAdminShop(target) || NameManager.isServerEconomyAccount(target)) {
    return;
  }
  Account account=NameManager.getServerEconomyAccount();
  target=account != null ? account.getUuid() : null;
  if (target == null) {
    event.hasEnough(true);
    return;
  }
  CurrencyCheckEvent currencyCheckEvent=new CurrencyCheckEvent(event.getAmount(),target,event.getWorld());
  ChestShop.callEvent(currencyCheckEvent);
  event.hasEnough(currencyCheckEvent.hasEnough());
}
Program: 17109
Project: 17109
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencyHoldCheck(CurrencyHoldEvent event){
  UUID target=event.getAccount();
  if (!NameManager.isAdminShop(target) || SERVER_ECONOMY_ACCOUNT.equals(NameManager.getUsername(target))) {
    return;
  }
  event.canHold(true);
  event.setAccount(null);
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onCurrencyHoldCheck(CurrencyHoldEvent event){
  UUID target=event.getAccount();
  if (!NameManager.isAdminShop(target) || NameManager.isServerEconomyAccount(target)) {
    return;
  }
  event.canHold(true);
  event.setAccount(null);
}
Program: 17110
Project: 17110
Buggy source:
@EventHandler(priority=EventPriority.LOW) public static void onCurrencyAdd(CurrencyAddEvent event){
  if (event.isAdded()) {
    return;
  }
  UUID target=event.getTarget();
  if (Economy.getServerAccountName().equals(NameManager.getUsername(target))) {
    return;
  }
  float taxAmount=isServerAccount(target) ? Properties.SERVER_TAX_AMOUNT : Properties.TAX_AMOUNT;
  if (taxAmount == 0) {
    return;
  }
  BigDecimal tax=getTax(event.getAmount(),taxAmount);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(tax,NameManager.getUUID(Economy.getServerAccountName()),event.getWorld());
    ChestShop.callEvent(currencyAddEvent);
  }
  event.setAmount(event.getAmount().subtract(tax));
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public static void onCurrencyAdd(CurrencyAddEvent event){
  if (event.isAdded()) {
    return;
  }
  UUID target=event.getTarget();
  if (NameManager.isServerEconomyAccount(target)) {
    return;
  }
  float taxAmount=isServerAccount(target) ? Properties.SERVER_TAX_AMOUNT : Properties.TAX_AMOUNT;
  if (taxAmount == 0) {
    return;
  }
  BigDecimal tax=getTax(event.getAmount(),taxAmount);
  if (NameManager.getServerEconomyAccount() != null) {
    CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(tax,NameManager.getServerEconomyAccount().getUuid(),event.getWorld());
    ChestShop.callEvent(currencyAddEvent);
  }
  event.setAmount(event.getAmount().subtract(tax));
}
Program: 17111
Project: 17111
Buggy source:
@EventHandler public static void onShopCreation(ShopCreatedEvent event){
  double shopCreationPrice=Properties.SHOP_CREATION_PRICE;
  if (shopCreationPrice == 0) {
    return;
  }
  if (ChestShopSign.isAdminShop(event.getSignLine(NAME_LINE))) {
    return;
  }
  Player player=event.getPlayer();
  if (Permission.has(player,NOFEE)) {
    return;
  }
  CurrencySubtractEvent subtractionEvent=new CurrencySubtractEvent(BigDecimal.valueOf(shopCreationPrice),player);
  ChestShop.callEvent(subtractionEvent);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(BigDecimal.valueOf(shopCreationPrice),NameManager.getUUID(Economy.getServerAccountName()),player.getWorld());
    ChestShop.callEvent(currencyAddEvent);
  }
  player.sendMessage(Messages.prefix(Messages.SHOP_FEE_PAID.replace("String_Node_Str",Economy.formatBalance(shopCreationPrice))));
}

Fixed version (ground truth):
@EventHandler public static void onShopCreation(ShopCreatedEvent event){
  double shopCreationPrice=Properties.SHOP_CREATION_PRICE;
  if (shopCreationPrice == 0) {
    return;
  }
  if (ChestShopSign.isAdminShop(event.getSignLine(NAME_LINE))) {
    return;
  }
  Player player=event.getPlayer();
  if (Permission.has(player,NOFEE)) {
    return;
  }
  CurrencySubtractEvent subtractionEvent=new CurrencySubtractEvent(BigDecimal.valueOf(shopCreationPrice),player);
  ChestShop.callEvent(subtractionEvent);
  if (NameManager.getServerEconomyAccount() != null) {
    CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(BigDecimal.valueOf(shopCreationPrice),NameManager.getServerEconomyAccount().getUuid(),player.getWorld());
    ChestShop.callEvent(currencyAddEvent);
  }
  player.sendMessage(Messages.prefix(Messages.SHOP_FEE_PAID.replace("String_Node_Str",Economy.formatBalance(shopCreationPrice))));
}
Program: 17112
Project: 17112
Buggy source:
@EventHandler(priority=EventPriority.MONITOR) public static void onShopDestroy(ShopDestroyedEvent event){
  double refundPrice=Properties.SHOP_REFUND_PRICE;
  if (event.getDestroyer() == null || Permission.has(event.getDestroyer(),NOFEE) || refundPrice == 0) {
    return;
  }
  Account account=NameManager.getAccountFromShortName(event.getSign().getLine(NAME_LINE));
  if (account == null) {
    return;
  }
  CurrencyAddEvent currencyEvent=new CurrencyAddEvent(BigDecimal.valueOf(refundPrice),account.getUuid(),event.getSign().getWorld());
  ChestShop.callEvent(currencyEvent);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencySubtractEvent currencySubtractEvent=new CurrencySubtractEvent(BigDecimal.valueOf(refundPrice),NameManager.getUUID(Economy.getServerAccountName()),event.getSign().getWorld());
    ChestShop.callEvent(currencySubtractEvent);
  }
  String message=Messages.SHOP_REFUNDED.replace("String_Node_Str",Economy.formatBalance(refundPrice));
  event.getDestroyer().sendMessage(Messages.prefix(message));
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.MONITOR) public static void onShopDestroy(ShopDestroyedEvent event){
  double refundPrice=Properties.SHOP_REFUND_PRICE;
  if (event.getDestroyer() == null || Permission.has(event.getDestroyer(),NOFEE) || refundPrice == 0) {
    return;
  }
  Account account=NameManager.getAccountFromShortName(event.getSign().getLine(NAME_LINE));
  if (account == null) {
    return;
  }
  CurrencyAddEvent currencyEvent=new CurrencyAddEvent(BigDecimal.valueOf(refundPrice),account.getUuid(),event.getSign().getWorld());
  ChestShop.callEvent(currencyEvent);
  if (NameManager.getServerEconomyAccount() != null) {
    CurrencySubtractEvent currencySubtractEvent=new CurrencySubtractEvent(BigDecimal.valueOf(refundPrice),NameManager.getServerEconomyAccount().getUuid(),event.getSign().getWorld());
    ChestShop.callEvent(currencySubtractEvent);
  }
  String message=Messages.SHOP_REFUNDED.replace("String_Node_Str",Economy.formatBalance(refundPrice));
  event.getDestroyer().sendMessage(Messages.prefix(message));
}
Program: 17113
Project: 17113
Buggy source:
public static void load(){
  try {
    accounts=DaoCreator.getDaoAndCreateTable(Account.class);
    adminAccount=new Account(Properties.ADMIN_SHOP_NAME,Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
    accounts.createOrUpdate(adminAccount);
    if (!Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
      serverEconomyAccount=getAccount(Properties.SERVER_ECONOMY_ACCOUNT);
      if (serverEconomyAccount == null || serverEconomyAccount.getUuid() == null) {
        ChestShop.getBukkitLogger().log(Level.WARNING,"String_Node_Str" + Properties.SERVER_ECONOMY_ACCOUNT + "String_Node_Str");
      }
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void load(){
  try {
    accounts=DaoCreator.getDaoAndCreateTable(Account.class);
    adminAccount=new Account(Properties.ADMIN_SHOP_NAME,Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
    accounts.createOrUpdate(adminAccount);
    if (!Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
      serverEconomyAccount=getAccount(Properties.SERVER_ECONOMY_ACCOUNT);
      if (serverEconomyAccount == null || serverEconomyAccount.getUuid() == null) {
        serverEconomyAccount=null;
        ChestShop.getBukkitLogger().log(Level.WARNING,"String_Node_Str" + Properties.SERVER_ECONOMY_ACCOUNT + "String_Node_Str");
      }
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}
Program: 17114
Project: 17114
Buggy source:
/** 
 * Checks if the inventory has stock of this type
 * @param items     items
 * @param inventory inventory
 * @return Does the inventory contain stock of this type?
 */
public static boolean hasItems(ItemStack[] items,Inventory inventory){
  for (  ItemStack item : items) {
    if (getAmount(item,inventory) < item.getAmount()) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks if the inventory has stock of this type
 * @param items     items
 * @param inventory inventory
 * @return Does the inventory contain stock of this type?
 */
public static boolean hasItems(ItemStack[] items,Inventory inventory){
  ItemStack[] mergedItems=mergeSimilarStacks(items);
  for (  ItemStack item : mergedItems) {
    if (getAmount(item,inventory) < item.getAmount()) {
      return false;
    }
  }
  return true;
}
Program: 17115
Project: 17115
Buggy source:
/** 
 * Checks if the item fits the inventory
 * @param item      Item to check
 * @param inventory inventory
 * @return Does item fit inside inventory?
 */
public static boolean fits(ItemStack item,Inventory inventory){
  int left=item.getAmount();
  if (inventory.getMaxStackSize() == Integer.MAX_VALUE) {
    return true;
  }
  for (  ItemStack iStack : getStorageContents(inventory)) {
    if (left <= 0) {
      return true;
    }
    if (MaterialUtil.isEmpty(iStack)) {
      left-=item.getMaxStackSize();
      continue;
    }
    if (!MaterialUtil.equals(iStack,item)) {
      continue;
    }
    left-=(iStack.getMaxStackSize() - iStack.getAmount());
  }
  return left <= 0;
}

Fixed version (ground truth):
/** 
 * Checks if the item fits the inventory
 * @param item      Item to check
 * @param inventory inventory
 * @return Does item fit inside inventory?
 */
public static boolean fits(ItemStack item,Inventory inventory){
  int left=item.getAmount();
  if (inventory.getMaxStackSize() == Integer.MAX_VALUE) {
    return true;
  }
  for (  ItemStack iStack : getStorageContents(inventory)) {
    if (left <= 0) {
      return true;
    }
    if (MaterialUtil.isEmpty(iStack)) {
      left-=getMaxStackSize(item);
      continue;
    }
    if (!MaterialUtil.equals(iStack,item)) {
      continue;
    }
    left-=(getMaxStackSize(iStack) - iStack.getAmount());
  }
  return left <= 0;
}
Program: 17116
Project: 17116
Buggy source:
/** 
 * Removes an item from the inventory
 * @param item      Item to remove
 * @param inventory Inventory
 * @return Number of items that couldn't be removed
 */
public static int remove(ItemStack item,Inventory inventory){
  Map<Integer,ItemStack> leftovers=inventory.removeItem(item);
  if (!leftovers.isEmpty()) {
    for (Iterator<ItemStack> iterator=leftovers.values().iterator(); iterator.hasNext(); ) {
      ItemStack left=iterator.next();
      if (removeManually(left,inventory) == 0) {
        iterator.remove();
      }
    }
  }
  return countItems(leftovers);
}

Fixed version (ground truth):
/** 
 * Removes an item from the inventory
 * @param item      Item to remove
 * @param inventory Inventory
 * @return Number of items that couldn't be removed
 */
public static int remove(ItemStack item,Inventory inventory){
  Map<Integer,ItemStack> leftovers=inventory.removeItem(item);
  if (!leftovers.isEmpty()) {
    leftovers.values().removeIf(left -> removeManually(left,inventory) == 0);
  }
  return countItems(leftovers);
}
Program: 17117
Project: 17117
Buggy source:
/** 
 * If items in arguments are similar, this function merges them into stacks of the same type
 * @param items Items to merge
 * @return Merged stack array
 */
public static ItemStack[] mergeSimilarStacks(ItemStack... items){
  if (items.length <= 1) {
    return items;
  }
  List<ItemStack> itemList=new LinkedList<ItemStack>();
  Iterating:   for (  ItemStack item : items) {
    for (    ItemStack iStack : itemList) {
      if (MaterialUtil.equals(item,iStack)) {
        iStack.setAmount(iStack.getAmount() + item.getAmount());
        continue Iterating;
      }
    }
    itemList.add(item);
  }
  return itemList.toArray(new ItemStack[itemList.size()]);
}

Fixed version (ground truth):
/** 
 * If items in arguments are similar, this function merges them into stacks of the same type
 * @param items Items to merge
 * @return Merged stack array
 */
public static ItemStack[] mergeSimilarStacks(ItemStack... items){
  if (items.length <= 1) {
    return items;
  }
  List<ItemStack> itemList=new LinkedList<ItemStack>();
  Iterating:   for (  ItemStack item : items) {
    for (    ItemStack iStack : itemList) {
      if (MaterialUtil.equals(item,iStack)) {
        iStack.setAmount(iStack.getAmount() + item.getAmount());
        continue Iterating;
      }
    }
    itemList.add(item.clone());
  }
  return itemList.toArray(new ItemStack[itemList.size()]);
}
Program: 17119
Project: 17119
Buggy source:
private static int getStackAmount(ItemStack item,Inventory inventory,Player player,Action action){
  Action buy=Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
  Inventory checkedInventory=(action == buy ? inventory : player.getInventory());
  if (checkedInventory.containsAtLeast(item,item.getMaxStackSize())) {
    return item.getMaxStackSize();
  }
 else {
    return InventoryUtil.getAmount(item,checkedInventory);
  }
}

Fixed version (ground truth):
private static int getStackAmount(ItemStack item,Inventory inventory,Player player,Action action){
  Action buy=Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
  Inventory checkedInventory=(action == buy ? inventory : player.getInventory());
  if (checkedInventory.containsAtLeast(item,InventoryUtil.getMaxStackSize(item))) {
    return InventoryUtil.getMaxStackSize(item);
  }
 else {
    return InventoryUtil.getAmount(item,checkedInventory);
  }
}
Program: 17120
Project: 17120
Buggy source:
private static boolean itemsFitInInventory(ItemStack[] items,Inventory inventory){
  for (  ItemStack item : items) {
    if (!InventoryUtil.fits(item,inventory)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private static boolean itemsFitInInventory(ItemStack[] items,Inventory inventory){
  ItemStack[] mergedItems=InventoryUtil.mergeSimilarStacks(items);
  for (  ItemStack item : mergedItems) {
    if (!InventoryUtil.fits(item,inventory)) {
      return false;
    }
  }
  return true;
}
Program: 17121
Project: 17121
Buggy source:
/** 
 * Checks if the itemStacks are equal, ignoring their amount
 * @param one first itemStack
 * @param two second itemStack
 * @return Are they equal?
 */
public static boolean equals(ItemStack one,ItemStack two){
  if (one == null || two == null) {
    return one != two;
  }
  if (one.isSimilar(two)) {
    return true;
  }
  return one.getType() == two.getType() && one.getDurability() == two.getDurability() && one.getData().equals(two.getData()) && one.hasItemMeta() && two.hasItemMeta() && one.getItemMeta() instanceof BookMeta && two.getItemMeta() instanceof BookMeta && one.getItemMeta().serialize().equals(two.getItemMeta().serialize());
}

Fixed version (ground truth):
/** 
 * Checks if the itemStacks are equal, ignoring their amount
 * @param one first itemStack
 * @param two second itemStack
 * @return Are they equal?
 */
public static boolean equals(ItemStack one,ItemStack two){
  if (one == null || two == null) {
    return one == two;
  }
  if (one.isSimilar(two)) {
    return true;
  }
  return one.getType() == two.getType() && one.getDurability() == two.getDurability() && one.getData().equals(two.getData()) && one.hasItemMeta() && two.hasItemMeta() && one.getItemMeta() instanceof BookMeta && two.getItemMeta() instanceof BookMeta && one.getItemMeta().serialize().equals(two.getItemMeta().serialize());
}
Program: 17122
Project: 17122
Buggy source:
/** 
 * Make an array of items fit into an inventory.
 * @param stock     The items to fit in the inventory
 * @param inventory The inventory to fit it in
 * @return Whether or not the items fit into the inventory
 */
private static ItemStack[] getItemsThatFit(ItemStack[] stock,Inventory inventory){
  List<ItemStack> resultStock=new ArrayList<>();
  int emptySlots=InventoryUtil.countEmpty(inventory);
  ItemStack[] itemsInInventory=getItems(stock,inventory);
  for (  ItemStack item : stock) {
    int maxStackSize=InventoryUtil.getMaxStackSize(item);
    int free=0;
    for (    ItemStack itemInInventory : itemsInInventory) {
      if (MaterialUtil.equals(item,itemInInventory)) {
        free=(maxStackSize - itemInInventory.getAmount()) % maxStackSize;
        break;
      }
    }
    if (free == 0 && emptySlots == 0) {
      continue;
    }
    ItemStack clone=item.clone();
    if (item.getAmount() > free) {
      if (emptySlots > 0) {
        int requiredSlots=(int)Math.ceil((item.getAmount() - free) / maxStackSize);
        if (requiredSlots <= emptySlots) {
          emptySlots=emptySlots - requiredSlots;
        }
 else {
          emptySlots=0;
          clone.setAmount(free + maxStackSize * emptySlots);
        }
      }
 else {
        clone.setAmount(free);
      }
    }
    resultStock.add(clone);
  }
  return resultStock.toArray(new ItemStack[resultStock.size()]);
}

Fixed version (ground truth):
/** 
 * Make an array of items fit into an inventory.
 * @param stock     The items to fit in the inventory
 * @param inventory The inventory to fit it in
 * @return Whether or not the items fit into the inventory
 */
private static ItemStack[] getItemsThatFit(ItemStack[] stock,Inventory inventory){
  List<ItemStack> resultStock=new ArrayList<>();
  int emptySlots=InventoryUtil.countEmpty(inventory);
  for (  ItemStack item : InventoryUtil.mergeSimilarStacks(stock)) {
    int maxStackSize=InventoryUtil.getMaxStackSize(item);
    int free=0;
    for (    ItemStack itemInInventory : inventory.getContents()) {
      if (MaterialUtil.equals(item,itemInInventory)) {
        free+=(maxStackSize - itemInInventory.getAmount()) % maxStackSize;
      }
    }
    if (free == 0 && emptySlots == 0) {
      continue;
    }
    if (item.getAmount() > free) {
      if (emptySlots > 0) {
        int requiredSlots=(int)Math.ceil(((double)item.getAmount() - free) / maxStackSize);
        if (requiredSlots <= emptySlots) {
          emptySlots=emptySlots - requiredSlots;
        }
 else {
          item.setAmount(free + maxStackSize * emptySlots);
          emptySlots=0;
        }
      }
 else {
        item.setAmount(free);
      }
    }
    resultStock.add(item);
  }
  return resultStock.toArray(new ItemStack[resultStock.size()]);
}
Program: 17123
Project: 17123
Buggy source:
/** 
 * Make an array of items fit into an inventory.
 * @param stock     The items to fit in the inventory
 * @param inventory The inventory to fit it in
 * @return Whether or not the items fit into the inventory
 */
private static ItemStack[] getItemsThatFit(ItemStack[] stock,Inventory inventory){
  List<ItemStack> resultStock=new ArrayList<>();
  int emptySlots=InventoryUtil.countEmpty(inventory);
  ItemStack[] itemsInInventory=getItems(stock,inventory);
  for (  ItemStack item : stock) {
    int maxStackSize=InventoryUtil.getMaxStackSize(item);
    int free=0;
    for (    ItemStack itemInInventory : itemsInInventory) {
      if (MaterialUtil.equals(item,itemInInventory)) {
        free=(maxStackSize - itemInInventory.getAmount()) % maxStackSize;
        break;
      }
    }
    if (free == 0 && emptySlots == 0) {
      continue;
    }
    ItemStack clone=item.clone();
    if (item.getAmount() > free) {
      if (emptySlots > 0) {
        int requiredSlots=(int)Math.ceil((item.getAmount() - free) / maxStackSize);
        if (requiredSlots <= emptySlots) {
          emptySlots=emptySlots - requiredSlots;
        }
 else {
          emptySlots=0;
          clone.setAmount(free + maxStackSize * emptySlots);
        }
      }
 else {
        clone.setAmount(free);
      }
    }
    resultStock.add(clone);
  }
  return (ItemStack[])resultStock.toArray();
}

Fixed version (ground truth):
/** 
 * Make an array of items fit into an inventory.
 * @param stock     The items to fit in the inventory
 * @param inventory The inventory to fit it in
 * @return Whether or not the items fit into the inventory
 */
private static ItemStack[] getItemsThatFit(ItemStack[] stock,Inventory inventory){
  List<ItemStack> resultStock=new ArrayList<>();
  int emptySlots=InventoryUtil.countEmpty(inventory);
  ItemStack[] itemsInInventory=getItems(stock,inventory);
  for (  ItemStack item : stock) {
    int maxStackSize=InventoryUtil.getMaxStackSize(item);
    int free=0;
    for (    ItemStack itemInInventory : itemsInInventory) {
      if (MaterialUtil.equals(item,itemInInventory)) {
        free=(maxStackSize - itemInInventory.getAmount()) % maxStackSize;
        break;
      }
    }
    if (free == 0 && emptySlots == 0) {
      continue;
    }
    ItemStack clone=item.clone();
    if (item.getAmount() > free) {
      if (emptySlots > 0) {
        int requiredSlots=(int)Math.ceil((item.getAmount() - free) / maxStackSize);
        if (requiredSlots <= emptySlots) {
          emptySlots=emptySlots - requiredSlots;
        }
 else {
          emptySlots=0;
          clone.setAmount(free + maxStackSize * emptySlots);
        }
      }
 else {
        clone.setAmount(free);
      }
    }
    resultStock.add(clone);
  }
  return resultStock.toArray(new ItemStack[resultStock.size()]);
}
Program: 17124
Project: 17124
Buggy source:
/** 
 * Adds an item to the inventor
 * @param item      Item to add
 * @param inventory Inventory
 * @return Number of leftover items
 */
public static int add(ItemStack item,Inventory inventory){
  Map<Integer,ItemStack> leftovers=inventory.addItem(item.clone());
  return countItems(leftovers);
}

Fixed version (ground truth):
/** 
 * Adds an item to the inventor
 * @param item      Item to add
 * @param inventory Inventory
 * @return Number of leftover items
 */
public static int add(ItemStack item,Inventory inventory){
  Map<Integer,ItemStack> leftovers=inventory.addItem(item.clone());
  if (!leftovers.isEmpty()) {
    for (Iterator<ItemStack> iterator=leftovers.values().iterator(); iterator.hasNext(); ) {
      ItemStack left=iterator.next();
      int amountLeft=addManually(left,inventory,left.getMaxStackSize());
      if (amountLeft == 0) {
        iterator.remove();
      }
 else {
        left.setAmount(amountLeft);
      }
    }
  }
  return countItems(leftovers);
}
Program: 17125
Project: 17125
Buggy source:
/** 
 * Counts leftovers from a map
 * @param items Leftovers
 * @return Number of leftovers
 */
public static int countItems(Map<Integer,?> items){
  int totalLeft=0;
  for (  int left : items.keySet()) {
    totalLeft+=left;
  }
  return totalLeft;
}

Fixed version (ground truth):
/** 
 * Counts leftovers from a map
 * @param items Leftovers
 * @return Number of leftovers
 */
public static int countItems(Map<Integer,ItemStack> items){
  int totalLeft=0;
  for (  ItemStack left : items.values()) {
    totalLeft+=left.getAmount();
  }
  return totalLeft;
}
Program: 17126
Project: 17126
Buggy source:
/** 
 * Checks if the inventory has stock of this type
 * @param items     items
 * @param inventory inventory
 * @return Does the inventory contain stock of this type?
 */
public static boolean hasItems(ItemStack[] items,Inventory inventory){
  for (  ItemStack item : items) {
    if (!inventory.containsAtLeast(item,item.getAmount())) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks if the inventory has stock of this type
 * @param items     items
 * @param inventory inventory
 * @return Does the inventory contain stock of this type?
 */
public static boolean hasItems(ItemStack[] items,Inventory inventory){
  for (  ItemStack item : items) {
    if (getAmount(item,inventory) < item.getAmount()) {
      return false;
    }
  }
  return true;
}
Program: 17127
Project: 17127
Buggy source:
/** 
 * Removes an item from the inventory
 * @param item      Item to remove
 * @param inventory Inventory
 * @return Number of items that couldn't be removed
 */
public static int remove(ItemStack item,Inventory inventory){
  Map<Integer,ItemStack> leftovers=inventory.removeItem(item);
  return countItems(leftovers);
}

Fixed version (ground truth):
/** 
 * Removes an item from the inventory
 * @param item      Item to remove
 * @param inventory Inventory
 * @return Number of items that couldn't be removed
 */
public static int remove(ItemStack item,Inventory inventory){
  Map<Integer,ItemStack> leftovers=inventory.removeItem(item);
  if (!leftovers.isEmpty()) {
    for (Iterator<ItemStack> iterator=leftovers.values().iterator(); iterator.hasNext(); ) {
      ItemStack left=iterator.next();
      if (removeManually(left,inventory) == 0) {
        iterator.remove();
      }
    }
  }
  return countItems(leftovers);
}
Program: 17128
Project: 17128
Buggy source:
/** 
 * Checks if the itemStacks are equal, ignoring their amount
 * @param one first itemStack
 * @param two second itemStack
 * @return Are they equal?
 */
public static boolean equals(ItemStack one,ItemStack two){
  return one.isSimilar(two);
}

Fixed version (ground truth):
/** 
 * Checks if the itemStacks are equal, ignoring their amount
 * @param one first itemStack
 * @param two second itemStack
 * @return Are they equal?
 */
public static boolean equals(ItemStack one,ItemStack two){
  if (one == null || two == null) {
    return one != two;
  }
  if (one.isSimilar(two)) {
    return true;
  }
  return one.getType() == two.getType() && one.getDurability() == two.getDurability() && one.getData().equals(two.getData()) && one.hasItemMeta() && two.hasItemMeta() && one.getItemMeta() instanceof BookMeta && two.getItemMeta() instanceof BookMeta && one.getItemMeta().serialize().equals(two.getItemMeta().serialize());
}