Program: 51660
Project: 51660
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(),config.getItemManagement(6))) {
        if (isSellModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_SELL);
        if (isBuyModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 2,config.getItemManagement(2));
        getInventory().setItem(getInventory().getSize() - 3,(getBasicManageModeByWool().equals(TraderStatus.MANAGE_SELL) ? config.getItemManagement(5) : config.getItemManagement(3)));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(2))) {
        this.setTraderStatus(TraderStatus.MANAGE_PRICE);
        getInventory().setItem(getInventory().getSize() - 2,config.getItemManagement(6));
        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(),config.getItemManagement(5))) {
        p.sendMessage(ChatColor.RED + "String_Node_Str");
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(3))) {
        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(),config.getItemManagement(1))) {
        switchInventory(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 1,config.getItemManagement(0));
        getInventory().setItem(getInventory().getSize() - 3,config.getItemManagement(3));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(0))) {
        switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,config.getItemManagement(1));
        getInventory().setItem(getInventory().getSize() - 3,config.getItemManagement(5));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(7))) {
        this.switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,config.getItemManagement(1));
        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()) {
            if (event.isLeftClick()) {
              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 {
              switchInventory(getSelectedItem());
              setTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT);
            }
          }
        }
 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)) {
        event.setCancelled(true);
        if (event.isLeftClick()) {
          if (event.getCurrentItem().getType().equals(Material.AIR)) {
            ItemStack clonedStack=getSelectedItem().getItemStack().clone();
            clonedStack.setAmount(1);
            getInventory().setItem(clickedSlot,clonedStack);
          }
 else {
            int addAmount=event.getCursor().getAmount();
            int oldAmount=event.getCurrentItem().getAmount();
            if (event.getCurrentItem().getMaxStackSize() < oldAmount + addAmount)             event.getCurrentItem().setAmount(event.getCurrentItem().getMaxStackSize());
 else             event.getCurrentItem().setAmount(oldAmount + addAmount);
          }
        }
 else {
          int removeAmount=event.getCursor().getAmount();
          int oldAmount=event.getCurrentItem().getAmount();
          if (oldAmount - removeAmount <= 0)           event.setCurrentItem(new ItemStack(Material.AIR,0));
 else           event.getCurrentItem().setAmount(oldAmount - removeAmount);
        }
      }
    }
  }
 else {
    if (equalsTraderStatus(TraderStatus.MANAGE_PRICE) || equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL) || equalsTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT)) {
      return;
    }
    event.setCancelled(true);
    if (hasSelectedItem()) {
      if (event.getCursor().getTypeId() != 0) {
        event.setCursor(null);
        selectItem(null);
        switchInventory(getBasicManageModeByWool());
      }
    }
    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;
      }
      if (equalsTraderStatus(TraderStatus.MANAGE_BUY))       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(),config.getItemManagement(6))) {
        if (isSellModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_SELL);
        if (isBuyModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 2,config.getItemManagement(2));
        getInventory().setItem(getInventory().getSize() - 3,(getBasicManageModeByWool().equals(TraderStatus.MANAGE_SELL) ? config.getItemManagement(5) : config.getItemManagement(3)));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(2))) {
        this.setTraderStatus(TraderStatus.MANAGE_PRICE);
        getInventory().setItem(getInventory().getSize() - 2,config.getItemManagement(6));
        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(),config.getItemManagement(5))) {
        p.sendMessage(ChatColor.RED + "String_Node_Str");
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(3))) {
        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(),config.getItemManagement(1))) {
        switchInventory(TraderStatus.MANAGE_BUY);
        getInventory().setItem(getInventory().getSize() - 1,config.getItemManagement(0));
        getInventory().setItem(getInventory().getSize() - 3,config.getItemManagement(3));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(0))) {
        switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,config.getItemManagement(1));
        getInventory().setItem(getInventory().getSize() - 3,config.getItemManagement(5));
        p.sendMessage(locale.getMessage("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),config.getItemManagement(7))) {
        this.saveManagedAmouts();
        this.switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,config.getItemManagement(1));
        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()) {
            if (event.isLeftClick()) {
              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 {
              switchInventory(getSelectedItem());
              setTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT);
            }
          }
        }
 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)) {
        event.setCancelled(true);
        if (event.isLeftClick()) {
          if (event.getCurrentItem().getType().equals(Material.AIR)) {
            ItemStack clonedStack=getSelectedItem().getItemStack().clone();
            getInventory().setItem(clickedSlot,clonedStack);
            event.setCancelled(false);
          }
 else {
            int addAmount=event.getCursor().getAmount();
            int oldAmount=event.getCurrentItem().getAmount();
            if (event.getCurrentItem().getMaxStackSize() < oldAmount + addAmount)             event.getCurrentItem().setAmount(event.getCurrentItem().getMaxStackSize());
 else             event.getCurrentItem().setAmount(oldAmount + addAmount);
          }
        }
 else {
          if (event.getCurrentItem().getTypeId() == 0) {
            return;
          }
          int removeAmount=event.getCursor().getAmount();
          int oldAmount=event.getCurrentItem().getAmount();
          if (oldAmount - removeAmount <= 0)           event.setCurrentItem(new ItemStack(Material.AIR,0));
 else           event.getCurrentItem().setAmount(oldAmount - removeAmount);
        }
      }
    }
  }
 else {
    if (equalsTraderStatus(TraderStatus.MANAGE_PRICE) || equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL) || equalsTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT)) {
      return;
    }
    event.setCancelled(true);
    if (hasSelectedItem()) {
      if (event.getCursor().getTypeId() != 0) {
        event.setCursor(null);
        selectItem(null);
        switchInventory(getBasicManageModeByWool());
      }
    }
    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;
      }
      if (equalsTraderStatus(TraderStatus.MANAGE_BUY))       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);
}