Package com.l2jfrozen.gameserver.templates

Examples of com.l2jfrozen.gameserver.templates.L2NpcTemplate


        {
          String[] commandSplit = command.split(" ");

          int npcId = Integer.valueOf(commandSplit[1]);

          L2NpcTemplate npc = NpcTable.getInstance().getTemplate(npcId);
          Show_Npc_Property(activeChar, npc);

          commandSplit = null;
          npc = null;
        }
        catch(Exception e)
        {
          if(Config.ENABLE_ALL_EXCEPTIONS)
            e.printStackTrace();
         
          activeChar.sendMessage("Wrong usage: //edit_npc <npcId>");
        }
      }else{
        if(activeChar.getTarget() instanceof L2NpcInstance){
         
          int npcId = Integer.valueOf(((L2NpcInstance) activeChar.getTarget()).getNpcId());

          L2NpcTemplate npc = NpcTable.getInstance().getTemplate(npcId);
          Show_Npc_Property(activeChar, npc);

          npc = null;
         
        }
      }
     
    }
    else if(command.startsWith("admin_load_npc"))
    {
      StringTokenizer st = new StringTokenizer(command);
      st.nextToken();
      int id = 0;
      try
      {
        id = Integer.parseInt(st.nextToken());
      }
      catch(Exception e)
      {
        activeChar.sendMessage("Usage: //load_npc <id>");
      }
      if(id > 0)
        NpcTable.getInstance().reloadNpc(id);
    }
    else if(command.startsWith("admin_show_droplist "))
    {
      int npcId = 0;

      try
      {
        npcId = Integer.parseInt(command.substring(20).trim());
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }

      if(npcId > 0)
      {
        showNpcDropList(activeChar, npcId);
      }
      else
      {
        activeChar.sendMessage("Usage: //show_droplist <npc_id>");
      }
    }
    else if(command.startsWith("admin_addShopItem "))
    {
      String[] args = command.split(" ");

      if(args.length > 1)
      {
        addShopItem(activeChar, args);
      }

      args = null;
    }
    else if(command.startsWith("admin_delShopItem "))
    {
      String[] args = command.split(" ");

      if(args.length > 2)
      {
        delShopItem(activeChar, args);
      }

      args = null;
    }
    else if(command.startsWith("admin_editShopItem "))
    {
      String[] args = command.split(" ");

      if(args.length > 2)
      {
        editShopItem(activeChar, args);
      }

      args = null;
    }
    else if(command.startsWith("admin_save_npc "))
    {
      try
      {
        save_npc_property(activeChar, command);
      }
      catch(StringIndexOutOfBoundsException e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }
    else if(command.startsWith("admin_show_skilllist_npc "))
    {
      StringTokenizer st = new StringTokenizer(command.substring(25), " ");
      try
      {
        int npcId = -1;
        int page = 0;
        if (st.countTokens() <= 2)
        {
          if (st.hasMoreTokens())
            npcId = Integer.parseInt(st.nextToken());
          if (st.hasMoreTokens())
            page = Integer.parseInt(st.nextToken());
        }

        if(npcId > 0)
        {
          showNpcSkillList(activeChar, npcId, page);
        }
        else
          activeChar.sendMessage("Usage: //show_skilllist_npc <npc_id> <page>");
      }
      catch (Exception e)
      {
        activeChar.sendMessage("Usage: //show_skilllist_npc <npc_id> <page>");
      }
    }
    else if(command.startsWith("admin_edit_skill_npc "))
    {
      int npcId = -1, skillId = -1;
      try
      {
        StringTokenizer st = new StringTokenizer(command.substring(21).trim(), " ");
        if (st.countTokens() == 2)
        {
          try
          {
            npcId = Integer.parseInt(st.nextToken());
            skillId = Integer.parseInt(st.nextToken());
            showNpcSkillEdit(activeChar, npcId, skillId);
          }
          catch(Exception e)
          {}
        }
        else if (st.countTokens() == 3)
        {
          try
          {
            npcId = Integer.parseInt(st.nextToken());
            skillId = Integer.parseInt(st.nextToken());
            int level = Integer.parseInt(st.nextToken());
           
            updateNpcSkillData(activeChar, npcId, skillId, level);
          }
          catch(Exception e)
          {
            _log.fine("admin_edit_skill_npc parements error: " + command);
          }
        }
        else
        {
          activeChar.sendMessage("Usage: //edit_skill_npc <npc_id> <item_id> [<level>]");
        }
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Usage: //edit_skill_npc <npc_id> <item_id> [<level>]");
      }
    }
    else  if(command.startsWith("admin_add_skill_npc "))
    {
      int npcId = -1, skillId = -1;
      try
      {
        StringTokenizer st = new StringTokenizer(command.substring(20).trim(), " ");
        if(st.countTokens() == 1)
        {     
          try
          {
            String[] input = command.substring(20).split(" ");
            if (input.length < 1)
              return true;
            npcId = Integer.parseInt(input[0]);
          }
          catch(Exception e){}
       
          if(npcId > 0)
          {
            L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
            showNpcSkillAdd(activeChar, npcData);
          }
        }
        else if (st.countTokens() == 3)
        {
          try
          {
            npcId = Integer.parseInt(st.nextToken());
            skillId = Integer.parseInt(st.nextToken());
            int level = Integer.parseInt(st.nextToken());
           
            addNpcSkillData(activeChar, npcId, skillId, level);
          }
          catch(Exception e)
          {
            _log.fine("admin_add_skill_npc parements error: " + command);
          }
        }
        else
        {
          activeChar.sendMessage("Usage: //add_skill_npc <npc_id> [<level>]");
        }
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Usage: //add_skill_npc <npc_id> [<level>]");
      }
    }
    else if(command.startsWith("admin_del_skill_npc "))
    {
      int npcId = -1, skillId = -1;
      try
      {
        String[] input = command.substring(20).split(" ");
        if (input.length >= 2)
        {
          npcId = Integer.parseInt(input[0]);
          skillId = Integer.parseInt(input[1]);
        }
      }
      catch(Exception e){}
     
      if(npcId > 0)
      {
        deleteNpcSkillData(activeChar, npcId, skillId);
      }
      else
      {
        activeChar.sendMessage("Usage: //del_skill_npc <npc_id> <skill_id>");
      }
    }
    else if(command.startsWith("admin_edit_drop "))
    {
      int npcId = -1, itemId = 0, category = -1000;
      try
      {
        StringTokenizer st = new StringTokenizer(command.substring(16).trim());
        if(st.countTokens() == 3)
        {
          try
          {
            npcId = Integer.parseInt(st.nextToken());
            itemId = Integer.parseInt(st.nextToken());
            category = Integer.parseInt(st.nextToken());
            showEditDropData(activeChar, npcId, itemId, category);
          }
          catch(Exception e)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              e.printStackTrace();
          }
        }
        else if(st.countTokens() == 6)
        {
          try
          {
            npcId = Integer.parseInt(st.nextToken());
            itemId = Integer.parseInt(st.nextToken());
            category = Integer.parseInt(st.nextToken());
            int min = Integer.parseInt(st.nextToken());
            int max = Integer.parseInt(st.nextToken());
            int chance = Integer.parseInt(st.nextToken());

            updateDropData(activeChar, npcId, itemId, min, max, category, chance);
          }
          catch(Exception e)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              e.printStackTrace();
           
            _log.fine("admin_edit_drop parements error: " + command);
          }
        }
        else
        {
          activeChar.sendMessage("Usage: //edit_drop <npc_id> <item_id> <category> [<min> <max> <chance>]");
        }

        st = null;
      }
      catch(StringIndexOutOfBoundsException e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
       
        activeChar.sendMessage("Usage: //edit_drop <npc_id> <item_id> <category> [<min> <max> <chance>]");
      }
    }
    else if(command.startsWith("admin_add_drop "))
    {
      int npcId = -1;
      try
      {
        StringTokenizer st = new StringTokenizer(command.substring(15).trim());
        if(st.countTokens() == 1)
        {
          try
          {
            String[] input = command.substring(15).split(" ");

            if(input.length < 1)
              return true;

            npcId = Integer.parseInt(input[0]);
            input = null;
          }
          catch(Exception e)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              e.printStackTrace();
          }

          if(npcId > 0)
          {
            L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
            showAddDropData(activeChar, npcData);
            npcData = null;
          }
        }
        else if(st.countTokens() == 6)
View Full Code Here


     
      _log.warning("Error saving new npc value: " + e);
    }

    int npcId = newNpcData.getInteger("npcId");
    final L2NpcTemplate old = NpcTable.getInstance().getTemplate(npcId);
   
    if(old.isCustom()){
      activeChar.sendMessage("You are going to save Custom NPC");
    }
   
    NpcTable.getInstance().saveNpc(newNpcData);
   
