コード例 #1
1
  public String getGeneralStats() {
    final StringBuilder sb = new StringBuilder(1000);
    ThreadFactory tf = _generalThreadPool.getThreadFactory();

    if (tf instanceof PriorityThreadFactory) {
      PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
      int count = ptf.getGroup().activeCount();
      Thread[] threads = new Thread[count + 2];
      ptf.getGroup().enumerate(threads);
      StringUtil.append(
          sb,
          "General Thread Pool:\r\n" + "Tasks in the queue: ",
          String.valueOf(_generalThreadPool.getQueue().size()),
          "\r\n" + "Showing threads stack trace:\r\n" + "There should be ",
          String.valueOf(count),
          " Threads\r\n");

      for (Thread t : threads) {
        if (t == null) continue;

        StringUtil.append(sb, t.getName(), "\r\n");

        for (StackTraceElement ste : t.getStackTrace()) {
          StringUtil.append(sb, ste.toString(), "\r\n");
        }
      }
    }

    sb.append("Packet Tp stack traces printed.\r\n");

    return sb.toString();
  }
コード例 #2
0
  private void showFortSelectPage(L2PcInstance activeChar) {
    int i = 0;
    final NpcHtmlMessage adminReply = new NpcHtmlMessage();
    adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/forts.htm");

    final List<Fort> forts = FortManager.getInstance().getForts();
    final StringBuilder cList = new StringBuilder(forts.size() * 100);

    for (Fort fort : forts) {
      if (fort != null) {
        // L2JTW uses fort.getCName() instead of fort.getName()
        StringUtil.append(
            cList,
            "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ",
            String.valueOf(fort.getResidenceId()),
            "\">",
            fort.getName(),
            " id: ",
            String.valueOf(fort.getResidenceId()),
            "</a></td>");
        i++;
      }
      // L2JTW: if (i > 0)
      if (i > 2) {
        cList.append("</tr><tr>");
        i = 0;
      }
    }

    adminReply.replace("%forts%", cList.toString());
    activeChar.sendPacket(adminReply);
  }
コード例 #3
0
  private static final void showTutorialHtml(L2PcInstance player) {
    final ClassId currentClassId = player.getClassId();
    if (getMinLevel(currentClassId.level()) > player.getLevel() && !Config.ALLOW_ENTIRE_TREE)
      return;

    String msg =
        HtmCache.getInstance()
            .getHtm(player.getHtmlPrefix(), "data/html/classmaster/tutorialtemplate.htm");

    msg =
        msg.replaceAll(
            "%name%", CharTemplateTable.getInstance().getClassNameById(currentClassId.getId()));

    final StringBuilder menu = new StringBuilder(100);
    for (ClassId cid : ClassId.values()) {
      if (cid == ClassId.inspector && player.getTotalSubClasses() < 2) continue;
      if (validateClassId(currentClassId, cid)) {
        StringUtil.append(
            menu,
            "<a action=\"link CO",
            String.valueOf(cid.getId()),
            "\">",
            CharTemplateTable.getInstance().getClassNameById(cid.getId()),
            "</a><br>");
      }
    }

    msg = msg.replaceAll("%menu%", menu.toString());
    msg = msg.replace("%req_items%", getRequiredItems(currentClassId.level() + 1));
    player.sendPacket(new TutorialShowHtml(msg));
  }
コード例 #4
0
ファイル: ShowBoard.java プロジェクト: rukhavi/l2j-mobius
 public ShowBoard(List<String> arg) {
   StringBuilder builder =
       new StringBuilder(5 + StringUtil.getLength(arg) + arg.size()).append("1002\u0008");
   for (String str : arg) {
     builder.append(str).append("\u0008");
   }
   _content = builder.toString();
 }
