Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =============================================
- Index: RequestBypassToServer
- + else if (_command.startsWith("droplist"))
- + {
- + StringTokenizer st = new StringTokenizer(_command, " ");
- + st.nextToken();
- +
- + int npcId = Integer.parseInt(st.nextToken());
- + int page = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 1;
- +
- + if (st.hasMoreTokens())
- + activeChar.ignored(Integer.parseInt(st.nextToken()));
- +
- + L2Npc.sendNpcDrop(activeChar, npcId, page);
- + }
- =============================================
- Index: L2Npc
- + public static void sendNpcDrop(Player player, int npcId, int page)
- + {
- + final int ITEMS_PER_LIST = 7;
- + final NpcTemplate npc = NpcTable.getInstance().getTemplate(npcId);
- + if (npc == null)
- + return;
- +
- + if (npc.getDropData().isEmpty())
- + {
- + player.sendMessage("This target have not drop info.");
- + return;
- + }
- +
- + final List<DropCategory> list = new ArrayList<>();
- + npc.getDropData().forEach(c -> list.add(c));
- + Collections.reverse(list);
- +
- + int myPage = 1;
- + int i = 0;
- + int shown = 0;
- + boolean hasMore = false;
- +
- + final StringBuilder sb = new StringBuilder();
- + for (DropCategory cat : list)
- + {
- + if (shown == ITEMS_PER_LIST)
- + {
- + hasMore = true;
- + break;
- + }
- +
- + for (DropData drop : cat.getAllDrops())
- + {
- + double chance = (drop.getItemId() == 57 ? drop.getChance() * Config.RATE_DROP_ADENA : drop.getChance() * Config.RATE_DROP_ITEMS) / 10000;
- + chance = chance > 100 ? 100 : chance;
- +
- + String percent = null;
- + if (chance <= 0.001)
- + {
- + DecimalFormat df = new DecimalFormat("#.####");
- + percent = df.format(chance);
- + }
- + else if (chance <= 0.01)
- + {
- + DecimalFormat df = new DecimalFormat("#.###");
- + percent = df.format(chance);
- + }
- + else
- + {
- + DecimalFormat df = new DecimalFormat("##.##");
- + percent = df.format(chance);
- + }
- +
- + Item item = ItemTable.getInstance().getTemplate(drop.getItemId());
- + String name = item.getName();
- +
- + if (name.startsWith("Recipe: "))
- + name = "R: " + name.substring(8);
- +
- + if (name.length() >= 40)
- + name = name.substring(0, 37) + "...";
- +
- + if (myPage != page)
- + {
- + i++;
- + if (i == ITEMS_PER_LIST)
- + {
- + myPage++;
- + i = 0;
- + }
- + continue;
- + }
- +
- + if (shown == ITEMS_PER_LIST)
- + {
- + hasMore = true;
- + break;
- + }
- +
- + String check = player.ignoredDropContain(item.getItemId()) ? "L2UI.CheckBox" : "L2UI.CheckBox_checked";
- + sb.append("<table width=280 bgcolor=000000><tr>");
- + sb.append("<td width=44 height=41 align=center><table bgcolor=" + (cat.isSweep() ? "FF00FF" : "FFFFFF") + " cellpadding=6 cellspacing=\"-5\"><tr><td><button width=32 height=32 back=" +IconTable.getIcon(item.getItemId())+ " fore=" +IconTable.getIcon(item.getItemId())+ "></td></tr></table></td>");
- + sb.append("<td width=240>" + (cat.isSweep() ? "<font color=ff00ff>" + name + "</font>" : name) + "<br1><font color=B09878>" + (cat.isSweep() ? "Spoil" : "Drop") + " Chance : " + percent + "%</font></td>");
- + sb.append("<td width=20><button action=\"bypass droplist " + npcId + " " + page + " " + item.getItemId() + "\" width=12 height=12 back=\"" + check + "\" fore=\"" + check + "\"/></td>");
- + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>");
- + shown++;
- + }
- + }
- + sb.append("<img height=" + (294 - (shown * 42)) + ">");
- + sb.append("<img height=8><img src=L2UI.SquareGray width=280 height=1>");
- + sb.append("<table width=280 bgcolor=000000><tr>");
- + sb.append("<td align=center width=70>" + (page > 1 ? "<button value=\"< PREV\" action=\"bypass droplist " + npcId + " " + (page - 1) + "\" width=65 height=19 back=L2UI_ch3.smallbutton2_over fore=L2UI_ch3.smallbutton2>" : "") + "</td>");
- + sb.append("<td align=center width=140>Page " + page + "</td>");
- + sb.append("<td align=center width=70>" + (hasMore ? "<button value=\"NEXT >\" action=\"bypass droplist " + npcId + " " + (page + 1) + "\" width=65 height=19 back=L2UI_ch3.smallbutton2_over fore=L2UI_ch3.smallbutton2>" : "") + "</td>");
- + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>");
- +
- + final NpcHtmlMessage html = new NpcHtmlMessage(200);
- + html.setFile("data/html/droplist.htm");
- + html.replace("%list%", sb.toString());
- + html.replace("%name%", npc.getName());
- + player.sendPacket(html);
- + }
- @Override
- public void onActionShift(Player player)
- {
- +else if (this instanceof L2MonsterInstance || this instanceof L2RaidBossInstance || this instanceof L2GrandBossInstance || this instanceof L2ChestInstance)
- +sendNpcDrop(player, getTemplate().getNpcId(), 1);
- if (player.getTarget() != this)
- {
- // Set the target of the Player player
- player.setTarget(this);
- ===============================================
- Index: data/html/droplist.htm
- +<html><title>Droplist : %name%</title><body><img height=14>
- +<font color=B09878>* NOTE : Uncheck to ignore specific drop.</font>
- +<img src=L2UI.SquareGray width=280 height=1>
- +%list%
- +</body></html>
Add Comment
Please, Sign In to add comment