View Full Code Here

    newNpcData = null;
  }

  private void showNpcDropList(L2PcInstance activeChar, int npcId)
  {
    L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);

    if(npcData == null)
    {
      activeChar.sendMessage("unknown npc template id" + npcId);
      return;
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    TextBuilder replyMSG = new TextBuilder("<html><title>NPC: " + npcData.name + "(" + npcData.npcId + ") 's drop manage</title>");
    replyMSG.append("<body>");
    replyMSG.append("<br>Notes: click[drop_id]to show the detail of drop data,click[del] to delete the drop data!");
    replyMSG.append("<table>");
    replyMSG.append("<tr><td>npc_id itemId category</td><td>item[id]</td><td>type</td><td>del</td></tr>");
    L2Item itemTemplate;
    for(L2DropCategory cat : npcData.getDropData())
    {
      for(L2DropData drop : cat.getAllDrops())
      {
        itemTemplate = ItemTable.getInstance().getTemplate(drop.getItemId());
        if (itemTemplate == null)
View Full Code Here

  }

  private void reLoadNpcDropList(int npcId)
  {
    L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);

    if(npcData == null)
      return;

    // reset the drop lists
    npcData.clearAllDropData();

    // get the drops
    Connection con = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection(false);
      L2DropData dropData = null;

      npcData.getDropData().clear();

      PreparedStatement statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
      {
          "mobId", "itemId", "min", "max", "category", "chance"
      }) + " FROM droplist WHERE mobId=?");
      statement.setInt(1, npcId);
      ResultSet dropDataList = statement.executeQuery();

      while(dropDataList.next())
      {
        dropData = new L2DropData();

        dropData.setItemId(dropDataList.getInt("itemId"));
        dropData.setMinDrop(dropDataList.getInt("min"));
        dropData.setMaxDrop(dropDataList.getInt("max"));
        dropData.setChance(dropDataList.getInt("chance"));

        int category = dropDataList.getInt("category");

        npcData.addDropData(dropData, category);
      }
      dropDataList.close();
      statement.close();
      statement = null;
      dropDataList = null;