コード例 #5
0
  private void showNpcs(L2PcInstance activeChar, String starting, int from) {
    final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllNpcStartingWith(starting);
    final int mobsCount = mobs.size();
    final StringBuilder tb =
        StringUtil.startAppend(
            500 + (mobsCount * 80),
            "<html><title>Spawn Monster:</title><body><p> There are ",
            Integer.toString(mobsCount),
            " Npcs whose name starts with ",
            starting,
            ":<br>");

    // Loop
    int i = from;
    for (int j = 0; (i < mobsCount) && (j < 50); i++, j++) {
      StringUtil.append(
          tb,
          "<a action=\"bypass -h admin_spawn_monster ",
          Integer.toString(mobs.get(i).getId()),
          "\">",
          mobs.get(i).getName(),
          "</a><br1>");
    }

    if (i == mobsCount) {
      tb.append(
          "<br><center><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
    } else {
      StringUtil.append(
          tb,
          "<br><center><button value=\"Next\" action=\"bypass -h admin_npc_index ",
          starting,
          " ",
          Integer.toString(i),
          "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
    }

    activeChar.sendPacket(new NpcHtmlMessage(tb.toString()));
  }
コード例 #6
0
 public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) {
   if (activeChar.getAccessLevel().isGm()) {
     NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
     final String html1 =
         StringUtil.concat(
             "<html><body><center><font color=\"LEVEL\">Item Info</font></center><br><table border=0>",
             "<tr><td>Object ID: </td><td>",
             String.valueOf(target.getObjectId()),
             "</td></tr><tr><td>Item ID: </td><td>",
             String.valueOf(((L2ItemInstance) target).getItemId()),
             "</td></tr><tr><td>Owner ID: </td><td>",
             String.valueOf(((L2ItemInstance) target).getOwnerId()),
             "</td></tr><tr><td>Location: </td><td>",
             String.valueOf(((L2ItemInstance) target).getLocation()),
             "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>",
             target.getClass().getSimpleName(),
             "</td></tr></table></body></html>");
     html.setHtml(html1);
     activeChar.sendPacket(html);
   }
   return true;
 }
コード例 #7
0
  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);
  }
コード例 #8
0
ファイル: Hero.java プロジェクト: LucusAngel/L2J_Server_BETA
  public void showHeroFights(L2PcInstance activeChar, int heroclass, int charid, int page) {
    final int perpage = 20;
    int _win = 0;
    int _loss = 0;
    int _draw = 0;

    if (_herofights.containsKey(charid)) {
      List<StatsSet> _list = _herofights.get(charid);

      final NpcHtmlMessage FightReply = new NpcHtmlMessage();
      final String htmContent =
          HtmCache.getInstance()
              .getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herohistory.htm");
      if (htmContent != null) {
        FightReply.setHtml(htmContent);
        FightReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));

        if (!_list.isEmpty()) {
          if (_herocounts.containsKey(charid)) {
            StatsSet _herocount = _herocounts.get(charid);
            _win = _herocount.getInt("victory");
            _loss = _herocount.getInt("loss");
            _draw = _herocount.getInt("draw");
          }

          boolean color = true;
          final StringBuilder fList = new StringBuilder(500);
          int counter = 0;
          int breakat = 0;
          for (int i = ((page - 1) * perpage); i < _list.size(); i++) {
            breakat = i;
            StatsSet fight = _list.get(i);
            StringUtil.append(fList, "<tr><td>");
            if (color) {
              StringUtil.append(fList, "<table width=270 bgcolor=\"131210\">");
            } else {
              StringUtil.append(fList, "<table width=270>");
            }
            StringUtil.append(
                fList,
                "<tr><td width=220><font color=\"LEVEL\">"
                    + fight.getString("start")
                    + "</font>&nbsp;&nbsp;"
                    + fight.getString("result")
                    + "</td><td width=50 align=right>"
                    + (fight.getInt("classed") > 0
                        ? "<font color=\"FFFF99\">cls</font>"
                        : "<font color=\"999999\">non-cls<font>")
                    + "</td></tr>");
            StringUtil.append(
                fList,
                "<tr><td width=220>vs "
                    + fight.getString("oponent")
                    + " ("
                    + fight.getString("oponentclass")
                    + ")</td><td width=50 align=right>("
                    + fight.getString("time")
                    + ")</td></tr>");
            StringUtil.append(fList, "<tr><td colspan=2>&nbsp;</td></tr></table>");
            StringUtil.append(fList, "</td></tr>");
            color = !color;
            counter++;
            if (counter >= perpage) {
              break;
            }
          }

          if (breakat < (_list.size() - 1)) {
            FightReply.replace(
                "%buttprev%",
                "<button value=\"Prev\" action=\"bypass _match?class="
                    + heroclass
                    + "&page="
                    + (page + 1)
                    + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
          } else {
            FightReply.replace("%buttprev%", "");
          }

          if (page > 1) {
            FightReply.replace(
                "%buttnext%",
                "<button value=\"Next\" action=\"bypass _match?class="
                    + heroclass
                    + "&page="
                    + (page - 1)
                    + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
          } else {
            FightReply.replace("%buttnext%", "");
          }

          FightReply.replace("%list%", fList.toString());
        } else {
          FightReply.replace("%list%", "");
          FightReply.replace("%buttprev%", "");
          FightReply.replace("%buttnext%", "");
        }

        FightReply.replace("%win%", String.valueOf(_win));
        FightReply.replace("%draw%", String.valueOf(_draw));
        FightReply.replace("%loos%", String.valueOf(_loss));

        activeChar.sendPacket(FightReply);
      }
    }
  }
