Ejemplo n.º 1
0
  @Override
  public boolean doDie(L2Character killer) {
    if (!super.doDie(killer)) {
      return false;
    }

    final L2PcInstance player = killer.getActingPlayer();
    if (player != null) {
      broadcastPacket(
          SystemMessage.getSystemMessage(SystemMessageId.CONGRATULATIONS_YOUR_RAID_WAS_SUCCESSFUL));
      if (player.getParty() != null) {
        for (L2PcInstance member : player.getParty().getMembers()) {
          member.setRaidPoints(member.getRaidPoints() + ((getLevel() / 2) + Rnd.get(-5, 5)));
          if (member.isNoble()) {
            Hero.getInstance().setRBkilled(member.getObjectId(), getId());
          }
        }
      } else {
        player.setRaidPoints(player.getRaidPoints() + ((getLevel() / 2) + Rnd.get(-5, 5)));
        if (player.isNoble()) {
          Hero.getInstance().setRBkilled(player.getObjectId(), getId());
        }
      }
    }

    RaidBossSpawnManager.getInstance().updateStatus(this, true);
    return true;
  }
Ejemplo n.º 2
0
  public void recoverClan(L2PcInstance player, int clanId) {
    if (Config.DEBUG) {
      _log.info(
          player.getObjectId()
              + "("
              + player.getName()
              + ") requested recover a clan from "
              + getObjectId()
              + "("
              + getName()
              + ")");
    }

    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }
    L2Clan clan = player.getClan();

    clan.setDissolvingExpiryTime(0);
    clan.updateClanInDB();

    clan = null;
  }
Ejemplo n.º 3
0
  public void assignSubPledgeLeader(L2PcInstance player, String clanName, String leaderName) {
    if (Config.DEBUG) {
      _log.info(
          player.getObjectId()
              + "("
              + player.getName()
              + ") requested to assign sub clan"
              + clanName
              + "leader "
              + "("
              + leaderName
              + ")");
    }

    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }

    if (leaderName.length() > 16) {
      player.sendPacket(new SystemMessage(SystemMessageId.NAMING_CHARNAME_UP_TO_16CHARS));
      return;
    }

    if (player.getName().equals(leaderName)) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED));
      return;
    }

    L2Clan clan = player.getClan();
    SubPledge subPledge = player.getClan().getSubPledge(clanName);
    if (null == subPledge) {
      player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT));
      return;
    }

    if (subPledge.getId() == L2Clan.SUBUNIT_ACADEMY) {
      player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT));
      return;
    }

    if (clan.getClanMember(leaderName) == null
        || clan.getClanMember(leaderName).getPledgeType() != 0) {
      if (subPledge.getId() >= L2Clan.SUBUNIT_KNIGHT1) {
        player.sendPacket(
            new SystemMessage(SystemMessageId.CAPTAIN_OF_ORDER_OF_KNIGHTS_CANNOT_BE_APPOINTED));
      } else if (subPledge.getId() >= L2Clan.SUBUNIT_ROYAL1) {
        player.sendPacket(
            new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED));
      }
      return;
    }

    L2ClanMember leaderSubPledge = clan.getClanMember(leaderName);
    subPledge.setLeaderId(leaderSubPledge.getObjectId());
    clan.updateSubPledgeInDB(subPledge.getId());
    L2PcInstance leaderPlayer = leaderSubPledge.getPlayerInstance();
    if (leaderPlayer != null) {
      leaderPlayer.setPledgeClass(leaderSubPledge.calculatePledgeClass(leaderPlayer));
      leaderPlayer.sendPacket(new UserInfo(leaderPlayer));
    }
    clan.broadcastClanStatus();
    SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_SELECTED_AS_CAPTAIN_OF_S2);
    sm.addString(leaderName);
    sm.addString(clanName);
    clan.broadcastToOnlineMembers(sm);
    sm = null;
    clan = null;
    subPledge = null;
    leaderPlayer = null;
    leaderSubPledge = null;
  }
