Ranking system rework.
Contributed by iDesy.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.enums;
|
||||
|
||||
import static org.l2jmobius.gameserver.enums.RankingScope.ALL;
|
||||
import static org.l2jmobius.gameserver.enums.RankingScope.SELF;
|
||||
import static org.l2jmobius.gameserver.enums.RankingScope.TOP_100;
|
||||
import static org.l2jmobius.gameserver.enums.RankingScope.TOP_150;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public enum RankingCategory
|
||||
{
|
||||
SERVER,
|
||||
RACE,
|
||||
CLAN,
|
||||
FRIEND;
|
||||
|
||||
public RankingScope getScopeByGroup(int id)
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case SERVER:
|
||||
{
|
||||
return id == 0 ? TOP_150 : SELF;
|
||||
}
|
||||
case RACE:
|
||||
{
|
||||
return id == 0 ? TOP_100 : SELF;
|
||||
}
|
||||
case CLAN:
|
||||
case FRIEND:
|
||||
{
|
||||
return ALL;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.enums;
|
||||
|
||||
import static org.l2jmobius.gameserver.enums.RankingOlympiadScope.SELF;
|
||||
import static org.l2jmobius.gameserver.enums.RankingOlympiadScope.TOP_100;
|
||||
import static org.l2jmobius.gameserver.enums.RankingOlympiadScope.TOP_50;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public enum RankingOlympiadCategory
|
||||
{
|
||||
SERVER,
|
||||
CLASS;
|
||||
|
||||
public RankingOlympiadScope getScopeByGroup(int id)
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case SERVER:
|
||||
{
|
||||
return id == 0 ? TOP_100 : SELF;
|
||||
}
|
||||
case CLASS:
|
||||
{
|
||||
return id == 0 ? TOP_50 : SELF;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.enums;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public enum RankingOlympiadScope
|
||||
{
|
||||
TOP_100(0),
|
||||
TOP_50(0),
|
||||
ALL(0),
|
||||
SELF(1);
|
||||
|
||||
final private int _id;
|
||||
|
||||
private RankingOlympiadScope(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.enums;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public enum RankingScope
|
||||
{
|
||||
TOP_100(0),
|
||||
TOP_150(0),
|
||||
ALL(0),
|
||||
SELF(1);
|
||||
|
||||
final private int _id;
|
||||
|
||||
private RankingScope(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
}
|
@@ -42,10 +42,11 @@ public class RankManager
|
||||
|
||||
public static final Long TIME_LIMIT = 2592000000L; // 30 days in milliseconds
|
||||
public static final long CURRENT_TIME = Chronos.currentTimeMillis();
|
||||
public static final int PLAYER_LIMIT = 100;
|
||||
public static final int PLAYER_LIMIT = 500;
|
||||
|
||||
private static final String SELECT_CHARACTERS = "SELECT charId,char_name,level,race,base_class, clanid FROM characters WHERE (" + CURRENT_TIME + " - cast(lastAccess as signed) < " + TIME_LIMIT + ") AND accesslevel = 0 AND level > 84 ORDER BY exp DESC, onlinetime DESC LIMIT " + PLAYER_LIMIT;
|
||||
private static final String SELECT_CHARACTERS_BY_RACE = "SELECT charId FROM characters WHERE (" + CURRENT_TIME + " - cast(lastAccess as signed) < " + TIME_LIMIT + ") AND accesslevel = 0 AND level > 84 AND race = ? ORDER BY exp DESC, onlinetime DESC LIMIT " + PLAYER_LIMIT;
|
||||
private static final String SELECT_CHARACTERS = "SELECT charId,char_name,level,race,base_class, clanid FROM characters WHERE (" + CURRENT_TIME + " - cast(lastAccess as signed) < " + TIME_LIMIT + ") AND accesslevel = 0 AND level > 39 ORDER BY exp DESC, onlinetime DESC LIMIT " + PLAYER_LIMIT;
|
||||
private static final String SELECT_CHARACTERS_PVP = "SELECT charId,char_name,level,race,base_class, clanid, deaths, kills, pvpkills FROM characters WHERE (" + CURRENT_TIME + " - cast(lastAccess as signed) < " + TIME_LIMIT + ") AND accesslevel = 0 AND level > 84 ORDER BY kills DESC, onlinetime DESC LIMIT " + PLAYER_LIMIT;
|
||||
private static final String SELECT_CHARACTERS_BY_RACE = "SELECT charId FROM characters WHERE (" + CURRENT_TIME + " - cast(lastAccess as signed) < " + TIME_LIMIT + ") AND accesslevel = 0 AND level > 39 AND race = ? ORDER BY exp DESC, onlinetime DESC LIMIT " + PLAYER_LIMIT;
|
||||
|
||||
private static final String GET_CURRENT_CYCLE_DATA = "SELECT characters.char_name, characters.level, characters.base_class, characters.clanid, olympiad_nobles.charId, olympiad_nobles.olympiad_points, olympiad_nobles.competitions_won, olympiad_nobles.competitions_lost FROM characters, olympiad_nobles WHERE characters.charId = olympiad_nobles.charId ORDER BY olympiad_nobles.olympiad_points DESC LIMIT " + PLAYER_LIMIT;
|
||||
private static final String GET_CHARACTERS_BY_CLASS = "SELECT characters.charId, olympiad_nobles.olympiad_points FROM characters, olympiad_nobles WHERE olympiad_nobles.charId = characters.charId AND characters.base_class = ? ORDER BY olympiad_nobles.olympiad_points DESC LIMIT " + PLAYER_LIMIT;
|
||||
@@ -54,6 +55,8 @@ public class RankManager
|
||||
private Map<Integer, StatSet> _snapshotList = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, StatSet> _mainOlyList = new ConcurrentHashMap<>();
|
||||
private Map<Integer, StatSet> _snapshotOlyList = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, StatSet> _mainPvpList = new ConcurrentHashMap<>();
|
||||
private Map<Integer, StatSet> _snapshotPvpList = new ConcurrentHashMap<>();
|
||||
|
||||
protected RankManager()
|
||||
{
|
||||
@@ -67,6 +70,8 @@ public class RankManager
|
||||
_mainList.clear();
|
||||
_snapshotOlyList = _mainOlyList;
|
||||
_mainOlyList.clear();
|
||||
_snapshotPvpList = _mainPvpList;
|
||||
_mainPvpList.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(SELECT_CHARACTERS))
|
||||
@@ -166,6 +171,46 @@ public class RankManager
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Could not load olympiad total rank data: " + this + " - " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(SELECT_CHARACTERS_PVP))
|
||||
{
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int i = 1;
|
||||
while (rset.next())
|
||||
{
|
||||
final StatSet player = new StatSet();
|
||||
final int charId = rset.getInt("charId");
|
||||
player.set("charId", charId);
|
||||
player.set("name", rset.getString("char_name"));
|
||||
player.set("level", rset.getInt("level"));
|
||||
player.set("classId", rset.getInt("base_class"));
|
||||
final int race = rset.getInt("race");
|
||||
player.set("race", race);
|
||||
player.set("kills", rset.getInt("kills"));
|
||||
player.set("deaths", rset.getInt("deaths"));
|
||||
player.set("points", rset.getInt("pvpkills"));
|
||||
loadRaceRank(charId, race, player);
|
||||
final int clanId = rset.getInt("clanid");
|
||||
if (clanId > 0)
|
||||
{
|
||||
player.set("clanName", ClanTable.getInstance().getClan(clanId).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
player.set("clanName", "");
|
||||
}
|
||||
|
||||
_mainPvpList.put(i, player);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Could not load pvp total rank data: " + this + " - " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadClassRank(int charId, int classId, StatSet player)
|
||||
@@ -246,6 +291,16 @@ public class RankManager
|
||||
return _snapshotOlyList;
|
||||
}
|
||||
|
||||
public Map<Integer, StatSet> getPvpRankList()
|
||||
{
|
||||
return _mainPvpList;
|
||||
}
|
||||
|
||||
public Map<Integer, StatSet> getSnapshotPvpRankList()
|
||||
{
|
||||
return _snapshotPvpList;
|
||||
}
|
||||
|
||||
public int getPlayerGlobalRank(PlayerInstance player)
|
||||
{
|
||||
final int playerOid = player.getObjectId();
|
||||
|
@@ -960,6 +960,7 @@ public class Npc extends Creature
|
||||
else if (Config.FAKE_PLAYER_KILL_PVP)
|
||||
{
|
||||
player.setPvpKills(player.getPvpKills() + 1);
|
||||
player.setTotalKills(player.getTotalKills() + 1);
|
||||
player.broadcastUserInfo(UserInfoType.SOCIAL);
|
||||
// pvp item rewards
|
||||
if (Config.REWARD_PVP_ITEM)
|
||||
|
@@ -389,8 +389,8 @@ public class PlayerInstance extends Playable
|
||||
private static final String DELETE_ITEM_REUSE_SAVE = "DELETE FROM character_item_reuse_save WHERE charId=?";
|
||||
|
||||
// Character Character SQL String Definitions:
|
||||
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,reputation,fame,raidbossPoints,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,online,clan_privs,wantspeace,base_class,nobless,power_grade,vitality_points,createDate) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,reputation=?,fame=?,raidbossPoints=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,online=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,pccafe_points=? WHERE charId=?";
|
||||
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,reputation,fame,raidbossPoints,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,online,clan_privs,wantspeace,base_class,nobless,power_grade,vitality_points,createDate,kills,deaths) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,reputation=?,fame=?,raidbossPoints=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,online=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,pccafe_points=?,kills=?,deaths=? WHERE charId=?";
|
||||
private static final String UPDATE_CHARACTER_ACCESS = "UPDATE characters SET accesslevel = ? WHERE charId = ?";
|
||||
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
|
||||
|
||||
@@ -476,6 +476,12 @@ public class PlayerInstance extends Playable
|
||||
/** The PK counter of the PlayerInstance (= Number of non PvP Flagged player killed) */
|
||||
private int _pkKills;
|
||||
|
||||
/** The total kill counter of the PlayerInstance */
|
||||
private int _totalKills = 0;
|
||||
|
||||
/** The total death counter of the PlayerInstance */
|
||||
private int _totalDeaths = 0;
|
||||
|
||||
/** The PvP Flag state of the PlayerInstance (0=White, 1=Purple) */
|
||||
private byte _pvpFlag;
|
||||
|
||||
@@ -1948,6 +1954,26 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
}
|
||||
|
||||
public int getTotalKills()
|
||||
{
|
||||
return _totalKills;
|
||||
}
|
||||
|
||||
public int getTotalDeaths()
|
||||
{
|
||||
return _totalDeaths;
|
||||
}
|
||||
|
||||
public void setTotalKills(int value)
|
||||
{
|
||||
_totalKills = value;
|
||||
}
|
||||
|
||||
public void setTotalDeaths(int value)
|
||||
{
|
||||
_totalDeaths = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _deleteTimer of the PlayerInstance.
|
||||
*/
|
||||
@@ -4762,6 +4788,7 @@ public class PlayerInstance extends Playable
|
||||
if (pk != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPvPKill(pk, this), this);
|
||||
setTotalDeaths(getTotalDeaths() + 1);
|
||||
if (GameEvent.isParticipant(pk))
|
||||
{
|
||||
pk.getEventStatus().addKill(this);
|
||||
@@ -5105,11 +5132,13 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
setPvpKills(_pvpKills + 1);
|
||||
setTotalKills(getTotalKills() + 1);
|
||||
updatePvpTitleAndColor(true);
|
||||
}
|
||||
else if ((getReputation() > 0) && (_pkKills == 0))
|
||||
{
|
||||
setReputation(0);
|
||||
setTotalKills(getTotalKills() + 1);
|
||||
setPkKills(getPkKills() + 1);
|
||||
}
|
||||
else // Calculate new karma and increase pk count
|
||||
@@ -5120,12 +5149,14 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), killedPlayable.isSummon()));
|
||||
setPkKills(getPkKills() + 1);
|
||||
setTotalKills(getTotalKills() + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), killedPlayable.isSummon()));
|
||||
setPkKills(getPkKills() + 1);
|
||||
setTotalKills(getTotalKills() + 1);
|
||||
|
||||
// Einhasad debuffs.
|
||||
if (_pkKills > 9)
|
||||
@@ -6454,6 +6485,8 @@ public class PlayerInstance extends Playable
|
||||
statement.setLong(34, 0);
|
||||
statement.setInt(35, PlayerStat.MIN_VITALITY_POINTS);
|
||||
statement.setDate(36, new Date(_createDate.getTimeInMillis()));
|
||||
statement.setInt(37, getTotalKills());
|
||||
statement.setInt(38, getTotalDeaths());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -6579,7 +6612,8 @@ public class PlayerInstance extends Playable
|
||||
|
||||
player.getClanPrivileges().clear();
|
||||
}
|
||||
|
||||
player.setTotalDeaths(rset.getInt("deaths"));
|
||||
player.setTotalKills(rset.getInt("kills"));
|
||||
player.setDeleteTimer(rset.getLong("deletetime"));
|
||||
player.setTitle(rset.getString("title"));
|
||||
player.setAccessLevel(rset.getInt("accesslevel"), false, false);
|
||||
@@ -7187,7 +7221,9 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
statement.setInt(47, factionId);
|
||||
statement.setInt(48, _pcCafePoints);
|
||||
statement.setInt(49, getObjectId());
|
||||
statement.setInt(49, getTotalKills());
|
||||
statement.setInt(50, getTotalDeaths());
|
||||
statement.setInt(51, getObjectId());
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@@ -119,6 +119,8 @@ import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidSe
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestOlympiadHeroAndLegendInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestOlympiadMyRankingInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestOlympiadRankingInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestPvpRankingList;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestPvpRankingMyInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove;
|
||||
@@ -590,8 +592,8 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
||||
EX_BLESS_OPTION_PUT_ITEM(0x1BF, null, ConnectionState.IN_GAME),
|
||||
EX_BLESS_OPTION_ENCHANT(0x1C0, null, ConnectionState.IN_GAME),
|
||||
EX_BLESS_OPTION_CANCEL(0x1C1, null, ConnectionState.IN_GAME),
|
||||
EX_PVP_RANKING_MY_INFO(0x1C2, null, ConnectionState.IN_GAME),
|
||||
EX_PVP_RANKING_LIST(0x1C3, null, ConnectionState.IN_GAME),
|
||||
EX_PVP_RANKING_MY_INFO(0x1C2, RequestPvpRankingMyInfo::new, ConnectionState.IN_GAME),
|
||||
EX_PVP_RANKING_LIST(0x1C3, RequestPvpRankingList::new, ConnectionState.IN_GAME),
|
||||
EX_ACQUIRE_PET_SKILL(0x1C4, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_V3_INFO(0x1C5, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ENEMY_INFO_LIST(0x1C6, null, ConnectionState.IN_GAME),
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExOlympiadHeroAndLegendInfo;
|
||||
@@ -35,6 +36,12 @@ public class RequestOlympiadHeroAndLegendInfo implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
client.sendPacket(new ExOlympiadHeroAndLegendInfo());
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExOlympiadHeroAndLegendInfo());
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExOlympiadMyRankingInfo;
|
||||
@@ -35,6 +36,12 @@ public class RequestOlympiadMyRankingInfo implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
client.sendPacket(new ExOlympiadMyRankingInfo(client.getPlayer()));
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExOlympiadMyRankingInfo(player));
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExOlympiadRankingInfo;
|
||||
@@ -46,6 +47,12 @@ public class RequestOlympiadRankingInfo implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
client.sendPacket(new ExOlympiadRankingInfo(client.getPlayer(), _tabId, _rankingType, _unk, _classId, _serverId));
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExOlympiadRankingInfo(player, _tabId, _rankingType, _unk, _classId, _serverId));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExPvpRankingList;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public class RequestPvpRankingList implements IClientIncomingPacket
|
||||
{
|
||||
private int _season;
|
||||
private int _tabId;
|
||||
private int _type;
|
||||
private int _race;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_season = packet.readC();
|
||||
_tabId = packet.readC();
|
||||
_type = packet.readC();
|
||||
_race = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExPvpRankingList(player, _season, _tabId, _type, _race));
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExPvpRankingMyInfo;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public class RequestPvpRankingMyInfo implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExPvpRankingMyInfo(player));
|
||||
}
|
||||
}
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExRankingCharInfo;
|
||||
@@ -38,6 +39,12 @@ public class RequestRankingCharInfo implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
client.sendPacket(new ExRankingCharInfo(client.getPlayer(), _unk));
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExRankingCharInfo(player, _unk));
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets.ranking;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ranking.ExRankingCharRankers;
|
||||
@@ -42,6 +43,12 @@ public class RequestRankingCharRankers implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
client.sendPacket(new ExRankingCharRankers(client.getPlayer(), _group, _scope, _race));
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(new ExRankingCharRankers(player, _group, _scope, _race));
|
||||
}
|
||||
}
|
||||
|
@@ -75,16 +75,7 @@ public class ExOlympiadHeroAndLegendInfo implements IClientOutgoingPacket
|
||||
}
|
||||
packet.writeD(Config.SERVER_ID);
|
||||
packet.writeD(rset.getInt("race"));
|
||||
// a stupid, client uses 0 for female and 1 for male, while server no.
|
||||
final int sex = rset.getInt("sex");
|
||||
if (sex == 1)
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(1);
|
||||
}
|
||||
packet.writeD(rset.getInt("sex") == 1 ? 0 : 1);
|
||||
packet.writeD(rset.getInt("base_class"));
|
||||
packet.writeD(rset.getInt("level"));
|
||||
packet.writeD(rset.getInt("legend_count"));
|
||||
@@ -121,16 +112,7 @@ public class ExOlympiadHeroAndLegendInfo implements IClientOutgoingPacket
|
||||
}
|
||||
packet.writeD(Config.SERVER_ID);
|
||||
packet.writeD(rset.getInt("race"));
|
||||
// a stupid, client uses 0 for female and 1 for male, while server no.
|
||||
final int sex = rset.getInt("sex");
|
||||
if (sex == 1)
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(1);
|
||||
}
|
||||
packet.writeD(rset.getInt("sex") == 1 ? 0 : 1);
|
||||
packet.writeD(rset.getInt("base_class"));
|
||||
packet.writeD(rset.getInt("level"));
|
||||
packet.writeD(rset.getInt("count"));
|
||||
|
@@ -61,116 +61,96 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
// Add one to month {0 - 11}
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
if (Olympiad.getInstance().getCurrentCycle() > 1)
|
||||
if (month == 1)
|
||||
{
|
||||
if (month == 1)
|
||||
{
|
||||
year--;
|
||||
month = 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
month--;
|
||||
}
|
||||
int currentPlace = 0;
|
||||
int currentWins = 0;
|
||||
int currentLoses = 0;
|
||||
int currentPoints = 0;
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(GET_CURRENT_CYCLE_DATA))
|
||||
{
|
||||
statement.setInt(1, _player.getBaseClass());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int i = 1;
|
||||
while (rset.next())
|
||||
{
|
||||
if (rset.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
currentPlace = i;
|
||||
currentWins = rset.getInt("competitions_won");
|
||||
currentLoses = rset.getInt("competitions_lost");
|
||||
currentPoints = rset.getInt("olympiad_points");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage());
|
||||
}
|
||||
|
||||
int previousPlace = 0;
|
||||
int previousWins = 0;
|
||||
int previousLoses = 0;
|
||||
int previousPoints = 0;
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(GET_PREVIOUS_CYCLE_DATA))
|
||||
{
|
||||
statement.setInt(1, _player.getBaseClass());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int i = 1;
|
||||
while (rset.next())
|
||||
{
|
||||
if (rset.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
previousPlace = i;
|
||||
previousWins = rset.getInt("competitions_won");
|
||||
previousLoses = rset.getInt("competitions_lost");
|
||||
previousPoints = rset.getInt("olympiad_points");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage());
|
||||
}
|
||||
|
||||
int heroCount = 0;
|
||||
int legendCount = 0;
|
||||
if (Hero.getInstance().getCompleteHeroes().containsKey(_player.getObjectId()))
|
||||
{
|
||||
final StatSet hero = Hero.getInstance().getCompleteHeroes().get(_player.getObjectId());
|
||||
heroCount = hero.getInt("count", 0);
|
||||
legendCount = hero.getInt("legend_count", 0);
|
||||
}
|
||||
|
||||
packet.writeD(year); // Year
|
||||
packet.writeD(month); // Month
|
||||
packet.writeD(Olympiad.getInstance().getCurrentCycle() - 1); // cycle ?
|
||||
packet.writeD(currentPlace); // Place on current cycle ?
|
||||
packet.writeD(currentWins); // Wins
|
||||
packet.writeD(currentLoses); // Loses
|
||||
packet.writeD(currentPoints); // Points
|
||||
packet.writeD(previousPlace); // Place on previous cycle
|
||||
packet.writeD(previousWins); // win count & lose count previous cycle? lol
|
||||
packet.writeD(previousLoses); // ??
|
||||
packet.writeD(previousPoints); // Points on previous cycle
|
||||
packet.writeD(heroCount); // Hero counts
|
||||
packet.writeD(legendCount); // Legend counts
|
||||
packet.writeD(0); // change to 1 causes shows nothing
|
||||
year--;
|
||||
month = 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(year); // Year
|
||||
packet.writeD(month); // Month
|
||||
packet.writeD(0); // cycle
|
||||
packet.writeD(0); // ??
|
||||
packet.writeD(0); // Wins
|
||||
packet.writeD(0); // Loses
|
||||
packet.writeD(0); // Points
|
||||
packet.writeD(0); // Place on previous cycle
|
||||
packet.writeD(0); // win count & lose count previous cycle? lol
|
||||
packet.writeD(0); // ??
|
||||
packet.writeD(0); // Points on previous cycle
|
||||
packet.writeD(0); // Hero counts
|
||||
packet.writeD(0); // Legend counts
|
||||
packet.writeD(0); // change to 1 causes shows nothing
|
||||
month--;
|
||||
}
|
||||
int currentPlace = 0;
|
||||
int currentWins = 0;
|
||||
int currentLoses = 0;
|
||||
int currentPoints = 0;
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(GET_CURRENT_CYCLE_DATA))
|
||||
{
|
||||
statement.setInt(1, _player.getBaseClass());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int i = 1;
|
||||
while (rset.next())
|
||||
{
|
||||
if (rset.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
currentPlace = i;
|
||||
currentWins = rset.getInt("competitions_won");
|
||||
currentLoses = rset.getInt("competitions_lost");
|
||||
currentPoints = rset.getInt("olympiad_points");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage());
|
||||
}
|
||||
|
||||
int previousPlace = 0;
|
||||
int previousWins = 0;
|
||||
int previousLoses = 0;
|
||||
int previousPoints = 0;
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(GET_PREVIOUS_CYCLE_DATA))
|
||||
{
|
||||
statement.setInt(1, _player.getBaseClass());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int i = 1;
|
||||
while (rset.next())
|
||||
{
|
||||
if (rset.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
previousPlace = i;
|
||||
previousWins = rset.getInt("competitions_won");
|
||||
previousLoses = rset.getInt("competitions_lost");
|
||||
previousPoints = rset.getInt("olympiad_points");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage());
|
||||
}
|
||||
|
||||
int heroCount = 0;
|
||||
int legendCount = 0;
|
||||
if (Hero.getInstance().getCompleteHeroes().containsKey(_player.getObjectId()))
|
||||
{
|
||||
final StatSet hero = Hero.getInstance().getCompleteHeroes().get(_player.getObjectId());
|
||||
heroCount = hero.getInt("count", 0);
|
||||
legendCount = hero.getInt("legend_count", 0);
|
||||
}
|
||||
|
||||
packet.writeD(year); // Year
|
||||
packet.writeD(month); // Month
|
||||
packet.writeD(Math.min(Olympiad.getInstance().getCurrentCycle() - 1, 0)); // cycle ?
|
||||
packet.writeD(currentPlace); // Place on current cycle ?
|
||||
packet.writeD(currentWins); // Wins
|
||||
packet.writeD(currentLoses); // Loses
|
||||
packet.writeD(currentPoints); // Points
|
||||
packet.writeD(previousPlace); // Place on previous cycle
|
||||
packet.writeD(previousWins); // win count & lose count previous cycle? lol
|
||||
packet.writeD(previousLoses); // ??
|
||||
packet.writeD(previousPoints); // Points on previous cycle
|
||||
packet.writeD(heroCount); // Hero counts
|
||||
packet.writeD(legendCount); // Legend counts
|
||||
packet.writeD(0); // change to 1 causes shows nothing
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -16,11 +16,18 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets.ranking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.enums.ClassId;
|
||||
import org.l2jmobius.gameserver.enums.RankingOlympiadCategory;
|
||||
import org.l2jmobius.gameserver.enums.RankingOlympiadScope;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@@ -28,12 +35,11 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author NviX
|
||||
* @author Berezkin Nikolay
|
||||
*/
|
||||
public class ExOlympiadRankingInfo implements IClientOutgoingPacket
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
private final int _tabId;
|
||||
private final int _rankingType;
|
||||
private final int _unk;
|
||||
@@ -68,233 +74,102 @@ public class ExOlympiadRankingInfo implements IClientOutgoingPacket
|
||||
|
||||
if (_playerList.size() > 0)
|
||||
{
|
||||
switch (_tabId)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (_rankingType == 0)
|
||||
{
|
||||
packet.writeD(_playerList.size() > 100 ? 100 : _playerList.size());
|
||||
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
packet.writeString(player.getString("name")); // name
|
||||
packet.writeString(player.getString("clanName")); // clan name
|
||||
packet.writeD(id); // rank
|
||||
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id2 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id2);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id2); // previous rank
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(id);
|
||||
}
|
||||
|
||||
packet.writeD(Config.SERVER_ID);// server id
|
||||
packet.writeD(player.getInt("level"));// level
|
||||
packet.writeD(player.getInt("classId"));// class id
|
||||
packet.writeD(player.getInt("clanLevel"));// clan level
|
||||
packet.writeD(player.getInt("competitions_won"));// win count
|
||||
packet.writeD(player.getInt("competitions_lost"));// lose count
|
||||
packet.writeD(player.getInt("olympiad_points"));// points
|
||||
packet.writeD(player.getInt("count"));// hero counts
|
||||
packet.writeD(player.getInt("legend_count"));// legend counts
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean found = false;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
if (player.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
found = true;
|
||||
|
||||
final int first = id > 10 ? (id - 9) : 1;
|
||||
final int last = _playerList.size() >= (id + 10) ? id + 10 : id + (_playerList.size() - id);
|
||||
if (first == 1)
|
||||
{
|
||||
packet.writeD(last - (first - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(last - first);
|
||||
}
|
||||
|
||||
for (int id2 = first; id2 <= last; id2++)
|
||||
{
|
||||
final StatSet plr = _playerList.get(id2);
|
||||
packet.writeString(plr.getString("name"));
|
||||
packet.writeString(plr.getString("clanName"));
|
||||
packet.writeD(id2);
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id3 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id3);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id3); // class rank snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(id2);
|
||||
}
|
||||
|
||||
packet.writeD(Config.SERVER_ID);
|
||||
packet.writeD(plr.getInt("level"));
|
||||
packet.writeD(plr.getInt("classId"));
|
||||
packet.writeD(plr.getInt("clanLevel"));// clan level
|
||||
packet.writeD(plr.getInt("competitions_won"));// win count
|
||||
packet.writeD(plr.getInt("competitions_lost"));// lose count
|
||||
packet.writeD(plr.getInt("olympiad_points"));// points
|
||||
packet.writeD(plr.getInt("count"));// hero counts
|
||||
packet.writeD(plr.getInt("legend_count"));// legend counts
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (_rankingType == 0)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 1; i <= _playerList.size(); i++)
|
||||
{
|
||||
final StatSet player = _playerList.get(i);
|
||||
if (_classId == player.getInt("classId"))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
packet.writeD(count > 50 ? 50 : count);
|
||||
|
||||
int i = 1;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
if (_classId == player.getInt("classId"))
|
||||
{
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(i); // class rank
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
final Map<Integer, StatSet> snapshotRaceList = new ConcurrentHashMap<>();
|
||||
int j = 1;
|
||||
for (Integer id2 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id2);
|
||||
if (_classId == snapshot.getInt("classId"))
|
||||
{
|
||||
snapshotRaceList.put(j, _snapshotList.get(id2));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (Integer id2 : snapshotRaceList.keySet())
|
||||
{
|
||||
final StatSet snapshot = snapshotRaceList.get(id2);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id2); // class rank snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(i);
|
||||
}
|
||||
|
||||
packet.writeD(Config.SERVER_ID);
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("clanLevel"));// clan level
|
||||
packet.writeD(player.getInt("competitions_won"));// win count
|
||||
packet.writeD(player.getInt("competitions_lost"));// lose count
|
||||
packet.writeD(player.getInt("olympiad_points"));// points
|
||||
packet.writeD(player.getInt("count"));// hero counts
|
||||
packet.writeD(player.getInt("legend_count"));// legend counts
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean found = false;
|
||||
final Map<Integer, StatSet> classList = new ConcurrentHashMap<>();
|
||||
int i = 1;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet set = _playerList.get(id);
|
||||
if (_player.getBaseClass() == set.getInt("classId"))
|
||||
{
|
||||
classList.put(i, _playerList.get(id));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer id : classList.keySet())
|
||||
{
|
||||
final StatSet player = classList.get(id);
|
||||
if (player.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
found = true;
|
||||
final int first = id > 10 ? (id - 9) : 1;
|
||||
final int last = classList.size() >= (id + 10) ? id + 10 : id + (classList.size() - id);
|
||||
if (first == 1)
|
||||
{
|
||||
packet.writeD(last - (first - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(last - first);
|
||||
}
|
||||
for (int id2 = first; id2 <= last; id2++)
|
||||
{
|
||||
final StatSet plr = classList.get(id2);
|
||||
packet.writeString(plr.getString("name"));
|
||||
packet.writeString(plr.getString("clanName"));
|
||||
packet.writeD(id2); // class rank
|
||||
packet.writeD(id2);
|
||||
packet.writeD(Config.SERVER_ID);
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("clanLevel"));// clan level
|
||||
packet.writeD(player.getInt("competitions_won"));// win count
|
||||
packet.writeD(player.getInt("competitions_lost"));// lose count
|
||||
packet.writeD(player.getInt("olympiad_points"));// points
|
||||
packet.writeD(player.getInt("count"));// hero counts
|
||||
packet.writeD(player.getInt("legend_count"));// legend counts
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
final RankingOlympiadCategory category = RankingOlympiadCategory.values()[_tabId];
|
||||
writeFilteredRankingData(packet, category, category.getScopeByGroup(_rankingType), ClassId.getClassId(_classId));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeFilteredRankingData(PacketWriter packet, RankingOlympiadCategory category, RankingOlympiadScope scope, ClassId classId)
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case SERVER:
|
||||
{
|
||||
writeScopeData(packet, scope, new ArrayList<>(_playerList.entrySet()), new ArrayList<>(_snapshotList.entrySet()));
|
||||
break;
|
||||
}
|
||||
case CLASS:
|
||||
{
|
||||
writeScopeData(packet, scope, _playerList.entrySet().stream().filter(it -> it.getValue().getInt("classId") == classId.getId()).collect(Collectors.toList()), _snapshotList.entrySet().stream().filter(it -> it.getValue().getInt("classId") == classId.getId()).collect(Collectors.toList()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeScopeData(PacketWriter packet, RankingOlympiadScope scope, List<Entry<Integer, StatSet>> list, List<Entry<Integer, StatSet>> snapshot)
|
||||
{
|
||||
|
||||
Entry<Integer, StatSet> playerData = list.stream().filter(it -> it.getValue().getInt("charId", 0) == _player.getObjectId()).findFirst().orElse(null);
|
||||
final int indexOf = list.indexOf(playerData);
|
||||
|
||||
final List<Entry<Integer, StatSet>> limited;
|
||||
switch (scope)
|
||||
{
|
||||
case TOP_100:
|
||||
{
|
||||
limited = list.stream().limit(100).collect(Collectors.toList());
|
||||
break;
|
||||
}
|
||||
case ALL:
|
||||
{
|
||||
limited = list;
|
||||
break;
|
||||
}
|
||||
case TOP_50:
|
||||
{
|
||||
limited = list.stream().limit(50).collect(Collectors.toList());
|
||||
break;
|
||||
}
|
||||
case SELF:
|
||||
{
|
||||
limited = playerData == null ? Collections.emptyList() : list.subList(Math.max(0, indexOf - 10), Math.min(list.size(), indexOf + 10));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
limited = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
packet.writeD(limited.size());
|
||||
|
||||
int rank = 1;
|
||||
for (Entry<Integer, StatSet> data : limited.stream().sorted(Entry.comparingByKey()).collect(Collectors.toList()))
|
||||
{
|
||||
int curRank = rank++;
|
||||
final StatSet player = data.getValue();
|
||||
packet.writeString(player.getString("name")); // name
|
||||
packet.writeString(player.getString("clanName")); // clan name
|
||||
packet.writeD(scope == RankingOlympiadScope.SELF ? data.getKey() : curRank); // rank
|
||||
|
||||
if (snapshot.size() > 0)
|
||||
{
|
||||
int snapshotRank = 1;
|
||||
for (Entry<Integer, StatSet> ssData : snapshot.stream().sorted(Entry.comparingByKey()).collect(Collectors.toList()))
|
||||
{
|
||||
final StatSet snapshotData = ssData.getValue();
|
||||
if (player.getInt("charId") == snapshotData.getInt("charId"))
|
||||
{
|
||||
packet.writeD(scope == RankingOlympiadScope.SELF ? ssData.getKey() : snapshotRank++); // previous rank
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(scope == RankingOlympiadScope.SELF ? data.getKey() : curRank);
|
||||
}
|
||||
|
||||
packet.writeD(Config.SERVER_ID); // server id
|
||||
packet.writeD(player.getInt("level")); // level
|
||||
packet.writeD(player.getInt("classId")); // class id
|
||||
packet.writeD(player.getInt("clanLevel")); // clan level
|
||||
packet.writeD(player.getInt("competitions_won")); // win count
|
||||
packet.writeD(player.getInt("competitions_lost")); // lose count
|
||||
packet.writeD(player.getInt("olympiad_points")); // points
|
||||
packet.writeD(player.getInt("count")); // hero counts
|
||||
packet.writeD(player.getInt("legend_count")); // legend counts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets.ranking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.enums.Race;
|
||||
import org.l2jmobius.gameserver.enums.RankingCategory;
|
||||
import org.l2jmobius.gameserver.enums.RankingScope;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public class ExPvpRankingList implements IClientOutgoingPacket
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private final int _season;
|
||||
private final int _tabId;
|
||||
private final int _type;
|
||||
private final int _race;
|
||||
private final Map<Integer, StatSet> _playerList;
|
||||
private final Map<Integer, StatSet> _snapshotList;
|
||||
|
||||
public ExPvpRankingList(PlayerInstance player, int season, int tabId, int type, int race)
|
||||
{
|
||||
_player = player;
|
||||
_season = season;
|
||||
_tabId = tabId;
|
||||
_type = type;
|
||||
_race = race;
|
||||
_playerList = RankManager.getInstance().getPvpRankList();
|
||||
_snapshotList = RankManager.getInstance().getSnapshotPvpRankList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_PVP_RANKING_LIST.writeId(packet);
|
||||
packet.writeC(_season);
|
||||
packet.writeC(_tabId);
|
||||
packet.writeC(_type);
|
||||
packet.writeD(_race);
|
||||
if ((_playerList.size() > 0) && (_type != 255) && (_race != 255))
|
||||
{
|
||||
final RankingCategory category = RankingCategory.values()[_tabId];
|
||||
writeFilteredRankingData(packet, category, category.getScopeByGroup(_type), Race.values()[_race]);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeFilteredRankingData(PacketWriter packet, RankingCategory category, RankingScope scope, Race race)
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case SERVER:
|
||||
{
|
||||
writeScopeData(packet, scope, new ArrayList<>(_playerList.entrySet()), new ArrayList<>(_snapshotList.entrySet()));
|
||||
break;
|
||||
}
|
||||
case RACE:
|
||||
{
|
||||
writeScopeData(packet, scope, _playerList.entrySet().stream().filter(it -> it.getValue().getInt("race") == race.ordinal()).collect(Collectors.toList()), _snapshotList.entrySet().stream().filter(it -> it.getValue().getInt("race") == race.ordinal()).collect(Collectors.toList()));
|
||||
break;
|
||||
}
|
||||
case CLAN:
|
||||
{
|
||||
writeScopeData(packet, scope, _player.getClan() == null ? Collections.emptyList() : _playerList.entrySet().stream().filter(it -> it.getValue().getString("clanName").equals(_player.getClan().getName())).collect(Collectors.toList()), _player.getClan() == null ? Collections.emptyList() : _snapshotList.entrySet().stream().filter(it -> it.getValue().getString("clanName").equals(_player.getClan().getName())).collect(Collectors.toList()));
|
||||
break;
|
||||
}
|
||||
case FRIEND:
|
||||
{
|
||||
writeScopeData(packet, scope, _playerList.entrySet().stream().filter(it -> _player.getFriendList().contains(it.getValue().getInt("charId"))).collect(Collectors.toList()), _snapshotList.entrySet().stream().filter(it -> _player.getFriendList().contains(it.getValue().getInt("charId"))).collect(Collectors.toList()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeScopeData(PacketWriter packet, RankingScope scope, List<Entry<Integer, StatSet>> list, List<Entry<Integer, StatSet>> snapshot)
|
||||
{
|
||||
|
||||
Entry<Integer, StatSet> playerData = list.stream().filter(it -> it.getValue().getInt("charId", 0) == _player.getObjectId()).findFirst().orElse(null);
|
||||
final int indexOf = list.indexOf(playerData);
|
||||
|
||||
final List<Entry<Integer, StatSet>> limited;
|
||||
switch (scope)
|
||||
{
|
||||
case TOP_100:
|
||||
{
|
||||
limited = list.stream().limit(100).collect(Collectors.toList());
|
||||
break;
|
||||
}
|
||||
case ALL:
|
||||
{
|
||||
limited = list;
|
||||
break;
|
||||
}
|
||||
case TOP_150:
|
||||
{
|
||||
limited = list.stream().limit(150).collect(Collectors.toList());
|
||||
break;
|
||||
}
|
||||
case SELF:
|
||||
{
|
||||
limited = playerData == null ? Collections.emptyList() : list.subList(Math.max(0, indexOf - 10), Math.min(list.size(), indexOf + 10));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
limited = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
packet.writeD(limited.size());
|
||||
|
||||
int rank = 1;
|
||||
for (Entry<Integer, StatSet> data : limited.stream().sorted(Entry.comparingByKey()).collect(Collectors.toList()))
|
||||
{
|
||||
int curRank = rank++;
|
||||
final StatSet player = data.getValue();
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("race"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeQ(player.getInt("points")); // server rank
|
||||
if (snapshot.size() > 0)
|
||||
{
|
||||
for (Entry<Integer, StatSet> ssData : snapshot.stream().sorted(Entry.comparingByKey()).collect(Collectors.toList()))
|
||||
{
|
||||
final StatSet snapshotData = ssData.getValue();
|
||||
if (player.getInt("charId") == snapshotData.getInt("charId"))
|
||||
{
|
||||
packet.writeD(scope == RankingScope.SELF ? ssData.getKey() : curRank); // server rank snapshot
|
||||
packet.writeD(snapshotData.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(player.getInt("kills"));
|
||||
packet.writeD(player.getInt("deaths"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(scope == RankingScope.SELF ? data.getKey() : curRank);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets.ranking;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* Written by Berezkin Nikolay, on 10.05.2021
|
||||
*/
|
||||
public class ExPvpRankingMyInfo implements IClientOutgoingPacket
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private final Map<Integer, StatSet> _playerList;
|
||||
private final Map<Integer, StatSet> _snapshotList;
|
||||
|
||||
public ExPvpRankingMyInfo(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
_playerList = RankManager.getInstance().getPvpRankList();
|
||||
_snapshotList = RankManager.getInstance().getSnapshotPvpRankList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_PVP_RANKING_MY_INFO.writeId(packet);
|
||||
if (_playerList.size() > 0)
|
||||
{
|
||||
boolean found = false;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet ss = _playerList.get(id);
|
||||
if (ss.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
final Optional<Map.Entry<Integer, StatSet>> snapshotValue = _snapshotList.entrySet().stream().filter(it -> it.getValue().getInt("charId") == _player.getObjectId()).findFirst();
|
||||
found = true;
|
||||
packet.writeQ(ss.getInt("points")); // pvp points
|
||||
packet.writeD(id); // current rank
|
||||
packet.writeD(snapshotValue.isPresent() ? snapshotValue.get().getKey() : id); // ingame shown change in rank as this value - current rank value.
|
||||
packet.writeD(ss.getInt("kills")); // kills
|
||||
packet.writeD(ss.getInt("deaths")); // deaths
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
packet.writeQ(0); // pvp points
|
||||
packet.writeD(0); // current rank
|
||||
packet.writeD(0); // ingame shown change in rank as this value - current rank value.
|
||||
packet.writeD(0); // kills
|
||||
packet.writeD(0); // deaths
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeQ(0); // pvp points
|
||||
packet.writeD(0); // current rank
|
||||
packet.writeD(0); // ingame shown change in rank as this value - current rank value.
|
||||
packet.writeD(0); // kills
|
||||
packet.writeD(0); // deaths
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -66,6 +66,8 @@ public class ExRankingCharInfo implements IClientOutgoingPacket
|
||||
{
|
||||
packet.writeD(id2); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank")); // race rank snapshot
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -16,11 +16,16 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets.ranking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.enums.Race;
|
||||
import org.l2jmobius.gameserver.enums.RankingCategory;
|
||||
import org.l2jmobius.gameserver.enums.RankingScope;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@@ -28,7 +33,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author NviX
|
||||
* @author Berezkin Nikolay
|
||||
*/
|
||||
public class ExRankingCharRankers implements IClientOutgoingPacket
|
||||
{
|
||||
@@ -61,361 +66,8 @@ public class ExRankingCharRankers implements IClientOutgoingPacket
|
||||
|
||||
if (_playerList.size() > 0)
|
||||
{
|
||||
switch (_group)
|
||||
{
|
||||
case 0: // all
|
||||
{
|
||||
if (_scope == 0) // all
|
||||
{
|
||||
final int count = _playerList.size() > 150 ? 150 : _playerList.size();
|
||||
packet.writeD(count);
|
||||
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("race"));
|
||||
packet.writeD(id); // server rank
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id2 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id2);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id2); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(id);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean found = false;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
if (player.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
found = true;
|
||||
final int first = id > 10 ? (id - 9) : 1;
|
||||
final int last = _playerList.size() >= (id + 10) ? id + 10 : id + (_playerList.size() - id);
|
||||
if (first == 1)
|
||||
{
|
||||
packet.writeD(last - (first - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(last - first);
|
||||
}
|
||||
for (int id2 = first; id2 <= last; id2++)
|
||||
{
|
||||
final StatSet plr = _playerList.get(id2);
|
||||
packet.writeString(plr.getString("name"));
|
||||
packet.writeString(plr.getString("clanName"));
|
||||
packet.writeD(plr.getInt("level"));
|
||||
packet.writeD(plr.getInt("classId"));
|
||||
packet.writeD(plr.getInt("race"));
|
||||
packet.writeD(id2); // server rank
|
||||
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id3 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id3);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id3); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank", 0));
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: // race
|
||||
{
|
||||
if (_scope == 0) // all
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 1; i <= _playerList.size(); i++)
|
||||
{
|
||||
final StatSet player = _playerList.get(i);
|
||||
if (_race == player.getInt("race"))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
packet.writeD(count > 100 ? 100 : count);
|
||||
|
||||
int i = 1;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
if (_race == player.getInt("race"))
|
||||
{
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("race"));
|
||||
packet.writeD(i); // server rank
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
final Map<Integer, StatSet> snapshotRaceList = new ConcurrentHashMap<>();
|
||||
int j = 1;
|
||||
for (Integer id2 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id2);
|
||||
if (_race == snapshot.getInt("race"))
|
||||
{
|
||||
snapshotRaceList.put(j, _snapshotList.get(id2));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (Integer id2 : snapshotRaceList.keySet())
|
||||
{
|
||||
final StatSet snapshot = snapshotRaceList.get(id2);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id2); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(i);
|
||||
packet.writeD(i);
|
||||
packet.writeD(i); // TODO: Check this. nClassRank_Snapshot?
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
final Map<Integer, StatSet> raceList = new ConcurrentHashMap<>();
|
||||
int i = 1;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet set = _playerList.get(id);
|
||||
if (_player.getRace().ordinal() == set.getInt("race"))
|
||||
{
|
||||
raceList.put(i, _playerList.get(id));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer id : raceList.keySet())
|
||||
{
|
||||
final StatSet player = raceList.get(id);
|
||||
if (player.getInt("charId") == _player.getObjectId())
|
||||
{
|
||||
found = true;
|
||||
final int first = id > 10 ? (id - 9) : 1;
|
||||
final int last = raceList.size() >= (id + 10) ? id + 10 : id + (raceList.size() - id);
|
||||
if (first == 1)
|
||||
{
|
||||
packet.writeD(last - (first - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(last - first);
|
||||
}
|
||||
for (int id2 = first; id2 <= last; id2++)
|
||||
{
|
||||
final StatSet plr = raceList.get(id2);
|
||||
packet.writeString(plr.getString("name"));
|
||||
packet.writeString(plr.getString("clanName"));
|
||||
packet.writeD(plr.getInt("level"));
|
||||
packet.writeD(plr.getInt("classId"));
|
||||
packet.writeD(plr.getInt("race"));
|
||||
packet.writeD(id2); // server rank
|
||||
packet.writeD(id2);
|
||||
packet.writeD(id2);
|
||||
packet.writeD(id2); // TODO: Check this. nClassRank_Snapshot?
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: // clan
|
||||
{
|
||||
if (_player.getClan() != null)
|
||||
{
|
||||
final Map<Integer, StatSet> clanList = new ConcurrentHashMap<>();
|
||||
int i = 1;
|
||||
for (Integer id : _playerList.keySet())
|
||||
{
|
||||
final StatSet set = _playerList.get(id);
|
||||
if (_player.getClan().getName() == set.getString("clanName"))
|
||||
{
|
||||
clanList.put(i, _playerList.get(id));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
packet.writeD(clanList.size());
|
||||
|
||||
for (Integer id : clanList.keySet())
|
||||
{
|
||||
final StatSet player = clanList.get(id);
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("race"));
|
||||
packet.writeD(id); // clan rank
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id2 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id2);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id2); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(id);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: // friend
|
||||
{
|
||||
if (_player.getFriendList().size() > 0)
|
||||
{
|
||||
final Set<Integer> friendList = ConcurrentHashMap.newKeySet();
|
||||
int count = 1;
|
||||
for (int id : _player.getFriendList())
|
||||
{
|
||||
for (Integer id2 : _playerList.keySet())
|
||||
{
|
||||
final StatSet temp = _playerList.get(id2);
|
||||
if (temp.getInt("charId") == id)
|
||||
{
|
||||
friendList.add(temp.getInt("charId"));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
friendList.add(_player.getObjectId());
|
||||
|
||||
packet.writeD(count);
|
||||
|
||||
for (int id : _playerList.keySet())
|
||||
{
|
||||
final StatSet player = _playerList.get(id);
|
||||
if (friendList.contains(player.getInt("charId")))
|
||||
{
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("race"));
|
||||
packet.writeD(id); // friend rank
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id2 : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id2);
|
||||
if (player.getInt("charId") == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id2); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(id);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(1);
|
||||
|
||||
packet.writeString(_player.getName());
|
||||
if (_player.getClan() != null)
|
||||
{
|
||||
packet.writeString(_player.getClan().getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeString("");
|
||||
}
|
||||
packet.writeD(_player.getStat().getBaseLevel());
|
||||
packet.writeD(_player.getBaseClass());
|
||||
packet.writeD(_player.getRace().ordinal());
|
||||
packet.writeD(1); // clan rank
|
||||
if (_snapshotList.size() > 0)
|
||||
{
|
||||
for (Integer id : _snapshotList.keySet())
|
||||
{
|
||||
final StatSet snapshot = _snapshotList.get(id);
|
||||
if (_player.getObjectId() == snapshot.getInt("charId"))
|
||||
{
|
||||
packet.writeD(id); // server rank snapshot
|
||||
packet.writeD(snapshot.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
final RankingCategory category = RankingCategory.values()[_group];
|
||||
writeFilteredRankingData(packet, category, category.getScopeByGroup(_scope), Race.values()[_race]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -423,4 +75,64 @@ public class ExRankingCharRankers implements IClientOutgoingPacket
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeFilteredRankingData(PacketWriter packet, RankingCategory category, RankingScope scope, Race race)
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case SERVER -> writeScopeData(packet, scope, new ArrayList<>(_playerList.entrySet()), new ArrayList<>(_snapshotList.entrySet()));
|
||||
case RACE -> writeScopeData(packet, scope, _playerList.entrySet().stream().filter(it -> it.getValue().getInt("race") == race.ordinal()).collect(Collectors.toList()), _snapshotList.entrySet().stream().filter(it -> it.getValue().getInt("race") == race.ordinal()).collect(Collectors.toList()));
|
||||
case CLAN -> writeScopeData(packet, scope, _player.getClan() == null ? Collections.emptyList() : _playerList.entrySet().stream().filter(it -> it.getValue().getString("clanName").equals(_player.getClan().getName())).collect(Collectors.toList()), _player.getClan() == null ? Collections.emptyList() : _snapshotList.entrySet().stream().filter(it -> it.getValue().getString("clanName").equals(_player.getClan().getName())).collect(Collectors.toList()));
|
||||
case FRIEND -> writeScopeData(packet, scope, _playerList.entrySet().stream().filter(it -> _player.getFriendList().contains(it.getValue().getInt("charId"))).collect(Collectors.toList()), _snapshotList.entrySet().stream().filter(it -> _player.getFriendList().contains(it.getValue().getInt("charId"))).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
private void writeScopeData(PacketWriter packet, RankingScope scope, List<Map.Entry<Integer, StatSet>> list, List<Map.Entry<Integer, StatSet>> snapshot)
|
||||
{
|
||||
|
||||
Map.Entry<Integer, StatSet> playerData = list.stream().filter(it -> it.getValue().getInt("charId", 0) == _player.getObjectId()).findFirst().orElse(null);
|
||||
final int indexOf = list.indexOf(playerData);
|
||||
final List<Map.Entry<Integer, StatSet>> limited = switch (scope)
|
||||
{
|
||||
case TOP_100 -> list.stream().limit(100).collect(Collectors.toList());
|
||||
case ALL -> list;
|
||||
case TOP_150 -> list.stream().limit(150).collect(Collectors.toList());
|
||||
case SELF -> playerData == null ? Collections.emptyList() : list.subList(Math.max(0, indexOf - 10), Math.min(list.size(), indexOf + 10));
|
||||
};
|
||||
|
||||
packet.writeD(limited.size());
|
||||
|
||||
int rank = 1;
|
||||
for (Map.Entry<Integer, StatSet> data : limited.stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toList()))
|
||||
{
|
||||
int curRank = rank++;
|
||||
final StatSet player = data.getValue();
|
||||
packet.writeString(player.getString("name"));
|
||||
packet.writeString(player.getString("clanName"));
|
||||
packet.writeD(player.getInt("level"));
|
||||
packet.writeD(player.getInt("classId"));
|
||||
packet.writeD(player.getInt("race"));
|
||||
packet.writeD(scope == RankingScope.SELF ? data.getKey() : curRank); // server rank
|
||||
if (snapshot.size() > 0)
|
||||
{
|
||||
int snapshotRank = 1;
|
||||
for (Map.Entry<Integer, StatSet> ssData : snapshot.stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toList()))
|
||||
{
|
||||
final StatSet snapshotData = ssData.getValue();
|
||||
if (player.getInt("charId") == snapshotData.getInt("charId"))
|
||||
{
|
||||
packet.writeD(scope == RankingScope.SELF ? ssData.getKey() : snapshotRank++); // server rank snapshot
|
||||
packet.writeD(snapshotData.getInt("raceRank", 0)); // race rank snapshot
|
||||
packet.writeD(0); // TODO: nClassRank_Snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(scope == RankingScope.SELF ? data.getKey() : curRank);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user