Package com.l2jfrozen.gameserver.network.serverpackets

Examples of com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage


        {
          getCastle().banishForeigners(); // Move non-clan members off castle area
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
        }
        return;
      }
      else if(actualCommand.equalsIgnoreCase("list_siege_clans"))
      {
        if((player.getClanPrivileges() & L2Clan.CP_CS_MANAGE_SIEGE) == L2Clan.CP_CS_MANAGE_SIEGE)
        {
          getCastle().getSiege().listRegisterClan(player); // List current register clan
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
        }
        return;
      }
      else if(actualCommand.equalsIgnoreCase("receive_report"))
      {
        if(player.isClanLeader())
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-report.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          L2Clan clan = ClanTable.getInstance().getClan(getCastle().getOwnerId());
          html.replace("%clanname%", clan.getName());
          html.replace("%clanleadername%", clan.getLeaderName());
          html.replace("%castlename%", getCastle().getName());
          {
            int currentPeriod = SevenSigns.getInstance().getCurrentPeriod();
            switch(currentPeriod)
            {
              case SevenSigns.PERIOD_COMP_RECRUITING:
                html.replace("%ss_event%", "Quest Event Initialization");
                break;
              case SevenSigns.PERIOD_COMPETITION:
                html.replace("%ss_event%", "Competition (Quest Event)");
                break;
              case SevenSigns.PERIOD_COMP_RESULTS:
                html.replace("%ss_event%", "Quest Event Results");
                break;
              case SevenSigns.PERIOD_SEAL_VALIDATION:
                html.replace("%ss_event%", "Seal Validation");
                break;
            }
          }
          {
            int sealOwner1 = SevenSigns.getInstance().getSealOwner(1);
            switch(sealOwner1)
            {
              case SevenSigns.CABAL_NULL:
                html.replace("%ss_avarice%", "Not in Possession");
                break;
              case SevenSigns.CABAL_DAWN:
                html.replace("%ss_avarice%", "Lords of Dawn");
                break;
              case SevenSigns.CABAL_DUSK:
                html.replace("%ss_avarice%", "Revolutionaries of Dusk");
                break;
            }
          }
          {
            int sealOwner2 = SevenSigns.getInstance().getSealOwner(2);
            switch(sealOwner2)
            {
              case SevenSigns.CABAL_NULL:
                html.replace("%ss_gnosis%", "Not in Possession");
                break;
              case SevenSigns.CABAL_DAWN:
                html.replace("%ss_gnosis%", "Lords of Dawn");
                break;
              case SevenSigns.CABAL_DUSK:
                html.replace("%ss_gnosis%", "Revolutionaries of Dusk");
                break;
            }
          }
          {
            int sealOwner3 = SevenSigns.getInstance().getSealOwner(3);
            switch(sealOwner3)
            {
              case SevenSigns.CABAL_NULL:
                html.replace("%ss_strife%", "Not in Possession");
                break;
              case SevenSigns.CABAL_DAWN:
                html.replace("%ss_strife%", "Lords of Dawn");
                break;
              case SevenSigns.CABAL_DUSK:
                html.replace("%ss_strife%", "Revolutionaries of Dusk");
                break;
            }
          }
          player.sendPacket(html);
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
        }
        return;
      }
      else if(actualCommand.equalsIgnoreCase("items"))
      {
        if((player.getClanPrivileges() & L2Clan.CP_CS_USE_FUNCTIONS) == L2Clan.CP_CS_USE_FUNCTIONS)
        {
          if(val == "")
            return;

          player.tempInvetoryDisable();

          if(Config.DEBUG)
          {
            _log.fine("Showing chamberlain buylist");
          }
          int buy;
          {
            int castleId = getCastle().getCastleId();
            int circlet = CastleManager.getInstance().getCircletByCastleId(castleId);
            PcInventory s = player.getInventory();
            if(s.getItemByItemId(circlet) == null)
            {
              buy = Integer.parseInt(val + "1");
            }
            else
            {
              buy = Integer.parseInt(val + "2");
            }
          }
          L2TradeList list = TradeController.getInstance().getBuyList(buy);
          if(list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
          {
            BuyList bl = new BuyList(list, player.getAdena(), 0);
            player.sendPacket(bl);
          }
          else
          {
            _log.warning("player: " + player.getName() + " attempting to buy from chamberlain that don't have buylist!");
            _log.warning("buylist id:" + buy);
          }
          list = null;

          player.sendPacket(ActionFailed.STATIC_PACKET);
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
          html = null;
          return;
        }
      }
      else if(actualCommand.equalsIgnoreCase("manage_vault"))
      {
        if((player.getClanPrivileges() & L2Clan.CP_CS_TAXES) == L2Clan.CP_CS_TAXES)
        {
          String filename = "data/html/chamberlain/chamberlain-vault.htm";
          int amount = 0;
          if(val.equalsIgnoreCase("deposit"))
          {
            try
            {
              amount = Integer.parseInt(st.nextToken());
            }
            catch(NoSuchElementException e)
            {
              if(Config.ENABLE_ALL_EXCEPTIONS)
                e.printStackTrace();
            }
            if(amount > 0 && (long) getCastle().getTreasury() + amount < Integer.MAX_VALUE)
            {
              if(player.reduceAdena("Castle", amount, this, true))
              {
                getCastle().addToTreasuryNoTax(amount);
              }
              else
              {
                sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
              }
            }
          }
          else if(val.equalsIgnoreCase("withdraw"))
          {
            try
            {
              amount = Integer.parseInt(st.nextToken());
            }
            catch(NoSuchElementException e)
            {
              if(Config.ENABLE_ALL_EXCEPTIONS)
                e.printStackTrace();
            }
            if(amount > 0)
            {
              if(getCastle().getTreasury() < amount)
              {
                filename = "data/html/chamberlain/chamberlain-vault-no.htm";
              }
              else
              {
                if(getCastle().addToTreasuryNoTax(-1 * amount))
                {
                  player.addAdena("Castle", amount, this, true);
                }
              }
            }
          }

          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile(filename);
          html.replace("%objectId%", String.valueOf(getObjectId()));
          html.replace("%npcname%", getName());
          html.replace("%tax_income%", Util.formatAdena(getCastle().getTreasury()));
          html.replace("%withdraw_amount%", Util.formatAdena(amount));
          player.sendPacket(html);
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
        }
        return;
      }
      else if(actualCommand.equalsIgnoreCase("manor"))
      {
        if((player.getClanPrivileges() & L2Clan.CP_CS_MANOR_ADMIN) == L2Clan.CP_CS_MANOR_ADMIN)
        {
          String filename = "";
          if(CastleManorManager.getInstance().isDisabled())
          {
            filename = "data/html/npcdefault.htm";
          }
          else
          {
            int cmd = Integer.parseInt(val);
            switch(cmd)
            {
              case 0:
                filename = "data/html/chamberlain/manor/manor.htm";
                break;
              // TODO: correct in html's to 1
              case 4:
                filename = "data/html/chamberlain/manor/manor_help00" + st.nextToken() + ".htm";
                break;
              default:
                filename = "data/html/chamberlain/chamberlain-no.htm";
                break;
            }
          }
          if(filename.length() != 0)
          {
            NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
            html.setFile(filename);
            html.replace("%objectId%", String.valueOf(getObjectId()));
            html.replace("%npcname%", getName());
            player.sendPacket(html);
            html = null;
            filename = null;
          }
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
        }
        return;
      }
      else if(command.startsWith("manor_menu_select"))
      {// input string format:
        // manor_menu_select?ask=X&state=Y&time=X
        if((player.getClanPrivileges() & L2Clan.CP_CS_MANOR_ADMIN) == L2Clan.CP_CS_MANOR_ADMIN)
        {
          if(CastleManorManager.getInstance().isUnderMaintenance())
          {
            player.sendPacket(ActionFailed.STATIC_PACKET);
            player.sendPacket(new SystemMessage(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE));
            return;
          }

          String params = command.substring(command.indexOf("?") + 1);
          StringTokenizer str = new StringTokenizer(params, "&");
          int ask = Integer.parseInt(str.nextToken().split("=")[1]);
          int state = Integer.parseInt(str.nextToken().split("=")[1]);
          int time = Integer.parseInt(str.nextToken().split("=")[1]);

          int castleId;
          if(state == -1)
          {
            castleId = getCastle().getCastleId();
          }
          else
          {
            // info for requested manor
            castleId = state;
          }

          switch(ask)
          { // Main action
            case 3: // Current seeds (Manor info)
              if(time == 1 && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
              {
                player.sendPacket(new ExShowSeedInfo(castleId, null));
              }
              else
              {
                player.sendPacket(new ExShowSeedInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getSeedProduction(time)));
              }
              break;
            case 4: // Current crops (Manor info)
              if(time == 1 && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
              {
                player.sendPacket(new ExShowCropInfo(castleId, null));
              }
              else
              {
                player.sendPacket(new ExShowCropInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getCropProcure(time)));
              }
              break;
            case 5: // Basic info (Manor info)
              player.sendPacket(new ExShowManorDefaultInfo());
              break;
            case 7: // Edit seed setup
              if(getCastle().isNextPeriodApproved())
              {
                player.sendPacket(new SystemMessage(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM));
              }
              else
              {
                player.sendPacket(new ExShowSeedSetting(getCastle().getCastleId()));
              }
              break;
            case 8: // Edit crop setup
              if(getCastle().isNextPeriodApproved())
              {
                player.sendPacket(new SystemMessage(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM));
              }
              else
              {
                player.sendPacket(new ExShowCropSetting(getCastle().getCastleId()));
              }
              break;
          }
          params = null;
          str = null;
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
          html = null;
          return;
        }
      }
      else if(actualCommand.equalsIgnoreCase("operate_door")) // door control
      {
        if((player.getClanPrivileges() & L2Clan.CP_CS_OPEN_DOOR) == L2Clan.CP_CS_OPEN_DOOR)
        {
          if(!val.isEmpty())
          {
            boolean open = Integer.parseInt(val) == 1;
            while(st.hasMoreTokens())
            {
              getCastle().openCloseDoor(player, Integer.parseInt(st.nextToken()), open);
            }
          }

          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/" + getTemplate().npcId + "-d.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          html.replace("%npcname%", getName());
          player.sendPacket(html);
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-noprivs.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          player.sendPacket(html);
        }
        return;
      }
      else if(actualCommand.equalsIgnoreCase("tax_set")) // tax rates control
      {
        if((player.getClanPrivileges() & L2Clan.CP_CS_TAXES) == L2Clan.CP_CS_TAXES)
        {
          if(!val.isEmpty())
          {
            getCastle().setTaxPercent(player, Integer.parseInt(val));
          }

          TextBuilder msg = new TextBuilder("<html><body>");
          msg.append(getName() + ":<br>");
          msg.append("Current tax rate: " + getCastle().getTaxPercent() + "%<br>");
          msg.append("<table>");
          msg.append("<tr>");
          msg.append("<td>Change tax rate to:</td>");
          msg.append("<td><edit var=\"value\" width=40><br>");
          msg.append("<button value=\"Adjust\" action=\"bypass -h npc_%objectId%_tax_set $value\" width=80 height=15></td>");
          msg.append("</tr>");
          msg.append("</table>");
          msg.append("</center>");
          msg.append("</body></html>");

          sendHtmlMessage(player, msg.toString());
          msg = null;
        }
        else
        {
          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setFile("data/html/chamberlain/chamberlain-tax.htm");
          html.replace("%objectId%", String.valueOf(getObjectId()));
          html.replace("%tax%", String.valueOf(getCastle().getTaxPercent()));
          player.sendPacket(html);
        }
        return;
      }
    }
