Program: 51400
Project: 51400
Buggy source:
/** 
 * Makes sure that players cannot put items in disabled slots. Assumes that the inventory has   {@link BetterEnderInventoryHolder} as the holder, thatthe player has indeed shift clicked and that there are actually disabled slots.
 * @param event The inventory click event.
 */
protected void handleTakeOnlySlotsShiftClick(InventoryClickEvent event){
  Inventory inventory=event.getInventory();
  BetterEnderInventoryHolder holder=(BetterEnderInventoryHolder)inventory.getHolder();
  if (event.getSlot() == event.getRawSlot()) {
    return;
  }
  if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) {
    return;
  }
  event.setCancelled(true);
  ItemStack adding=event.getCurrentItem();
  if (!canPlaceStack(adding)) {
    sendInvalidItemMessage(event.getWhoClicked());
    return;
  }
  int useableSlotsCount=inventory.getSize() - holder.getTakeOnlySlots();
  for (int i=0; i < useableSlotsCount; i++) {
    ItemStack inSlot=inventory.getItem(i);
    if (inSlot == null || !inSlot.isSimilar(adding)) {
      continue;
    }
    int itemsToAdd=Math.min(inventory.getMaxStackSize(),inSlot.getMaxStackSize()) - inSlot.getAmount();
    itemsToAdd=Math.min(adding.getAmount(),itemsToAdd);
    if (itemsToAdd > 0) {
      inSlot.setAmount(inSlot.getAmount() + itemsToAdd);
      inventory.setItem(i,inSlot);
    }
    if (itemsToAdd >= adding.getAmount()) {
      event.setCurrentItem(new ItemStack(Material.AIR,0));
      return;
    }
 else {
      adding.setAmount(adding.getAmount() - itemsToAdd);
    }
  }
  for (int i=0; i < useableSlotsCount; i++) {
    ItemStack inSlot=inventory.getItem(i);
    if (inSlot == null || inSlot.getType().equals(Material.AIR)) {
      inventory.setItem(i,adding);
      event.setCurrentItem(new ItemStack(Material.AIR,0));
      return;
    }
  }
  event.setCurrentItem(adding);
}

Fixed version (ground truth):
/** 
 * Makes sure that players cannot put items in disabled slots. Assumes that the inventory has   {@link BetterEnderInventoryHolder} as the holder, thatthe player has indeed shift clicked and that there are actually disabled slots.
 * @param event The inventory click event.
 */
protected void handleTakeOnlySlotsShiftClick(InventoryClickEvent event){
  Inventory inventory=event.getInventory();
  BetterEnderInventoryHolder holder=(BetterEnderInventoryHolder)inventory.getHolder();
  if (event.getSlot() == event.getRawSlot()) {
    return;
  }
  if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) {
    return;
  }
  event.setCancelled(true);
  ItemStack adding=event.getCurrentItem();
  if (!canPlaceStack(adding)) {
    sendInvalidItemMessage(event.getWhoClicked());
    return;
  }
  int useableSlotsCount=inventory.getSize() - holder.getTakeOnlySlots();
  for (int i=0; i < useableSlotsCount; i++) {
    ItemStack inSlot=inventory.getItem(i);
    if (inSlot == null || !inSlot.isSimilar(adding)) {
      continue;
    }
    int itemsToAdd=Math.min(inventory.getMaxStackSize(),inSlot.getMaxStackSize()) - inSlot.getAmount();
    itemsToAdd=Math.max(itemsToAdd,0);
    itemsToAdd=Math.min(adding.getAmount(),itemsToAdd);
    if (itemsToAdd > 0) {
      inSlot.setAmount(inSlot.getAmount() + itemsToAdd);
      inventory.setItem(i,inSlot);
    }
    if (itemsToAdd >= adding.getAmount()) {
      event.setCurrentItem(new ItemStack(Material.AIR,0));
      return;
    }
 else {
      adding.setAmount(adding.getAmount() - itemsToAdd);
    }
  }
  for (int i=0; i < useableSlotsCount; i++) {
    ItemStack inSlot=inventory.getItem(i);
    if (inSlot == null || inSlot.getType().equals(Material.AIR)) {
      inventory.setItem(i,adding);
      event.setCurrentItem(new ItemStack(Material.AIR,0));
      return;
    }
  }
  event.setCurrentItem(adding);
}