/** * Claims the hero status for the given player. * * @param player the player to become hero */ public void claimHero(L2PcInstance player) { _heroes.get(player.getObjectId()).set(CLAIMED, true); final L2Clan clan = player.getClan(); if ((clan != null) && (clan.getLevel() >= 5)) { clan.addReputationScore(Config.HERO_POINTS, true); final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.CLAN_MEMBER_C1_BECAME_HERO_AND_GAINED_S2_REPUTATION_POINTS); sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId())); sm.addInt(Config.HERO_POINTS); clan.broadcastToOnlineMembers(sm); } player.setHero(true); player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation player.sendPacket(new UserInfo(player)); player.sendPacket(new ExBrExtraUserInfo(player)); player.broadcastUserInfo(); // Set Gained hero and reload data setHeroGained(player.getObjectId()); loadFights(player.getObjectId()); loadDiary(player.getObjectId()); _heroMessage.put(player.getObjectId(), ""); updateHeroes(false); }
private void init() { _heroes.clear(); _completeHeroes.clear(); _herocounts.clear(); _herofights.clear(); _herodiary.clear(); _heroMessage.clear(); try (Connection con = L2DatabaseFactory.getInstance().getConnection(); Statement s1 = con.createStatement(); ResultSet rset = s1.executeQuery(GET_HEROES); PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY); Statement s2 = con.createStatement(); ResultSet rset2 = s2.executeQuery(GET_ALL_HEROES)) { while (rset.next()) { StatsSet hero = new StatsSet(); int charId = rset.getInt(Olympiad.CHAR_ID); hero.set(Olympiad.CHAR_NAME, rset.getString(Olympiad.CHAR_NAME)); hero.set(Olympiad.CLASS_ID, rset.getInt(Olympiad.CLASS_ID)); hero.set(COUNT, rset.getInt(COUNT)); hero.set(PLAYED, rset.getInt(PLAYED)); hero.set(CLAIMED, Boolean.parseBoolean(rset.getString(CLAIMED))); loadFights(charId); loadDiary(charId); loadMessage(charId); processHeros(ps, charId, hero); _heroes.put(charId, hero); } while (rset2.next()) { StatsSet hero = new StatsSet(); int charId = rset2.getInt(Olympiad.CHAR_ID); hero.set(Olympiad.CHAR_NAME, rset2.getString(Olympiad.CHAR_NAME)); hero.set(Olympiad.CLASS_ID, rset2.getInt(Olympiad.CLASS_ID)); hero.set(COUNT, rset2.getInt(COUNT)); hero.set(PLAYED, rset2.getInt(PLAYED)); hero.set(CLAIMED, Boolean.parseBoolean(rset2.getString(CLAIMED))); processHeros(ps, charId, hero); _completeHeroes.put(charId, hero); } } catch (SQLException e) { _log.log(Level.WARNING, "Hero System: Couldnt load Heroes", e); } _log.info("Hero System: Loaded " + _heroes.size() + " Heroes."); _log.info("Hero System: Loaded " + _completeHeroes.size() + " all time Heroes."); }