Program: 34098
Project: 34098
Buggy source:
/** 
 * Checks if a player has enough for a challenge. Supports two types of checks, inventory and island
 * @param player
 * @param challenge
 * @param type
 * @return true if the player has everything required
 */
protected boolean hasRequired(final Player player,final String challenge,final String type){
  final String[] reqList=plugin.getChallengeConfig().getString("String_Node_Str" + challenge + "String_Node_Str").split("String_Node_Str");
  if (type.equalsIgnoreCase("String_Node_Str")) {
    List<ItemStack> toBeRemoved=new ArrayList<ItemStack>();
    Material reqItem;
    int reqAmount=0;
    for (    final String s : reqList) {
      final String[] part=s.split("String_Node_Str");
      if (part.length == 2) {
        try {
          if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
          reqItem=Material.getMaterial(part[0]);
          reqAmount=Integer.parseInt(part[1]);
          ItemStack item=new ItemStack(reqItem);
          if (!player.getInventory().contains(reqItem)) {
            return false;
          }
 else {
            int amount=0;
            for (            Entry<Integer,? extends ItemStack> en : player.getInventory().all(reqItem).entrySet()) {
              ItemStack i=en.getValue();
              if (i.getDurability() == 0 || (reqItem == Material.MAP && i.getType() == Material.MAP)) {
                i.setItemMeta(null);
                player.getInventory().setItem(en.getKey(),i);
                if ((amount + i.getAmount()) < reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                }
 else                 if ((amount + i.getAmount()) == reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                  break;
                }
 else {
                  item.setAmount(reqAmount - amount);
                  item.setDurability(i.getDurability());
                  toBeRemoved.add(item);
                  amount+=i.getAmount();
                  break;
                }
              }
            }
            if (amount < reqAmount) {
              return false;
            }
          }
        }
 catch (        Exception e) {
          plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
          player.sendMessage(ChatColor.RED + Locale.errorCommandNotReady);
          String materialList="String_Node_Str";
          boolean hint=false;
          for (          Material m : Material.values()) {
            materialList+=m.toString() + "String_Node_Str";
            if (m.toString().contains(s.substring(0,3).toUpperCase())) {
              plugin.getLogger().severe("String_Node_Str" + m.toString() + "String_Node_Str");
              hint=true;
            }
          }
          if (!hint) {
            plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
            plugin.getLogger().severe(materialList.substring(0,materialList.length() - 1));
          }
 else {
            plugin.getLogger().severe("String_Node_Str");
          }
          return false;
        }
      }
 else       if (part.length == 3) {
        try {
          if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
          reqItem=Material.getMaterial(part[0]);
          int reqDurability=Integer.parseInt(part[1]);
          reqAmount=Integer.parseInt(part[2]);
          int count=reqAmount;
          ItemStack item=new ItemStack(reqItem);
          if (reqItem.equals(Material.POTION)) {
            ItemStack[] playerInv=player.getInventory().getContents();
            for (            ItemStack i : playerInv) {
              if (i != null && i.getType().equals(Material.POTION)) {
                if (i.getDurability() == reqDurability) {
                  item=i.clone();
                  if (item.getAmount() > reqAmount) {
                    item.setAmount(reqAmount);
                  }
                  count=count - item.getAmount();
                  toBeRemoved.add(item);
                }
              }
              if (count == 0) {
                break;
              }
            }
            if (count > 0) {
              return false;
            }
          }
 else {
            item.setDurability((short)reqDurability);
            int amount=0;
            for (            Entry<Integer,? extends ItemStack> en : player.getInventory().all(reqItem).entrySet()) {
              ItemStack i=en.getValue();
              if (i.getDurability() == reqDurability) {
                i.setItemMeta(null);
                player.getInventory().setItem(en.getKey(),i);
                if ((amount + i.getAmount()) < reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                }
 else                 if ((amount + i.getAmount()) == reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                  break;
                }
 else {
                  item.setAmount(reqAmount - amount);
                  item.setDurability(i.getDurability());
                  toBeRemoved.add(item);
                  amount+=i.getAmount();
                  break;
                }
              }
            }
            if (amount < reqAmount) {
              return false;
            }
          }
        }
 catch (        Exception e) {
          plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
          player.sendMessage(ChatColor.RED + Locale.errorCommandNotReady);
          if (part[0].equalsIgnoreCase("String_Node_Str")) {
            plugin.getLogger().severe("String_Node_Str");
            for (            PotionType p : PotionType.values()) {
              plugin.getLogger().info(p.toString() + "String_Node_Str" + p.getDamageValue());
            }
          }
 else {
            String materialList="String_Node_Str";
            boolean hint=false;
            for (            Material m : Material.values()) {
              materialList+=m.toString() + "String_Node_Str";
              if (m.toString().contains(s.substring(0,3))) {
                plugin.getLogger().severe("String_Node_Str" + m.toString() + "String_Node_Str");
                hint=true;
              }
            }
            if (!hint) {
              plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
              plugin.getLogger().severe(materialList.substring(0,materialList.length() - 1));
            }
 else {
              plugin.getLogger().severe("String_Node_Str");
            }
            return false;
          }
          return false;
        }
      }
    }
    if (plugin.getChallengeConfig().getBoolean("String_Node_Str" + challenge + "String_Node_Str")) {
      for (      ItemStack i : toBeRemoved) {
        HashMap<Integer,ItemStack> leftOver=player.getInventory().removeItem(i);
        if (!leftOver.isEmpty()) {
          plugin.getLogger().warning("String_Node_Str" + challenge + "String_Node_Str"+ player.getName()+ "String_Node_Str");
          for (          ItemStack left : leftOver.values()) {
            plugin.getLogger().info(left.toString());
          }
          return false;
        }
      }
    }
    return true;
  }
  if (type.equalsIgnoreCase("String_Node_Str")) {
    final HashMap<Material,Integer> neededItem=new HashMap<Material,Integer>();
    final HashMap<EntityType,Integer> neededEntities=new HashMap<EntityType,Integer>();
    for (int i=0; i < reqList.length; i++) {
      final String[] sPart=reqList[i].split("String_Node_Str");
      try {
        final int qty=Integer.parseInt(sPart[1]);
        Material item=Material.getMaterial(sPart[0]);
        if (item != null) {
          neededItem.put(item,qty);
        }
 else {
          EntityType entityType=EntityType.valueOf(sPart[0].toUpperCase());
          if (entityType != null) {
            neededEntities.put(entityType,qty);
          }
 else {
            plugin.getLogger().warning("String_Node_Str" + challenge + "String_Node_Str");
            return false;
          }
        }
      }
 catch (      Exception intEx) {
        plugin.getLogger().warning("String_Node_Str" + challenge + "String_Node_Str");
        return false;
      }
    }
    final Location l=player.getLocation();
    final int px=l.getBlockX();
    final int py=l.getBlockY();
    final int pz=l.getBlockZ();
    for (int x=-10; x <= 10; x++) {
      for (int y=-10; y <= 10; y++) {
        for (int z=-10; z <= 10; z++) {
          final Material b=new Location(l.getWorld(),px + x,py + y,pz + z).getBlock().getType();
          if (neededItem.containsKey(b)) {
            if (neededItem.get(b) == 1) {
              neededItem.remove(b);
            }
 else {
              neededItem.put(b,neededItem.get(b) - 1);
            }
          }
        }
      }
    }
    if (!neededItem.isEmpty()) {
      for (      Material missing : neededItem.keySet()) {
        player.sendMessage(ChatColor.RED + Locale.challengeserrorYouAreMissing + "String_Node_Str"+ neededItem.get(missing)+ "String_Node_Str"+ ASkyBlock.prettifyText(missing.toString()));
      }
      return false;
    }
 else {
      for (      Entity entity : player.getNearbyEntities(10,10,10)) {
        if (neededEntities.containsKey(entity.getType())) {
          if (neededEntities.get(entity.getType()) == 1) {
            neededEntities.remove(entity.getType());
          }
 else {
            neededEntities.put(entity.getType(),neededEntities.get(entity.getType()) - 1);
          }
        }
 else {
        }
      }
      if (neededEntities.isEmpty()) {
        return true;
      }
 else {
        for (        EntityType missing : neededEntities.keySet()) {
          player.sendMessage(ChatColor.RED + Locale.challengeserrorYouAreMissing + "String_Node_Str"+ neededEntities.get(missing)+ "String_Node_Str"+ ASkyBlock.prettifyText(missing.toString()));
        }
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks if a player has enough for a challenge. Supports two types of checks, inventory and island
 * @param player
 * @param challenge
 * @param type
 * @return true if the player has everything required
 */
protected boolean hasRequired(final Player player,final String challenge,final String type){
  final String[] reqList=plugin.getChallengeConfig().getString("String_Node_Str" + challenge + "String_Node_Str").split("String_Node_Str");
  if (type.equalsIgnoreCase("String_Node_Str")) {
    List<ItemStack> toBeRemoved=new ArrayList<ItemStack>();
    Material reqItem;
    int reqAmount=0;
    for (    final String s : reqList) {
      final String[] part=s.split("String_Node_Str");
      if (part.length == 2) {
        try {
          if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
          reqItem=Material.getMaterial(part[0]);
          reqAmount=Integer.parseInt(part[1]);
          ItemStack item=new ItemStack(reqItem);
          if (!player.getInventory().contains(reqItem)) {
            return false;
          }
 else {
            int amount=0;
            for (            Entry<Integer,? extends ItemStack> en : player.getInventory().all(reqItem).entrySet()) {
              ItemStack i=en.getValue();
              if (i.getDurability() == 0 || (reqItem == Material.MAP && i.getType() == Material.MAP)) {
                i.setItemMeta(null);
                player.getInventory().setItem(en.getKey(),i);
                if ((amount + i.getAmount()) < reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                }
 else                 if ((amount + i.getAmount()) == reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                  break;
                }
 else {
                  item.setAmount(reqAmount - amount);
                  item.setDurability(i.getDurability());
                  toBeRemoved.add(item);
                  amount+=i.getAmount();
                  break;
                }
              }
            }
            if (amount < reqAmount) {
              return false;
            }
          }
        }
 catch (        Exception e) {
          plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
          player.sendMessage(ChatColor.RED + Locale.errorCommandNotReady);
          String materialList="String_Node_Str";
          boolean hint=false;
          for (          Material m : Material.values()) {
            materialList+=m.toString() + "String_Node_Str";
            if (m.toString().contains(s.substring(0,3).toUpperCase())) {
              plugin.getLogger().severe("String_Node_Str" + m.toString() + "String_Node_Str");
              hint=true;
            }
          }
          if (!hint) {
            plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
            plugin.getLogger().severe(materialList.substring(0,materialList.length() - 1));
          }
 else {
            plugin.getLogger().severe("String_Node_Str");
          }
          return false;
        }
      }
 else       if (part.length == 3) {
        try {
          if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
 else           if (part[0].equalsIgnoreCase("String_Node_Str")) {
            part[0]="String_Node_Str";
          }
          reqItem=Material.getMaterial(part[0]);
          int reqDurability=Integer.parseInt(part[1]);
          reqAmount=Integer.parseInt(part[2]);
          int count=reqAmount;
          ItemStack item=new ItemStack(reqItem);
          if (reqItem.equals(Material.POTION)) {
            ItemStack[] playerInv=player.getInventory().getContents();
            for (            ItemStack i : playerInv) {
              if (i != null && i.getType().equals(Material.POTION)) {
                if (i.getDurability() == reqDurability) {
                  item=i.clone();
                  if (item.getAmount() > reqAmount) {
                    item.setAmount(reqAmount);
                  }
                  count=count - item.getAmount();
                  toBeRemoved.add(item);
                }
              }
              if (count == 0) {
                break;
              }
            }
            if (count > 0) {
              return false;
            }
          }
 else {
            item.setDurability((short)reqDurability);
            int amount=0;
            for (            Entry<Integer,? extends ItemStack> en : player.getInventory().all(reqItem).entrySet()) {
              ItemStack i=en.getValue();
              if (i.getDurability() == reqDurability) {
                i.setItemMeta(null);
                player.getInventory().setItem(en.getKey(),i);
                if ((amount + i.getAmount()) < reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                }
 else                 if ((amount + i.getAmount()) == reqAmount) {
                  toBeRemoved.add(i.clone());
                  amount+=i.getAmount();
                  break;
                }
 else {
                  item.setAmount(reqAmount - amount);
                  item.setDurability(i.getDurability());
                  toBeRemoved.add(item);
                  amount+=i.getAmount();
                  break;
                }
              }
            }
            if (amount < reqAmount) {
              return false;
            }
          }
        }
 catch (        Exception e) {
          plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
          player.sendMessage(ChatColor.RED + Locale.errorCommandNotReady);
          if (part[0].equalsIgnoreCase("String_Node_Str")) {
            plugin.getLogger().severe("String_Node_Str");
            for (            PotionType p : PotionType.values()) {
              plugin.getLogger().info(p.toString() + "String_Node_Str" + p.getDamageValue());
            }
          }
 else {
            String materialList="String_Node_Str";
            boolean hint=false;
            for (            Material m : Material.values()) {
              materialList+=m.toString() + "String_Node_Str";
              if (m.toString().contains(s.substring(0,3))) {
                plugin.getLogger().severe("String_Node_Str" + m.toString() + "String_Node_Str");
                hint=true;
              }
            }
            if (!hint) {
              plugin.getLogger().severe("String_Node_Str" + s + "String_Node_Str");
              plugin.getLogger().severe(materialList.substring(0,materialList.length() - 1));
            }
 else {
              plugin.getLogger().severe("String_Node_Str");
            }
            return false;
          }
          return false;
        }
      }
    }
    if (plugin.getChallengeConfig().getBoolean("String_Node_Str" + challenge + "String_Node_Str")) {
      for (      ItemStack i : toBeRemoved) {
        HashMap<Integer,ItemStack> leftOver=player.getInventory().removeItem(i);
        if (!leftOver.isEmpty()) {
          plugin.getLogger().warning("String_Node_Str" + challenge + "String_Node_Str"+ player.getName()+ "String_Node_Str");
          for (          ItemStack left : leftOver.values()) {
            plugin.getLogger().info(left.toString());
          }
          return false;
        }
      }
    }
    return true;
  }
  if (type.equalsIgnoreCase("String_Node_Str")) {
    final HashMap<Material,Integer> neededItem=new HashMap<Material,Integer>();
    final HashMap<EntityType,Integer> neededEntities=new HashMap<EntityType,Integer>();
    for (int i=0; i < reqList.length; i++) {
      final String[] sPart=reqList[i].split("String_Node_Str");
      try {
        final int qty=Integer.parseInt(sPart[1]);
        boolean isEntity=false;
        for (        EntityType entityType : EntityType.values()) {
          if (entityType.toString().equalsIgnoreCase(sPart[0])) {
            isEntity=true;
            break;
          }
        }
        if (isEntity) {
          EntityType entityType=EntityType.valueOf(sPart[0].toUpperCase());
          if (entityType != null) {
            neededEntities.put(entityType,qty);
          }
        }
 else {
          Material item=Material.getMaterial(sPart[0].toUpperCase());
          if (item != null) {
            neededItem.put(item,qty);
          }
 else {
            plugin.getLogger().warning("String_Node_Str" + challenge + "String_Node_Str");
            return false;
          }
        }
      }
 catch (      Exception intEx) {
        plugin.getLogger().warning("String_Node_Str" + challenge + "String_Node_Str");
        return false;
      }
    }
    final Location l=player.getLocation();
    final int px=l.getBlockX();
    final int py=l.getBlockY();
    final int pz=l.getBlockZ();
    for (int x=-10; x <= 10; x++) {
      for (int y=-10; y <= 10; y++) {
        for (int z=-10; z <= 10; z++) {
          final Material b=new Location(l.getWorld(),px + x,py + y,pz + z).getBlock().getType();
          if (neededItem.containsKey(b)) {
            if (neededItem.get(b) == 1) {
              neededItem.remove(b);
            }
 else {
              neededItem.put(b,neededItem.get(b) - 1);
            }
          }
        }
      }
    }
    if (!neededItem.isEmpty()) {
      for (      Material missing : neededItem.keySet()) {
        player.sendMessage(ChatColor.RED + Locale.challengeserrorYouAreMissing + "String_Node_Str"+ neededItem.get(missing)+ "String_Node_Str"+ ASkyBlock.prettifyText(missing.toString()));
      }
      return false;
    }
 else {
      for (      Entity entity : player.getNearbyEntities(10,10,10)) {
        plugin.getLogger().info("String_Node_Str" + entity.getType().toString());
        if (neededEntities.containsKey(entity.getType())) {
          if (neededEntities.get(entity.getType()) == 1) {
            neededEntities.remove(entity.getType());
          }
 else {
            neededEntities.put(entity.getType(),neededEntities.get(entity.getType()) - 1);
          }
        }
 else {
        }
      }
      if (neededEntities.isEmpty()) {
        return true;
      }
 else {
        for (        EntityType missing : neededEntities.keySet()) {
          player.sendMessage(ChatColor.RED + Locale.challengeserrorYouAreMissing + "String_Node_Str"+ neededEntities.get(missing)+ "String_Node_Str"+ ASkyBlock.prettifyText(missing.toString()));
        }
        return false;
      }
    }
  }
  return true;
}