Ejemplo n.º 4
0
  public void createSubPledge(
      L2PcInstance player, String clanName, String leaderName, int pledgeType, int minClanLvl) {
    if (Config.DEBUG) {
      _log.info(
          player.getObjectId()
              + "("
              + player.getName()
              + ") requested sub clan creation from "
              + getObjectId()
              + "("
              + getName()
              + ")");
    }

    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }

    L2Clan clan = player.getClan();
    if (clan.getLevel() < minClanLvl) {
      if (pledgeType == L2Clan.SUBUNIT_ACADEMY) {
        player.sendPacket(
            new SystemMessage(
                SystemMessageId.YOU_DO_NOT_MEET_CRITERIA_IN_ORDER_TO_CREATE_A_CLAN_ACADEMY));
      } else {
        player.sendPacket(
            new SystemMessage(
                SystemMessageId.YOU_DO_NOT_MEET_CRITERIA_IN_ORDER_TO_CREATE_A_MILITARY_UNIT));
      }
      return;
    }

    if (!Util.isAlphaNumeric(clanName) || 2 > clanName.length()) {
      player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT));
      return;
    }

    if (clanName.length() > 16) {
      player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_TOO_LONG));
      return;
    }
    for (L2Clan tempClan : ClanTable.getInstance().getClans()) {
      if (tempClan.getSubPledge(clanName) != null) {
        if (pledgeType == L2Clan.SUBUNIT_ACADEMY) {
          SystemMessage sm = new SystemMessage(SystemMessageId.S1_ALREADY_EXISTS);
          sm.addString(clanName);
          player.sendPacket(sm);
          sm = null;
        } else {
          player.sendPacket(
              new SystemMessage(SystemMessageId.ANOTHER_MILITARY_UNIT_IS_ALREADY_USING_THAT_NAME));
        }
        return;
      }
    }

    if (pledgeType != L2Clan.SUBUNIT_ACADEMY)
      if (clan.getClanMember(leaderName) == null
          || clan.getClanMember(leaderName).getPledgeType() != 0) {
        if (pledgeType >= L2Clan.SUBUNIT_KNIGHT1) {
          player.sendPacket(
              new SystemMessage(SystemMessageId.CAPTAIN_OF_ORDER_OF_KNIGHTS_CANNOT_BE_APPOINTED));
        } else if (pledgeType >= L2Clan.SUBUNIT_ROYAL1) {
          player.sendPacket(
              new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED));
        }
        return;
      }

    int leaderId =
        clan.getClanMember(leaderName) != null ? clan.getClanMember(leaderName).getObjectId() : 0;

    if (clan.createSubPledge(player, pledgeType, leaderId, clanName) == null) return;

    SystemMessage sm;
    if (pledgeType == L2Clan.SUBUNIT_ACADEMY) {
      sm = new SystemMessage(SystemMessageId.THE_S1S_CLAN_ACADEMY_HAS_BEEN_CREATED);
      sm.addString(player.getClan().getName());
    } else if (pledgeType >= L2Clan.SUBUNIT_KNIGHT1) {
      sm = new SystemMessage(SystemMessageId.THE_KNIGHTS_OF_S1_HAVE_BEEN_CREATED);
      sm.addString(player.getClan().getName());
    } else if (pledgeType >= L2Clan.SUBUNIT_ROYAL1) {
      sm = new SystemMessage(SystemMessageId.THE_ROYAL_GUARD_OF_S1_HAVE_BEEN_CREATED);
      sm.addString(player.getClan().getName());
    } else {
      sm = new SystemMessage(SystemMessageId.CLAN_CREATED);
    }

    player.sendPacket(sm);
    if (pledgeType != L2Clan.SUBUNIT_ACADEMY) {
      L2ClanMember leaderSubPledge = clan.getClanMember(leaderName);
      if (leaderSubPledge.getPlayerInstance() == null) return;

      leaderSubPledge
          .getPlayerInstance()
          .setPledgeClass(
              leaderSubPledge.calculatePledgeClass(leaderSubPledge.getPlayerInstance()));
      leaderSubPledge
          .getPlayerInstance()
          .sendPacket(new UserInfo(leaderSubPledge.getPlayerInstance()));
    }
    clan = null;
    sm = null;
  }
