Commit 9fc8cc1c authored by Kengxxiao's avatar Kengxxiao Committed by GitHub
Browse files

Merge pull request #1 from Grasscutters/development

merge
parents 627a2f1e d1fc8c1f
......@@ -5,32 +5,33 @@ import java.time.OffsetDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.CommandMap;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.World;
import emu.grasscutter.game.dungeons.DungeonManager;
import emu.grasscutter.game.gacha.GachaManager;
import emu.grasscutter.game.managers.ChatManager;
import emu.grasscutter.game.managers.InventoryManager;
import emu.grasscutter.game.managers.MultiplayerManager;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.shop.ShopManager;
import emu.grasscutter.game.world.World;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
import emu.grasscutter.netty.MihoyoKcpServer;
import emu.grasscutter.netty.KcpServer;
import emu.grasscutter.server.event.ServerEvent;
import emu.grasscutter.server.event.game.ServerTickEvent;
import emu.grasscutter.server.event.internal.ServerStartEvent;
import emu.grasscutter.server.event.internal.ServerStopEvent;
import emu.grasscutter.task.TaskMap;
public final class GameServer extends MihoyoKcpServer {
public final class GameServer extends KcpServer {
private final InetSocketAddress address;
private final GameServerPacketHandler packetHandler;
private final Map<Integer, GenshinPlayer> players;
private final Map<Integer, Player> players;
private final Set<World> worlds;
private final ChatManager chatManager;
......@@ -40,6 +41,7 @@ public final class GameServer extends MihoyoKcpServer {
private final MultiplayerManager multiplayerManager;
private final DungeonManager dungeonManager;
private final CommandMap commandMap;
private final TaskMap taskMap;
public GameServer(InetSocketAddress address) {
super(address);
......@@ -57,6 +59,7 @@ public final class GameServer extends MihoyoKcpServer {
this.multiplayerManager = new MultiplayerManager(this);
this.dungeonManager = new DungeonManager(this);
this.commandMap = new CommandMap(true);
this.taskMap = new TaskMap(true);
// Schedule game loop.
Timer gameLoop = new Timer();
......@@ -79,7 +82,7 @@ public final class GameServer extends MihoyoKcpServer {
return packetHandler;
}
public Map<Integer, GenshinPlayer> getPlayers() {
public Map<Integer, Player> getPlayers() {
return players;
}
......@@ -114,23 +117,27 @@ public final class GameServer extends MihoyoKcpServer {
public CommandMap getCommandMap() {
return this.commandMap;
}
public TaskMap getTaskMap() {
return this.taskMap;
}
public void registerPlayer(GenshinPlayer player) {
public void registerPlayer(Player player) {
getPlayers().put(player.getUid(), player);
}
public GenshinPlayer getPlayerByUid(int id) {
public Player getPlayerByUid(int id) {
return this.getPlayerByUid(id, false);
}
public GenshinPlayer getPlayerByUid(int id, boolean allowOfflinePlayers) {
public Player getPlayerByUid(int id, boolean allowOfflinePlayers) {
// Console check
if (id == GenshinConstants.SERVER_CONSOLE_UID) {
if (id == GameConstants.SERVER_CONSOLE_UID) {
return null;
}
// Get from online players
GenshinPlayer player = this.getPlayers().get(id);
Player player = this.getPlayers().get(id);
if (!allowOfflinePlayers) {
return player;
......@@ -146,7 +153,7 @@ public final class GameServer extends MihoyoKcpServer {
public SocialDetail.Builder getSocialDetailByUid(int id) {
// Get from online players
GenshinPlayer player = this.getPlayerByUid(id, true);
Player player = this.getPlayerByUid(id, true);
if (player == null) {
return null;
......@@ -156,7 +163,7 @@ public final class GameServer extends MihoyoKcpServer {
}
public Account getAccountByName(String username) {
Optional<GenshinPlayer> playerOpt = getPlayers().values().stream().filter(player -> player.getAccount().getUsername().equals(username)).findFirst();
Optional<Player> playerOpt = getPlayers().values().stream().filter(player -> player.getAccount().getUsername().equals(username)).findFirst();
if (playerOpt.isPresent()) {
return playerOpt.get().getAccount();
}
......@@ -197,10 +204,10 @@ public final class GameServer extends MihoyoKcpServer {
ServerStopEvent event = new ServerStopEvent(ServerEvent.Type.GAME, OffsetDateTime.now()); event.call();
// Kick and save all players
List<GenshinPlayer> list = new ArrayList<>(this.getPlayers().size());
List<Player> list = new ArrayList<>(this.getPlayers().size());
list.addAll(this.getPlayers().values());
for (GenshinPlayer player : list) {
for (Player player : list) {
player.getSession().close();
}
}
......
package emu.grasscutter.server.game;
import emu.grasscutter.netty.MihoyoKcpServerInitializer;
import emu.grasscutter.netty.KcpServerInitializer;
import io.jpower.kcp.netty.UkcpChannel;
import io.netty.channel.ChannelPipeline;
public class GameServerInitializer extends MihoyoKcpServerInitializer {
public class GameServerInitializer extends KcpServerInitializer {
private GameServer server;
public GameServerInitializer(GameServer server) {
......
......@@ -89,7 +89,7 @@ public class GameServerPacketHandler {
// Log unhandled packets
if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) {
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode));
Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + emu.grasscutter.net.packet.PacketOpcodesUtil.getOpcodeName(opcode));
}
}
}
......@@ -3,13 +3,16 @@ package emu.grasscutter.server.game;
import java.io.File;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.Set;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketOpcodesUtil;
import emu.grasscutter.netty.MihoyoKcpChannel;
import emu.grasscutter.netty.KcpChannel;
import emu.grasscutter.server.event.game.SendPacketEvent;
import emu.grasscutter.utils.Crypto;
import emu.grasscutter.utils.FileUtils;
......@@ -18,11 +21,11 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
public class GameSession extends MihoyoKcpChannel {
public class GameSession extends KcpChannel {
private GameServer server;
private Account account;
private GenshinPlayer player;
private Player player;
private boolean useSecretKey;
private SessionState state;
......@@ -64,11 +67,11 @@ public class GameSession extends MihoyoKcpChannel {
return this.getAccount().getId();
}
public GenshinPlayer getPlayer() {
public Player getPlayer() {
return player;
}
public synchronized void setPlayer(GenshinPlayer player) {
public synchronized void setPlayer(Player player) {
this.player = player;
this.player.setSession(this);
this.player.setAccount(this.getAccount());
......@@ -141,46 +144,48 @@ public class GameSession extends MihoyoKcpChannel {
byte[] packet = FileUtils.read(p);
GenshinPacket genshinPacket = new GenshinPacket(opcode);
genshinPacket.setData(packet);
BasePacket basePacket = new BasePacket(opcode);
basePacket.setData(packet);
// Log
logPacket(genshinPacket.getOpcode());
send(genshinPacket);
send(basePacket);
}
public void send(GenshinPacket genshinPacket) {
public void send(BasePacket packet) {
// Test
if (genshinPacket.getOpcode() <= 0) {
if (packet.getOpcode() <= 0) {
Grasscutter.getLogger().warn("Tried to send packet with missing cmd id!");
return;
}
// Header
if (genshinPacket.shouldBuildHeader()) {
genshinPacket.buildHeader(this.getNextClientSequence());
if (packet.shouldBuildHeader()) {
packet.buildHeader(this.getNextClientSequence());
}
// Log
if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) {
logPacket(genshinPacket);
logPacket(packet);
}
// Invoke event.
SendPacketEvent event = new SendPacketEvent(this, genshinPacket); event.call();
SendPacketEvent event = new SendPacketEvent(this, packet); event.call();
if(!event.isCanceled()) // If event is not cancelled, continue.
this.send(event.getPacket().build());
}
private void logPacket(int opcode) {
//Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(opcode));
//System.out.println(Utils.bytesToHex(genshinPacket.getData()));
}
private void logPacket(GenshinPacket genshinPacket) {
Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(genshinPacket.getOpcode()) + " (" + genshinPacket.getOpcode() + ")");
System.out.println(Utils.bytesToHex(genshinPacket.getData()));
private static final Set<Integer> loopPacket = Set.of(
PacketOpcodes.PingReq,
PacketOpcodes.PingRsp,
PacketOpcodes.WorldPlayerRTTNotify,
PacketOpcodes.UnionCmdNotify,
PacketOpcodes.QueryPathReq
);
private void logPacket(BasePacket packet) {
if (!loopPacket.contains(packet.getOpcode())) {
Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(packet.getOpcode()) + " (" + packet.getOpcode() + ")");
System.out.println(Utils.bytesToHex(packet.getData()));
}
}
@Override
......@@ -226,8 +231,10 @@ public class GameSession extends MihoyoKcpChannel {
// Log packet
if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) {
Grasscutter.getLogger().info("RECV: " + PacketOpcodesUtil.getOpcodeName(opcode) + " (" + opcode + ")");
System.out.println(Utils.bytesToHex(payload));
if (!loopPacket.contains(opcode)) {
Grasscutter.getLogger().info("RECV: " + PacketOpcodesUtil.getOpcodeName(opcode) + " (" + opcode + ")");
System.out.println(Utils.bytesToHex(payload));
}
}
// Handle
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.RewardData;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
......@@ -27,14 +27,14 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
} else {
long avatarGuid = req.getAvatarGuid();
GenshinAvatar avatar = session
Avatar avatar = session
.getPlayer()
.getAvatars()
.getAvatarByGuid(avatarGuid);
int rewardId = avatar.getNameCardRewardId();
RewardData card = GenshinData.getRewardDataMap().get(rewardId);
RewardData card = GameData.getRewardDataMap().get(rewardId);
int cardId = card.getRewardItemList().get(0).getItemId();
if (session.getPlayer().getNameCardList().contains(cardId)) {
......@@ -43,9 +43,8 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler {
return;
}
GenshinItem item = new GenshinItem(cardId);
session.getPlayer().getInventory().addItem(item);
session.getPlayer().sendPacket(new PacketItemAddHintNotify(item, ActionReason.FetterLevelReward));
GameItem item = new GameItem(cardId);
session.getPlayer().getInventory().addItem(item, ActionReason.FetterLevelReward);
session.getPlayer().sendPacket(new PacketUnlockNameCardNotify(cardId));
session.send(new PacketAvatarFetterDataNotify(avatar));
session.send(new PacketAvatarDataNotify(avatar.getPlayer()));
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ChangeMailStarNotifyOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
import java.util.ArrayList;
import java.util.List;
@Opcodes(PacketOpcodes.ChangeMailStarNotify)
public class HandlerChangeMailStarNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
ChangeMailStarNotifyOuterClass.ChangeMailStarNotify req = ChangeMailStarNotifyOuterClass.ChangeMailStarNotify.parseFrom(payload);
List<Mail> updatedMail = new ArrayList<>();
for (int mailId : req.getMailIdListList()) {
Mail message = session.getPlayer().getMail(mailId);
message.importance = req.getIsStar() == true ? 1 : 0;
session.getPlayer().replaceMailByIndex(mailId, message);
updatedMail.add(message);
}
session.send(new PacketMailChangeNotify(session.getPlayer(), updatedMail));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.entity.GenshinEntity;
import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.CombatInvocationsNotifyOuterClass.CombatInvocationsNotify;
......@@ -19,15 +19,15 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
for (CombatInvokeEntry entry : notif.getInvokeListList()) {
switch (entry.getArgumentType()) {
case CombatEvtBeingHit:
case COMBAT_EVT_BEING_HIT:
// Handle damage
EvtBeingHitInfo hitInfo = EvtBeingHitInfo.parseFrom(entry.getCombatData());
session.getPlayer().getScene().handleAttack(hitInfo.getAttackResult());
break;
case EntityMove:
case ENTITY_MOVE:
// Handle movement
EntityMoveInfo moveInfo = EntityMoveInfo.parseFrom(entry.getCombatData());
GenshinEntity entity = session.getPlayer().getScene().getEntityById(moveInfo.getEntityId());
GameEntity entity = session.getPlayer().getScene().getEntityById(moveInfo.getEntityId());
if (entity != null) {
entity.getPosition().set(moveInfo.getMotionInfo().getPos());
entity.getRotation().set(moveInfo.getMotionInfo().getRot());
......
......@@ -3,22 +3,18 @@ package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SitReqOuterClass;
import emu.grasscutter.net.proto.CombineReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketSitRsp;
import emu.grasscutter.utils.Position;
@Opcodes(PacketOpcodes.SitReq)
public class HandleSitReq extends PacketHandler {
@Opcodes(PacketOpcodes.CombineReq)
public class HandlerCombineReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
SitReqOuterClass.SitReq req = SitReqOuterClass.SitReq.parseFrom(payload);
float x = req.getPosition().getX();
float y = req.getPosition().getY();
float z = req.getPosition().getZ();
CombineReqOuterClass.CombineReq req = CombineReqOuterClass.CombineReq.parseFrom(payload);
session.send(new PacketSitRsp(req.getChairId(), new Position(x, y, z), session.getPlayer().getTeamManager().getCurrentAvatarEntity().getId()));
}
}
\ No newline at end of file
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.DelMailReqOuterClass;
import emu.grasscutter.net.proto.DeleteFriendReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketDelMailRsp;
@Opcodes(PacketOpcodes.DelMailReq)
public class HandlerDelMailReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
DelMailReqOuterClass.DelMailReq req = DelMailReqOuterClass.DelMailReq.parseFrom(payload);
session.send(new PacketDelMailRsp(session.getPlayer(), req.getMailIdListList()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.GenshinPlayer.SceneLoadState;
import emu.grasscutter.game.player.Player.SceneLoadState;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
......
......@@ -8,7 +8,7 @@ import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketEvtAvatarSitDownNotify;
@Opcodes(PacketOpcodes.EvtAvatarSitDownNotify)
public class HandleEvtAvatarSitDownNotify extends PacketHandler {
public class HandlerEvtAvatarSitDownNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.GetAllMailReqOuterClass;
import emu.grasscutter.net.proto.GetPlayerTokenReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketGetAllMailRsp;
import emu.grasscutter.server.packet.send.PacketGetGachaInfoRsp;
@Opcodes(PacketOpcodes.GetAllMailReq)
public class HandlerGetAllMailReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
GetAllMailReqOuterClass.GetAllMailReq req = GetAllMailReqOuterClass.GetAllMailReq.parseFrom(payload);
session.send(new PacketGetAllMailRsp(session.getPlayer(), req.getIsGiftMail()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetMailItemReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketGetMailItemRsp;
@Opcodes(PacketOpcodes.GetMailItemReq)
public class HandlerGetMailItemReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
GetMailItemReqOuterClass.GetMailItemReq req = GetMailItemReqOuterClass.GetMailItemReq.parseFrom(payload);
session.send(new PacketGetMailItemRsp(session.getPlayer(), req.getMailIdListList()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
......@@ -11,7 +11,7 @@ public class HandlerGetPlayerBlacklistReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.send(new GenshinPacket(PacketOpcodes.GetPlayerBlacklistRsp).buildHeader(3));
session.send(new BasePacket(PacketOpcodes.GetPlayerBlacklistRsp).buildHeader(3));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.World;
import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.game.world.World;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
......@@ -32,7 +32,7 @@ public class HandlerMarkMapReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
MarkMapReq req = MarkMapReq.parseFrom(payload);
if (req.getOp() != Operation.Add) {
if (req.getOp() != MarkMapReq.Operation.ADD) {
return;
}
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.NpcTalkReqOuterClass.NpcTalkReq;
......
......@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketPlayerGetForceQuitBanInfoRsp;
......@@ -14,10 +15,10 @@ public class HandlerPlayerGetForceQuitBanInfoReq extends PacketHandler {
if (session.getServer().getMultiplayerManager().leaveCoop(session.getPlayer())) {
// Success
session.send(new PacketPlayerGetForceQuitBanInfoRsp(0));
session.send(new PacketPlayerGetForceQuitBanInfoRsp(RetcodeOuterClass.Retcode.RET_SUCC_VALUE));
} else {
// Fail
session.send(new PacketPlayerGetForceQuitBanInfoRsp(1));
session.send(new PacketPlayerGetForceQuitBanInfoRsp(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE));
}
}
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerLoginReqOuterClass.PlayerLoginReq;
......@@ -30,12 +30,12 @@ public class HandlerPlayerLoginReq extends PacketHandler {
}
// Load character from db
GenshinPlayer player = DatabaseHelper.getPlayerById(session.getAccount().getPlayerUid());
Player player = DatabaseHelper.getPlayerById(session.getAccount().getPlayerUid());
if (player == null) {
// Send packets
session.setState(SessionState.PICKING_CHARACTER);
session.send(new GenshinPacket(PacketOpcodes.DoSetPlayerBornDataNotify));
session.send(new BasePacket(PacketOpcodes.DoSetPlayerBornDataNotify));
} else {
// Set character
session.setPlayer(player);
......
......@@ -19,8 +19,6 @@ public class HandlerPrivateChatReq extends PacketHandler {
} else if (content == PrivateChatReq.ContentCase.ICON) {
session.getServer().getChatManager().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getIcon());
}
//session.send(new GenshinPacket(PacketOpcodes.PrivateChatRsp)); // Unused by server
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetAllMailReqOuterClass;
import emu.grasscutter.net.proto.ReadMailNotifyOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
import java.util.ArrayList;
import java.util.List;
@Opcodes(PacketOpcodes.ReadMailNotify)
public class HandlerReadMailNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
ReadMailNotifyOuterClass.ReadMailNotify req = ReadMailNotifyOuterClass.ReadMailNotify.parseFrom(payload);
List<Mail> updatedMail = new ArrayList<>();
for (int mailId : req.getMailIdListList()) {
Mail message = session.getPlayer().getMail(mailId);
message.isRead = true;
session.getPlayer().replaceMailByIndex(mailId, message);
updatedMail.add(message);
}
session.send(new PacketMailChangeNotify(session.getPlayer(), updatedMail));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment