Program: 51671
Project: 51671
Buggy source:
@Override public void managerMode(InventoryClickEvent event){
  boolean top=event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot();
  Player p=(Player)event.getWhoClicked();
  DecimalFormat f=new DecimalFormat("String_Node_Str");
  int clickedSlot=event.getSlot();
  if (top) {
    setInventoryClicked(true);
    if (isManagementSlot(clickedSlot,3)) {
      if (isWool(event.getCurrentItem(),(byte)0)) {
        if (isSellModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_SELL);
        if (isBuyModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)15));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.WOOL,1,(short)0,(byte)(getBasicManageModeByWool().equals(TraderStatus.MANAGE_SELL) ? 11 : 12)));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)15)) {
        this.setTraderStatus(TraderStatus.MANAGE_PRICE);
        getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)0));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)11)) {
        p.sendMessage(ChatColor.RED + "String_Node_Str");
      }
 else       if (isWool(event.getCurrentItem(),(byte)12)) {
        p.sendMessage(ChatColor.RED + "String_Node_Str");
        setTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL);
        getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)0));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
      }
 else       if (isWool(event.getCurrentItem(),(byte)5)) {
        switchInventory(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 1,new ItemStack(Material.WOOL,1,(short)0,(byte)3));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.WOOL,1,(short)0,(byte)12));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)3)) {
        switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,new ItemStack(Material.WOOL,1,(short)0,(byte)5));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.WOOL,1,(short)0,(byte)11));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)2)) {
        this.setTraderStatus(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,new ItemStack(Material.WOOL,1,(short)0,(byte)5));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
      event.setCancelled(true);
      return;
    }
 else {
      if (event.isShiftClick()) {
        event.setCancelled(true);
        if (isSellModeByWool()) {
          if (selectItem(clickedSlot,TraderStatus.MANAGE_SELL).hasSelectedItem()) {
            int leftAmount=getSelectedItem().getLimitSystem().getGlobalLimit() - getSelectedItem().getLimitSystem().getGlobalAmount();
            if (inventoryHasPlaceAmount(p,leftAmount)) {
              if (isBuyModeByWool())               getTraderStock().removeItem(false,clickedSlot);
              if (isSellModeByWool())               getTraderStock().removeItem(true,clickedSlot);
              this.addAmountToInventory(p,leftAmount);
              getInventory().setItem(clickedSlot,new ItemStack(0));
              selectItem(null);
              p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str" + leftAmount));
            }
          }
        }
 else         if (isBuyModeByWool()) {
          if (selectItem(clickedSlot,TraderStatus.MANAGE_BUY).hasSelectedItem()) {
            int stockedAmount=getSelectedItem().getLimitSystem().getGlobalAmount();
            if (inventoryHasPlaceAmount(p,stockedAmount)) {
              if (event.isLeftClick()) {
                if (isBuyModeByWool())                 getTraderStock().removeItem(false,clickedSlot);
                if (isSellModeByWool())                 getTraderStock().removeItem(true,clickedSlot);
                getInventory().setItem(clickedSlot,new ItemStack(0));
                p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
              }
 else {
                p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
              }
              this.addAmountToInventory(p,stockedAmount);
              selectItem(null);
            }
          }
        }
      }
      if (equalsTraderStatus(getBasicManageModeByWool())) {
        if (event.isRightClick()) {
          if (selectItem(event.getSlot(),getTraderStatus()).hasSelectedItem()) {
            if (getSelectedItem().hasStackPrice()) {
              getSelectedItem().setStackPrice(false);
              p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
 else {
              getSelectedItem().setStackPrice(true);
              p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
          }
          selectItem(null);
          event.setCancelled(true);
          return;
        }
        if (hasSelectedItem()) {
          StockItem stockItem=getSelectedItem();
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            p.sendMessage(locale.getMessage("String_Node_Str"));
          }
          stockItem.setSlot(clickedSlot);
        }
 else {
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            p.sendMessage(locale.getMessage("String_Node_Str"));
          }
        }
        return;
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_PRICE)) {
        if (event.getCursor().getType().equals(Material.AIR)) {
          if (selectItem(event.getSlot(),getBasicManageModeByWool()).hasSelectedItem())           p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str",f.format(getSelectedItem().getRawPrice())));
        }
 else {
          if (selectItem(event.getSlot(),getBasicManageModeByWool()).hasSelectedItem()) {
            if (event.isRightClick())             getSelectedItem().lowerPrice(calculatePrice(event.getCursor()));
 else             getSelectedItem().increasePrice(calculatePrice(event.getCursor()));
            p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str",f.format(getSelectedItem().getRawPrice())));
          }
        }
        selectItem(null);
        event.setCancelled(true);
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL)) {
        if (event.getCursor().getType().equals(Material.AIR)) {
          if (selectItem(clickedSlot,getBasicManageModeByWool()).hasSelectedItem()) {
            p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str" + getSelectedItem().getLimitSystem().getGlobalLimit()).replace("String_Node_Str","String_Node_Str" + getSelectedItem().getLimitSystem().getGlobalAmount()));
          }
        }
 else {
          if (selectItem(clickedSlot,getBasicManageModeByWool()).hasSelectedItem()) {
            if (event.isRightClick())             getSelectedItem().getLimitSystem().changeGlobalLimit(-calculateLimit(event.getCursor()));
 else             getSelectedItem().getLimitSystem().changeGlobalLimit(calculateLimit(event.getCursor()));
            p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str" + getSelectedItem().getLimitSystem().getGlobalLimit()));
          }
        }
        selectItem(null);
        event.setCancelled(true);
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_LIMIT_PLAYER)) {
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT)) {
      }
    }
  }
 else {
    if (equalsTraderStatus(TraderStatus.MANAGE_PRICE)) {
      return;
    }
    event.setCancelled(true);
    if (event.isLeftClick() && event.getCurrentItem().getTypeId() != 0) {
      int backUpAmount=event.getCurrentItem().getAmount();
      ItemStack itemToAdd=event.getCurrentItem();
      itemToAdd.setAmount(1);
      this.selectItem(itemToAdd,getBasicManageModeByWool(),false,false);
      if (hasSelectedItem()) {
        p.sendMessage(locale.getMessage("String_Node_Str"));
        itemToAdd.setAmount(backUpAmount);
        selectItem(null);
        setInventoryClicked(false);
        return;
      }
      int firstEmpty=getInventory().firstEmpty();
      if (firstEmpty >= 0 && firstEmpty < getInventory().getSize() - 3) {
        getInventory().setItem(firstEmpty,itemToAdd.clone());
        StockItem stockItem=toStockItem(itemToAdd.clone());
        stockItem.setSlot(firstEmpty);
        LimitSystem limitSystem=stockItem.getLimitSystem();
        limitSystem.setGlobalLimit(0);
        limitSystem.setGlobalTimeout(-2000);
        if (isSellModeByWool())         getTraderStock().addItem(true,stockItem);
        if (isBuyModeByWool())         getTraderStock().addItem(false,stockItem);
        itemToAdd.setAmount(backUpAmount);
        p.sendMessage(locale.getMessage("String_Node_Str"));
      }
    }
 else     if (event.getCurrentItem().getTypeId() != 0) {
      if (!event.isShiftClick()) {
        p.sendMessage(locale.getMessage("String_Node_Str"));
        selectItem(null);
        setInventoryClicked(false);
        return;
      }
      ItemStack itemToAdd=event.getCurrentItem();
      this.selectItem(itemToAdd,getBasicManageModeByWool(),false,false);
      if (hasSelectedItem()) {
        event.setCancelled(false);
        LimitSystem limitSystem=getSelectedItem().getLimitSystem();
        limitSystem.setGlobalTimeout(-2000);
        int getItemsLeft=limitSystem.getGlobalLimit() - limitSystem.getGlobalAmount();
        if (getItemsLeft < 0)         getItemsLeft=0;
        limitSystem.setGlobalLimit(getItemsLeft + itemToAdd.getAmount());
        itemToAdd.setAmount(0);
        event.setCurrentItem(itemToAdd);
        limitSystem.setGlobalAmount(0);
        p.sendMessage(locale.getMessage("String_Node_Str"));
        selectItem(null);
      }
 else {
        p.sendMessage(locale.getMessage("String_Node_Str"));
      }
    }
  }
  setInventoryClicked(false);
}

