Guest User

AdminEditNpc//l2jfrozen

a guest
Feb 10th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.86 KB | None | 0 0
  1. private void showNpcSkillList(L2PcInstance activeChar, int npcId, int page)
  2.     {
  3.         L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
  4.         if (npcData == null)
  5.         {
  6.             activeChar.sendMessage("Template id unknown: " + npcId);
  7.             return;
  8.         }
  9.        
  10.         Map<Integer, L2Skill> skills = npcData.getSkills();
  11.        
  12.         int _skillsize = Integer.valueOf(skills.size());
  13.        
  14.         int MaxSkillsPerPage = 10;
  15.         int MaxPages = _skillsize / MaxSkillsPerPage;
  16.         if (_skillsize > MaxSkillsPerPage * MaxPages)
  17.             MaxPages++;
  18.        
  19.         if (page > MaxPages)
  20.             page = MaxPages;
  21.        
  22.         int SkillsStart = MaxSkillsPerPage * page;
  23.         int SkillsEnd = _skillsize;
  24.         if (SkillsEnd - SkillsStart > MaxSkillsPerPage)
  25.             SkillsEnd = SkillsStart + MaxSkillsPerPage;
  26.        
  27.         NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  28.        
  29.         StringBuffer replyMSG = new StringBuffer("");
  30.         replyMSG.append("<html><title>" + npcData.getName() + " Skillist");
  31.         replyMSG.append(" (ID:" + npcData.getNpcId() + "Skills " + Integer.valueOf(_skillsize) + ")</title>");
  32.         replyMSG.append("<body>");
  33.         String pages = "<center><table width=270><tr>";
  34.         for (int x = 0; x < MaxPages; x++)
  35.         {
  36.             int pagenr = x + 1;
  37.             if (page == x)
  38.             {
  39.                 pages += "<td>Page " + pagenr + "</td>";
  40.             }
  41.             else
  42.             {
  43.                 pages += "<td><a action=\"bypass -h admin_show_skilllist_npc " + npcData.getNpcId() + " " + x + "\">Page " + pagenr + "</a></td>";
  44.             }
  45.         }
  46.         pages += "</tr></table></center>";
  47.         replyMSG.append(pages);
  48.        
  49.         replyMSG.append("<table width=270>");
  50.        
  51.         Set<Integer> skillset = skills.keySet();
  52.         Iterator<Integer> skillite = skillset.iterator();
  53.         Object skillobj = null;
  54.        
  55.         for (int i = 0; i < SkillsStart; i++)
  56.         {
  57.             if (skillite.hasNext())
  58.             {
  59.                 skillobj = skillite.next();
  60.             }
  61.         }
  62.        
  63.         int cnt = SkillsStart;
  64.         while (skillite.hasNext())
  65.         {
  66.             cnt++;
  67.             if (cnt > SkillsEnd)
  68.             {
  69.                 break;
  70.             }
  71.             skillobj = skillite.next();
  72.             replyMSG.append("<tr><td><a action=\"bypass -h admin_edit_skill_npc " + npcData.getNpcId() + " " + skills.get(skillobj).getId() + "\">" + skills.get(skillobj).getName() + " [" + skills.get(skillobj).getId() + "]" + "</a></td>" + "<td>" + skills.get(skillobj).getLevel() + "</td>" + "<td><a action=\"bypass -h admin_del_skill_npc " + npcData.getNpcId() + " " + skillobj + "\">Delete</a></td></tr>");
  73.            
  74.         }
  75.         replyMSG.append("</table>");
  76.         replyMSG.append("<br><br>");
  77.         replyMSG.append("<center>");
  78.         replyMSG.append("<button value=\"Add Skill\" action=\"bypass -h admin_add_skill_npc " + npcId + "\" width=100 height=20 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
  79.         replyMSG.append("<button value=\"Droplist\" action=\"bypass -h admin_show_droplist " + npcId + "\" width=100 height=20 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
  80.         replyMSG.append("</center></body></html>");
  81.        
  82.         adminReply.setHtml(replyMSG.toString());
  83.         activeChar.sendPacket(adminReply); 
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment