Package net.sf.l2j.gameserver.serverpackets

Examples of net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage


            content = content.replaceAll("%objectId%", String.valueOf(player.getTarget().getObjectId()));

        //Send message to client if message not empty    
         if (content != null)
         {
             NpcHtmlMessage npcReply = new NpcHtmlMessage(5);
             npcReply.setHtml(content);
             player.sendPacket(npcReply);
         }
        
         return content;
  }
View Full Code Here


  }

  private void showCastleSelectPage(L2PcInstance activeChar)
  {
    int i=0;
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/castles.htm");
    TextBuilder cList = new TextBuilder();
    for (Castle castle: CastleManager.getInstance().getCastles())
    {
      if (castle != null)
      {
        String name=castle.getName();
        cList.append("<td fixwidth=90><a action=\"bypass -h admin_siege "+name+"\">"+name+"</a></td>");
        i++;
      }
      if (i>2)
      {
        cList.append("</tr><tr>");
        i=0;
      }
    }
    adminReply.replace("%castles%", cList.toString());
    cList.clear();
    i=0;
    for (ClanHall clanhall: ClanHallManager.getInstance().getClanHalls().values())
    {
      if (clanhall != null)
      {
        cList.append("<td fixwidth=134><a action=\"bypass -h admin_clanhall "+clanhall.getId()+"\">");
        cList.append(clanhall.getName()+"</a></td>");
        i++;
      }
      if (i>1)
      {
        cList.append("</tr><tr>");
        i=0;
      }
    }
    adminReply.replace("%clanhalls%", cList.toString());
    cList.clear();
    i=0;
    for (ClanHall clanhall: ClanHallManager.getInstance().getFreeClanHalls().values())
    {
      if (clanhall != null)
      {
        cList.append("<td fixwidth=134><a action=\"bypass -h admin_clanhall "+clanhall.getId()+"\">");
        cList.append(clanhall.getName()+"</a></td>");
        i++;
      }
      if (i>1)
      {
        cList.append("</tr><tr>");
        i=0;
      }
    }
    adminReply.replace("%freeclanhalls%", cList.toString());
    activeChar.sendPacket(adminReply);
  }
View Full Code Here

    activeChar.sendPacket(adminReply);
  }

  private void showSiegePage(L2PcInstance activeChar, String castleName)
  {
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/castle.htm");
    adminReply.replace("%castleName%", castleName);
    activeChar.sendPacket(adminReply);
  }
View Full Code Here

    activeChar.sendPacket(adminReply);
  }

  private void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
  {
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/clanhall.htm");
    adminReply.replace("%clanhallName%", clanhall.getName());
    adminReply.replace("%clanhallId%", String.valueOf(clanhall.getId()));
    L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
    if (owner == null)
      adminReply.replace("%clanhallOwner%","None");
    else
      adminReply.replace("%clanhallOwner%",owner.getName());
    activeChar.sendPacket(adminReply);
  }
