Addition of player ranks.
This commit is contained in:
parent
d92b0d9627
commit
2bd0acbcd5
@ -20,6 +20,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -28,6 +29,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import org.l2jmobius.gameserver.model.StatsSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.entity.Hero;
|
||||
|
||||
/**
|
||||
@ -241,6 +243,35 @@ public class RankManager
|
||||
return _snapshotOlyList;
|
||||
}
|
||||
|
||||
public int getPlayerGlobalRank(PlayerInstance player)
|
||||
{
|
||||
final int playerOid = player.getObjectId();
|
||||
for (Entry<Integer, StatsSet> entry : _mainList.entrySet())
|
||||
{
|
||||
final StatsSet stats = entry.getValue();
|
||||
if (stats.getInt("charId") != playerOid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return entry.getKey();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getPlayerRaceRank(PlayerInstance player)
|
||||
{
|
||||
final int playerOid = player.getObjectId();
|
||||
for (StatsSet stats : _mainList.values())
|
||||
{
|
||||
if (stats.getInt("charId") != playerOid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return stats.getInt("raceRank");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static RankManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@ -71,6 +71,7 @@ public class Olympiad extends ListenersContainer
|
||||
private static final String OLYMPIAD_SAVE_NOBLES = "INSERT INTO olympiad_nobles (`charId`,`class_id`,`olympiad_points`,`competitions_done`,`competitions_won`,`competitions_lost`,`competitions_drawn`, `competitions_done_week`) VALUES (?,?,?,?,?,?,?,?)";
|
||||
private static final String OLYMPIAD_UPDATE_NOBLES = "UPDATE olympiad_nobles SET olympiad_points = ?, competitions_done = ?, competitions_won = ?, competitions_lost = ?, competitions_drawn = ?, competitions_done_week = ? WHERE charId = ?";
|
||||
private static final String OLYMPIAD_GET_HEROS = "SELECT olympiad_nobles.charId, characters.char_name FROM olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId AND olympiad_nobles.class_id = ? AND olympiad_nobles.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " AND olympiad_nobles.competitions_won > 0 ORDER BY olympiad_nobles.olympiad_points DESC, olympiad_nobles.competitions_done DESC, olympiad_nobles.competitions_won DESC";
|
||||
private static final String OLYMPIAD_GET_LEGEND = "SELECT olympiad_nobles.charId FROM olympiad_nobles WHERE olympiad_nobles.competitions_done >=" + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles.olympiad_points DESC LIMIT 1";
|
||||
private static final String GET_ALL_CLASSIFIED_NOBLESS = "SELECT charId from olympiad_nobles_eom WHERE competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_points DESC, competitions_done DESC, competitions_won DESC";
|
||||
private static final String GET_EACH_CLASS_LEADER = "SELECT characters.char_name from olympiad_nobles_eom, characters WHERE characters.charId = olympiad_nobles_eom.charId AND olympiad_nobles_eom.class_id = ? AND olympiad_nobles_eom.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles_eom.olympiad_points DESC, olympiad_nobles_eom.competitions_done DESC, olympiad_nobles_eom.competitions_won DESC LIMIT 10";
|
||||
private static final String GET_EACH_CLASS_LEADER_CURRENT = "SELECT characters.char_name from olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId AND olympiad_nobles.class_id = ? AND olympiad_nobles.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles.olympiad_points DESC, olympiad_nobles.competitions_done DESC, olympiad_nobles.competitions_won DESC LIMIT 10";
|
||||
@ -982,6 +983,20 @@ public class Olympiad extends ListenersContainer
|
||||
|
||||
final List<StatsSet> heroesToBe = new LinkedList<>();
|
||||
|
||||
int legendId = 0;
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_LEGEND))
|
||||
{
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
legendId = rset.getInt("charId");
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Olympiad System: Couldnt load legend from DB");
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
|
||||
{
|
||||
@ -995,11 +1010,13 @@ public class Olympiad extends ListenersContainer
|
||||
if (rset.next())
|
||||
{
|
||||
hero = new StatsSet();
|
||||
final int charId = rset.getInt(CHAR_ID);
|
||||
hero.set(CLASS_ID, element);
|
||||
hero.set(CHAR_ID, rset.getInt(CHAR_ID));
|
||||
hero.set(CHAR_ID, charId);
|
||||
hero.set(CHAR_NAME, rset.getString(CHAR_NAME));
|
||||
hero.set("LEGEND", charId == legendId ? 1 : 0);
|
||||
|
||||
LOGGER_OLYMPIAD.info("Hero " + hero.getString(CHAR_NAME) + "," + hero.getInt(CHAR_ID) + "," + hero.getInt(CLASS_ID));
|
||||
LOGGER_OLYMPIAD.info("Hero " + hero.getString(CHAR_NAME) + "," + charId + "," + hero.getInt(CLASS_ID));
|
||||
heroesToBe.add(hero);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.Set;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DecoyInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@ -259,6 +260,11 @@ public class CharInfo implements IClientOutgoingPacket
|
||||
packet.writeC(cocPlayer != null ? cocPlayer.getPosition() : _player.isTrueHero() ? 100 : 0);
|
||||
packet.writeC(_player.isHairAccessoryEnabled() ? 0x01 : 0x00); // Hair accessory
|
||||
packet.writeC(_player.getAbilityPointsUsed()); // Used Ability Points
|
||||
|
||||
packet.writeD(0x00);
|
||||
packet.writeD(0x00);
|
||||
packet.writeC(RankManager.getInstance().getPlayerGlobalRank(_player) == 1 ? 1 : RankManager.getInstance().getPlayerRaceRank(_player) == 1 ? 2 : 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ import java.util.List;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.instancemanager.MentorManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.NpcStringId;
|
||||
@ -31,7 +33,7 @@ import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _objectId;
|
||||
private final ChatType _textType;
|
||||
private final ChatType _chatType;
|
||||
private String _charName = null;
|
||||
private int _charId = 0;
|
||||
private String _text = null;
|
||||
@ -52,7 +54,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
_objectId = sender.getObjectId();
|
||||
_charName = name;
|
||||
_charLevel = sender.getLevel();
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_text = text;
|
||||
if (receiver != null)
|
||||
{
|
||||
@ -93,7 +95,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
_objectId = sender.getObjectId();
|
||||
_charName = name;
|
||||
_charLevel = sender.getLevel();
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_text = text;
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, String charName, String text)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charName = charName;
|
||||
_text = text;
|
||||
}
|
||||
@ -114,7 +116,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(PlayerInstance player, ChatType messageType, String text)
|
||||
{
|
||||
_objectId = player.getObjectId();
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charName = player.getAppearance().getVisibleName();
|
||||
_text = text;
|
||||
}
|
||||
@ -122,7 +124,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, int charId, NpcStringId npcString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charId = charId;
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
@ -130,7 +132,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, String charName, NpcStringId npcString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charName = charName;
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
@ -138,7 +140,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, int charId, SystemMessageId sysString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charId = charId;
|
||||
_npcString = sysString.getId();
|
||||
}
|
||||
@ -162,7 +164,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
OutgoingPackets.SAY2.writeId(packet);
|
||||
|
||||
packet.writeD(_objectId);
|
||||
packet.writeD(_textType.getClientId());
|
||||
packet.writeD(_chatType.getClientId());
|
||||
if (_charName != null)
|
||||
{
|
||||
packet.writeS(_charName);
|
||||
@ -175,7 +177,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
if (_text != null)
|
||||
{
|
||||
packet.writeS(_text);
|
||||
if ((_charLevel > 0) && (_textType == ChatType.WHISPER))
|
||||
if ((_charLevel > 0) && (_chatType == ChatType.WHISPER))
|
||||
{
|
||||
packet.writeC(_mask);
|
||||
if ((_mask & 0x10) == 0)
|
||||
@ -191,6 +193,39 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
packet.writeS(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Rank
|
||||
final PlayerInstance player = World.getInstance().getPlayer(_objectId);
|
||||
if (player != null)
|
||||
{
|
||||
if (((_chatType == ChatType.CLAN) || (_chatType == ChatType.ALLIANCE)) && (player.getClan() != null))
|
||||
{
|
||||
packet.writeC(player.getClan().getCastleId());
|
||||
}
|
||||
|
||||
final int rank = RankManager.getInstance().getPlayerGlobalRank(player);
|
||||
if ((rank == 0) || (rank > 100))
|
||||
{
|
||||
packet.writeC(0);
|
||||
}
|
||||
else if (rank <= 10)
|
||||
{
|
||||
packet.writeC(1);
|
||||
}
|
||||
else if (rank <= 50)
|
||||
{
|
||||
packet.writeC(2);
|
||||
}
|
||||
else if (rank <= 100)
|
||||
{
|
||||
packet.writeC(3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeC(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -199,7 +234,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.broadcastSnoop(_textType, _charName, _text);
|
||||
player.broadcastSnoop(_chatType, _charName, _text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.enums.AttributeType;
|
||||
import org.l2jmobius.gameserver.enums.ItemGrade;
|
||||
import org.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.Party;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.base.ClassId;
|
||||
@ -409,7 +410,7 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
|
||||
if (containsMask(UserInfoType.RANKING)) // 196
|
||||
{
|
||||
packet.writeH(6);
|
||||
packet.writeD(0x00);
|
||||
packet.writeD(RankManager.getInstance().getPlayerGlobalRank(_player) == 1 ? 1 : RankManager.getInstance().getPlayerRaceRank(_player) == 1 ? 2 : 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -20,6 +20,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -28,6 +29,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import org.l2jmobius.gameserver.model.StatsSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.entity.Hero;
|
||||
|
||||
/**
|
||||
@ -241,6 +243,35 @@ public class RankManager
|
||||
return _snapshotOlyList;
|
||||
}
|
||||
|
||||
public int getPlayerGlobalRank(PlayerInstance player)
|
||||
{
|
||||
final int playerOid = player.getObjectId();
|
||||
for (Entry<Integer, StatsSet> entry : _mainList.entrySet())
|
||||
{
|
||||
final StatsSet stats = entry.getValue();
|
||||
if (stats.getInt("charId") != playerOid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return entry.getKey();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getPlayerRaceRank(PlayerInstance player)
|
||||
{
|
||||
final int playerOid = player.getObjectId();
|
||||
for (StatsSet stats : _mainList.values())
|
||||
{
|
||||
if (stats.getInt("charId") != playerOid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return stats.getInt("raceRank");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static RankManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@ -73,6 +73,7 @@ public class Olympiad extends ListenersContainer
|
||||
private static final String OLYMPIAD_SAVE_NOBLES = "INSERT INTO olympiad_nobles (`charId`,`class_id`,`olympiad_points`,`competitions_done`,`competitions_won`,`competitions_lost`,`competitions_drawn`, `competitions_done_week`) VALUES (?,?,?,?,?,?,?,?)";
|
||||
private static final String OLYMPIAD_UPDATE_NOBLES = "UPDATE olympiad_nobles SET olympiad_points = ?, competitions_done = ?, competitions_won = ?, competitions_lost = ?, competitions_drawn = ?, competitions_done_week = ? WHERE charId = ?";
|
||||
private static final String OLYMPIAD_GET_HEROS = "SELECT olympiad_nobles.charId, characters.char_name FROM olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId AND olympiad_nobles.class_id in (?, ?) AND olympiad_nobles.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " AND olympiad_nobles.competitions_won > 0 ORDER BY olympiad_nobles.olympiad_points DESC, olympiad_nobles.competitions_done DESC, olympiad_nobles.competitions_won DESC";
|
||||
private static final String OLYMPIAD_GET_LEGEND = "SELECT olympiad_nobles.charId FROM olympiad_nobles WHERE olympiad_nobles.competitions_done >=" + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles.olympiad_points DESC LIMIT 1";
|
||||
private static final String GET_ALL_CLASSIFIED_NOBLESS = "SELECT charId from olympiad_nobles_eom WHERE competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_points DESC, competitions_done DESC, competitions_won DESC";
|
||||
private static final String GET_EACH_CLASS_LEADER = "SELECT characters.char_name from olympiad_nobles_eom, characters WHERE characters.charId = olympiad_nobles_eom.charId AND olympiad_nobles_eom.class_id = ? AND olympiad_nobles_eom.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles_eom.olympiad_points DESC, olympiad_nobles_eom.competitions_done DESC, olympiad_nobles_eom.competitions_won DESC LIMIT 10";
|
||||
private static final String GET_EACH_CLASS_LEADER_CURRENT = "SELECT characters.char_name from olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId AND olympiad_nobles.class_id = ? AND olympiad_nobles.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles.olympiad_points DESC, olympiad_nobles.competitions_done DESC, olympiad_nobles.competitions_won DESC LIMIT 10";
|
||||
@ -981,6 +982,20 @@ public class Olympiad extends ListenersContainer
|
||||
|
||||
final List<StatsSet> heroesToBe = new LinkedList<>();
|
||||
|
||||
int legendId = 0;
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_LEGEND))
|
||||
{
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
legendId = rset.getInt("charId");
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Olympiad System: Couldnt load legend from DB");
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
|
||||
{
|
||||
@ -997,11 +1012,13 @@ public class Olympiad extends ListenersContainer
|
||||
if (rset.next())
|
||||
{
|
||||
hero = new StatsSet();
|
||||
final int charId = rset.getInt(CHAR_ID);
|
||||
hero.set(CLASS_ID, element); // save the 3rd class title
|
||||
hero.set(CHAR_ID, rset.getInt(CHAR_ID));
|
||||
hero.set(CHAR_ID, charId);
|
||||
hero.set(CHAR_NAME, rset.getString(CHAR_NAME));
|
||||
hero.set("LEGEND", charId == legendId ? 1 : 0);
|
||||
|
||||
LOGGER_OLYMPIAD.info("Hero " + hero.getString(CHAR_NAME) + "," + hero.getInt(CHAR_ID) + "," + hero.getInt(CLASS_ID));
|
||||
LOGGER_OLYMPIAD.info("Hero " + hero.getString(CHAR_NAME) + "," + charId + "," + hero.getInt(CLASS_ID));
|
||||
heroesToBe.add(hero);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.Set;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.DecoyInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@ -259,6 +260,11 @@ public class CharInfo implements IClientOutgoingPacket
|
||||
packet.writeC(cocPlayer != null ? cocPlayer.getPosition() : _player.isTrueHero() ? 100 : 0);
|
||||
packet.writeC(_player.isHairAccessoryEnabled() ? 0x01 : 0x00); // Hair accessory
|
||||
packet.writeC(_player.getAbilityPointsUsed()); // Used Ability Points
|
||||
|
||||
packet.writeD(0x00);
|
||||
packet.writeD(0x00);
|
||||
packet.writeC(RankManager.getInstance().getPlayerGlobalRank(_player) == 1 ? 1 : RankManager.getInstance().getPlayerRaceRank(_player) == 1 ? 2 : 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ import java.util.List;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.instancemanager.MentorManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.NpcStringId;
|
||||
@ -31,7 +33,7 @@ import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _objectId;
|
||||
private final ChatType _textType;
|
||||
private final ChatType _chatType;
|
||||
private String _charName = null;
|
||||
private int _charId = 0;
|
||||
private String _text = null;
|
||||
@ -52,7 +54,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
_objectId = sender.getObjectId();
|
||||
_charName = name;
|
||||
_charLevel = sender.getLevel();
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_text = text;
|
||||
if (receiver != null)
|
||||
{
|
||||
@ -93,7 +95,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
_objectId = sender.getObjectId();
|
||||
_charName = name;
|
||||
_charLevel = sender.getLevel();
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_text = text;
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, String charName, String text)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charName = charName;
|
||||
_text = text;
|
||||
}
|
||||
@ -114,7 +116,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(PlayerInstance player, ChatType messageType, String text)
|
||||
{
|
||||
_objectId = player.getObjectId();
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charName = player.getAppearance().getVisibleName();
|
||||
_text = text;
|
||||
}
|
||||
@ -122,7 +124,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, int charId, NpcStringId npcString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charId = charId;
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
@ -130,7 +132,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, String charName, NpcStringId npcString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charName = charName;
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
@ -138,7 +140,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
public CreatureSay(int objectId, ChatType messageType, int charId, SystemMessageId sysString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_chatType = messageType;
|
||||
_charId = charId;
|
||||
_npcString = sysString.getId();
|
||||
}
|
||||
@ -162,7 +164,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
OutgoingPackets.SAY2.writeId(packet);
|
||||
|
||||
packet.writeD(_objectId);
|
||||
packet.writeD(_textType.getClientId());
|
||||
packet.writeD(_chatType.getClientId());
|
||||
if (_charName != null)
|
||||
{
|
||||
packet.writeS(_charName);
|
||||
@ -175,7 +177,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
if (_text != null)
|
||||
{
|
||||
packet.writeS(_text);
|
||||
if ((_charLevel > 0) && (_textType == ChatType.WHISPER))
|
||||
if ((_charLevel > 0) && (_chatType == ChatType.WHISPER))
|
||||
{
|
||||
packet.writeC(_mask);
|
||||
if ((_mask & 0x10) == 0)
|
||||
@ -191,6 +193,39 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
packet.writeS(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Rank
|
||||
final PlayerInstance player = World.getInstance().getPlayer(_objectId);
|
||||
if (player != null)
|
||||
{
|
||||
if (((_chatType == ChatType.CLAN) || (_chatType == ChatType.ALLIANCE)) && (player.getClan() != null))
|
||||
{
|
||||
packet.writeC(player.getClan().getCastleId());
|
||||
}
|
||||
|
||||
final int rank = RankManager.getInstance().getPlayerGlobalRank(player);
|
||||
if ((rank == 0) || (rank > 100))
|
||||
{
|
||||
packet.writeC(0);
|
||||
}
|
||||
else if (rank <= 10)
|
||||
{
|
||||
packet.writeC(1);
|
||||
}
|
||||
else if (rank <= 50)
|
||||
{
|
||||
packet.writeC(2);
|
||||
}
|
||||
else if (rank <= 100)
|
||||
{
|
||||
packet.writeC(3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeC(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -199,7 +234,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.broadcastSnoop(_textType, _charName, _text);
|
||||
player.broadcastSnoop(_chatType, _charName, _text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import org.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.RankManager;
|
||||
import org.l2jmobius.gameserver.model.Party;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.base.ClassId;
|
||||
@ -422,7 +423,7 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
|
||||
if (containsMask(UserInfoType.RANKING)) // 196
|
||||
{
|
||||
packet.writeH(6);
|
||||
packet.writeD(0x00);
|
||||
packet.writeD(RankManager.getInstance().getPlayerGlobalRank(_player) == 1 ? 1 : RankManager.getInstance().getPlayerRaceRank(_player) == 1 ? 2 : 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user