Program: 44721
Project: 44721
Buggy source:
public static void showInventory(Player p,ArrayList<String> itemList){
  CraftPlayer cp=(CraftPlayer)p;
  CraftInventoryPlayer inv=new CraftInventoryPlayer(new InventoryPlayer(cp.getHandle()));
  inv.clear();
  try {
switch (itemList.size()) {
case 1:
      for (int i=0; i < 36; i++)       inv.addItem(getItem(itemList.get(0)));
    break;
case 2:
  for (int i=0; i < 18; i++)   inv.addItem(getItem(itemList.get(0)));
for (int i=0; i < 18; i++) inv.addItem(getItem(itemList.get(1)));
break;
case 3:
for (int i=0; i < 4; i++) {
inv.setItem((i * 9),getItem(itemList.get(0)));
inv.setItem((i * 9) + 1,getItem(itemList.get(0)));
inv.setItem((i * 9) + 2,getItem(itemList.get(0)));
inv.setItem((i * 9) + 3,getItem(itemList.get(1)));
inv.setItem((i * 9) + 4,getItem(itemList.get(1)));
inv.setItem((i * 9) + 5,getItem(itemList.get(1)));
inv.setItem((i * 9) + 6,getItem(itemList.get(2)));
inv.setItem((i * 9) + 7,getItem(itemList.get(2)));
inv.setItem((i * 9) + 8,getItem(itemList.get(2)));
}
break;
case 4:
for (int i=0; i < 4; i++) for (int j=0; j < 9; j++) inv.setItem((i * 9) + j,getItem(itemList.get(i)));
break;
case 5:
for (int i=0; i < 4; i++) for (int j=0; j < 7; j++) inv.setItem((i * 9) + j,getItem(itemList.get(i)));
for (int k=0; k < 4; k++) {
inv.setItem((k * 9) + 7,getItem(itemList.get(4)));
inv.setItem((k * 9) + 8,getItem(itemList.get(4)));
}
break;
case 6:
for (int i=0; i < 2; i++) {
inv.setItem((i * 9),getItem(itemList.get(0)));
inv.setItem((i * 9) + 1,getItem(itemList.get(0)));
inv.setItem((i * 9) + 2,getItem(itemList.get(0)));
inv.setItem((i * 9) + 3,getItem(itemList.get(1)));
inv.setItem((i * 9) + 4,getItem(itemList.get(1)));
inv.setItem((i * 9) + 5,getItem(itemList.get(1)));
inv.setItem((i * 9) + 6,getItem(itemList.get(2)));
inv.setItem((i * 9) + 7,getItem(itemList.get(2)));
inv.setItem((i * 9) + 8,getItem(itemList.get(2)));
}
for (int i=2; i < 4; i++) {
inv.setItem((i * 9),getItem(itemList.get(3)));
inv.setItem((i * 9) + 1,getItem(itemList.get(3)));
inv.setItem((i * 9) + 2,getItem(itemList.get(3)));
inv.setItem((i * 9) + 3,getItem(itemList.get(4)));
inv.setItem((i * 9) + 4,getItem(itemList.get(4)));
inv.setItem((i * 9) + 5,getItem(itemList.get(4)));
inv.setItem((i * 9) + 6,getItem(itemList.get(5)));
inv.setItem((i * 9) + 7,getItem(itemList.get(5)));
inv.setItem((i * 9) + 8,getItem(itemList.get(5)));
}
break;
case 7:
for (int i=0; i < 7; i++) {
int jmax;
if (i % 2 == 0) jmax=5;
 else jmax=4;
for (int j=0; j < jmax; j++) inv.addItem(getItem(itemList.get(i)));
}
break;
case 8:
for (int i=0; i < 4; i++) {
inv.addItem(getItem(itemList.get((2 * i))));
inv.addItem(getItem(itemList.get((2 * i))));
inv.addItem(getItem(itemList.get((2 * i))));
inv.addItem(getItem(itemList.get((2 * i))));
inv.addItem(getItem(itemList.get((2 * i) + 1)));
inv.addItem(getItem(itemList.get((2 * i) + 1)));
inv.addItem(getItem(itemList.get((2 * i) + 1)));
inv.addItem(getItem(itemList.get((2 * i) + 1)));
inv.addItem(getItem(itemList.get((2 * i) + 1)));
}
break;
case 9:
for (int j=0; j < 4; j++) for (int i=0; i < 9; i++) inv.addItem(getItem(itemList.get(i)));
break;
case 10:
case 11:
case 12:
for (int i=0; i < itemList.size(); i++) for (int j=0; j < 3; j++) inv.addItem(getItem(itemList.get(i)));
break;
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
int pos;
for (int i=0; i < itemList.size(); i++) {
if (i < 9) pos=i;
 else pos=i + 9;
inv.setItem(pos,getItem(itemList.get(i)));
inv.setItem(pos + 9,getItem(itemList.get(i)));
}
break;
default :
for (int i=0; i < itemList.size(); i++) inv.setItem(i,getItem(itemList.get(i)));
}
}
 catch (Exception e) {
System.out.println("String_Node_Str" + e.getMessage());
}
IInventory ii=(IInventory)inv.getInventory();
cp.getHandle().a(ii);
}

