catch (Exception e)
{
show("Incorrect data", player, npc);
return;
}
ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
if (template == null)
{
show("Error - itemId not specified.", player, npc);
return;
}
TreeMap<String, TreeMap<Long, Item>> tmpItems = getItems(type);
if (tmpItems == null)
{
show("Error - this type of subject matter is not.", player, npc);
return;
}
TreeMap<Long, Item> allItems = tmpItems.get(template.getName());
if (allItems == null)
{
show("Error - items with the same name found.", player, npc);
return;
}
StringBuilder out = new StringBuilder(200);
if (search == null)
{
listPageNum(out, type, itemType, returnPage, minEnchant, rare, "��");
}
else
{
findPageNum(out, type, returnPage, search, "��");
}
out.append(" ");
NavigableMap<Long, Item> sortedItems = type == Player.STORE_PRIVATE_BUY ? allItems.descendingMap() : allItems;
if (sortedItems == null)
{
show("Error - No results.", player, npc);
return;
}
List<Item> items = new ArrayList<>(sortedItems.size());
for (Item item : sortedItems.values())
{
if ((item == null) || (item.enchant < minEnchant) || ((rare > 0) && !item.rare))
{
continue;
}
items.add(item);
}
int totalPages = items.size();
totalPages = (totalPages / MAX_ITEMS_PER_PAGE) + ((totalPages % MAX_ITEMS_PER_PAGE) > 0 ? 1 : 0);
totalPages = Math.max(1, totalPages);
currentPage = Math.min(totalPages, Math.max(1, currentPage));
if (totalPages > 1)
{
int page = Math.max(1, Math.min((totalPages - MAX_PAGES_PER_LIST) + 1, currentPage - (MAX_PAGES_PER_LIST / 2)));
if (page > 1)
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, 1, returnPage, search, "1");
}
if (currentPage > 11)
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, currentPage - 10, returnPage, search, String.valueOf(currentPage - 10));
}
if (currentPage > 1)
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, currentPage - 1, returnPage, search, "<");
}
for (int count = 0; (count < MAX_PAGES_PER_LIST) && (page <= totalPages); count++, page++)
{
if (page == currentPage)
{
out.append(page).append(" ");
}
else
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, page, returnPage, search, String.valueOf(page));
}
}
if (currentPage < totalPages)
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, currentPage + 1, returnPage, search, ">");
}
if (currentPage < (totalPages - 10))
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, currentPage + 10, returnPage, search, String.valueOf(currentPage + 10));
}
if (page <= totalPages)
{
listForItemPageNum(out, type, itemId, minEnchant, rare, itemType, totalPages, returnPage, search, String.valueOf(totalPages));
}
}
out.append("<table width=100%>");
if (items.size() > 0)
{
int count = 0;
ListIterator<Item> iter = items.listIterator((currentPage - 1) * MAX_ITEMS_PER_PAGE);
while (iter.hasNext() && (count < MAX_ITEMS_PER_PAGE))
{
Item item = iter.next();
ItemTemplate temp = item.item != null ? item.item.getItem() : ItemHolder.getInstance().getTemplate(item.itemId);
if (temp == null)
{
continue;
}
out.append("<tr><td>");
out.append(temp.getIcon32());
out.append("</td><td><table width=100%><tr><td>[scripts_services.ItemBroker:path ");
out.append(type);
out.append(' ');
out.append(item.itemId);
out.append(' ');
out.append(item.itemObjId);
out.append('|');
out.append(item.name);
out.append("</td></tr><tr><td>price: ");
out.append(Util.formatAdena(item.price));
if (temp.isStackable())
{
out.append(", count: ").append(Util.formatAdena(item.count));
}
out.append(", owner: ").append(item.merchantName);
out.append("</td></tr></table></td></tr>");