public class RequestExChangeName extends L2GameClientPacket
{
+ private int _unk1, _unk2;
+ private String _name;
@Override
protected void readImpl()
{
+ _unk1 = readD(); // всегда приходит 1
+ _name = readS(); // новое имя, введенное в диалоге
+ _unk2 = readD(); // всегда приходит 0
}
@Override
protected void runImpl()
{
+ GameClient client = getClient();
+ Player activeChar = client.getActiveChar();
+
+ if(activeChar == null)
+ return;
+
+ if(_name == null || _name.isEmpty())
+ {
+ activeChar.sendPacket(new ExNeedToChangeName(1, 1, ""));
+ return;
+ }
+ else if(!Util.isMatchingRegexp(_name, Config.CNAME_TEMPLATE))
+ {
+ activeChar.sendPacket(new ExNeedToChangeName(1, 1, ""));
+ return;
+ }
+ else if(CharacterDAO.getInstance().getObjectIdByName(_name) > 0)
+ {
+ activeChar.sendPacket(new ExNeedToChangeName(1, 1, ""));
+ return;
+ }
+
+ activeChar.setName(_name);
+ activeChar.saveNameToDB();
+ activeChar.setRenameOnEnter(false, true);
+
+ sendPacket(new CharacterSelectedPacket(activeChar, client.getSessionKey().playOkID1));
}
}