コード例 #9
0
ファイル: Hero.java プロジェクト: LucusAngel/L2J_Server_BETA
  public void showHeroDiary(L2PcInstance activeChar, int heroclass, int charid, int page) {
    final int perpage = 10;

    if (_herodiary.containsKey(charid)) {
      List<StatsSet> _mainlist = _herodiary.get(charid);
      final NpcHtmlMessage DiaryReply = new NpcHtmlMessage();
      final String htmContent =
          HtmCache.getInstance()
              .getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herodiary.htm");
      if ((htmContent != null) && _heroMessage.containsKey(charid)) {
        DiaryReply.setHtml(htmContent);
        DiaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
        DiaryReply.replace("%message%", _heroMessage.get(charid));
        DiaryReply.disableValidation();

        if (!_mainlist.isEmpty()) {
          FastList<StatsSet> _list = FastList.newInstance();
          _list.addAll(_mainlist);
          Collections.reverse(_list);

          boolean color = true;
          final StringBuilder fList = new StringBuilder(500);
          int counter = 0;
          int breakat = 0;
          for (int i = ((page - 1) * perpage); i < _list.size(); i++) {
            breakat = i;
            StatsSet _diaryentry = _list.get(i);
            StringUtil.append(fList, "<tr><td>");
            if (color) {
              StringUtil.append(fList, "<table width=270 bgcolor=\"131210\">");
            } else {
              StringUtil.append(fList, "<table width=270>");
            }
            StringUtil.append(
                fList,
                "<tr><td width=270><font color=\"LEVEL\">"
                    + _diaryentry.getString("date")
                    + ":xx</font></td></tr>");
            StringUtil.append(
                fList, "<tr><td width=270>" + _diaryentry.getString("action") + "</td></tr>");
            StringUtil.append(fList, "<tr><td>&nbsp;</td></tr></table>");
            StringUtil.append(fList, "</td></tr>");
            color = !color;
            counter++;
            if (counter >= perpage) {
              break;
            }
          }

          if (breakat < (_list.size() - 1)) {
            DiaryReply.replace(
                "%buttprev%",
                "<button value=\"Prev\" action=\"bypass _diary?class="
                    + heroclass
                    + "&page="
                    + (page + 1)
                    + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
          } else {
            DiaryReply.replace("%buttprev%", "");
          }

          if (page > 1) {
            DiaryReply.replace(
                "%buttnext%",
                "<button value=\"Next\" action=\"bypass _diary?class="
                    + heroclass
                    + "&page="
                    + (page - 1)
                    + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
          } else {
            DiaryReply.replace("%buttnext%", "");
          }

          DiaryReply.replace("%list%", fList.toString());

          FastList.recycle(_list);
        } else {
          DiaryReply.replace("%list%", "");
          DiaryReply.replace("%buttprev%", "");
          DiaryReply.replace("%buttnext%", "");
        }

        activeChar.sendPacket(DiaryReply);
      }
    }
  }
コード例 #10
0
 @Override
 public boolean useAdminCommand(String command, L2PcInstance activeChar) {
   if (command.equals("admin_show_spawns")) {
     AdminHtml.showAdminHtml(activeChar, "spawns.htm");
   } else if (command.equalsIgnoreCase("admin_spawn_debug_menu")) {
     AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
   } else if (command.startsWith("admin_spawn_debug_print")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     L2Object target = activeChar.getTarget();
     if (target instanceof L2Npc) {
       try {
         st.nextToken();
         int type = Integer.parseInt(st.nextToken());
         printSpawn((L2Npc) target, type);
         if (command.contains("_menu")) {
           AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
         }
       } catch (Exception e) {
       }
     } else {
       activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
     }
   } else if (command.startsWith("admin_spawn_index")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       int level = Integer.parseInt(st.nextToken());
       int from = 0;
       try {
         from = Integer.parseInt(st.nextToken());
       } catch (NoSuchElementException nsee) {
       }
       showMonsters(activeChar, level, from);
     } catch (Exception e) {
       AdminHtml.showAdminHtml(activeChar, "spawns.htm");
     }
   } else if (command.equals("admin_show_npcs")) {
     AdminHtml.showAdminHtml(activeChar, "npcs.htm");
   } else if (command.startsWith("admin_npc_index")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       String letter = st.nextToken();
       int from = 0;
       try {
         from = Integer.parseInt(st.nextToken());
       } catch (NoSuchElementException nsee) {
       }
       showNpcs(activeChar, letter, from);
     } catch (Exception e) {
       AdminHtml.showAdminHtml(activeChar, "npcs.htm");
     }
   } else if (command.startsWith("admin_instance_spawns")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       int instance = Integer.parseInt(st.nextToken());
       if (instance >= 300000) {
         final StringBuilder html =
             StringUtil.startAppend(
                 500 + 1000,
                 "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>",
                 "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>",
                 "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>",
                 "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>");
         int counter = 0;
         int skiped = 0;
         Instance inst = InstanceManager.getInstance().getInstance(instance);
         if (inst != null) {
           for (L2Npc npc : inst.getNpcs()) {
             if (!npc.isDead()) {
               // Only 50 because of client html limitation
               if (counter < 50) {
                 StringUtil.append(
                     html,
                     "<tr><td>" + npc.getName() + "</td><td>",
                     "<a action=\"bypass -h admin_move_to "
                         + npc.getX()
                         + " "
                         + npc.getY()
                         + " "
                         + npc.getZ()
                         + "\">Go</a>",
                     "</td></tr>");
                 counter++;
               } else {
                 skiped++;
               }
             }
           }
           StringUtil.append(
               html,
               "<tr><td>Skipped:</td><td>"
                   + String.valueOf(skiped)
                   + "</td></tr></table></body></html>");
           final NpcHtmlMessage ms = new NpcHtmlMessage();
           ms.setHtml(html.toString());
           activeChar.sendPacket(ms);
         } else {
           activeChar.sendMessage("Cannot find instance " + instance);
         }
       } else {
         activeChar.sendMessage("Invalid instance number.");
       }
     } catch (Exception e) {
       activeChar.sendMessage("Usage //instance_spawns <instance_number>");
     }
   } else if (command.startsWith("admin_unspawnall")) {
     Broadcast.toAllOnlinePlayers(
         SystemMessage.getSystemMessage(SystemMessageId.NPC_SERVER_NOT_OPERATING));
     RaidBossSpawnManager.getInstance().cleanUp();
     DayNightSpawnManager.getInstance().cleanUp();
     L2World.getInstance().deleteVisibleNpcSpawns();
     AdminTable.getInstance().broadcastMessageToGMs("NPC Unspawn completed!");
   } else if (command.startsWith("admin_spawnday")) {
     DayNightSpawnManager.getInstance().spawnDayCreatures();
   } else if (command.startsWith("admin_spawnnight")) {
     DayNightSpawnManager.getInstance().spawnNightCreatures();
   } else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload")) {
     // make sure all spawns are deleted
     RaidBossSpawnManager.getInstance().cleanUp();
     DayNightSpawnManager.getInstance().cleanUp();
     L2World.getInstance().deleteVisibleNpcSpawns();
     // now respawn all
     NpcData.getInstance().load();
     SpawnTable.getInstance().load();
     RaidBossSpawnManager.getInstance().load();
     AutoSpawnHandler.getInstance().reload();
     SevenSigns.getInstance().spawnSevenSignsNPC();
     QuestManager.getInstance().reloadAllScripts();
     AdminTable.getInstance().broadcastMessageToGMs("NPC Respawn completed!");
   } else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       String cmd = st.nextToken();
       String id = st.nextToken();
       int respawnTime = 0;
       int mobCount = 1;
       if (st.hasMoreTokens()) {
         mobCount = Integer.parseInt(st.nextToken());
       }
       if (st.hasMoreTokens()) {
         respawnTime = Integer.parseInt(st.nextToken());
       }
       if (cmd.equalsIgnoreCase("admin_spawn_once")) {
         spawnMonster(activeChar, id, respawnTime, mobCount, false);
       } else {
         spawnMonster(activeChar, id, respawnTime, mobCount, true);
       }
     } catch (Exception e) { // Case of wrong or missing monster data
       AdminHtml.showAdminHtml(activeChar, "spawns.htm");
     }
   } else if (command.startsWith("admin_list_spawns")
       || command.startsWith("admin_list_positions")) {
     int npcId = 0;
     int teleportIndex = -1;
     try { // admin_list_spawns x[xxxx] x[xx]
       String[] params = command.split(" ");
       Pattern pattern = Pattern.compile("[0-9]*");
       Matcher regexp = pattern.matcher(params[1]);
       if (regexp.matches()) {
         npcId = Integer.parseInt(params[1]);
       } else {
         params[1] = params[1].replace('_', ' ');
         npcId = NpcData.getInstance().getTemplateByName(params[1]).getId();
       }
       if (params.length > 2) {
         teleportIndex = Integer.parseInt(params[2]);
       }
     } catch (Exception e) {
       activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]");
     }
     if (command.startsWith("admin_list_positions")) {
       findNPCInstances(activeChar, npcId, teleportIndex, true);
     } else {
       findNPCInstances(activeChar, npcId, teleportIndex, false);
     }
   }
   return true;
 }
