Program: 10372
Project: 10372
Buggy source:
@Override public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
  dInventory inventory=(dInventory)scriptEntry.getObject("String_Node_Str");
  Element qty=scriptEntry.getElement("String_Node_Str");
  Type type=(Type)scriptEntry.getObject("String_Node_Str");
  dList list_of_items=(dList)scriptEntry.getObject("String_Node_Str");
  Object items_object=null;
  List<dItem> items=null;
  if (list_of_items != null)   items_object=list_of_items.filter(dItem.class);
  if (items_object != null)   items=(List<dItem>)items_object;
  dB.report(getName(),aH.debugObj("String_Node_Str",type.name()) + qty.debug() + inventory.debug()+ aH.debugObj("String_Node_Str",items));
switch (type) {
case INVENTORY:
    inventory.clear();
  break;
case ITEMINHAND:
int inHandAmt=scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getAmount();
int theAmount=qty.asInt();
ItemStack newHandItem=new ItemStack(0);
if (theAmount > inHandAmt) {
dB.echoDebug("String_Node_Str");
scriptEntry.getPlayer().getPlayerEntity().setItemInHand(newHandItem);
}
 else {
if (theAmount == inHandAmt) {
scriptEntry.getPlayer().getPlayerEntity().setItemInHand(newHandItem);
}
 else {
newHandItem=new ItemStack(scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getType(),inHandAmt - theAmount,scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getData().getData());
newHandItem.setItemMeta(scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getItemMeta());
scriptEntry.getPlayer().getPlayerEntity().setItemInHand(newHandItem);
scriptEntry.getPlayer().getPlayerEntity().updateInventory();
}
}
break;
case MONEY:
if (Depends.economy != null) {
dB.echoDebug("String_Node_Str" + qty.asDouble() + "String_Node_Str");
Depends.economy.withdrawPlayer(scriptEntry.getPlayer().getName(),qty.asDouble());
}
 else {
dB.echoError("String_Node_Str");
}
break;
case ITEM:
for (dItem item : items) {
ItemStack is=item.getItemStack();
if (is.getItemMeta() instanceof BookMeta) inventory.removeBook(is);
is.setAmount(qty.asInt());
if (!inventory.getInventory().removeItem(is).isEmpty()) dB.echoError("String_Node_Str" + qty.asInt() + "String_Node_Str"+ item.identify()+ "String_Node_Str");
}
break;
}
}

Fixed version (ground truth):
@Override public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
  dInventory inventory=(dInventory)scriptEntry.getObject("String_Node_Str");
  Element qty=scriptEntry.getElement("String_Node_Str");
  Type type=(Type)scriptEntry.getObject("String_Node_Str");
  Object items_object=((dList)scriptEntry.getObject("String_Node_Str")).filter(dItem.class);
  List<dItem> items=(List<dItem>)items_object;
  if (items_object != null)   items=(List<dItem>)items_object;
  dB.report(getName(),aH.debugObj("String_Node_Str",type.name()) + qty.debug() + inventory.debug()+ aH.debugObj("String_Node_Str",items));
switch (type) {
case INVENTORY:
    inventory.clear();
  break;
case ITEMINHAND:
int inHandAmt=scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getAmount();
int theAmount=qty.asInt();
ItemStack newHandItem=new ItemStack(0);
if (theAmount > inHandAmt) {
dB.echoDebug("String_Node_Str");
scriptEntry.getPlayer().getPlayerEntity().setItemInHand(newHandItem);
}
 else {
if (theAmount == inHandAmt) {
scriptEntry.getPlayer().getPlayerEntity().setItemInHand(newHandItem);
}
 else {
newHandItem=new ItemStack(scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getType(),inHandAmt - theAmount,scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getData().getData());
newHandItem.setItemMeta(scriptEntry.getPlayer().getPlayerEntity().getItemInHand().getItemMeta());
scriptEntry.getPlayer().getPlayerEntity().setItemInHand(newHandItem);
scriptEntry.getPlayer().getPlayerEntity().updateInventory();
}
}
break;
case MONEY:
if (Depends.economy != null) {
dB.echoDebug("String_Node_Str" + qty.asDouble() + "String_Node_Str");
Depends.economy.withdrawPlayer(scriptEntry.getPlayer().getName(),qty.asDouble());
}
 else {
dB.echoError("String_Node_Str");
}
break;
case ITEM:
for (dItem item : items) {
ItemStack is=item.getItemStack();
if (is.getItemMeta() instanceof BookMeta) inventory.removeBook(is);
is.setAmount(qty.asInt());
if (!inventory.getInventory().removeItem(is).isEmpty()) dB.echoError("String_Node_Str" + qty.asInt() + "String_Node_Str"+ item.identify()+ "String_Node_Str");
}
break;
}
}