Ejemplo n.º 5
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];
    }

    commandStr = null;

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

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

      createSubPledge(player, cmdParams, null, L2Clan.SUBUNIT_ACADEMY, 5);
    } else if (actualCommand.equalsIgnoreCase("create_royal")) {
      if (cmdParams.equals("")) return;

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

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

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

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

      changeClanLeader(player, cmdParams);
    } else if (actualCommand.equalsIgnoreCase("recover_clan")) {
      recoverClan(player, player.getClanId());
    } else if (actualCommand.equalsIgnoreCase("increase_clan_level")) {
      if (!player.isClanLeader()) {
        player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
        return;
      }
      player.getClan().levelUpClan(player);
    } else if (actualCommand.equalsIgnoreCase("learn_clan_skills")) {
      showPledgeSkillList(player);
    } else if (command.startsWith("Subclass")) {
      int cmdChoice = Integer.parseInt(command.substring(9, 10).trim());

      // 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;
      }

      if (player.getPet() != null && player.getPet().isSummonInstance) {
        if (player.getPet().isCastingNow() || player.getPet().isAllSkillsDisabled()) {
          player.sendPacket(
              new SystemMessage(SystemMessageId.SUBCLASS_NO_CHANGE_OR_CREATE_WHILE_SKILL_IN_USE));
          return;
        }
      }

      if (player.isCursedWeaponEquiped()) {
        player.sendMessage("You can`t change Subclass while Cursed weapon equiped!");
        return;
      }

      TextBuilder content = new TextBuilder("<html><body>");
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      Set<PlayerClass> subsAvailable;

      int paramOne = 0;
      int paramTwo = 0;

      try {
        int endIndex = command.length();

        if (command.length() > 13) {
          endIndex = 13;
          paramTwo = Integer.parseInt(command.substring(13).trim());
        }

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

      switch (cmdChoice) {
        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.ALT_MAX_SUBCLASS_COUNT) {
            player.sendMessage("You can now only change one of your current sub classes.");
            return;
          }
          subsAvailable = getAvailableSubClasses(player);

          if (subsAvailable != null && !subsAvailable.isEmpty()) {
            content.append("Add Subclass:<br>Which sub class do you wish to add?<br>");

            for (PlayerClass subClass : subsAvailable) {
              content.append(
                  "<a action=\"bypass -h npc_"
                      + getObjectId()
                      + "_Subclass 4 "
                      + subClass.ordinal()
                      + "\" msg=\"1268;"
                      + formatClassForDisplay(subClass)
                      + "\">"
                      + formatClassForDisplay(subClass)
                      + "</a><br>");
            }
          } else {
            player.sendMessage("There are no sub classes available at this time.");
            return;
          }
          break;
        case 2: // Change Class - Initial
          content.append("Change Subclass:<br>");

          final int baseClassId = player.getBaseClass();

          if (player.getSubClasses().isEmpty()) {
            content.append(
                "You can't change sub classes when you don't have a sub class to begin with.<br>"
                    + "<a action=\"bypass -h npc_"
                    + getObjectId()
                    + "_Subclass 1\">Add subclass.</a>");
          } else {
            content.append("Which class would you like to switch to?<br>");

            if (baseClassId == player.getActiveClass()) {
              content.append(
                  CharTemplateTable.getClassNameById(baseClassId)
                      + "&nbsp;<font color=\"LEVEL\">(Base Class)</font><br><br>");
            } else {
              content.append(
                  "<a action=\"bypass -h npc_"
                      + getObjectId()
                      + "_Subclass 5 0\">"
                      + CharTemplateTable.getClassNameById(baseClassId)
                      + "</a>&nbsp;"
                      + "<font color=\"LEVEL\">(Base Class)</font><br><br>");
            }

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

              if (subClassId == player.getActiveClass()) {
                content.append(CharTemplateTable.getClassNameById(subClassId) + "<br>");
              } else {
                content.append(
                    "<a action=\"bypass -h npc_"
                        + getObjectId()
                        + "_Subclass 5 "
                        + subClass.getClassIndex()
                        + "\">"
                        + CharTemplateTable.getClassNameById(subClassId)
                        + "</a><br>");
              }
            }
          }
          break;
        case 3: // Change/Cancel Subclass - Initial
          content.append(
              "Change Subclass:<br>Which of the following sub classes would you like to change?<br>");
          int classIndex = 1;

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

            content.append("Sub-class " + classIndex + "<br1>");
            content.append(
                "<a action=\"bypass -h npc_"
                    + getObjectId()
                    + "_Subclass 6 "
                    + subClass.getClassIndex()
                    + "\">"
                    + CharTemplateTable.getClassNameById(subClass.getClassId())
                    + "</a><br>");

            classIndex++;
          }

          content.append(
              "<br>If you change a sub class, you'll start at level 40 after the 2nd class transfer.");
          break;
        case 4: // Add Subclass - Action (Subclass 4 x[x])
          boolean allowAddition = true;
          /*
           * 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.getLevel() < 75) {
            player.sendMessage(
                "You may not add a new sub class before you are level 75 on your previous class.");
            allowAddition = false;
          }

          if (player._event != null) {
            player.sendMessage("Недоступно в данный момент.");
            return;
          }

          if (Olympiad.getInstance().isRegisteredInComp(player) || player.getOlympiadGameId() > 0) {
            player.sendPacket(
                new SystemMessage(
                    SystemMessageId
                        .YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
            return;
          }

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

                if (subClass.getLevel() < 75) {
                  player.sendMessage(
                      "You may not add a new sub class before you are level 75 on your previous sub class.");
                  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 (!Config.ALT_GAME_SUBCLASS_WITHOUT_QUESTS) {
            QuestState qs = player.getQuestState("235_MimirsElixir");
            if (qs == null || !qs.getState().getName().equalsIgnoreCase("Completed")) {
              player.sendMessage(
                  "You must have completed the Mimir's Elixir quest to continue adding your sub class.");
              return;
            }
            /*qs = player.getQuestState("234_FatesWhisper");
            if(qs == null || qs.getState().getName() != "Completed")
            {
            	player.sendMessage("You must have completed the Fate's Whisper quest to continue adding your sub class.");
            	return;
            }*/
          }

          ////////////////// \\\\\\\\\\\\\\\\\\
          if (allowAddition) {
            String className = CharTemplateTable.getClassNameById(paramOne);

            if (!player.addSubClass(paramOne, player.getTotalSubClasses() + 1)) {
              player.sendMessage("The sub class could not be added.");
              return;
            }

            player.setActiveClass(player.getTotalSubClasses());

            content.append(
                "Add Subclass:<br>The sub class of <font color=\"LEVEL\">"
                    + className
                    + "</font> has been added.");
            player.sendPacket(
                new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Transfer to new class.

            className = null;
          } else {
            html.setFile("data/html/villagemaster/SubClass_Fail.htm");
          }
          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.
           * fix: in waiting for battle in oly can change sublcass
           * Note: paramOne = classIndex
           */

          if (Olympiad.getInstance().isRegisteredInComp(player)
              || player.getOlympiadGameId() > 0
              || Olympiad.getInstance().isRegistered(player)) {
            player.sendPacket(
                new SystemMessage(
                    SystemMessageId
                        .YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
            return;
          }

          // sub class exploit fix
          if (!FloodProtector.getInstance()
              .tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_SUBCLASS)) {
            player.sendMessage(
                "You can change Subclass only every "
                    + Config.PROTECTED_SUBCLASS_C
                    + " Millisecond(s)");
            return;
          }

          player.setActiveClass(paramOne);

          content.append(
              "Change Subclass:<br>Your active sub class is now a <font color=\"LEVEL\">"
                  + CharTemplateTable.getClassNameById(player.getActiveClass())
                  + "</font>.");

          player.sendPacket(
              new SystemMessage(
                  SystemMessageId.SUBCLASS_TRANSFER_COMPLETED)); // Transfer completed.
          break;
        case 6: // Change/Cancel Subclass - Choice
          content.append(
              "Please choose a sub class to change to. If the one you are looking for is not here, "
                  + "please seek out the appropriate master for that class.<br>"
                  + "<font color=\"LEVEL\">Warning!</font> All classes and skills for this class will be removed.<br><br>");

          subsAvailable = getAvailableSubClasses(player);

          if (subsAvailable != null && !subsAvailable.isEmpty()) {
            for (PlayerClass subClass : subsAvailable) {
              content.append(
                  "<a action=\"bypass -h npc_"
                      + getObjectId()
                      + "_Subclass 7 "
                      + paramOne
                      + " "
                      + subClass.ordinal()
                      + "\">"
                      + formatClassForDisplay(subClass)
                      + "</a><br>");
            }
          } else {
            player.sendMessage("There are no sub classes available at this time.");
            return;
          }
          break;
        case 7: // Change Subclass - Action

          // check player skills
          if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN) {
            player.checkAllowedSkills();
          }

          /*
           * Warning: the information about this subclass will be removed from the
           * subclass list even if false!
           */

          if (!FloodProtector.getInstance()
              .tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_SUBCLASS)) {
            _log.warn("Player " + player.getName() + " has performed a subclass change too fast");
            player.sendMessage(
                "You can change Subclass only every "
                    + Config.PROTECTED_SUBCLASS_C
                    + " Millisecond(s)");
            return;
          }

          if (player.modifySubClass(paramOne, paramTwo)) {
            player.setActiveClass(paramOne);

            content.append(
                "Change Subclass:<br>Your sub class has been changed to <font color=\"LEVEL\">"
                    + CharTemplateTable.getClassNameById(paramTwo)
                    + "</font>.");

            player.sendPacket(
                new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added.

            // check player skills
            if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN) {
              player.checkAllowedSkills();
            }

          } 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;
      }

      content.append("</body></html>");

      // If the content is greater than for a basic blank page,
      // then assume no external HTML file was assigned.
      if (content.length() > 26) {
        html.setHtml(content.toString());
      }

      player.sendPacket(html);

      content = null;
      html = null;
      subsAvailable = null;
    } else {
      // this class dont know any other commands, let forward
      // the command to the parent class
      super.onBypassFeedback(player, command);
    }
    actualCommand = null;
    cmdParams = null;
    cmdParams2 = null;
  }
