private static final void dissolveClan(L2PcInstance player, int clanId) {
    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }

    final L2Clan clan = player.getClan();
    if (clan.getAllyId() != 0) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISPERSE_THE_CLANS_IN_ALLY));
      return;
    }
    if (clan.isAtWar()) {
      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_WHILE_IN_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, false, false);
  }
Exemple #2
0
  public void convertOldPedgeFiles() {
    File dir = new File(Config.DATAPACK_ROOT, "data/crests/");

    File[] files = dir.listFiles(new OldPledgeFilter());

    for (File file : files) {
      int clanId = Integer.parseInt(file.getName().substring(7, file.getName().length() - 4));

      _log.info("Found old crest file \"" + file.getName() + "\" for clanId " + clanId);

      int newId = IdFactory.getInstance().getNextId();

      L2Clan clan = ClanTable.getInstance().getClan(clanId);

      if (clan != null) {
        removeOldPledgeCrest(clan.getCrestId());

        file.renameTo(new File(Config.DATAPACK_ROOT, "data/crests/Crest_" + newId + ".bmp"));
        _log.info("Renamed Clan crest to new format: Crest_" + newId + ".bmp");

        Connection con = null;

        try {
          con = L2DatabaseFactory.getInstance().getConnection();
          PreparedStatement statement =
              con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?");
          statement.setInt(1, newId);
          statement.setInt(2, clan.getClanId());
          statement.executeUpdate();
          statement.close();
        } catch (SQLException e) {
          _log.log(Level.WARNING, "Could not update the crest id:" + e.getMessage(), e);
        } finally {
          L2DatabaseFactory.close(con);
        }

        clan.setCrestId(newId);
      } else {
        _log.info("Clan Id: " + clanId + " does not exist in table.. deleting.");
        file.delete();
      }
    }
  }
Exemple #3
0
  @Override
  protected final void writeImpl() {
    writeC(0x96);
    writeS(_activeChar.getName());
    writeD(_clan.getClanId());
    writeD(0x00);
    writeS(_clan.getName());
    writeS(_clan.getLeaderName());
    writeD(_clan.getCrestId()); // -> no, it's no longer used (nuocnam) fix by game
    writeD(_clan.getLevel());
    writeD(_clan.getCastleId());
    writeD(_clan.getHideoutId());
    writeD(_clan.getFortId());
    writeD(_clan.getRank());
    writeD(_clan.getReputationScore());
    writeD(0x00);
    writeD(0x00);

    writeD(_clan.getAllyId()); // c2
    writeS(_clan.getAllyName()); // c2
    writeD(_clan.getAllyCrestId()); // c2
    writeD(_clan.isAtWar() ? 1 : 0); // c3
    writeD(0x00); // T3 Unknown
    writeD(_clan.getMembers().length);

    for (L2ClanMember member : _clan.getMembers()) {
      if (member != null) {
        writeS(member.getName());
        writeD(member.getLevel());
        writeD(member.getClassId());
        writeD(member.getSex() ? 1 : 0);
        writeD(member.getRaceOrdinal());
        writeD(member.isOnline() ? member.getObjectId() : 0);
        writeD(member.getSponsor() != 0 ? 1 : 0);
      }
    }
  }