View Full Code Here

                        showVaultWindowDeposit(player);
                    else if (val.equalsIgnoreCase("withdraw"))
                        showVaultWindowWithdraw(player);
                    else
                    {
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/vault.htm");
                        sendHtmlMessage(player, html);
                    }
                }
                else
                    player.sendMessage("You are not authorized to do this!");
                return;
            }
            else if (actualCommand.equalsIgnoreCase("door"))
            {
                if ((player.getClanPrivileges() & L2Clan.CP_CH_OPEN_DOOR) == L2Clan.CP_CH_OPEN_DOOR)
                {
                    if (val.equalsIgnoreCase("open"))
                        getClanHall().openCloseDoors(true);
                    else if (val.equalsIgnoreCase("close"))
                        getClanHall().openCloseDoors(false);
                    else
                    {
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/door.htm");
                        sendHtmlMessage(player, html);
                    }
                }
                else
                    player.sendMessage("You are not authorized to do this!");
            }
            else if (actualCommand.equalsIgnoreCase("functions"))
            {
                if (val.equalsIgnoreCase("tele"))
                {
                    NpcHtmlMessage html = new NpcHtmlMessage(1);
                    if (getClanHall().getFunction(ClanHall.FUNC_TELEPORT) == null)
                      html.setFile("data/html/clanHallManager/chamberlain-nac.htm");
                    else
                      html.setFile("data/html/clanHallManager/tele"+getClanHall().getLocation()+getClanHall().getFunction(ClanHall.FUNC_TELEPORT).getLvl()+".htm");
                    sendHtmlMessage(player, html);
                }
                else if (val.equalsIgnoreCase("item_creation"))
                {
                    if (getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE) == null){
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/chamberlain-nac.htm");
                        sendHtmlMessage(player, html);
                        return;
                    }
                    if (st.countTokens() < 1) return;
                    int valbuy = Integer.parseInt(st.nextToken())+(getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE).getLvl()*100000);
                    showBuyWindow(player, valbuy);
                }
                else if (val.equalsIgnoreCase("support"))
                {

                    NpcHtmlMessage html = new NpcHtmlMessage(1);
                    if (getClanHall().getFunction(ClanHall.FUNC_SUPPORT)== null)
                        html.setFile("data/html/clanHallManager/chamberlain-nac.htm");
                    else{
                      html.setFile("data/html/clanHallManager/support"+getClanHall().getFunction(ClanHall.FUNC_SUPPORT).getLvl()+".htm");
                      html.replace("%mp%", String.valueOf(getCurrentMp()));
                    }
                    sendHtmlMessage(player, html);
                }
                else if (val.equalsIgnoreCase("back"))
                    showMessageWindow(player);
                else{
                  NpcHtmlMessage html = new NpcHtmlMessage(1);
                  html.setFile("data/html/clanHallManager/functions.htm");
                  if (getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP) != null)
                      html.replace("%xp_regen%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP).getLvl()) + "%");
                  else
                      html.replace("%xp_regen%", "0");
                  if (getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP) != null)
                      html.replace("%hp_regen%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP).getLvl()) + "%");
                  else
                      html.replace("%hp_regen%", "0");
                  if (getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP) != null)
                      html.replace("%mp_regen%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP).getLvl()) + "%");
                  else
                      html.replace("%mp_regen", "0");
                  sendHtmlMessage(player, html);
                }
            }
            else if (actualCommand.equalsIgnoreCase("manage"))
            {
                if ((player.getClanPrivileges() & L2Clan.CP_CH_SET_FUNCTIONS) == L2Clan.CP_CH_SET_FUNCTIONS)
                {
                    if (val.equalsIgnoreCase("recovery"))
                    {
                        if (st.countTokens() >= 1)
                        {
                          if(getClanHall().getOwnerId() == 0){
                            player.sendMessage("This clan Hall have no owner, you cannot change configuration");
                            return;
                          }
                            val = st.nextToken();
                            if (val.equalsIgnoreCase("hp"))
                            {
                                if (st.countTokens() >= 1)
                                {
                                    int fee;
                                    if (Config.DEBUG) _log.warning("Mp editing invoked");
                                    val = st.nextToken();
                                    int percent = Integer.valueOf(val);
                                    switch (percent)
                                    {
                                    case 0:
                                      fee = 0;
                                      break;
                                        case 20:
                                            fee = Config.CH_HPREG1_FEE;
                                            break;
                                        case 40:
                                            fee = Config.CH_HPREG2_FEE;
                                            break;
                                        case 80:
                                            fee = Config.CH_HPREG3_FEE;
                                            break;
                                        case 100:
                                            fee = Config.CH_HPREG4_FEE;
                                            break;
                                        case 120:
                                            fee = Config.CH_HPREG5_FEE;
                                            break;
                                        case 140:
                                            fee = Config.CH_HPREG6_FEE;
                                            break;
                                        case 160:
                                            fee = Config.CH_HPREG7_FEE;
                                            break;
                                        case 180:
                                            fee = Config.CH_HPREG8_FEE;
                                            break;
                                        case 200:
                                            fee = Config.CH_HPREG9_FEE;
                                            break;
                                        case 220:
                                            fee = Config.CH_HPREG10_FEE;
                                            break;
                                        case 240:
                                            fee = Config.CH_HPREG11_FEE;
                                            break;
                                        case 260:
                                            fee = Config.CH_HPREG12_FEE;
                                            break;
                                        default:
                                            fee = Config.CH_HPREG13_FEE;
                                            break;
                                    }
                                    if (!getClanHall().updateFunctions(ClanHall.FUNC_RESTORE_HP, percent, fee, Config.CH_HPREG_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP) == null)))
                                        player.sendMessage("You don't have enough adena in your clan's warehouse");
                                    else
                                      revalidateDeco(player);
                                }
                            }
                            else if (val.equalsIgnoreCase("mp"))
                            {
                                if (st.countTokens() >= 1)
                                {
                                    int fee;
                                    if (Config.DEBUG) _log.warning("Mp editing invoked");
                                    val = st.nextToken();
                                    int percent = Integer.valueOf(val);
                                    switch (percent)
                                    {
                                    case 0:
                                      fee = 0;
                                      break;
                                        case 5:
                                            fee = Config.CH_MPREG1_FEE;
                                            break;
                                        case 10:
                                            fee = Config.CH_MPREG2_FEE;
                                            break;
                                        case 15:
                                            fee = Config.CH_MPREG3_FEE;
                                            break;
                                        case 30:
                                            fee = Config.CH_MPREG4_FEE;
                                            break;
                                        default:
                                            fee = Config.CH_MPREG5_FEE;
                                            break;
                                    }
                                    if(!getClanHall().updateFunctions(ClanHall.FUNC_RESTORE_MP, percent, fee, Config.CH_MPREG_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP) == null)))
                                        player.sendMessage("You don't have enough adena in your clan's warehouse");
                                    else
                                      revalidateDeco(player);
                                }
                            }
                            else if (val.equalsIgnoreCase("exp"))
                            {
                                if (st.countTokens() >= 1)
                                {
                                    int fee;
                                    if (Config.DEBUG) _log.warning("Exp editing invoked");
                                    val = st.nextToken();
                                    int percent = Integer.valueOf(val);
                                    switch (percent)
                                    {
                                      case 0:
                                        fee = 0;
                                        break;
                                        case 5:
                                            fee = Config.CH_EXPREG1_FEE;
                                            break;
                                        case 10:
                                            fee = Config.CH_EXPREG2_FEE;
                                            break;
                                        case 15:
                                            fee = Config.CH_EXPREG3_FEE;
                                            break;
                                        case 25:
                                            fee = Config.CH_EXPREG4_FEE;
                                            break;
                                        case 35:
                                            fee = Config.CH_EXPREG5_FEE;
                                            break;
                                        case 40:
                                            fee = Config.CH_EXPREG6_FEE;
                                            break;
                                        default:
                                            fee = Config.CH_EXPREG7_FEE;
                                            break;
                                    }
                                    if (!getClanHall().updateFunctions(ClanHall.FUNC_RESTORE_EXP, percent, fee, Config.CH_EXPREG_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP) == null)))
                                        player.sendMessage("You don't have enough adena in your clan's warehouse");
                                    else
                                      revalidateDeco(player);
                                }
                            }
                        }
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/edit_recovery"+getClanHall().getGrade()+".htm");
                        if (getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP) != null){
                          html.replace("%hp%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP).getLvl()) + "%");
                            html.replace("%hpPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP).getLease()));
                            html.replace("%hpDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_RESTORE_HP).getEndTime()));
                        }else{
                            html.replace("%hp%", "0");
                            html.replace("%hpPrice%", "0");
                            html.replace("%hpDate%","0");
                        }
                        if (getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP) != null){
                            html.replace("%exp%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP).getLvl()) + "%");
                            html.replace("%expPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP).getLease()));
                            html.replace("%expDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_RESTORE_EXP).getEndTime()));
                        }else{
                            html.replace("%exp%", "0");
                            html.replace("%expPrice%", "0");
                            html.replace("%expDate%","0");
                        }
                        if (getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP) != null ){
                            html.replace("%mp%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP).getLvl()) + "%");
                            html.replace("%mpPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP).getLease()));
                            html.replace("%mpDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_RESTORE_MP).getEndTime()));
                        }else{
                            html.replace("%mp%", "0");
                            html.replace("%mpPrice%", "0");
                            html.replace("%mpDate%","0");
                        }
                        sendHtmlMessage(player, html);
                    }
                    else if (val.equalsIgnoreCase("other"))
                    {
                        if (st.countTokens() >= 1)
                        {
                          if(getClanHall().getOwnerId() == 0){
                            player.sendMessage("This clan Hall have no owner, you cannot change configuration");
                            return;
                          }
                            val = st.nextToken();
                            if (val.equalsIgnoreCase("item"))
                            {
                                if (st.countTokens() >= 1)
                                {
                                  if(getClanHall().getOwnerId() == 0){
                                    player.sendMessage("This clan Hall have no owner, you cannot change configuration");
                                    return;
                                  }
                                  if (Config.DEBUG) _log.warning("Item editing invoked");
                                    val = st.nextToken();
                                    int fee;
                                    int lvl = Integer.valueOf(val);
                                    switch (lvl)
                                    {
                                    case 0:
                                      fee = 0;
                                      break;
                                        case 1:
                                            fee = Config.CH_ITEM1_FEE;
                                            break;
                                        case 2:
                                            fee = Config.CH_ITEM2_FEE;
                                            break;
                                        default:
                                            fee = Config.CH_ITEM3_FEE;
                                            break;
                                    }
                                    if (!getClanHall().updateFunctions(ClanHall.FUNC_ITEM_CREATE, lvl, fee, Config.CH_ITEM_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE) == null)))
                                        player.sendMessage("You don't have enough adena in your clan's warehouse");
                                    else
                                      revalidateDeco(player);
                                }
                            }
                            else if (val.equalsIgnoreCase("tele"))
                            {
                                if (st.countTokens() >= 1)
                                {
                                    int fee;
                                    if (Config.DEBUG) _log.warning("Tele editing invoked");
                                    val = st.nextToken();
                                    int lvl = Integer.valueOf(val);
                                    switch (lvl)
                                    {
                                    case 0:
                                      fee = 0;
                                      break;
                                        case 1:
                                            fee = Config.CH_TELE1_FEE;
                                            break;
                                        default:
                                            fee = Config.CH_TELE2_FEE;
                                            break;
                                    }
                                    if (!getClanHall().updateFunctions(ClanHall.FUNC_TELEPORT, lvl, fee, Config.CH_TELE_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_TELEPORT) == null)))
                                        player.sendMessage("You don't have enough adena in your clan's warehouse");
                                    else
                                      revalidateDeco(player);
                                }
                            }
                            else if (val.equalsIgnoreCase("support"))
                            {
                                if (st.countTokens() >= 1)
                                {
                                    int fee;
                                    if (Config.DEBUG) _log.warning("Support editing invoked");
                                    val = st.nextToken();
                                    int lvl = Integer.valueOf(val);
                                    switch (lvl)
                                    {
                                    case 0:
                                      fee = 0;
                                      break;
                                        case 1:
                                            fee = Config.CH_SUPPORT1_FEE;
                                            break;
                                        case 2:
                                            fee = Config.CH_SUPPORT2_FEE;
                                            break;
                                        case 3:
                                            fee = Config.CH_SUPPORT3_FEE;
                                            break;
                                        case 4:
                                            fee = Config.CH_SUPPORT4_FEE;
                                            break;
                                        case 5:
                                            fee = Config.CH_SUPPORT5_FEE;
                                            break;
                                        case 6:
                                            fee = Config.CH_SUPPORT6_FEE;
                                            break;
                                        case 7:
                                            fee = Config.CH_SUPPORT7_FEE;
                                            break;
                                        default:
                                            fee = Config.CH_SUPPORT8_FEE;
                                            break;
                                    }
                                    if (!getClanHall().updateFunctions(ClanHall.FUNC_SUPPORT, lvl, fee, Config.CH_SUPPORT_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_SUPPORT) == null)))
                                        player.sendMessage("You don't have enough adena in your clan's warehouse");
                                    else
                                      revalidateDeco(player);
                                }
                            }
                        }
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/edit_other"+getClanHall().getGrade()+".htm");
                        if (getClanHall().getFunction(ClanHall.FUNC_TELEPORT) != null){
                            html.replace("%tele%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_TELEPORT).getLvl()));
                            html.replace("%telePrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_TELEPORT).getLease()));
                            html.replace("%teleDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_TELEPORT).getEndTime()));
                        }else{
                            html.replace("%tele%", "0");
                            html.replace("%telePrice%", "0");
                            html.replace("%teleDate%","0");
                        }
                        if (getClanHall().getFunction(ClanHall.FUNC_SUPPORT) != null){
                            html.replace("%support%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_SUPPORT).getLvl()));
                            html.replace("%supportPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_SUPPORT).getLease()));
                            html.replace("%supportDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_SUPPORT).getEndTime()));
                        }else{
                            html.replace("%support%", "0");
                            html.replace("%supportPrice%", "0");
                            html.replace("%supportDate%","0");
                        }
                        if (getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE) != null){
                            html.replace("%item%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE).getLvl()));
                            html.replace("%itemPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE).getLease()));
                            html.replace("%itemDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_ITEM_CREATE).getEndTime()));
                        }else{
                            html.replace("%item%", "0");
                            html.replace("%itemPrice%", "0");
                            html.replace("%itemDate%","0");
                        }
                        sendHtmlMessage(player, html);
                    }
                    else if (val.equalsIgnoreCase("deco"))
                    {
                        if (st.countTokens() >= 1)
                        {
                          if(getClanHall().getOwnerId() == 0){
                            player.sendMessage("This clan Hall have no owner, you cannot change configuration");
                            return;
                          }
                            val = st.nextToken();
                        if (val.equalsIgnoreCase("curtains")){
                              if (st.countTokens() >= 1)
                              {
                                  int fee;
                                  if (Config.DEBUG) _log.warning("Deco curtains editing invoked");
                                  val = st.nextToken();
                                  int lvl = Integer.valueOf(val);
                                  switch (lvl)
                                  {
                                    case 0:
                                      fee = 0;
                                      break;
                                      case 1:
                                          fee = Config.CH_CURTAIN1_FEE;
                                          break;
                                      default:
                                          fee = Config.CH_CURTAIN2_FEE;
                                          break;
                                  }
                                  if (!getClanHall().updateFunctions(ClanHall.FUNC_DECO_CURTAINS, lvl, fee, Config.CH_CURTAIN_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_DECO_CURTAINS) == null)))
                                      player.sendMessage("You don't have enough adena in your clan's warehouse");
                                  else
                                    revalidateDeco(player);
                              }
                        }else if (val.equalsIgnoreCase("porch")){
                              if (st.countTokens() >= 1)
                              {
                                  int fee;
                                  if (Config.DEBUG) _log.warning("Deco curtains editing invoked");
                                  val = st.nextToken();
                                  int lvl = Integer.valueOf(val);
                                  switch (lvl)
                                  {
                                    case 0:
                                      fee = 0;
                                      break;
                                      case 1:
                                          fee = Config.CH_FRONT1_FEE;
                                          break;
                                      default:
                                          fee = Config.CH_FRONT2_FEE;
                                          break;
                                  }
                                  if (!getClanHall().updateFunctions(ClanHall.FUNC_DECO_FRONTPLATEFORM, lvl, fee, Config.CH_FRONT_FEE_RATIO, (getClanHall().getFunction(ClanHall.FUNC_DECO_FRONTPLATEFORM) == null)))
                                      player.sendMessage("You don't have enough adena in your clan's warehouse");
                                  else
                                    revalidateDeco(player);
                              }
                        }
                        }
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/deco.htm");
                        if (getClanHall().getFunction(ClanHall.FUNC_DECO_CURTAINS) != null){
                            html.replace("%curtain%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_DECO_CURTAINS).getLvl()));
                            html.replace("%curtainPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_DECO_CURTAINS).getLease()));
                            html.replace("%curtainDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_DECO_CURTAINS).getEndTime()));
                        }else{
                            html.replace("%curtain%", "0");
                            html.replace("%curtainPrice%", "0");
                            html.replace("%curtainDate%","0");
                        }
                        if (getClanHall().getFunction(ClanHall.FUNC_DECO_FRONTPLATEFORM) != null){
                            html.replace("%porch%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_DECO_FRONTPLATEFORM).getLvl()));
                            html.replace("%porchPrice%", String.valueOf(getClanHall().getFunction(ClanHall.FUNC_DECO_FRONTPLATEFORM).getLease()));
                            html.replace("%porchDate%",format.format(getClanHall().getFunction(ClanHall.FUNC_DECO_FRONTPLATEFORM).getEndTime()));
                        }else{
                            html.replace("%porch%", "0");
                            html.replace("%porchPrice%", "0");
                            html.replace("%porchDate%","0");
                        }
                        sendHtmlMessage(player, html);
                    }
                    else if (val.equalsIgnoreCase("back"))
                        showMessageWindow(player);
                    else
                    {
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        html.setFile("data/html/clanHallManager/manage.htm");
                        sendHtmlMessage(player, html);
                    }
                }
                else
                    player.sendMessage("You are not authorized to do this!");
                return;
            }
            else if (actualCommand.equalsIgnoreCase("support"))
            {
                setTarget(player);
                L2Skill skill;
                if (val == "") return;

                try
                {
                    int skill_id = Integer.parseInt(val);
                    try
                    {
                        int skill_lvl = 0;
                        if (st.countTokens() >= 1) skill_lvl = Integer.parseInt(st.nextToken());
                        skill = SkillTable.getInstance().getInfo(skill_id,skill_lvl);
                        if (skill.getSkillType() == SkillType.SUMMON)
                            player.doCast(skill);
                        else
                            doCast(skill);
                        if (getClanHall().getFunction(ClanHall.FUNC_SUPPORT)== null)
                            return;
                        NpcHtmlMessage html = new NpcHtmlMessage(1);
                        if(getClanHall().getFunction(ClanHall.FUNC_SUPPORT).getLvl() == 0)
                          return;
                        html.setFile("data/html/clanHallManager/support"+getClanHall().getFunction(ClanHall.FUNC_SUPPORT).getLvl()+".htm");
                        html.replace("%mp%", String.valueOf(getCurrentMp()));
                        sendHtmlMessage(player, html);
                    }
                    catch (Exception e)
                    {
                        player.sendMessage("Invalid skill level!");
View Full Code Here

     */
    public void insertObjectIdAndShowChatWindow(L2PcInstance player, String content)
    {
        // Send a Server->Client packet NpcHtmlMessage to the L2PcInstance in order to display the message of the L2NpcInstance
        content = content.replaceAll("%objectId%", String.valueOf(getObjectId()));
        NpcHtmlMessage npcReply = new NpcHtmlMessage(getObjectId());
        npcReply.setHtml(content);
        player.sendPacket(npcReply);
    }
View Full Code Here

    public void showLotoWindow(L2PcInstance player, int val)
    {
        int npcId = getTemplate().npcId;
        String filename;
        SystemMessage sm;
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
       
        if (val == 0) // 0 - first buy lottery ticket window
        {
            filename = (getHtmlPath(npcId, 1));
            html.setFile(filename);
        }
        else if (val >= 1 && val <= 21) // 1-20 - buttons, 21 - second buy lottery ticket window
        {
          if (!Lottery.getInstance().isStarted())
            {
                //tickets can't be sold
                player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_CURRENT_SOLD));
                return;
            }
            if (!Lottery.getInstance().isSellableTickets())
            {
                //tickets can't be sold
                player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_AVAILABLE));
                return;
            }

      filename = (getHtmlPath(npcId, 5));
      html.setFile(filename);
     
      int count = 0;
      int found = 0;
      // counting buttons and unsetting button if found
            for (int i = 0; i < 5; i++)
            {
                if (player.getLoto(i) == val)
                {
                         //unsetting button
                    player.setLoto(i, 0);
                    found = 1;
                }
                else if (player.getLoto(i) > 0)
                {
                  count++;
                }
            }
           
                 //if not rearched limit 5 and not unseted value
            if (count < 5 && found == 0 && val <= 20)
                for (int i = 0; i < 5; i++)
                    if (player.getLoto(i) == 0)
                    {
                        player.setLoto(i, val);
                        break;
                    }
           
            //setting pusshed buttons
            count = 0;
            for (int i = 0; i < 5; i++)
                if (player.getLoto(i) > 0)
                {
                    count++;
                    String button = String.valueOf(player.getLoto(i));
                    if (player.getLoto(i) < 10) button = "0" + button;
                    String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
                    String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
                    html.replace(search, replace);
                }
           
            if (count == 5)
            {
                String search = "0\">Return";
                String replace = "22\">The winner selected the numbers above.";
                html.replace(search, replace);
            }
        }
        else if (val == 22) //22 - selected ticket with 5 numbers
        {
            if (!Lottery.getInstance().isStarted())
            {
                //tickets can't be sold
                player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_CURRENT_SOLD));
                return;
            }
            if (!Lottery.getInstance().isSellableTickets())
            {
                //tickets can't be sold
                player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_AVAILABLE));
                return;
            }
                
            int price = Config.ALT_LOTTERY_TICKET_PRICE;
            int lotonumber = Lottery.getInstance().getId();
            int enchant = 0;
            int type2 = 0;
                
            for (int i = 0; i < 5; i++)
            {
                if (player.getLoto(i) == 0) return;
                    
                if (player.getLoto(i) < 17) enchant += Math.pow(2, player.getLoto(i) - 1);
                else type2 += Math.pow(2, player.getLoto(i) - 17);
            }
            if (player.getAdena() < price)
            {
                     sm = new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA);
                     player.sendPacket(sm);
                     return;
            }
            if (!player.reduceAdena("Loto", price, this, true)) return;
            Lottery.getInstance().increasePrize(price);

            sm = new SystemMessage(SystemMessageId.ACQUIRED);
            sm.addNumber(lotonumber);
            sm.addItemName(4442);
            player.sendPacket(sm);
           
            L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4442);
      item.setCount(1);
      item.setCustomType1(lotonumber);
      item.setEnchantLevel(enchant);
      item.setCustomType2(type2);
      player.getInventory().addItem("Loto", item, player, this);
     
      InventoryUpdate iu = new InventoryUpdate();
      iu.addItem(item);
      L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
      iu.addModifiedItem(adenaupdate);
      player.sendPacket(iu);
           
            filename = (getHtmlPath(npcId, 3));
            html.setFile(filename);
        }
        else if (val == 23) //23 - current lottery jackpot
        {
            filename = (getHtmlPath(npcId, 3));
            html.setFile(filename);
        }
        else if (val == 24) // 24 - Previous winning numbers/Prize claim
        {
            filename = (getHtmlPath(npcId, 4));
            html.setFile(filename);
           
            int lotonumber = Lottery.getInstance().getId();
            String message = "";
            for (L2ItemInstance item : player.getInventory().getItems())
            {
                if (item == null) continue;
                if (item.getItemId() == 4442 && item.getCustomType1() < lotonumber)
                {
                    message = message + "<a action=\"bypass -h npc_%objectId%_Loto "
                    + item.getObjectId() + "\">" + item.getCustomType1() + " Event Number ";
                    int[] numbers = Lottery.getInstance().decodeNumbers(item.getEnchantLevel(),
                                                                        item.getCustomType2());
                    for (int i = 0; i < 5; i++)
                    {
                        message += numbers[i] + " ";
                    }
                    int[] check = Lottery.getInstance().checkTicket(item);
                    if (check[0] > 0)
                    {
                        switch (check[0])
                        {
                            case 1:
                                message += "- 1st Prize";
                                break;
                            case 2:
                                message += "- 2nd Prize";
                                break;
                            case 3:
                                message += "- 3th Prize";
                                break;
                            case 4:
                                message += "- 4th Prize";
                                break;
                        }
                        message += " " + check[1] + "a.";
                    }
                    message += "</a><br>";
                }
            }
            if (message == "")
            {
                message += "There is no winning lottery ticket...<br>";
            }
            html.replace("%result%", message);
        }
        else if (val > 24) // >24 - check lottery ticket by item object id
        {
            int lotonumber = Lottery.getInstance().getId();
            L2ItemInstance item = player.getInventory().getItemByObjectId(val);
            if (item == null || item.getItemId() != 4442 || item.getCustomType1() >= lotonumber) return;
            int[] check = Lottery.getInstance().checkTicket(item);
           
            sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
            sm.addItemName(4442);
            player.sendPacket(sm);
           
            int adena = check[1];
            if (adena > 0)
                player.addAdena("Loto", adena, this, true);
            player.destroyItem("Loto", item, this, false);
            return;
        }
        html.replace("%objectId%", String.valueOf(getObjectId()));
        html.replace("%race%", "" + Lottery.getInstance().getId());
        html.replace("%adena%", "" + Lottery.getInstance().getPrize());
        html.replace("%ticket_price%", "" + Config.ALT_LOTTERY_TICKET_PRICE);
        html.replace("%prize5%", "" + (Config.ALT_LOTTERY_5_NUMBER_RATE * 100));
        html.replace("%prize4%", "" + (Config.ALT_LOTTERY_4_NUMBER_RATE * 100));
        html.replace("%prize3%", "" + (Config.ALT_LOTTERY_3_NUMBER_RATE * 100));
        html.replace("%prize2%", "" + Config.ALT_LOTTERY_2_AND_1_NUMBER_PRIZE);
        html.replace("%enddate%", "" + DateFormat.getDateInstance().format(Lottery.getInstance().getEndDate()));
        player.sendPacket(html);
            
        // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
        player.sendPacket(new ActionFailed());
    }
View Full Code Here

    public static void showEventHtml(L2PcInstance player, String objectid)
    {
        try
        {
            NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

            DataInputStream in = new DataInputStream(
                                                     new BufferedInputStream(
                                                                             new FileInputStream(
                                                                                                 "data/events/"
                                                                                                     + eventName)));
            BufferedReader inbr = new BufferedReader(new InputStreamReader(in));

            TextBuilder replyMSG = new TextBuilder("<html><body>");
            replyMSG.append("<center><font color=\"LEVEL\">" + eventName
                + "</font><font color=\"FF0000\"> bY " + inbr.readLine() + "</font></center><br>");

            replyMSG.append("<br>" + inbr.readLine());
            if (L2Event.participatingPlayers.contains(player.getName())) replyMSG.append("<br><center>You are already in the event players list !!</center></body></html>");
            else replyMSG.append("<br><center><button value=\"Participate !! \" action=\"bypass -h npc_"
                + objectid
                + "_event_participate\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>");

            adminReply.setHtml(replyMSG.toString());
            player.sendPacket(adminReply);
        }
        catch (Exception e)
        {
            System.out.println(e);
View Full Code Here

    {
      String html = HtmCache.getInstance().getHtm("data/html/" + type + "/" + getNpcId() + "-pk.htm");

      if (html != null)
      {
        NpcHtmlMessage pkDenyMsg = new NpcHtmlMessage(getObjectId());
        pkDenyMsg.setHtml(html);
        player.sendPacket(pkDenyMsg);
        player.sendPacket(new ActionFailed());
        return true;
      }
View Full Code Here

            filename = (getHtmlPath(npcId, val));
            break;
        }
       
        // Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile(filename);
       
        //String word = "npc-"+npcId+(val>0 ? "-"+val : "" )+"-dialog-append";
       
        if (this instanceof L2MerchantInstance)
            if (Config.LIST_PET_RENT_NPC.contains(npcId))
                html.replace("_Quest", "_RentPet\">Rent Pet</a><br><a action=\"bypass -h npc_%objectId%_Quest");
       
        html.replace("%objectId%", String.valueOf(getObjectId()));
        html.replace("%festivalMins%", SevenSignsFestival.getInstance().getTimeToNextFestivalStr());       
        player.sendPacket(html);
       
        // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
        player.sendPacket( new ActionFailed() );
    }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage

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.