コード例 #11
0
  @Override
  public void onBypassFeedback(L2PcInstance player, String command) {
    String[] commandStr = command.split(" ");
    String actualCommand = commandStr[0]; // Get actual command

    String cmdParams = "";
    String cmdParams2 = "";

    if (commandStr.length >= 2) cmdParams = commandStr[1];
    if (commandStr.length >= 3) cmdParams2 = commandStr[2];

    if (actualCommand.equalsIgnoreCase("create_clan")) {
      if (cmdParams.isEmpty()) return;

      ClanTable.getInstance().createClan(player, cmdParams);
    } else if (actualCommand.equalsIgnoreCase("create_academy")) {
      if (cmdParams.isEmpty()) return;

      createSubPledge(player, cmdParams, null, L2Clan.SUBUNIT_ACADEMY, 5);
    } else if (actualCommand.equalsIgnoreCase("rename_pledge")) {
      if (cmdParams.isEmpty() || cmdParams2.isEmpty()) return;

      renameSubPledge(player, Integer.valueOf(cmdParams), cmdParams2);
    } else if (actualCommand.equalsIgnoreCase("create_royal")) {
      if (cmdParams.isEmpty()) return;

      createSubPledge(player, cmdParams, cmdParams2, L2Clan.SUBUNIT_ROYAL1, 6);
    } else if (actualCommand.equalsIgnoreCase("create_knight")) {
      if (cmdParams.isEmpty()) return;

      createSubPledge(player, cmdParams, cmdParams2, L2Clan.SUBUNIT_KNIGHT1, 7);
    } else if (actualCommand.equalsIgnoreCase("assign_subpl_leader")) {
      if (cmdParams.isEmpty()) return;

      assignSubPledgeLeader(player, cmdParams, cmdParams2);
    } else if (actualCommand.equalsIgnoreCase("create_ally")) {
      if (cmdParams.isEmpty()) return;

      if (player.getClan() == null)
        player.sendPacket(new SystemMessage(SystemMessageId.ONLY_CLAN_LEADER_CREATE_ALLIANCE));
      else player.getClan().createAlly(player, cmdParams);
    } else if (actualCommand.equalsIgnoreCase("dissolve_ally")) {
      player.getClan().dissolveAlly(player);
    } else if (actualCommand.equalsIgnoreCase("dissolve_clan")) {
      dissolveClan(player, player.getClanId());
    } else if (actualCommand.equalsIgnoreCase("change_clan_leader")) {
      if (cmdParams.isEmpty()) return;

      changeClanLeader(player, cmdParams);
    } else if (actualCommand.equalsIgnoreCase("recover_clan")) {
      recoverClan(player, player.getClanId());
    } else if (actualCommand.equalsIgnoreCase("increase_clan_level")) {
      if (player.getClan().levelUpClan(player)) {
        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 0, 0));
        player.broadcastPacket(new MagicSkillLaunched(player, 5103, 1));
      }
    } else if (actualCommand.equalsIgnoreCase("learn_clan_skills")) {
      showPledgeSkillList(player);
    } else if (command.startsWith("Subclass")) {
      // Subclasses may not be changed while a skill is in use.
      if (player.isCastingNow() || player.isAllSkillsDisabled()) {
        player.sendPacket(
            new SystemMessage(SystemMessageId.SUBCLASS_NO_CHANGE_OR_CREATE_WHILE_SKILL_IN_USE));
        return;
      }

      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

      if (player.getTransformation() != null) {
        html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_NoTransformed.htm");
        player.sendPacket(html);
        return;
      }

      int cmdChoice = 0;
      int paramOne = 0;
      int paramTwo = 0;

      try {
        cmdChoice = Integer.parseInt(command.substring(9, 10).trim());

        int endIndex = command.indexOf(' ', 11);
        if (endIndex == -1) endIndex = command.length();

        paramOne = Integer.parseInt(command.substring(11, endIndex).trim());
        if (command.length() > endIndex)
          paramTwo = Integer.parseInt(command.substring(endIndex).trim());
      } catch (Exception NumberFormatException) {
      }

      switch (cmdChoice) {
        case 0: // Subclass change menu
          html.setFile(player.getHtmlPrefix(), getSubClassMenu(player.getRace()));
          break;
        case 1: // Add Subclass - Initial
          // Avoid giving player an option to add a new sub class, if they have three already.
          if (player.getTotalSubClasses() >= Config.MAX_SUBCLASS) {
            html.setFile(player.getHtmlPrefix(), getSubClassFail());
            break;
          }

          html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Add.htm");
          final StringBuilder content1 = StringUtil.startAppend(200);
          Set<PlayerClass> subsAvailable = getAvailableSubClasses(player);

          if (subsAvailable != null && !subsAvailable.isEmpty()) {
            for (PlayerClass subClass : subsAvailable) {
              StringUtil.append(
                  content1,
                  "<a action=\"bypass -h npc_%objectId%_Subclass 4 ",
                  String.valueOf(subClass.ordinal()),
                  "\" msg=\"1268;",
                  formatClassForDisplay(subClass),
                  "\">",
                  formatClassForDisplay(subClass),
                  "</a><br>");
            }
          } else {
            // TODO: Retail message
            player.sendMessage("There are no sub classes available at this time.");
            return;
          }
          html.replace("%list%", content1.toString());
          break;
        case 2: // Change Class - Initial
          if (player.getSubClasses().isEmpty())
            html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ChangeNo.htm");
          else {
            final StringBuilder content2 = StringUtil.startAppend(200);

            if (checkVillageMaster(player.getBaseClass())) {
              StringUtil.append(
                  content2,
                  "<a action=\"bypass -h npc_%objectId%_Subclass 5 0\">",
                  CharTemplateTable.getInstance().getClassNameById(player.getBaseClass()),
                  "</a><br>");
            }

            for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) {
              SubClass subClass = subList.next();
              if (checkVillageMaster(subClass.getClassDefinition())) {
                StringUtil.append(
                    content2,
                    "<a action=\"bypass -h npc_%objectId%_Subclass 5 ",
                    String.valueOf(subClass.getClassIndex()),
                    "\">",
                    formatClassForDisplay(subClass.getClassDefinition()),
                    "</a><br>");
              }
            }

            if (content2.length() > 0) {
              html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Change.htm");
              html.replace("%list%", content2.toString());
            } else
              html.setFile(
                  player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ChangeNotFound.htm");
          }
          break;
        case 3: // Change/Cancel Subclass - Initial
          if (player.getSubClasses() == null || player.getSubClasses().isEmpty()) {
            html.setFile(
                player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyEmpty.htm");
            break;
          }

          // custom value
          if (player.getTotalSubClasses() > 3) {
            html.setFile(
                player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyCustom.htm");
            final StringBuilder content3 = StringUtil.startAppend(200);
            int classIndex = 1;

            for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) {
              SubClass subClass = subList.next();

              StringUtil.append(
                  content3,
                  "Sub-class ",
                  String.valueOf(classIndex++),
                  "<br>",
                  "<a action=\"bypass -h npc_%objectId%_Subclass 6 ",
                  String.valueOf(subClass.getClassIndex()),
                  "\">",
                  CharTemplateTable.getInstance().getClassNameById(subClass.getClassId()),
                  "</a><br>");
            }
            html.replace("%list%", content3.toString());
          } else {
            // retail html contain only 3 subclasses
            html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Modify.htm");
            if (player.getSubClasses().containsKey(1))
              html.replace(
                  "%sub1%",
                  CharTemplateTable.getInstance()
                      .getClassNameById(player.getSubClasses().get(1).getClassId()));
            else
              html.replace(
                  "<a action=\"bypass -h npc_%objectId%_Subclass 6 1\">%sub1%</a><br>", "");

            if (player.getSubClasses().containsKey(2))
              html.replace(
                  "%sub2%",
                  CharTemplateTable.getInstance()
                      .getClassNameById(player.getSubClasses().get(2).getClassId()));
            else
              html.replace(
                  "<a action=\"bypass -h npc_%objectId%_Subclass 6 2\">%sub2%</a><br>", "");

            if (player.getSubClasses().containsKey(3))
              html.replace(
                  "%sub3%",
                  CharTemplateTable.getInstance()
                      .getClassNameById(player.getSubClasses().get(3).getClassId()));
            else
              html.replace(
                  "<a action=\"bypass -h npc_%objectId%_Subclass 6 3\">%sub3%</a><br>", "");
          }
          break;
        case 4: // Add Subclass - Action (Subclass 4 x[x])
          /*
           * If the character is less than level 75 on any of their previously chosen
           * classes then disallow them to change to their most recently added sub-class choice.
           */

          if (!player.getFloodProtectors().getSubclass().tryPerformAction("add subclass")) {
            _log.warning(
                "Player " + player.getName() + " has performed a subclass change too fast");
            return;
          }

          boolean allowAddition = true;

          if (player.getTotalSubClasses() >= Config.MAX_SUBCLASS) allowAddition = false;

          if (player.getLevel() < 75) allowAddition = false;

          if (allowAddition) {
            if (!player.getSubClasses().isEmpty()) {
              for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext(); ) {
                SubClass subClass = subList.next();

                if (subClass.getLevel() < 75) {
                  allowAddition = false;
                  break;
                }
              }
            }
          }

          /*
           * If quest checking is enabled, verify if the character has completed the Mimir's Elixir (Path to Subclass)
           * and Fate's Whisper (A Grade Weapon) quests by checking for instances of their unique reward items.
           *
           * If they both exist, remove both unique items and continue with adding the sub-class.
           */
          if (allowAddition && !Config.ALT_GAME_SUBCLASS_WITHOUT_QUESTS)
            allowAddition = checkQuests(player);

          if (allowAddition && isValidNewSubClass(player, paramOne)) {
            if (!player.addSubClass(paramOne, player.getTotalSubClasses() + 1)) return;

            player.setActiveClass(player.getTotalSubClasses());

            html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_AddOk.htm");

            player.sendPacket(
                new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added.
          } else html.setFile(player.getHtmlPrefix(), getSubClassFail());
          break;
        case 5: // Change Class - Action
          /*
           * If the character is less than level 75 on any of their previously chosen
           * classes then disallow them to change to their most recently added sub-class choice.
           *
           * Note: paramOne = classIndex
           */

          if (!player.getFloodProtectors().getSubclass().tryPerformAction("change class")) {
            _log.warning(
                "Player " + player.getName() + " has performed a subclass change too fast");
            return;
          }

          if (player.getClassIndex() == paramOne) {
            html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_Current.htm");
            break;
          }

          if (paramOne == 0) {
            if (!checkVillageMaster(player.getBaseClass())) return;
          } else {
            try {
              if (!checkVillageMaster(player.getSubClasses().get(paramOne).getClassDefinition()))
                return;
            } catch (NullPointerException e) {
              return;
            }
          }

          player.setActiveClass(paramOne);

          player.sendPacket(
              new SystemMessage(
                  SystemMessageId.SUBCLASS_TRANSFER_COMPLETED)); // Transfer completed.
          return;
        case 6: // Change/Cancel Subclass - Choice
          // validity check
          if (paramOne < 1 || paramOne > Config.MAX_SUBCLASS) return;

          subsAvailable = getAvailableSubClasses(player);

          // another validity check
          if (subsAvailable == null || subsAvailable.isEmpty()) {
            // TODO: Retail message
            player.sendMessage("There are no sub classes available at this time.");
            return;
          }

          final StringBuilder content6 = StringUtil.startAppend(200);

          for (PlayerClass subClass : subsAvailable) {
            StringUtil.append(
                content6,
                "<a action=\"bypass -h npc_%objectId%_Subclass 7 ",
                String.valueOf(paramOne),
                " ",
                String.valueOf(subClass.ordinal()),
                "\" msg=\"1445;",
                "\">",
                formatClassForDisplay(subClass),
                "</a><br>");
          }

          switch (paramOne) {
            case 1:
              html.setFile(
                  player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice1.htm");
              break;
            case 2:
              html.setFile(
                  player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice2.htm");
              break;
            case 3:
              html.setFile(
                  player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice3.htm");
              break;
            default:
              html.setFile(
                  player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyChoice.htm");
          }
          html.replace("%list%", content6.toString());
          break;
        case 7: // Change Subclass - Action
          /*
           * Warning: the information about this subclass will be removed from the
           * subclass list even if false!
           */

          if (!player.getFloodProtectors().getSubclass().tryPerformAction("change class")) {
            _log.warning(
                "Player " + player.getName() + " has performed a subclass change too fast");
            return;
          }

          if (!isValidNewSubClass(player, paramTwo)) return;

          if (player.modifySubClass(paramOne, paramTwo)) {
            player.abortCast();
            player
                .stopAllEffectsExceptThoseThatLastThroughDeath(); // all effects from old subclass
                                                                  // stopped!
            player.stopCubics();
            player.setActiveClass(paramOne);

            html.setFile(player.getHtmlPrefix(), "data/html/villagemaster/SubClass_ModifyOk.htm");
            html.replace("%name%", CharTemplateTable.getInstance().getClassNameById(paramTwo));

            player.sendPacket(
                new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added.
          } else {
            /*
             * This isn't good! modifySubClass() removed subclass from memory
             * we must update _classIndex! Else IndexOutOfBoundsException can turn
             * up some place down the line along with other seemingly unrelated
             * problems.
             */
            player.setActiveClass(
                0); // Also updates _classIndex plus switching _classid to baseclass.

            player.sendMessage(
                "The sub class could not be added, you have been reverted to your base class.");
            return;
          }
          break;
      }

      html.replace("%objectId%", String.valueOf(getObjectId()));
      player.sendPacket(html);
    } else {
      // this class dont know any other commands, let forward
      // the command to the parent class
      super.onBypassFeedback(player, command);
    }
  }