Ejemplo n.º 6
0
  public void changeClanLeader(L2PcInstance player, String target) {
    if (Config.DEBUG) {
      _log.info(
          player.getObjectId()
              + "("
              + player.getName()
              + ") requested change a clan leader from "
              + getObjectId()
              + "("
              + getName()
              + ")");
    }

    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }

    if (player.isFlying()) {
      player.sendMessage("Get off the Wyvern first.");
      return;
    }

    if (player.getName().equalsIgnoreCase(target)) return;

    L2Clan clan = player.getClan();
    L2ClanMember member = clan.getClanMember(target);
    if (member == null) {
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_DOES_NOT_EXIST);
      sm.addString(target);
      player.sendPacket(sm);
      sm = null;
      return;
    }

    if (!member.isOnline()) {
      player.sendPacket(new SystemMessage(SystemMessageId.INVITED_USER_NOT_ONLINE));
      return;
    }

    if (member.getPledgeType() == L2Clan.SUBUNIT_ACADEMY) {
      player.sendMessage("Can`t give to academy member.");
      return;
    }

    for (Siege siege : SiegeManager.getInstance().getSieges()) {
      if (!siege.getIsInProgress()) {
        continue;
      }

      if (siege.checkIsAttacker(clan) || siege.checkIsDefender(clan)) {
        player.sendMessage("You are not authorized to do that during the siege.");
        return;
      }
    }

    clan.setNewLeader(member);

    clan = null;
    member = null;
  }