View Full Code Here


    super.onBypassFeedback(player, command);
  }

  private void sendHtmlMessage(L2PcInstance player, String htmlMessage)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    html.setHtml(htmlMessage);
    html.replace("%objectId%", String.valueOf(getObjectId()));
    html.replace("%npcname%", getName());
    player.sendPacket(html);
    html = null;
  }
View Full Code Here

      {
        filename = "data/html/chamberlain/chamberlain.htm"; // Owner message window
      }
    }

    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    html.setFile(filename);
    html.replace("%objectId%", String.valueOf(getObjectId()));
    html.replace("%npcId%", String.valueOf(getNpcId()));
    html.replace("%npcname%", getName());
    player.sendPacket(html);
    filename = null;
    html = null;
  }
View Full Code Here

          //L2ItemInstance adenaItem = player.getInventory().getAdenaInstance(); ???
          if(!player.reduceAdena("SevenSigns", SevenSigns.RECORD_SEVEN_SIGNS_COST, this, false))
          {
            String filename = "data/html/seven_signs/noadena.htm";                           
            NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
            html.setFile(filename);
            html.replace("%objectId%", String.valueOf(getObjectId()));
            player.sendPacket(html);
            break;
          }
         
          player.addItem("SevenSigns", SevenSigns.RECORD_SEVEN_SIGNS_ID, 1, player, true);

          // Update current load as well
          su = new StatusUpdate(player.getObjectId());
          su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
          sendPacket(su);

          //adenaItem = null;
          break;
        case 3: // Join Cabal Intro 1
        case 8: // Festival of Darkness Intro - SevenSigns x [0]1
        case 10: // Teleport Locations List
          showChatWindow(player, val, SevenSigns.getCabalShortName(cabal), false);
          break;
        case 4: // Join a Cabal - SevenSigns 4 [0]1 x
          int newSeal = Integer.parseInt(command.substring(15));
          int oldCabal = SevenSigns.getInstance().getPlayerCabal(player);

          if(oldCabal != SevenSigns.CABAL_NULL)
          {
            player.sendMessage("You are already a member of the " + SevenSigns.getCabalName(cabal) + ".");
            return;
          }

          if(player.getClassId().level() == 0)
          {
            player.sendMessage("You must have already completed your first class transfer.");
            break;
          }
          else if(player.getClassId().level() >= 2)
          {
            if(Config.ALT_GAME_REQUIRE_CASTLE_DAWN)
            {
              if(getPlayerAllyHasCastle(player))
              {
                if(cabal == SevenSigns.CABAL_DUSK)
                {
                  player.sendMessage("You must not be a member of a castle-owning clan to join the Revolutionaries of Dusk.");
                  return;
                }
              }
              //TODO
              if(!getPlayerAllyHasCastle(player))
              {
                if(cabal == SevenSigns.CABAL_DAWN)
                {
                  player.sendMessage("You must be a member of a castle-owning clan to join the Lords Of Dawn.");
                  return;
                }
              }

              else
              {
                /*
                 * If the player is trying to join the Lords of Dawn, check if they are
                 * carrying a Lord's certificate.
                 *
                 * If not then try to take the required amount of adena instead.
                 */
                if(cabal == SevenSigns.CABAL_DAWN)
                {
                  boolean allowJoinDawn = false;

                  if(player.destroyItemByItemId("SevenSigns", SevenSigns.CERTIFICATE_OF_APPROVAL_ID, 1, this, false))
                  {
                    sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
                    sm.addNumber(1);
                    sm.addItemName(SevenSigns.CERTIFICATE_OF_APPROVAL_ID);
                    player.sendPacket(sm);
                    allowJoinDawn = true;
                  }
                  else if(player.reduceAdena("SevenSigns", SevenSigns.ADENA_JOIN_DAWN_COST, this, false))
                  {
                    sm = new SystemMessage(SystemMessageId.DISSAPEARED_ADENA);
                    sm.addNumber(SevenSigns.ADENA_JOIN_DAWN_COST);
                    player.sendPacket(sm);
                    allowJoinDawn = true;
                  }

                  if(!allowJoinDawn)
                  {
                    player.sendMessage("You must be a member of a castle-owning clan, have a Certificate of Lord's Approval, or pay 50000 adena to join the Lords of Dawn.");
                    return;
                  }
                }
              }
            }
          }

          SevenSigns.getInstance().setPlayerInfo(player, cabal, newSeal);

          // Joined Dawn
          if(cabal == SevenSigns.CABAL_DAWN)
          {
            player.sendPacket(new SystemMessage(SystemMessageId.SEVENSIGNS_PARTECIPATION_DAWN));
          }
          else
          {
            player.sendPacket(new SystemMessage(SystemMessageId.SEVENSIGNS_PARTECIPATION_DUSK)); // Joined Dusk
          }

          // Show a confirmation message to the user, indicating which seal they chose.
          switch(newSeal)
          {
            case SevenSigns.SEAL_AVARICE:
              player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_AVARICE));
              break;
            case SevenSigns.SEAL_GNOSIS:
              player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_GNOSIS));
              break;
            case SevenSigns.SEAL_STRIFE:
              player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_STRIFE));
              break;
          }

          showChatWindow(player, 4, SevenSigns.getCabalShortName(cabal), false);
          break;
        case 6: // Contribute Seal Stones - SevenSigns 6 x
          stoneType = Integer.parseInt(command.substring(13));
          L2ItemInstance redStones = player.getInventory().getItemByItemId(SevenSigns.SEAL_STONE_RED_ID);
          int redStoneCount = redStones == null ? 0 : redStones.getCount();
          L2ItemInstance greenStones = player.getInventory().getItemByItemId(SevenSigns.SEAL_STONE_GREEN_ID);
          int greenStoneCount = greenStones == null ? 0 : greenStones.getCount();
          L2ItemInstance blueStones = player.getInventory().getItemByItemId(SevenSigns.SEAL_STONE_BLUE_ID);
          int blueStoneCount = blueStones == null ? 0 : blueStones.getCount();
          int contribScore = SevenSigns.getInstance().getPlayerContribScore(player);
          boolean stonesFound = false;

          if(contribScore == Config.ALT_MAXIMUM_PLAYER_CONTRIB)
          {
            player.sendPacket(new SystemMessage(SystemMessageId.CONTRIB_SCORE_EXCEEDED));
            break;
          }
         
          int redContribCount = 0;
          int greenContribCount = 0;
          int blueContribCount = 0;

          switch(stoneType)
          {
            case 1:
              blueContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore) / SevenSigns.BLUE_CONTRIB_POINTS;
              if(blueContribCount > blueStoneCount)
              {
                blueContribCount = blueStoneCount;
              }
              break;
            case 2:
              greenContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore) / SevenSigns.GREEN_CONTRIB_POINTS;
              if(greenContribCount > greenStoneCount)
              {
                greenContribCount = greenStoneCount;
              }
              break;
            case 3:
              redContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore) / SevenSigns.RED_CONTRIB_POINTS;
              if(redContribCount > redStoneCount)
              {
                redContribCount = redStoneCount;
              }
              break;
            case 4:
              int tempContribScore = contribScore;
              redContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore) / SevenSigns.RED_CONTRIB_POINTS;
              if(redContribCount > redStoneCount)
              {
                redContribCount = redStoneCount;
              }
              tempContribScore += redContribCount * SevenSigns.RED_CONTRIB_POINTS;
              greenContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore) / SevenSigns.GREEN_CONTRIB_POINTS;
              if(greenContribCount > greenStoneCount)
              {
                greenContribCount = greenStoneCount;
              }
              tempContribScore += greenContribCount * SevenSigns.GREEN_CONTRIB_POINTS;
              blueContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore) / SevenSigns.BLUE_CONTRIB_POINTS;
              if(blueContribCount > blueStoneCount)
              {
                blueContribCount = blueStoneCount;
              }
              break;
          }
          if(redContribCount > 0)
          {
            if(player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_RED_ID, redContribCount, this, false))
            {
              stonesFound = true;
            }
          }
          if(greenContribCount > 0)
          {
            if(player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_GREEN_ID, greenContribCount, this, false))
            {
              stonesFound = true;
            }
          }
          if(blueContribCount > 0)
          {
            if(player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_BLUE_ID, blueContribCount, this, false))
            {
              stonesFound = true;
            }
          }

          if(!stonesFound)
          {
            player.sendMessage("You do not have any seal stones of that type.");
            break;
          }
         
          contribScore = SevenSigns.getInstance().addPlayerStoneContrib(player, blueContribCount, greenContribCount, redContribCount);

          sm = new SystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED);
          sm.addNumber(contribScore);
          player.sendPacket(sm);

          showChatWindow(player, 6, null, false);
          redStones = null;
          greenStones = null;
          blueStones = null;
          break;
        case 7: // Exchange Ancient Adena for Adena - SevenSigns 7 xxxxxxx
          int ancientAdenaConvert = 0;

          try
          {
            ancientAdenaConvert = Integer.parseInt(command.substring(13).trim());
          }
          catch(NumberFormatException e)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              e.printStackTrace();
           
            showChatWindow(player, SevenSigns.SEVEN_SIGNS_HTML_PATH + "blkmrkt_3.htm");
            break;
          }
          catch(StringIndexOutOfBoundsException e)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              e.printStackTrace();
           
            showChatWindow(player, SevenSigns.SEVEN_SIGNS_HTML_PATH + "blkmrkt_3.htm");
            break;
          }

          if(ancientAdenaConvert < 1)
          {
            showChatWindow(player, SevenSigns.SEVEN_SIGNS_HTML_PATH + "blkmrkt_3.htm");
            break;
          }

          if(ancientAdenaAmount < ancientAdenaConvert)
          {
            showChatWindow(player, SevenSigns.SEVEN_SIGNS_HTML_PATH + "blkmrkt_4.htm");
            break;
          }

          player.reduceAncientAdena("SevenSigns", ancientAdenaConvert, this, true);
          player.addAdena("SevenSigns", ancientAdenaConvert, this, true);

          iu = new InventoryUpdate();
          iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
          iu.addModifiedItem(player.getInventory().getAdenaInstance());
          player.sendPacket(iu);
          break;
        case 9: // Receive Contribution Rewards
          int playerCabal = SevenSigns.getInstance().getPlayerCabal(player);
          int winningCabal = SevenSigns.getInstance().getCabalHighestScore();

          if(SevenSigns.getInstance().isSealValidationPeriod() && playerCabal == winningCabal)
          {
            int ancientAdenaReward = SevenSigns.getInstance().getAncientAdenaReward(player, true);

            if(ancientAdenaReward < 3)
            {
              showChatWindow(player, 9, "b", false);
              break;
            }

            player.addAncientAdena("SevenSigns", ancientAdenaReward, this, true);

            // Send inventory update packet
            iu = new InventoryUpdate();
            iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
            sendPacket(iu);

            // Update current load as well
            su = new StatusUpdate(player.getObjectId());
            su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
            sendPacket(su);

            showChatWindow(player, 9, "a", false);
          }
          break;
        case 11: // Teleport to Hunting Grounds
          try
          {
            String portInfo = command.substring(14).trim();

            StringTokenizer st = new StringTokenizer(portInfo);
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());
            int z = Integer.parseInt(st.nextToken());
            int ancientAdenaCost = Integer.parseInt(st.nextToken());

            if(ancientAdenaCost > 0)
            {
              if(!player.reduceAncientAdena("SevenSigns", ancientAdenaCost, this, true))
              {
                break;
              }
            }

            portInfo = null;
            st = null;
            player.teleToLocation(x, y, z, true);
          }
          catch(Exception e)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              e.printStackTrace();
           
            _log.warning("SevenSigns: Error occurred while teleporting player: " + e);
          }
          break;
        case 17: // Exchange Seal Stones for Ancient Adena (Type Choice) - SevenSigns 17 x
          stoneType = Integer.parseInt(command.substring(14));
          int stoneId = 0;
          int stoneCount = 0;
          int stoneValue = 0;
          String stoneColor = null;
          String content;

          switch(stoneType)
          {
            case 1:
              stoneColor = "blue";
              stoneId = SevenSigns.SEAL_STONE_BLUE_ID;
              stoneValue = SevenSigns.SEAL_STONE_BLUE_VALUE;
              break;
            case 2:
              stoneColor = "green";
              stoneId = SevenSigns.SEAL_STONE_GREEN_ID;
              stoneValue = SevenSigns.SEAL_STONE_GREEN_VALUE;
              break;
            case 3:
              stoneColor = "red";
              stoneId = SevenSigns.SEAL_STONE_RED_ID;
              stoneValue = SevenSigns.SEAL_STONE_RED_VALUE;
              break;
          }

          L2ItemInstance stoneInstance = player.getInventory().getItemByItemId(stoneId);

          if(stoneInstance != null)
          {
            stoneCount = stoneInstance.getCount();
          }

          path = SevenSigns.SEVEN_SIGNS_HTML_PATH + "signs_17.htm";
          content = HtmCache.getInstance().getHtm(path);

          if(content != null)
          {
            content = content.replaceAll("%stoneColor%", stoneColor);
            content = content.replaceAll("%stoneValue%", String.valueOf(stoneValue));
            content = content.replaceAll("%stoneCount%", String.valueOf(stoneCount));
            content = content.replaceAll("%stoneItemId%", String.valueOf(stoneId));
            content = content.replaceAll("%objectId%", String.valueOf(getObjectId()));

            NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
            html.setHtml(content);
            player.sendPacket(html);
            html = null;
          }
          else
          {
            _log.warning("Problem with HTML text " + SevenSigns.SEVEN_SIGNS_HTML_PATH + "signs_17.htm: " + path);
          }

          stoneInstance = null;
          stoneColor = null;
          content = null;
          break;
        case 18: // Exchange Seal Stones for Ancient Adena - SevenSigns 18 xxxx xxxxxx
          int convertStoneId = Integer.parseInt(command.substring(14, 18));
          int convertCount = 0;

          try
          {
            convertCount = Integer.parseInt(command.substring(19).trim());
          }
          catch(Exception NumberFormatException)
          {
            if(Config.ENABLE_ALL_EXCEPTIONS)
              NumberFormatException.printStackTrace();
           
            player.sendMessage("You must enter an integer amount.");
            break;
          }

          L2ItemInstance convertItem = player.getInventory().getItemByItemId(convertStoneId);

          if(convertItem == null)
          {
            player.sendMessage("You do not have any seal stones of that type.");
            break;
          }

          int totalCount = convertItem.getCount();
          int ancientAdenaReward = 0;

          if(convertCount <= totalCount && convertCount > 0)
          {
            switch(convertStoneId)
            {
              case SevenSigns.SEAL_STONE_BLUE_ID:
                ancientAdenaReward = SevenSigns.calcAncientAdenaReward(convertCount, 0, 0);
                break;
              case SevenSigns.SEAL_STONE_GREEN_ID:
                ancientAdenaReward = SevenSigns.calcAncientAdenaReward(0, convertCount, 0);
                break;
              case SevenSigns.SEAL_STONE_RED_ID:
                ancientAdenaReward = SevenSigns.calcAncientAdenaReward(0, 0, convertCount);
                break;
            }

            if(player.destroyItemByItemId("SevenSigns", convertStoneId, convertCount, this, true))
            {
              player.addAncientAdena("SevenSigns", ancientAdenaReward, this, true);

              // Send inventory update packet
              iu = new InventoryUpdate();
              iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
              iu.addModifiedItem(convertItem);
              sendPacket(iu);

              // Update current load as well
              su = new StatusUpdate(player.getObjectId());
              su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
              sendPacket(su);
            }
          }
          else
          {
            player.sendMessage("You do not have that many seal stones.");
          }
          convertItem = null;
          break;
        case 19: // Seal Information (for when joining a cabal)
          int chosenSeal = Integer.parseInt(command.substring(16));
          String fileSuffix = SevenSigns.getSealName(chosenSeal, true) + "_" + SevenSigns.getCabalShortName(cabal);

          showChatWindow(player, val, fileSuffix, false);
          fileSuffix = null;
          break;
        case 20: // Seal Status (for when joining a cabal)
          TextBuilder contentBuffer = new TextBuilder("<html><body><font color=\"LEVEL\">[ Seal Status ]</font><br>");

          for(int i = 1; i < 4; i++)
          {
            int sealOwner = SevenSigns.getInstance().getSealOwner(i);

            if(sealOwner != SevenSigns.CABAL_NULL)
            {
              contentBuffer.append("[" + SevenSigns.getSealName(i, false) + ": " + SevenSigns.getCabalName(sealOwner) + "]<br>");
            }
            else
            {
              contentBuffer.append("[" + SevenSigns.getSealName(i, false) + ": Nothingness]<br>");
            }
          }

          contentBuffer.append("<a action=\"bypass -h npc_" + getObjectId() + "_SevenSigns 3 " + cabal + "\">Go back.</a></body></html>");

          NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
          html.setHtml(contentBuffer.toString());
          player.sendPacket(html);
          contentBuffer = null;
          html = null;
          break;
        default:
