@Override
  public void onBypassFeedback(L2PcInstance player, String command) {
    if (command.startsWith("1stClass")) {
      showHtmlMenu(player, getObjectId(), 1);
    } else if (command.startsWith("2ndClass")) {
      showHtmlMenu(player, getObjectId(), 2);
    } else if (command.startsWith("3rdClass")) {
      showHtmlMenu(player, getObjectId(), 3);
    } else if (command.startsWith("change_class")) {
      int val = Integer.parseInt(command.substring(13));

      if (checkAndChangeClass(player, val)) {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile(player.getHtmlPrefix(), "data/html/classmaster/ok.htm");
        html.replace("%name%", CharTemplateTable.getInstance().getClassNameById(val));
        player.sendPacket(html);
      }
    } else if (command.startsWith("become_noble")) {
      if (!player.isNoble()) {
        player.setNoble(true);
        player.sendPacket(new UserInfo(player));
        player.sendPacket(new ExBrExtraUserInfo(player));
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile(player.getHtmlPrefix(), "data/html/classmaster/nobleok.htm");
        player.sendPacket(html);
      }
    } else if (command.startsWith("learn_skills")) {
      player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, true);
    } else if (command.startsWith("increase_clan_level")) {
      if (!player.isClanLeader()) {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile(player.getHtmlPrefix(), "data/html/classmaster/noclanleader.htm");
        player.sendPacket(html);
      } else if (player.getClan().getLevel() >= 5) {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile(player.getHtmlPrefix(), "data/html/classmaster/noclanlevel.htm");
        player.sendPacket(html);
      } else {
        player.getClan().changeLevel(5);
      }
    } else {
      super.onBypassFeedback(player, command);
    }
  }
  @Override
  public void showChatWindow(L2PcInstance player, int val) {
    String filename = null;

    if (isInsideRadius(-79884, 86529, 50, true)
        || isInsideRadius(-78858, 111358, 50, true)
        || isInsideRadius(-76973, 87136, 50, true)
        || isInsideRadius(-75850, 111968, 50, true)) {
      if (val == 0) filename = "data/html/observation/" + getNpcId() + "-Oracle.htm";
      else filename = "data/html/observation/" + getNpcId() + "-Oracle-" + val + ".htm";
    } else {
      if (val == 0) filename = "data/html/observation/" + getNpcId() + ".htm";
      else filename = "data/html/observation/" + getNpcId() + "-" + val + ".htm";
    }

    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    html.setFile(player.getHtmlPrefix(), filename);
    html.replace("%objectId%", String.valueOf(getObjectId()));
    player.sendPacket(html);
  }
Exemplo n.º 3
0
  @Override
  public void runImpl() {
    L2PcInstance actor = getClient().getActiveChar();
    if (actor == null) return;

    if (_link.contains("..") || !_link.contains(".htm")) {
      _log.warning(
          "[RequestLinkHtml] hack? link contains prohibited characters: '" + _link + "', skipped");
      return;
    }
    try {
      String filename = "data/html/" + _link;
      NpcHtmlMessage msg = new NpcHtmlMessage(0);
      msg.disableValidation();
      msg.setFile(actor.getHtmlPrefix(), filename);
      sendPacket(msg);
    } catch (Exception e) {
      _log.log(Level.WARNING, "Bad RequestLinkHtml: ", e);
    }
  }
  private static final void showHtmlMenu(L2PcInstance player, int objectId, int level) {
    NpcHtmlMessage html = new NpcHtmlMessage(objectId);

    if (!Config.ALLOW_CLASS_MASTERS) {
      html.setFile(player.getHtmlPrefix(), "data/html/classmaster/disabled.htm");
    } else if (!Config.CLASS_MASTER_SETTINGS.isAllowed(level)) {
      int jobLevel = player.getClassId().level();
      final StringBuilder sb = new StringBuilder(100);
      sb.append("<html><body>");
      switch (jobLevel) {
        case 0:
          if (Config.CLASS_MASTER_SETTINGS.isAllowed(1))
            sb.append("Come back here when you reached level 20 to change your class.<br>");
          else if (Config.CLASS_MASTER_SETTINGS.isAllowed(2))
            sb.append("Come back after your first occupation change.<br>");
          else if (Config.CLASS_MASTER_SETTINGS.isAllowed(3))
            sb.append("Come back after your second occupation change.<br>");
          else sb.append("I can't change your occupation.<br>");
          break;
        case 1:
          if (Config.CLASS_MASTER_SETTINGS.isAllowed(2))
            sb.append("Come back here when you reached level 40 to change your class.<br>");
          else if (Config.CLASS_MASTER_SETTINGS.isAllowed(3))
            sb.append("Come back after your second occupation change.<br>");
          else sb.append("I can't change your occupation.<br>");
          break;
        case 2:
          if (Config.CLASS_MASTER_SETTINGS.isAllowed(3))
            sb.append("Come back here when you reached level 76 to change your class.<br>");
          else sb.append("I can't change your occupation.<br>");
          break;
        case 3:
          sb.append("There is no class change available for you anymore.<br>");
          break;
      }
      sb.append("</body></html>");
      html.setHtml(sb.toString());
    } else {
      final ClassId currentClassId = player.getClassId();
      if (currentClassId.level() >= level) {
        html.setFile(player.getHtmlPrefix(), "data/html/classmaster/nomore.htm");
      } else {
        final int minLevel = getMinLevel(currentClassId.level());
        if (player.getLevel() >= minLevel || Config.ALLOW_ENTIRE_TREE) {
          final StringBuilder menu = new StringBuilder(100);
          for (ClassId cid : ClassId.values()) {
            if (cid == ClassId.inspector && player.getTotalSubClasses() < 2) continue;
            if (validateClassId(currentClassId, cid) && cid.level() == level) {
              StringUtil.append(
                  menu,
                  "<a action=\"bypass -h npc_%objectId%_change_class ",
                  String.valueOf(cid.getId()),
                  "\">",
                  CharTemplateTable.getInstance().getClassNameById(cid.getId()),
                  "</a><br>");
            }
          }

          if (menu.length() > 0) {
            html.setFile(player.getHtmlPrefix(), "data/html/classmaster/template.htm");
            html.replace(
                "%name%", CharTemplateTable.getInstance().getClassNameById(currentClassId.getId()));
            html.replace("%menu%", menu.toString());
          } else {
            html.setFile(player.getHtmlPrefix(), "data/html/classmaster/comebacklater.htm");
            html.replace("%level%", String.valueOf(getMinLevel(level - 1)));
          }
        } else {
          if (minLevel < Integer.MAX_VALUE) {
            html.setFile(player.getHtmlPrefix(), "data/html/classmaster/comebacklater.htm");
            html.replace("%level%", String.valueOf(minLevel));
          } else html.setFile(player.getHtmlPrefix(), "data/html/classmaster/nomore.htm");
        }
      }
    }

    html.replace("%objectId%", String.valueOf(objectId));
    html.replace("%req_items%", getRequiredItems(level));
    player.sendPacket(html);
  }