Ejemplo n.º 7
0
  // Private stuff
  public void dissolveClan(L2PcInstance player, int clanId) {
    if (Config.DEBUG) {
      _log.info(
          player.getObjectId()
              + "("
              + player.getName()
              + ") requested dissolve a clan from "
              + getObjectId()
              + "("
              + getName()
              + ")");
    }

    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }

    L2Clan clan = player.getClan();
    if (clan.getAllyId() != 0) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISPERSE_THE_CLANS_IN_ALLY));
      return;
    }

    if (clan.isAtWar() != 0) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_WAR));
      return;
    }

    if (clan.getHasCastle() != 0 || clan.getHasHideout() != 0 || clan.getHasFort() != 0) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_OWNING_CLAN_HALL_OR_CASTLE));
      return;
    }

    for (Castle castle : CastleManager.getInstance().getCastles()) {
      if (SiegeManager.getInstance().checkIsRegistered(clan, castle.getCastleId())) {
        player.sendPacket(
            new SystemMessage(
                SystemMessageId.CANNOT_DISSOLVE_CAUSE_CLAN_WILL_PARTICIPATE_IN_CASTLE_SIEGE));
        return;
      }
    }

    for (Fort fort : FortManager.getInstance().getForts()) {
      if (FortSiegeManager.getInstance().checkIsRegistered(clan, fort.getFortId())) {
        player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_SIEGE));
        return;
      }
    }

    if (player.isInsideZone(L2PcInstance.ZONE_SIEGE)) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_SIEGE));
      return;
    }

    if (clan.getDissolvingExpiryTime() > System.currentTimeMillis()) {
      player.sendPacket(new SystemMessage(SystemMessageId.DISSOLUTION_IN_PROGRESS));
      return;
    }

    clan.setDissolvingExpiryTime(
        System.currentTimeMillis()
            + Config.ALT_CLAN_DISSOLVE_DAYS * 86400000L); // 24*60*60*1000 = 86400000
    clan.updateClanInDB();

    ClanTable.getInstance().scheduleRemoveClan(clan.getClanId());

    // The clan leader should take the XP penalty of a full death.
    player.deathPenalty(false);

    clan = null;
  }
