");
});
}
html.replace("%aggrolist%", sb.toString());
html.replace("%npc_name%", npc.getName());
html.replace("%npcId%", npc.getId());
html.replace("%objid%", npc.getObjectId());
activeChar.sendPacket(html);
}
public static String getDropListButtons(L2Npc npc)
{
final StringBuilder sb = new StringBuilder();
final Map> dropLists = npc.getTemplate().getDropLists();
if ((dropLists != null) && !dropLists.isEmpty() && (dropLists.containsKey(DropListScope.DEATH) || dropLists.containsKey(DropListScope.CORPSE)))
{
sb.append("
");
if (dropLists.containsKey(DropListScope.DEATH))
{
sb.append("
");
}
if (dropLists.containsKey(DropListScope.CORPSE))
{
sb.append("
");
}
sb.append("
");
}
return sb.toString();
}
public static void sendNpcDropList(L2PcInstance activeChar, L2Npc npc, DropListScope dropListScope, int page)
{
final List dropList = npc.getTemplate().getDropList(dropListScope);
if ((dropList == null) || dropList.isEmpty())
{
return;
}
int pages = dropList.size() / DROP_LIST_ITEMS_PER_PAGE;
if ((DROP_LIST_ITEMS_PER_PAGE * pages) < dropList.size())
{
pages++;
}
final StringBuilder pagesSb = new StringBuilder();
if (pages > 1)
{
pagesSb.append("
");
for (int i = 0; i < pages; i++)
{
pagesSb.append("
");
}
pagesSb.append("
");
}
if (page >= pages)
{
page = pages - 1;
}
final int start = page > 0 ? page * DROP_LIST_ITEMS_PER_PAGE : 0;
int end = (page * DROP_LIST_ITEMS_PER_PAGE) + DROP_LIST_ITEMS_PER_PAGE;
if (end > dropList.size())
{
end = dropList.size();
}
final DecimalFormat amountFormat = new DecimalFormat("#,###");
final DecimalFormat chanceFormat = new DecimalFormat("0.00##");
int leftHeight = 0;
int rightHeight = 0;
final StringBuilder leftSb = new StringBuilder();
final StringBuilder rightSb = new StringBuilder();
for (int i = start; i < end; i++)
{
final StringBuilder sb = new StringBuilder();
int height = 64;
final IDropItem dropItem = dropList.get(i);
if (dropItem instanceof GeneralDropItem)
{
final GeneralDropItem generalDropItem = (GeneralDropItem) dropItem;
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("
");
sb.append("
");
sb.append("");
sb.append("
");
sb.append(item.getName());
sb.append("
");
sb.append("
Amount:
");
sb.append("
");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("
");
}
else if (dropItem instanceof GroupedGeneralDropItem)
{
final GroupedGeneralDropItem generalGroupedDropItem = (GroupedGeneralDropItem) dropItem;
if (generalGroupedDropItem.getItems().size() == 1)
{
final GeneralDropItem generalDropItem = generalGroupedDropItem.getItems().get(0);
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("
");
sb.append("
");
sb.append("");
sb.append("
");
sb.append(item.getName());
sb.append("
");
sb.append("
Amount:
");
sb.append("
");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("
");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("
");
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/mods/NpcView/DropList.htm");
if (html == null)
{
_log.warning(NpcViewMod.class.getSimpleName() + ": The html file data/html/mods/NpcView/DropList.htm could not be found.");
return;
}
html = html.replaceAll("%name%", npc.getName());
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
html = html.replaceAll("%pages%", pagesSb.toString());
html = html.replaceAll("%items%", bodySb.toString());
Util.sendCBHtml(activeChar, html);
}
}