Fixed version (ground truth):
public static void showInventory(Player p,ArrayList<Object> itemList){
  CraftPlayer cp=(CraftPlayer)p;
  CraftInventoryPlayer inv=new CraftInventoryPlayer(new InventoryPlayer(cp.getHandle()));
  inv.clear();
  try {
switch (itemList.size()) {
case 1:
      for (int i=0; i < 36; i++)       inv.addItem(getItem(itemList.get(0).toString()));
    break;
case 2:
  for (int i=0; i < 18; i++)   inv.addItem(getItem(itemList.get(0).toString()));
for (int i=0; i < 18; i++) inv.addItem(getItem(itemList.get(1).toString()));
break;
case 3:
for (int i=0; i < 4; i++) {
inv.setItem((i * 9),getItem(itemList.get(0).toString()));
inv.setItem((i * 9) + 1,getItem(itemList.get(0).toString()));
inv.setItem((i * 9) + 2,getItem(itemList.get(0).toString()));
inv.setItem((i * 9) + 3,getItem(itemList.get(1).toString()));
inv.setItem((i * 9) + 4,getItem(itemList.get(1).toString()));
inv.setItem((i * 9) + 5,getItem(itemList.get(1).toString()));
inv.setItem((i * 9) + 6,getItem(itemList.get(2).toString()));
inv.setItem((i * 9) + 7,getItem(itemList.get(2).toString()));
inv.setItem((i * 9) + 8,getItem(itemList.get(2).toString()));
}
break;
case 4:
for (int i=0; i < 4; i++) for (int j=0; j < 9; j++) inv.setItem((i * 9) + j,getItem(itemList.get(i).toString()));
break;
case 5:
for (int i=0; i < 4; i++) for (int j=0; j < 7; j++) inv.setItem((i * 9) + j,getItem(itemList.get(i).toString()));
for (int k=0; k < 4; k++) {
inv.setItem((k * 9) + 7,getItem(itemList.get(4).toString()));
inv.setItem((k * 9) + 8,getItem(itemList.get(4).toString()));
}
break;
case 6:
for (int i=0; i < 2; i++) {
inv.setItem((i * 9),getItem(itemList.get(0).toString()));
inv.setItem((i * 9) + 1,getItem(itemList.get(0).toString()));
inv.setItem((i * 9) + 2,getItem(itemList.get(0).toString()));
inv.setItem((i * 9) + 3,getItem(itemList.get(1).toString()));
inv.setItem((i * 9) + 4,getItem(itemList.get(1).toString()));
inv.setItem((i * 9) + 5,getItem(itemList.get(1).toString()));
inv.setItem((i * 9) + 6,getItem(itemList.get(2).toString()));
inv.setItem((i * 9) + 7,getItem(itemList.get(2).toString()));
inv.setItem((i * 9) + 8,getItem(itemList.get(2).toString()));
}
for (int i=2; i < 4; i++) {
inv.setItem((i * 9),getItem(itemList.get(3).toString()));
inv.setItem((i * 9) + 1,getItem(itemList.get(3).toString()));
inv.setItem((i * 9) + 2,getItem(itemList.get(3).toString()));
inv.setItem((i * 9) + 3,getItem(itemList.get(4).toString()));
inv.setItem((i * 9) + 4,getItem(itemList.get(4).toString()));
inv.setItem((i * 9) + 5,getItem(itemList.get(4).toString()));
inv.setItem((i * 9) + 6,getItem(itemList.get(5).toString()));
inv.setItem((i * 9) + 7,getItem(itemList.get(5).toString()));
inv.setItem((i * 9) + 8,getItem(itemList.get(5).toString()));
}
break;
case 7:
for (int i=0; i < 7; i++) {
int jmax;
if (i % 2 == 0) jmax=5;
 else jmax=4;
for (int j=0; j < jmax; j++) inv.addItem(getItem(itemList.get(i).toString()));
}
break;
case 8:
for (int i=0; i < 4; i++) {
inv.addItem(getItem(itemList.get((2 * i)).toString()));
inv.addItem(getItem(itemList.get((2 * i)).toString()));
inv.addItem(getItem(itemList.get((2 * i)).toString()));
inv.addItem(getItem(itemList.get((2 * i)).toString()));
inv.addItem(getItem(itemList.get((2 * i) + 1).toString()));
inv.addItem(getItem(itemList.get((2 * i) + 1).toString()));
inv.addItem(getItem(itemList.get((2 * i) + 1).toString()));
inv.addItem(getItem(itemList.get((2 * i) + 1).toString()));
inv.addItem(getItem(itemList.get((2 * i) + 1).toString()));
}
break;
case 9:
for (int j=0; j < 4; j++) for (int i=0; i < 9; i++) inv.addItem(getItem(itemList.get(i).toString()));
break;
case 10:
case 11:
case 12:
for (int i=0; i < itemList.size(); i++) for (int j=0; j < 3; j++) inv.addItem(getItem(itemList.get(i).toString()));
break;
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
int pos;
for (int i=0; i < itemList.size(); i++) {
if (i < 9) pos=i;
 else pos=i + 9;
inv.setItem(pos,getItem(itemList.get(i).toString()));
inv.setItem(pos + 9,getItem(itemList.get(i).toString()));
}
break;
default :
for (int i=0; i < itemList.size(); i++) inv.setItem(i,getItem(itemList.get(i).toString()));
}
}
 catch (Exception e) {
System.out.println("String_Node_Str" + e.getMessage());
}
IInventory ii=(IInventory)inv.getInventory();
cp.getHandle().a(ii);
}