Fixed version (ground truth):
@Override public void managerMode(InventoryClickEvent event){
  boolean top=event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot();
  Player p=(Player)event.getWhoClicked();
  DecimalFormat f=new DecimalFormat("String_Node_Str");
  int clickedSlot=event.getSlot();
  if (top) {
    setInventoryClicked(true);
    if (isManagementSlot(clickedSlot,3)) {
      if (isWool(event.getCurrentItem(),(byte)0)) {
        if (isSellModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_SELL);
        if (isBuyModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)15));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.WOOL,1,(short)0,(byte)(getBasicManageModeByWool().equals(TraderStatus.MANAGE_SELL) ? 11 : 12)));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)15)) {
        this.setTraderStatus(TraderStatus.MANAGE_PRICE);
        getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)0));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)11)) {
        p.sendMessage(ChatColor.RED + "String_Node_Str");
      }
 else       if (isWool(event.getCurrentItem(),(byte)12)) {
        setTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL);
        getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)0));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)5)) {
        switchInventory(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 1,new ItemStack(Material.WOOL,1,(short)0,(byte)3));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.WOOL,1,(short)0,(byte)12));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)3)) {
        switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,new ItemStack(Material.WOOL,1,(short)0,(byte)5));
        getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.WOOL,1,(short)0,(byte)11));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),(byte)2)) {
        this.setTraderStatus(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,new ItemStack(Material.WOOL,1,(short)0,(byte)5));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
      event.setCancelled(true);
      return;
    }
 else {
      if (event.isShiftClick()) {
        event.setCancelled(true);
        if (isSellModeByWool()) {
          if (selectItem(clickedSlot,TraderStatus.MANAGE_SELL).hasSelectedItem()) {
            int leftAmount=getSelectedItem().getLimitSystem().getGlobalLimit() - getSelectedItem().getLimitSystem().getGlobalAmount();
            if (inventoryHasPlaceAmount(p,leftAmount)) {
              if (isBuyModeByWool())               getTraderStock().removeItem(false,clickedSlot);
              if (isSellModeByWool())               getTraderStock().removeItem(true,clickedSlot);
              this.addAmountToInventory(p,leftAmount);
              getInventory().setItem(clickedSlot,new ItemStack(0));
              selectItem(null);
              p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str" + leftAmount));
            }
          }
        }
 else         if (isBuyModeByWool()) {
          if (selectItem(clickedSlot,TraderStatus.MANAGE_BUY).hasSelectedItem()) {
            int stockedAmount=getSelectedItem().getLimitSystem().getGlobalAmount();
            if (inventoryHasPlaceAmount(p,stockedAmount)) {
              if (event.isLeftClick()) {
                if (isBuyModeByWool())                 getTraderStock().removeItem(false,clickedSlot);
                if (isSellModeByWool())                 getTraderStock().removeItem(true,clickedSlot);
                getInventory().setItem(clickedSlot,new ItemStack(0));
                p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
              }
 else {
                p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
                getSelectedItem().getLimitSystem().setGlobalAmount(0);
              }
              this.addAmountToInventory(p,stockedAmount);
              selectItem(null);
            }
          }
        }
        return;
      }
      if (equalsTraderStatus(getBasicManageModeByWool())) {
        if (event.isRightClick()) {
          if (selectItem(event.getSlot(),getTraderStatus()).hasSelectedItem()) {
            if (getSelectedItem().hasStackPrice()) {
              getSelectedItem().setStackPrice(false);
              p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
 else {
              getSelectedItem().setStackPrice(true);
              p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
          }
          selectItem(null);
          event.setCancelled(true);
          return;
        }
        if (hasSelectedItem()) {
          StockItem stockItem=getSelectedItem();
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            p.sendMessage(locale.getMessage("String_Node_Str"));
          }
          stockItem.setSlot(clickedSlot);
        }
 else {
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            p.sendMessage(locale.getMessage("String_Node_Str"));
          }
        }
        return;
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_PRICE)) {
        if (event.getCursor().getType().equals(Material.AIR)) {
          if (selectItem(event.getSlot(),getBasicManageModeByWool()).hasSelectedItem())           p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str",f.format(getSelectedItem().getRawPrice())));
        }
 else {
          if (selectItem(event.getSlot(),getBasicManageModeByWool()).hasSelectedItem()) {
            if (event.isRightClick())             getSelectedItem().lowerPrice(calculatePrice(event.getCursor()));
 else             getSelectedItem().increasePrice(calculatePrice(event.getCursor()));
            p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str",f.format(getSelectedItem().getRawPrice())));
          }
        }
        selectItem(null);
        event.setCancelled(true);
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL)) {
        if (event.getCursor().getType().equals(Material.AIR)) {
          if (selectItem(clickedSlot,getBasicManageModeByWool()).hasSelectedItem()) {
            p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str" + getSelectedItem().getLimitSystem().getGlobalLimit()).replace("String_Node_Str","String_Node_Str" + getSelectedItem().getLimitSystem().getGlobalAmount()));
          }
        }
 else {
          if (selectItem(clickedSlot,getBasicManageModeByWool()).hasSelectedItem()) {
            if (event.isRightClick())             getSelectedItem().getLimitSystem().changeGlobalLimit(-calculateLimit(event.getCursor()));
 else             getSelectedItem().getLimitSystem().changeGlobalLimit(calculateLimit(event.getCursor()));
            p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str" + getSelectedItem().getLimitSystem().getGlobalLimit()));
          }
        }
        selectItem(null);
        event.setCancelled(true);
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_LIMIT_PLAYER)) {
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT)) {
      }
    }
  }
 else {
    if (equalsTraderStatus(TraderStatus.MANAGE_PRICE) || equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL)) {
      return;
    }
    event.setCancelled(true);
    if (event.isLeftClick() && event.getCurrentItem().getTypeId() != 0) {
      int backUpAmount=event.getCurrentItem().getAmount();
      ItemStack itemToAdd=event.getCurrentItem();
      itemToAdd.setAmount(1);
      this.selectItem(itemToAdd,getBasicManageModeByWool(),false,false);
      if (hasSelectedItem()) {
        p.sendMessage(locale.getMessage("String_Node_Str"));
        itemToAdd.setAmount(backUpAmount);
        selectItem(null);
        setInventoryClicked(false);
        return;
      }
      int firstEmpty=getInventory().firstEmpty();
      if (firstEmpty >= 0 && firstEmpty < getInventory().getSize() - 3) {
        getInventory().setItem(firstEmpty,itemToAdd.clone());
        StockItem stockItem=toStockItem(itemToAdd.clone());
        stockItem.setSlot(firstEmpty);
        LimitSystem limitSystem=stockItem.getLimitSystem();
        limitSystem.setGlobalLimit(0);
        limitSystem.setGlobalTimeout(-2000);
        if (isSellModeByWool())         getTraderStock().addItem(true,stockItem);
        if (isBuyModeByWool())         getTraderStock().addItem(false,stockItem);
        itemToAdd.setAmount(backUpAmount);
        p.sendMessage(locale.getMessage("String_Node_Str"));
      }
    }
 else     if (event.getCurrentItem().getTypeId() != 0) {
      if (!event.isShiftClick()) {
        p.sendMessage(locale.getMessage("String_Node_Str"));
        selectItem(null);
        setInventoryClicked(false);
        return;
      }
      ItemStack itemToAdd=event.getCurrentItem();
      this.selectItem(itemToAdd,getBasicManageModeByWool(),false,false);
      if (hasSelectedItem()) {
        event.setCancelled(false);
        LimitSystem limitSystem=getSelectedItem().getLimitSystem();
        limitSystem.setGlobalTimeout(-2000);
        int getItemsLeft=limitSystem.getGlobalLimit() - limitSystem.getGlobalAmount();
        if (getItemsLeft < 0)         getItemsLeft=0;
        limitSystem.setGlobalLimit(getItemsLeft + itemToAdd.getAmount());
        itemToAdd.setAmount(0);
        event.setCurrentItem(itemToAdd);
        limitSystem.setGlobalAmount(0);
        p.sendMessage(locale.getMessage("String_Node_Str"));
        selectItem(null);
      }
 else {
        p.sendMessage(locale.getMessage("String_Node_Str"));
      }
    }
  }
  setInventoryClicked(false);
}