View Full Code Here

    else if(condition == COND_OWNER)
    {
      filename = "data/html/mercmanager/mercmanager.htm"; // Owner message window
    }

    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    html.setFile(filename);
    html.replace("%objectId%", String.valueOf(getObjectId()));
    html.replace("%npcId%", String.valueOf(getNpcId()));
    html.replace("%npcname%", getName());
    player.sendPacket(html);
    filename = null;
    html = null;
  }
View Full Code Here

    if(mid2 != 0)
    {
      npc2 = NpcTable.getInstance().getTemplate(mid2);
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    TextBuilder replyMSG = new TextBuilder();

    if(npc1 != null && npc2 != null)
    {
      replyMSG.append("<html><title>Selected mobs to fight</title>");
      replyMSG.append("<body>");
      replyMSG.append("<table>");
      replyMSG.append("<tr><td>First</td><td>Second</td></tr>");
      replyMSG.append("<tr><td>level " + lvl1 + "</td><td>level " + lvl2 + "</td></tr>");
      replyMSG.append("<tr><td>id " + npc1.npcId + "</td><td>id " + npc2.npcId + "</td></tr>");
      replyMSG.append("<tr><td>" + npc1.name + "</td><td>" + npc2.name + "</td></tr>");
      replyMSG.append("</table>");
      replyMSG.append("<center><br><br><br>");
      replyMSG.append("<button value=\"OK\" action=\"bypass -h admin_fight_calculator_show " + npc1.npcId + " " + npc2.npcId + "\"  width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
      replyMSG.append("</center>");
      replyMSG.append("</body></html>");
    }
    else if(lvl1 != 0 && npc1 == null)
    {
      replyMSG.append("<html><title>Select first mob to fight</title>");
      replyMSG.append("<body><table>");

      L2NpcTemplate[] npcs = NpcTable.getInstance().getAllOfLevel(lvl1);

      for(L2NpcTemplate n : npcs)
      {
        replyMSG.append("<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 " + lvl1 + " lvl2 " + lvl2 + " mid1 " + n.npcId + " mid2 " + mid2 + "\">" + n.name + "</a></td></tr>");
      }

      replyMSG.append("</table></body></html>");

      npcs = null;
    }
    else if(lvl2 != 0 && npc2 == null)
    {
      replyMSG.append("<html><title>Select second mob to fight</title>");
      replyMSG.append("<body><table>");

      L2NpcTemplate[] npcs = NpcTable.getInstance().getAllOfLevel(lvl2);

      for(L2NpcTemplate n : npcs)
      {
        replyMSG.append("<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 " + lvl1 + " lvl2 " + lvl2 + " mid1 " + mid1 + " mid2 " + n.npcId + "\">" + n.name + "</a></td></tr>");
      }

      replyMSG.append("</table></body></html>");

      npcs = null;
    }
    else
    {
      replyMSG.append("<html><title>Select mobs to fight</title>");
      replyMSG.append("<body>");
      replyMSG.append("<table>");
      replyMSG.append("<tr><td>First</td><td>Second</td></tr>");
      replyMSG.append("<tr><td><edit var=\"lvl1\" width=80></td><td><edit var=\"lvl2\" width=80></td></tr>");
      replyMSG.append("</table>");
      replyMSG.append("<center><br><br><br>");
      replyMSG.append("<button value=\"OK\" action=\"bypass -h admin_fight_calculator lvl1 $lvl1 lvl2 $lvl2\"  " + "width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
      replyMSG.append("</center>");
      replyMSG.append("</body></html>");
    }

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);

    npc1 = null;
    npc2 = null;
    adminReply = null;
View Full Code Here

    int hp1 = (int) (Formulas.calcHpRegen(npc1) * 100000 / Formulas.getRegeneratePeriod(npc1));

    double maxHp2 = npc2.getMaxHp();
    int hp2 = (int) (Formulas.calcHpRegen(npc2) * 100000 / Formulas.getRegeneratePeriod(npc2));

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    TextBuilder replyMSG = new TextBuilder();
    replyMSG.append("<html><title>Selected mobs to fight</title>");
    replyMSG.append("<body>");
    replyMSG.append("<table>");

    if(params.length() == 0)
    {
      replyMSG.append("<tr><td width=140>Parameter</td><td width=70>me</td><td width=70>target</td></tr>");
    }
    else
    {
      replyMSG.append("<tr><td width=140>Parameter</td><td width=70>" + ((L2NpcTemplate) npc1.getTemplate()).name + "</td><td width=70>" + ((L2NpcTemplate) npc2.getTemplate()).name + "</td></tr>");
    }

    replyMSG.append("<tr><td>miss</td><td>" + miss1 + "%</td><td>" + miss2 + "%</td></tr>");
    replyMSG.append("<tr><td>shld</td><td>" + shld2 + "%</td><td>" + shld1 + "%</td></tr>");
    replyMSG.append("<tr><td>Physic crit</td><td>" + crit1 + "%</td><td>" + crit2 + "%</td></tr>");
    replyMSG.append("<tr><td>Magic crit</td><td>" + crit4 + "%</td><td>" + crit3 + "%</td></tr>");
    replyMSG.append("<tr><td>pAtk / pDef</td><td>" + (int) patk1 + " / " + (int) pdef1 + "</td><td>" + (int) patk2 + " / " + (int) pdef2 + "</td></tr>");
    replyMSG.append("<tr><td>made hits</td><td>" + sAtk1 + "</td><td>" + sAtk2 + "</td></tr>");
    replyMSG.append("<tr><td>dmg per hit</td><td>" + (int) dmg1 + "</td><td>" + (int) dmg2 + "</td></tr>");
    replyMSG.append("<tr><td>got dmg</td><td>" + tdmg2 + "</td><td>" + tdmg1 + "</td></tr>");
    replyMSG.append("<tr><td>got regen</td><td>" + hp1 + "</td><td>" + hp2 + "</td></tr>");
    replyMSG.append("<tr><td>had HP</td><td>" + (int) maxHp1 + "</td><td>" + (int) maxHp2 + "</td></tr>");
    replyMSG.append("<tr><td>die</td>");

    if(tdmg2 - hp1 > 1)
    {
      replyMSG.append("<td>" + (int) (100 * maxHp1 / (tdmg2 - hp1)) + " sec</td>");
    }
    else
    {
      replyMSG.append("<td>never</td>");
    }

    if(tdmg1 - hp2 > 1)
    {
      replyMSG.append("<td>" + (int) (100 * maxHp2 / (tdmg1 - hp2)) + " sec</td>");
    }
    else
    {
      replyMSG.append("<td>never</td>");
    }

    replyMSG.append("</tr>");
    replyMSG.append("</table>");
    replyMSG.append("<center><br>");

    if(params.length() == 0)
    {
      replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show\"  width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
    }
    else
    {
      replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show " + ((L2NpcTemplate) npc1.getTemplate()).npcId + " " + ((L2NpcTemplate) npc2.getTemplate()).npcId + "\"  width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
    }

    replyMSG.append("</center>");
    replyMSG.append("</body></html>");
    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);

    if(params.length() != 0)
    {
      ((L2MonsterInstance) npc1).deleteMe();
View Full Code Here

      asl.addSkill(s.getId(), s.getLevel(), s.getLevel(), s.getSpCost(), 1);
    }

    if(counts == 0)
    {
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      int minlevel = SkillTreeTable.getInstance().getMinLevelForNewSkill(player);

      if(minlevel > 0)
      {
        // No more skills to learn, come back when you level.
        SystemMessage sm = new SystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN);
        sm.addNumber(minlevel);
        player.sendPacket(sm);
        sm = null;
      }
      else
      {
        TextBuilder sb = new TextBuilder();
        sb.append("<html><head><body>");
        sb.append("You've learned all skills.<br>");
        sb.append("</body></html>");
        html.setHtml(sb.toString());
        player.sendPacket(html);
        sb = null;
        html = null;
      }
    }
View Full Code Here

    player.sendPacket(new ActionFailed());
  }
  @Override
  public void showChatWindow(L2PcInstance player, int val)
  {
    NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
    msg.setHtml(rbWindow(player));
    msg.replace("%objectId%", String.valueOf(this.getObjectId()));
    player.sendPacket(msg);
  }
View Full Code Here

    tb.append("<br><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>");
    tb.append("</center></body></html>");
   
   
    NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
    msg.setHtml(tb.toString());
   
    activeChar.sendPacket(msg);
   
  }
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.network.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.