コード例 #1
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;
  }
コード例 #2
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;
  }