Program: 51622
Project: 51622
Buggy source:
@Override public void managerMode(InventoryClickEvent event){
  boolean top=event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot();
  DecimalFormat f=new DecimalFormat("String_Node_Str");
  int clickedSlot=event.getSlot();
  if (clickedSlot < 0) {
    event.setCursor(null);
    switchInventory(getBasicManageModeByWool());
    return;
  }
  if (top) {
    setInventoryClicked(true);
    if (isManagementSlot(clickedSlot,3)) {
      if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(6))) {
        if (isSellModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_SELL);
        if (isBuyModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_BUY);
        switchInventory(getBasicManageModeByWool(),"String_Node_Str");
        getInventory().setItem(getInventory().getSize() - 2,itemsConfig.getItemManagement(2));
        getInventory().setItem(getInventory().getSize() - 3,(getBasicManageModeByWool().equals(TraderStatus.MANAGE_SELL) ? itemsConfig.getItemManagement(4) : itemsConfig.getItemManagement(3)));
        player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(2))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          setTraderStatus(TraderStatus.MANAGE_PRICE);
          switchInventory(getBasicManageModeByWool(),"String_Node_Str");
          getInventory().setItem(getInventory().getSize() - 2,itemsConfig.getItemManagement(6));
          getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(3))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          setTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL);
          switchInventory(getBasicManageModeByWool(),"String_Node_Str");
          getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)0));
          getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(1))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          switchInventory(TraderStatus.MANAGE_BUY);
          getInventory().setItem(getInventory().getSize() - 1,itemsConfig.getItemManagement(0));
          getInventory().setItem(getInventory().getSize() - 3,itemsConfig.getItemManagement(3));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(0))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          switchInventory(TraderStatus.MANAGE_SELL);
          getInventory().setItem(getInventory().getSize() - 1,itemsConfig.getItemManagement(1));
          getInventory().setItem(getInventory().getSize() - 3,itemsConfig.getItemManagement(4));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(7))) {
        this.saveManagedAmouts();
        switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,itemsConfig.getItemManagement(1));
        player.sendMessage(localeManager.getLocaleString("String_Node_Str","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(leftAmount)) {
                if (isBuyModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                if (isSellModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                addAmountToInventory(leftAmount);
                getInventory().setItem(clickedSlot,new ItemStack(0));
                selectItem(null);
                player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
                player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str","String_Node_Str" + leftAmount));
              }
            }
 else {
              if (permissionsManager.has(player,"String_Node_Str")) {
                switchInventory(getSelectedItem());
                setTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT);
              }
 else               player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
            }
          }
        }
 else         if (isBuyModeByWool()) {
          if (selectItem(clickedSlot,TraderStatus.MANAGE_BUY).hasSelectedItem()) {
            int stockedAmount=getSelectedItem().getLimitSystem().getGlobalAmount();
            if (inventoryHasPlaceAmount(stockedAmount)) {
              if (event.isLeftClick()) {
                if (isBuyModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                if (isSellModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                getInventory().setItem(clickedSlot,new ItemStack(0));
                player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
                player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
              }
 else {
                player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
                getSelectedItem().getLimitSystem().setGlobalAmount(0);
              }
              addAmountToInventory(stockedAmount);
              selectItem(null);
            }
          }
        }
        return;
      }
      if (equalsTraderStatus(getBasicManageModeByWool())) {
        if (event.isRightClick()) {
          if (selectItem(event.getSlot(),getTraderStatus()).hasSelectedItem()) {
            if (!permissionsManager.has(player,"String_Node_Str")) {
              player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
              selectItem(null);
              event.setCancelled(true);
              return;
            }
            if (getSelectedItem().hasStackPrice()) {
              getSelectedItem().setStackPrice(false);
              player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
 else {
              getSelectedItem().setStackPrice(true);
              player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
            NBTTagEditor.removeDescription((CraftItemStack)event.getCurrentItem());
            TraderStockPart.setLore((CraftItemStack)event.getCurrentItem(),TraderStockPart.getManageLore(getSelectedItem(),getTraderStatus().name(),null,player));
          }
          selectItem(null);
          event.setCancelled(true);
          return;
        }
        if (hasSelectedItem()) {
          StockItem stockItem=getSelectedItem();
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
          stockItem.setSlot(clickedSlot);
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
        }
 else {
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
        }
        return;
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_PRICE)) {
        if (event.getCursor().getType().equals(Material.AIR)) {
          if (selectItem(event.getSlot(),getBasicManageModeByWool()).hasSelectedItem())           player.sendMessage(localeManager.getLocaleString("String_Node_Str","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()));
            NBTTagEditor.removeDescription((CraftItemStack)event.getCurrentItem());
            TraderStockPart.setLore((CraftItemStack)event.getCurrentItem(),TraderStockPart.getPriceLore(getSelectedItem(),getTraderStatus().name(),null,player));
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","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()) {
            player.sendMessage(localeManager.getLocaleString("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()));
            NBTTagEditor.removeDescription((CraftItemStack)event.getCurrentItem());
            TraderStockPart.setLore((CraftItemStack)event.getCurrentItem(),TraderStockPart.getLimitLore(getSelectedItem(),getTraderStatus().name(),null,player));
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","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);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
 else {
            int addAmount=event.getCursor().getAmount();
            if (event.getCursor().getTypeId() == 0)             addAmount=1;
            int oldAmount=event.getCurrentItem().getAmount();
            if (event.getCurrentItem().getMaxStackSize() < oldAmount + addAmount)             event.getCurrentItem().setAmount(event.getCurrentItem().getMaxStackSize());
 else             event.getCurrentItem().setAmount(oldAmount + addAmount);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
        }
 else {
          if (event.getCurrentItem().getTypeId() == 0) {
            return;
          }
          int removeAmount=event.getCursor().getAmount();
          if (event.getCursor().getTypeId() == 0)           removeAmount=1;
          int oldAmount=event.getCurrentItem().getAmount();
          if (oldAmount - removeAmount <= 0) {
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
            event.setCurrentItem(new ItemStack(Material.AIR,0));
          }
 else {
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
            event.getCurrentItem().setAmount(oldAmount - removeAmount);
          }
        }
      }
    }
  }
 else {
    if (equalsTraderStatus(TraderStatus.MANAGE_PRICE) || equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL) || equalsTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT)) {
      if (event.isShiftClick())       event.setCancelled(true);
      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()) {
        player.sendMessage(localeManager.getLocaleString("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.setAsPatternItem(false);
        stockItem.setPetternListening(false);
        stockItem.setSlot(firstEmpty);
        LimitSystem limitSystem=stockItem.getLimitSystem();
        limitSystem.setGlobalLimit(0);
        limitSystem.setGlobalTimeout(-2000);
        if (isSellModeByWool())         getStock().addItem("String_Node_Str",stockItem);
        if (isBuyModeByWool())         getStock().addItem("String_Node_Str",stockItem);
        itemToAdd.setAmount(backUpAmount);
        player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
      }
    }
 else     if (event.getCurrentItem().getTypeId() != 0) {
      if (!event.isShiftClick()) {
        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());
        player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str",itemToAdd.getAmount() + "String_Node_Str").replace((itemToAdd.getAmount() != 1 ? "String_Node_Str" : "String_Node_Str"),"String_Node_Str"));
        itemToAdd.setAmount(0);
        event.setCurrentItem(itemToAdd);
        limitSystem.setGlobalAmount(0);
        selectItem(null);
      }
 else {
        player.sendMessage(localeManager.getLocaleString("String_Node_Str"));
      }
    }
  }
  setInventoryClicked(false);
}

Fixed version (ground truth):
@Override public void managerMode(InventoryClickEvent event){
  boolean top=event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot();
  DecimalFormat f=new DecimalFormat("String_Node_Str");
  int clickedSlot=event.getSlot();
  if (clickedSlot < 0) {
    event.setCursor(null);
    switchInventory(getBasicManageModeByWool());
    return;
  }
  if (top) {
    setInventoryClicked(true);
    if (isManagementSlot(clickedSlot,3)) {
      if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(6))) {
        if (isSellModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_SELL);
        if (isBuyModeByWool())         this.setTraderStatus(TraderStatus.MANAGE_BUY);
        switchInventory(getBasicManageModeByWool(),"String_Node_Str");
        getInventory().setItem(getInventory().getSize() - 2,itemsConfig.getItemManagement(2));
        getInventory().setItem(getInventory().getSize() - 3,(getBasicManageModeByWool().equals(TraderStatus.MANAGE_SELL) ? itemsConfig.getItemManagement(4) : itemsConfig.getItemManagement(3)));
        player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(2))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          setTraderStatus(TraderStatus.MANAGE_PRICE);
          switchInventory(getBasicManageModeByWool(),"String_Node_Str");
          getInventory().setItem(getInventory().getSize() - 2,itemsConfig.getItemManagement(6));
          getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(3))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          setTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL);
          switchInventory(getBasicManageModeByWool(),"String_Node_Str");
          getInventory().setItem(getInventory().getSize() - 2,new ItemStack(Material.WOOL,1,(short)0,(byte)0));
          getInventory().setItem(getInventory().getSize() - 3,new ItemStack(Material.AIR));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(1))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          switchInventory(TraderStatus.MANAGE_BUY);
          getInventory().setItem(getInventory().getSize() - 1,itemsConfig.getItemManagement(0));
          getInventory().setItem(getInventory().getSize() - 3,itemsConfig.getItemManagement(3));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(0))) {
        if (!permissionsManager.has(player,"String_Node_Str")) {
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
 else {
          switchInventory(TraderStatus.MANAGE_SELL);
          getInventory().setItem(getInventory().getSize() - 1,itemsConfig.getItemManagement(1));
          getInventory().setItem(getInventory().getSize() - 3,itemsConfig.getItemManagement(4));
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
        }
      }
 else       if (isWool(event.getCurrentItem(),itemsConfig.getItemManagement(7))) {
        this.saveManagedAmouts();
        switchInventory(TraderStatus.MANAGE_SELL);
        getInventory().setItem(getInventory().getSize() - 1,itemsConfig.getItemManagement(1));
        player.sendMessage(localeManager.getLocaleString("String_Node_Str","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(leftAmount)) {
                if (isBuyModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                if (isSellModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                addAmountToInventory(leftAmount);
                getInventory().setItem(clickedSlot,new ItemStack(0));
                selectItem(null);
                player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
                player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str","String_Node_Str" + leftAmount));
              }
            }
 else {
              if (permissionsManager.has(player,"String_Node_Str")) {
                switchInventory(getSelectedItem());
                setTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT);
              }
 else               player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
            }
          }
        }
 else         if (isBuyModeByWool()) {
          if (selectItem(clickedSlot,TraderStatus.MANAGE_BUY).hasSelectedItem()) {
            int stockedAmount=getSelectedItem().getLimitSystem().getGlobalAmount();
            if (inventoryHasPlaceAmount(stockedAmount)) {
              if (event.isLeftClick()) {
                if (isBuyModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                if (isSellModeByWool())                 getStock().removeItem("String_Node_Str",clickedSlot);
                getInventory().setItem(clickedSlot,new ItemStack(0));
                player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
                player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
              }
 else {
                player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str","String_Node_Str" + stockedAmount));
                getSelectedItem().getLimitSystem().setGlobalAmount(0);
              }
              addAmountToInventory(stockedAmount);
              selectItem(null);
            }
          }
        }
        return;
      }
      if (equalsTraderStatus(getBasicManageModeByWool())) {
        if (event.isRightClick()) {
          if (selectItem(event.getSlot(),getTraderStatus()).hasSelectedItem()) {
            if (!permissionsManager.has(player,"String_Node_Str")) {
              player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","String_Node_Str"));
              selectItem(null);
              event.setCancelled(true);
              return;
            }
            if (getSelectedItem().hasStackPrice()) {
              getSelectedItem().setStackPrice(false);
              player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
 else {
              getSelectedItem().setStackPrice(true);
              player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str"));
            }
            NBTTagEditor.removeDescription((CraftItemStack)event.getCurrentItem());
            TraderStockPart.setLore((CraftItemStack)event.getCurrentItem(),TraderStockPart.getManageLore(getSelectedItem(),getTraderStatus().name(),null,player));
          }
          selectItem(null);
          event.setCancelled(true);
          return;
        }
        if (hasSelectedItem()) {
          StockItem stockItem=getSelectedItem();
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
          stockItem.setSlot(clickedSlot);
          player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
        }
 else {
          if (selectItem(clickedSlot,getTraderStatus()).hasSelectedItem()) {
            getSelectedItem().setSlot(-2);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
        }
        return;
      }
 else       if (equalsTraderStatus(TraderStatus.MANAGE_PRICE)) {
        if (event.getCursor().getType().equals(Material.AIR)) {
          if (selectItem(event.getSlot(),getBasicManageModeByWool()).hasSelectedItem())           player.sendMessage(localeManager.getLocaleString("String_Node_Str","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()));
            NBTTagEditor.removeDescription((CraftItemStack)event.getCurrentItem());
            TraderStockPart.setLore((CraftItemStack)event.getCurrentItem(),TraderStockPart.getPriceLore(getSelectedItem(),getBasicManageModeByWool().toString(),null,player));
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str","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()) {
            player.sendMessage(localeManager.getLocaleString("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()));
            NBTTagEditor.removeDescription((CraftItemStack)event.getCurrentItem());
            TraderStockPart.setLore((CraftItemStack)event.getCurrentItem(),TraderStockPart.getLimitLore(getSelectedItem(),getTraderStatus().name(),null,player));
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","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);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
 else {
            int addAmount=event.getCursor().getAmount();
            if (event.getCursor().getTypeId() == 0)             addAmount=1;
            int oldAmount=event.getCurrentItem().getAmount();
            if (event.getCurrentItem().getMaxStackSize() < oldAmount + addAmount)             event.getCurrentItem().setAmount(event.getCurrentItem().getMaxStackSize());
 else             event.getCurrentItem().setAmount(oldAmount + addAmount);
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
          }
        }
 else {
          if (event.getCurrentItem().getTypeId() == 0) {
            return;
          }
          int removeAmount=event.getCursor().getAmount();
          if (event.getCursor().getTypeId() == 0)           removeAmount=1;
          int oldAmount=event.getCurrentItem().getAmount();
          if (oldAmount - removeAmount <= 0) {
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
            event.setCurrentItem(new ItemStack(Material.AIR,0));
          }
 else {
            player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
            event.getCurrentItem().setAmount(oldAmount - removeAmount);
          }
        }
      }
    }
  }
 else {
    if (equalsTraderStatus(TraderStatus.MANAGE_PRICE) || equalsTraderStatus(TraderStatus.MANAGE_LIMIT_GLOBAL) || equalsTraderStatus(TraderStatus.MANAGE_SELL_AMOUNT)) {
      if (event.isShiftClick())       event.setCancelled(true);
      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()) {
        player.sendMessage(localeManager.getLocaleString("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.setAsPatternItem(false);
        stockItem.setPetternListening(false);
        stockItem.setSlot(firstEmpty);
        LimitSystem limitSystem=stockItem.getLimitSystem();
        limitSystem.setGlobalLimit(0);
        limitSystem.setGlobalTimeout(-2000);
        if (isSellModeByWool())         getStock().addItem("String_Node_Str",stockItem);
        if (isBuyModeByWool())         getStock().addItem("String_Node_Str",stockItem);
        itemToAdd.setAmount(backUpAmount);
        player.sendMessage(localeManager.getLocaleString("String_Node_Str","String_Node_Str"));
      }
    }
 else     if (event.getCurrentItem().getTypeId() != 0) {
      if (!event.isShiftClick()) {
        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());
        player.sendMessage(localeManager.getLocaleString("String_Node_Str").replace("String_Node_Str",itemToAdd.getAmount() + "String_Node_Str").replace((itemToAdd.getAmount() != 1 ? "String_Node_Str" : "String_Node_Str"),"String_Node_Str"));
        itemToAdd.setAmount(0);
        event.setCurrentItem(itemToAdd);
        limitSystem.setGlobalAmount(0);
        selectItem(null);
      }
 else {
        player.sendMessage(localeManager.getLocaleString("String_Node_Str"));
      }
    }
  }
  setInventoryClicked(false);
}