Ejemplo n.º 8
0
  @Override
  public void onBypassFeedback(L2PcInstance player, String command) {
    if (command.equalsIgnoreCase("start_mission") && Config.ALLOW_JAILMANAGER) {
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      html.setFile("data/html/mods/jail/mission.htm");
      html.replace("%objectId%", String.valueOf(getObjectId()));
      html.replace("%playername%", player.getName());
      html.replace("%amount%", String.valueOf(Config.REQUIRED_JAIL_POINTS));
      html.replace("%npcname%", String.valueOf(getName()));
      player.sendPacket(html);

      if (player.isDead() || player.isFakeDeath()) {
        player.sendMessage(
            Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT));
        return;
      }
    } else if (command.equalsIgnoreCase("check_points") && player.isInJailMission()) {
      NpcHtmlMessage html2 = new NpcHtmlMessage(getObjectId());
      html2.setFile("data/html/mods/jail/points.htm");
      html2.replace("%objectId%", String.valueOf(getObjectId()));
      html2.replace("%points%", String.valueOf(player.getJailPoints()));
      html2.replace("%rest%", String.valueOf(Config.REQUIRED_JAIL_POINTS - player.getJailPoints()));
      html2.replace("%npcname%", String.valueOf(getName()));
      player.sendPacket(html2);

      if (player.isDead() || player.isFakeDeath()) {
        player.sendMessage(
            Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT));
        return;
      }
    } else if (command.equalsIgnoreCase("get_mission")) {
      if (player.isInJailMission()) {
        WindowService.sendWindow(player, "data/html/mods/jail/", "mission_already.htm");
        return;
      }
      player.setIsInJailMission(true);
      PlaySound ps =
          new PlaySound(
              0,
              "ItemSound2.race_start",
              0,
              player.getObjectId(),
              player.getX(),
              player.getY(),
              player.getZ());
      player.sendPacket(ps);
      WindowService.sendWindow(player, "data/html/mods/jail/", "started.htm");

      if (player.isDead() || player.isFakeDeath()) {
        player.sendMessage(
            Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT));
        return;
      }
    } else if (command.equalsIgnoreCase("finish_mission")) {
      if (!player.isInJailMission()) {
        WindowService.sendWindow(player, "data/html/mods/jail/", "notstarted.htm");
        return;
      }
      if (player.getJailPoints() < Config.REQUIRED_JAIL_POINTS) {
        WindowService.sendWindow(player, "data/html/mods/jail/", "notcompleted.htm");
        return;
      }
      if (player.isDead() || player.isFakeDeath()) {
        player.sendMessage(
            Message.getMessage(player, Message.MessageId.MSG_NOT_ALLOWED_AT_THE_MOMENT));
        return;
      }
      PlaySound ps =
          new PlaySound(
              0,
              "ItemSound.quest_finish",
              0,
              player.getObjectId(),
              player.getX(),
              player.getY(),
              player.getZ());
      player.sendPacket(ps);
      WindowService.sendWindow(player, "data/html/mods/jail/", "completed.htm");

      try {
        Thread.sleep(Util.convertSecondsToMiliseconds(5));
      } catch (Throwable t) {
        _log.error("Error, L2JailManagerInstance, reason: " + t.getMessage());
      }
      player.setInJail(false, 0);
      player.resetJailPoints();
      player.sendMessage(Message.getMessage(player, Message.MessageId.MSG_JAIL_POINTS_RESET));
      player.setIsInJailMission(false);
    }
    super.onBypassFeedback(player, command);
  }