View Full Code Here

    }
  }
 
  private void showNpcSkillList(L2PcInstance activeChar, int npcId, int page)
  {
    L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
    if (npcData == null)
    {
      activeChar.sendMessage("Template id unknown: " + npcId);
      return;
    }
   
    Map<Integer, L2Skill> skills = npcData.getSkills();
   
    int _skillsize = Integer.valueOf(skills.size());
   
    int MaxSkillsPerPage = 10;
    int MaxPages = _skillsize / MaxSkillsPerPage;
    if (_skillsize > MaxSkillsPerPage * MaxPages)
      MaxPages++;
   
    if (page > MaxPages)
      page = MaxPages;
   
    int SkillsStart = MaxSkillsPerPage * page;
    int SkillsEnd = _skillsize;
    if (SkillsEnd - SkillsStart > MaxSkillsPerPage)
      SkillsEnd = SkillsStart + MaxSkillsPerPage;
   
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
   
    StringBuffer replyMSG = new StringBuffer("");
    replyMSG.append("<html><title>" + npcData.getName() + " Skillist");
    replyMSG.append(" (ID:" + npcData.getNpcId() + "Skills " + Integer.valueOf(_skillsize) + ")</title>");
    replyMSG.append("<body>");
    String pages = "<center><table width=270><tr>";
    for (int x = 0; x < MaxPages; x++)
    {
      int pagenr = x + 1;
      if (page == x)
      {
        pages += "<td>Page " + pagenr + "</td>";
      }
      else
      {
        pages += "<td><a action=\"bypass -h admin_show_skilllist_npc " + npcData.getNpcId() + " " + x + "\">Page " + pagenr + "</a></td>";
      }
    }
    pages += "</tr></table></center>";
    replyMSG.append(pages);
   
    replyMSG.append("<table width=270>");
   
    Set<Integer> skillset = skills.keySet();
    Iterator<Integer> skillite = skillset.iterator();
    Object skillobj = null;
   
    for (int i = 0; i < SkillsStart; i++)
    {
      if (skillite.hasNext())
      {
        skillobj = skillite.next();
      }
    }
   
    int cnt = SkillsStart;
    while (skillite.hasNext())
    {
      cnt++;
      if (cnt > SkillsEnd)
      {
        break;
      }
      skillobj = skillite.next();
      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>");
     
    }
    replyMSG.append("</table>");
    replyMSG.append("<br><br>");
    replyMSG.append("<center>");
View Full Code Here

    Connection con = null;

    try
    {
      con = L2DatabaseFactory.getInstance().getConnection(false);
      L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
      npcData.getSkills().clear();

      L2Skill skillData = null;
     
      // with out race
      String _sql = "SELECT npcid, skillid, level FROM npcskills WHERE npcid=? AND (skillid NOT BETWEEN 4290 AND 4302)";
     
      PreparedStatement statement = con.prepareStatement(_sql);
      statement.setInt(1, npcId);
      ResultSet skillDataList = statement.executeQuery();

      while(skillDataList.next()) {
        int idval = skillDataList.getInt("skillid");
        int levelval = skillDataList.getInt("level");
        skillData = SkillTable.getInstance().getInfo(idval,levelval);
          if (skillData != null) {
            npcData.addSkill(skillData);
          }
       
      }
      skillDataList.close();
      statement.close();
View Full Code Here

    _zones.clear();
  }
 
  public L2NpcTemplate getValidTemplate(int bossId)
  {
    L2NpcTemplate template = NpcTable.getInstance().getTemplate(bossId);
    if(template == null)
      return null;

    if(!template.type.equalsIgnoreCase("L2GrandBoss"))
      return null;
View Full Code Here

    tb.append("<img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>");

    for(int boss : Config.RAID_INFO_IDS_LIST)
    {
      String name = "";
      L2NpcTemplate template = null;
      if((template = NpcTable.getInstance().getTemplate(boss)) != null){
        name = template.getName();
      }else{
        _log.warning("[RaidInfoHandler][sendInfo] Raid Boss with ID "+boss+" is not defined into NpcTable");
        continue;
      }
      
View Full Code Here

   * @see com.l2jfrozen.gameserver.script.EngineInterface#addQuestDrop(int, int, int, int, int, String, String[])
   */
  @Override
  public void addQuestDrop(int npcID, int itemID, int min, int max, int chance, String questID, String[] states)
  {
    L2NpcTemplate npc = npcTable.getTemplate(npcID);
    if(npc == null){
      _log.info("FeanorInterface: Npc "+npcID+" is null..");
      return;
    }
    L2DropData drop = new L2DropData();
View Full Code Here

   *
   * @see com.l2jfrozen.gameserver.script.EngineInterface#addQuestDrop(int, int, int, int, int, String, String[])
   */
  public void addDrop(int npcID, int itemID, int min, int max, boolean sweep, int chance) throws NullPointerException
  {
    L2NpcTemplate npc = npcTable.getTemplate(npcID);
    if(npc == null)
    {
      if(Config.DEBUG)
      {
        _log.warning("Npc doesnt Exist");
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.templates.L2NpcTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.