mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-13 13:24:34 +01:00
feat: add in game command handler
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using KianaBH.GameServer.Command;
|
||||
using KianaBH.GameServer.Server.Packet.Send.Chat;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Recv.Chat;
|
||||
|
||||
[Opcode(CmdIds.SendChatMsgNotify)]
|
||||
public class HandlerSendChatMsgNotify : Handler
|
||||
{
|
||||
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
||||
{
|
||||
var req = SendChatMsgNotify.Parser.ParseFrom(data);
|
||||
var player = connection.Player!;
|
||||
if (player == null) return;
|
||||
|
||||
string msg = req.ChatMsg.Content.Items.Where(item => item.MsgStr != null).FirstOrDefault()?.MsgStr!;
|
||||
if (msg == null) return;
|
||||
|
||||
await player.WorldChatManager!.SendMessage(msg,req.ChatMsg);
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ public class HandlerSetWarshipAvatarReq : Handler
|
||||
var player = connection.Player!;
|
||||
var req = SetWarshipAvatarReq.Parser.ParseFrom(data);
|
||||
|
||||
player.Data.WarshipAvatar.FirstAvatarId = req.FirstAvatarId;
|
||||
player.Data.WarshipAvatar.SecondAvatarId = req.SecondAvatarId;
|
||||
player.Data.WarshipAvatar.FirstAvatarId = (int)req.FirstAvatarId;
|
||||
player.Data.WarshipAvatar.SecondAvatarId = (int)req.SecondAvatarId;
|
||||
|
||||
await connection.SendPacket(new PacketGetMainDataRsp(req.FirstAvatarId,req.SecondAvatarId));
|
||||
await connection.SendPacket(CmdIds.SetWarshipAvatarRsp);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using KianaBH.KcpSharp;
|
||||
using KianaBH.Proto;
|
||||
using KianaBH.Util;
|
||||
using KianaBH.Util.Extensions;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Send.Chat;
|
||||
|
||||
public class PacketRecvChatMsgNotify : BasePacket
|
||||
{
|
||||
public PacketRecvChatMsgNotify(ChatMsg msgs) : base(CmdIds.RecvChatMsgNotify)
|
||||
{
|
||||
var proto = new RecvChatMsgNotify
|
||||
{
|
||||
ChatMsgList = { msgs }
|
||||
};
|
||||
|
||||
SetData(proto);
|
||||
}
|
||||
|
||||
public PacketRecvChatMsgNotify(string message) : base(CmdIds.RecvChatMsgNotify)
|
||||
{
|
||||
var proto = new RecvChatMsgNotify
|
||||
{
|
||||
ChatMsgList =
|
||||
{
|
||||
new ChatMsg
|
||||
{
|
||||
Uid = (uint)ConfigManager.Config.ServerOption.ServerProfile.Uid,
|
||||
Nickname = ConfigManager.Config.ServerOption.ServerProfile.Name,
|
||||
Time = (uint)Extensions.GetUnixSec(),
|
||||
Msg = message,
|
||||
Channel = ChatMsg.Types.MsgChannel.World,
|
||||
AvatarId = (uint)ConfigManager.Config.ServerOption.ServerProfile.AvatarId,
|
||||
DressId = (uint)ConfigManager.Config.ServerOption.ServerProfile.DressId,
|
||||
FrameId = (uint)ConfigManager.Config.ServerOption.ServerProfile.FrameId,
|
||||
CustomHeadId = (uint)ConfigManager.Config.ServerOption.ServerProfile.HeadId,
|
||||
CheckResult = new ChatMsgSensitiveCheckResult
|
||||
{
|
||||
RewriteText = message
|
||||
},
|
||||
Content = new ChatMsgContent
|
||||
{
|
||||
Items =
|
||||
{
|
||||
new ChatMsgItem
|
||||
{
|
||||
MsgStr = message,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
SetData(proto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user