Ejemplo n.º 9
0
  @Override
  public void onBypassFeedback(L2PcInstance player, String command) {
    player.sendPacket(ActionFailed.STATIC_PACKET);

    StringTokenizer st = new StringTokenizer(command, " ");
    String actualCommand = st.nextToken(); // Get actual command

    String filename = SevenSigns.SEVEN_SIGNS_HTML_PATH;
    int sealAvariceOwner = SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_AVARICE);
    int sealGnosisOwner = SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_GNOSIS);
    int playerCabal = SevenSigns.getInstance().getPlayerCabal(player.getObjectId());
    boolean isSealValidationPeriod = SevenSigns.getInstance().isSealValidationPeriod();
    int compWinner = SevenSigns.getInstance().getCabalHighestScore();

    if (actualCommand.startsWith("necro")) {
      boolean canPort = true;
      if (isSealValidationPeriod) {
        if (compWinner == SevenSigns.CABAL_DAWN
            && (playerCabal != SevenSigns.CABAL_DAWN
                || sealAvariceOwner != SevenSigns.CABAL_DAWN)) {
          player.sendPacket(SystemMessageId.CAN_BE_USED_BY_DAWN);
          canPort = false;
        } else if (compWinner == SevenSigns.CABAL_DUSK
            && (playerCabal != SevenSigns.CABAL_DUSK
                || sealAvariceOwner != SevenSigns.CABAL_DUSK)) {
          player.sendPacket(SystemMessageId.CAN_BE_USED_BY_DUSK);
          canPort = false;
        } else if (compWinner == SevenSigns.CABAL_NULL && playerCabal != SevenSigns.CABAL_NULL)
          canPort = true;
        else if (playerCabal == SevenSigns.CABAL_NULL) canPort = false;
      } else {
        if (playerCabal == SevenSigns.CABAL_NULL) canPort = false;
      }

      if (!canPort) {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        filename += "necro_no.htm";
        html.setFile(filename);
        player.sendPacket(html);
      } else {
        doTeleport(player, Integer.parseInt(st.nextToken()));
        player.setIsIn7sDungeon(true);
      }
    } else if (actualCommand.startsWith("cata")) {
      boolean canPort = true;
      if (isSealValidationPeriod) {
        if (compWinner == SevenSigns.CABAL_DAWN
            && (playerCabal != SevenSigns.CABAL_DAWN || sealGnosisOwner != SevenSigns.CABAL_DAWN)) {
          player.sendPacket(SystemMessageId.CAN_BE_USED_BY_DAWN);
          canPort = false;
        } else if (compWinner == SevenSigns.CABAL_DUSK
            && (playerCabal != SevenSigns.CABAL_DUSK || sealGnosisOwner != SevenSigns.CABAL_DUSK)) {
          player.sendPacket(SystemMessageId.CAN_BE_USED_BY_DUSK);
          canPort = false;
        } else if (compWinner == SevenSigns.CABAL_NULL && playerCabal != SevenSigns.CABAL_NULL)
          canPort = true;
        else if (playerCabal == SevenSigns.CABAL_NULL) canPort = false;
      } else {
        if (playerCabal == SevenSigns.CABAL_NULL) canPort = false;
      }

      if (!canPort) {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        filename += "cata_no.htm";
        html.setFile(filename);
        player.sendPacket(html);
      } else {
        doTeleport(player, Integer.parseInt(st.nextToken()));
        player.setIsIn7sDungeon(true);
      }
    } else if (actualCommand.startsWith("exit")) {
      doTeleport(player, Integer.parseInt(st.nextToken()));
      player.setIsIn7sDungeon(false);
    } else if (actualCommand.startsWith("goto")) {
      doTeleport(player, Integer.parseInt(st.nextToken()));
    } else super.onBypassFeedback(player, command);
  }
  private static final boolean validateGateCondition(L2PcInstance clanLeader, L2PcInstance player) {
    if (clanLeader.isAlikeDead()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isInStoreMode()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isRooted() || clanLeader.isInCombat()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isInOlympiadMode()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isFestivalParticipant()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.inObserverMode()) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.isInsideZone(L2Character.ZONE_NOSUMMONFRIEND)) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    if (clanLeader.getInstanceId() > 0) {
      if (!Config.ALLOW_SUMMON_TO_INSTANCE
          || InstanceManager.getInstance().getInstance(player.getInstanceId()).isSummonAllowed()) {
        // Need retail message if there's one.
        player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
        return false;
      }
    }

    if (player.isIn7sDungeon()) {
      final int targetCabal = SevenSigns.getInstance().getPlayerCabal(clanLeader.getObjectId());
      if (SevenSigns.getInstance().isSealValidationPeriod()) {
        if (targetCabal != SevenSigns.getInstance().getCabalHighestScore()) {
          // Need retail message if there's one.
          player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
          return false;
        }
      } else {
        if (targetCabal == SevenSigns.CABAL_NULL) {
          // Need retail message if there's one.
          player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
          return false;
        }
      }
    }

    if (!TvTEvent.onEscapeUse(player.getObjectId())) {
      player.sendMessage("You on TvT Event, teleporting disabled.");
      return false;
    }

    if (!TvTEvent.onEscapeUse(clanLeader.getObjectId())) {
      // Need retail message if there's one.
      player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
      return false;
    }

    return true;
  }