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(); } } }
@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); } } }
public NpcInfo(L2Npc npc) { _npc = npc; _abnormalVisualEffects = npc.getCurrentAbnormalVisualEffects(); addComponentType( NpcInfoType.ATTACKABLE, NpcInfoType.UNKNOWN1, NpcInfoType.ID, NpcInfoType.POSITION, NpcInfoType.ALIVE, NpcInfoType.RUNNING); if (npc.getHeading() > 0) { addComponentType(NpcInfoType.HEADING); } if ((npc.getStat().getPAtkSpd() > 0) || (npc.getStat().getMAtkSpd() > 0)) { addComponentType(NpcInfoType.ATK_CAST_SPEED); } if (npc.getRunSpeed() > 0) { addComponentType(NpcInfoType.SPEED_MULTIPLIER); } if ((npc.getLeftHandItem() > 0) || (npc.getRightHandItem() > 0)) { addComponentType(NpcInfoType.EQUIPPED); } if (npc.getTeam() != Team.NONE) { addComponentType(NpcInfoType.TEAM); } if (npc.getDisplayEffect() > 0) { addComponentType(NpcInfoType.DISPLAY_EFFECT); } if (npc.isInsideZone(ZoneId.WATER) || npc.isFlying()) { addComponentType(NpcInfoType.SWIM_OR_FLY); } if (npc.isFlying()) { addComponentType(NpcInfoType.FLYING); } if (npc.getMaxHp() > 0) { addComponentType(NpcInfoType.MAX_HP); } if (npc.getMaxMp() > 0) { addComponentType(NpcInfoType.MAX_MP); } if (npc.getCurrentHp() <= npc.getMaxHp()) { addComponentType(NpcInfoType.CURRENT_HP); } if (npc.getCurrentMp() <= npc.getMaxMp()) { addComponentType(NpcInfoType.CURRENT_MP); } if (npc.getTemplate().isUsingServerSideName()) { addComponentType(NpcInfoType.NAME); } if (npc.getTemplate().isUsingServerSideTitle() || (Config.SHOW_NPC_LVL && npc.isMonster()) || npc.isChampion()) { addComponentType(NpcInfoType.TITLE); } if (!_abnormalVisualEffects.isEmpty()) { addComponentType(NpcInfoType.ABNORMALS); } if (npc.getEnchantEffect() > 0) { addComponentType(NpcInfoType.ENCHANT); } if ((npc.getTransformation() != null) && (npc.getTransformation().getId() > 0)) { addComponentType(NpcInfoType.TRANSFORMATION); } if (npc.isInsideZone(ZoneId.TOWN) && (npc.getCastle() != null) && (Config.SHOW_CREST_WITHOUT_QUEST || npc.getCastle().getShowNpcCrest()) && (npc.getCastle().getOwnerId() != 0)) { int townId = TownManager.getTown(npc.getX(), npc.getY(), npc.getZ()).getTownId(); if ((townId != 33) && (townId != 22)) { L2Clan clan = ClanTable.getInstance().getClan(npc.getCastle().getOwnerId()); _clanId = clan.getId(); _clanCrest = clan.getCrestId(); _clanLargeCrest = clan.getCrestLargeId(); _allyCrest = clan.getAllyCrestId(); _allyId = clan.getAllyId(); addComponentType(NpcInfoType.CLAN); } } addComponentType(NpcInfoType.UNKNOWN8); // TODO: Confirm me if (npc.isInCombat()) { _statusMask |= 0x01; } if (npc.isDead()) { _statusMask |= 0x02; } if (npc.isTargetable()) { _statusMask |= 0x04; } if (npc.isShowName()) { _statusMask |= 0x08; } if (_statusMask != 0) { addComponentType(NpcInfoType.VISUAL_STATE); } }
@Override protected final void writeImpl() { writeC(0xcb); writeD(_castle.getResidenceId()); writeD(0x00); // Unknown writeD(0x01); // Unknown writeD(0x00); // Unknown final int size = _castle.getSiege().getDefenderWaitingClans().size() + _castle.getSiege().getDefenderClans().size() + (_castle.getOwner() != null ? 1 : 0); writeD(size); writeD(size); // Add owners final L2Clan ownerClan = _castle.getOwner(); if (ownerClan != null) { writeD(ownerClan.getId()); writeS(ownerClan.getName()); writeS(ownerClan.getLeaderName()); writeD(ownerClan.getCrestId()); writeD(0x00); // signed time (seconds) (not storated by L2J) writeD(SiegeClanType.OWNER.ordinal()); writeD(ownerClan.getAllyId()); writeS(ownerClan.getAllyName()); writeS(""); // AllyLeaderName writeD(ownerClan.getAllyCrestId()); } // List of confirmed defenders for (L2SiegeClan siegeClan : _castle.getSiege().getDefenderClans()) { final L2Clan defendingClan = ClanTable.getInstance().getClan(siegeClan.getClanId()); if ((defendingClan == null) || (defendingClan == _castle.getOwner())) { continue; } writeD(defendingClan.getId()); writeS(defendingClan.getName()); writeS(defendingClan.getLeaderName()); writeD(defendingClan.getCrestId()); writeD(0x00); // signed time (seconds) (not storated by L2J) writeD(SiegeClanType.DEFENDER.ordinal()); writeD(defendingClan.getAllyId()); writeS(defendingClan.getAllyName()); writeS(""); // AllyLeaderName writeD(defendingClan.getAllyCrestId()); } // List of not confirmed defenders for (L2SiegeClan siegeClan : _castle.getSiege().getDefenderWaitingClans()) { final L2Clan defendingClan = ClanTable.getInstance().getClan(siegeClan.getClanId()); if (defendingClan == null) { continue; } writeD(defendingClan.getId()); writeS(defendingClan.getName()); writeS(defendingClan.getLeaderName()); writeD(defendingClan.getCrestId()); writeD(0x00); // signed time (seconds) (not storated by L2J) writeD(SiegeClanType.DEFENDER_PENDING.ordinal()); writeD(defendingClan.getAllyId()); writeS(defendingClan.getAllyName()); writeS(""); // AllyLeaderName writeD(defendingClan.getAllyCrestId()); } }