mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-13 01:34:35 +01:00
unstable whisper, now you can dm your friend(if you have any lol)
This commit is contained in:
49
GameServer/Game/Chatrooms/PrivateChatManager.cs
Normal file
49
GameServer/Game/Chatrooms/PrivateChatManager.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Common.Database;
|
||||
using Common;
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Game.Chatrooms
|
||||
{
|
||||
public static class PrivateChatManager
|
||||
{
|
||||
public static void OnSendChatMsg(Session session, SendChatMsgNotify chatMsgNotify)
|
||||
{
|
||||
ChatMsg chatMsg = chatMsgNotify.ChatMsg;
|
||||
string? StringMsg = chatMsg.Content.Items.Where(item => item.MsgStr != null).FirstOrDefault()?.MsgStr;
|
||||
if (StringMsg != null)
|
||||
{
|
||||
chatMsg.CheckResult = new()
|
||||
{
|
||||
ShieldType = 0,
|
||||
NumberCheck = 0,
|
||||
RewriteText = StringMsg
|
||||
};
|
||||
chatMsg.Msg = StringMsg;
|
||||
}
|
||||
UserScheme User = session.Player.User;
|
||||
chatMsg.Uid = User.Uid;
|
||||
chatMsg.Nickname = User.Nick;
|
||||
chatMsg.Time = (uint)Global.GetUnixInSeconds();
|
||||
chatMsg.AvatarId = (uint)User.AssistantAvatarId;
|
||||
chatMsg.DressId = session.Player.AvatarList.Where(avatar => avatar.AvatarId == User.AssistantAvatarId).First().DressId;
|
||||
chatMsg.FrameId = User.FrameId < 200001 ? 200001 : (uint)User.FrameId;
|
||||
chatMsg.CustomHeadId = (uint)User.CustomHeadId;
|
||||
|
||||
foreach (uint targetUid in chatMsgNotify.TargetUidLists)
|
||||
{
|
||||
SendPrivateMessage(session, targetUid, chatMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendPrivateMessage(Session session, uint targetUid, ChatMsg chatMsg)
|
||||
{
|
||||
PrivateMessageScheme privateMessage = PrivateMessage.Create(session.Player.User.Uid, targetUid, chatMsg);
|
||||
Session? targetSession = Session.FromUid(targetUid);
|
||||
RecvChatMsgNotify notify = new() { };
|
||||
notify.ChatMsgLists.Add(privateMessage.Msg);
|
||||
|
||||
session.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
|
||||
targetSession?.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Common.Database;
|
||||
using Common.Resources.Proto;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers.Chat
|
||||
{
|
||||
[PacketCmdId(CmdId.GetPrivateHistoryChatMsgReq)]
|
||||
internal class GetPrivateHistoryChatMsgReqHandler : IPacketHandler
|
||||
{
|
||||
public void Handle(Session session, Packet packet)
|
||||
{
|
||||
GetPrivateHistoryChatMsgReq Data = packet.GetDecodedBody<GetPrivateHistoryChatMsgReq>();
|
||||
GetPrivateHistoryChatMsgRsp Rsp = new() { retcode = GetPrivateHistoryChatMsgRsp.Retcode.Succ };
|
||||
|
||||
if (Data.UidLists.Length > 0)
|
||||
{
|
||||
foreach (uint targetUid in Data.UidLists)
|
||||
{
|
||||
Rsp.ChatLists.AddRange(PrivateMessage.GetMessages(session.Player.User.Uid, targetUid));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rsp.ChatLists.AddRange(PrivateMessage.GetMessages(session.Player.User.Uid));
|
||||
}
|
||||
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.GetPrivateHistoryChatMsgRsp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Common.Resources.Proto;
|
||||
using Common.Database;
|
||||
using Common.Resources.Proto;
|
||||
using PemukulPaku.GameServer.Game.Chatrooms;
|
||||
|
||||
namespace PemukulPaku.GameServer.Handlers
|
||||
@@ -11,6 +12,8 @@ namespace PemukulPaku.GameServer.Handlers
|
||||
SendChatMsgNotify Data = packet.GetDecodedBody<SendChatMsgNotify>();
|
||||
if (Data.ChatMsg.Channel == ChatMsg.MsgChannel.World)
|
||||
WorldChatroom.GetInstance().GetChatroom(session).OnSendChat(session, Data.ChatMsg);
|
||||
else if (Data.ChatMsg.Channel == ChatMsg.MsgChannel.Private)
|
||||
PrivateChatManager.OnSendChatMsg(session, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace PemukulPaku.GameServer.Handlers
|
||||
}
|
||||
}
|
||||
}
|
||||
stigmata.WaitSelectRuneGroupLists.Clear();
|
||||
stigmata.WaitSelectRuneGroupLists?.Clear();
|
||||
}
|
||||
session.Player.Equipment.Save();
|
||||
session.Send(Packet.FromProto(Rsp, CmdId.SelectNewStigmataRuneRsp));
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace PemukulPaku.GameServer.Handlers.Two
|
||||
|
||||
if(user is not null)
|
||||
{
|
||||
Player player = new(user);
|
||||
Player? player = Session.FromUid(user.Uid)?.Player;
|
||||
player ??= new(user);
|
||||
|
||||
Rsp.CardData = new()
|
||||
{
|
||||
Uid = player.User.Uid,
|
||||
|
||||
@@ -154,5 +154,10 @@ namespace PemukulPaku.GameServer
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
public static Session? FromUid(uint uid)
|
||||
{
|
||||
return Server.GetInstance().Sessions.FirstOrDefault(s => s.Value.Player.User.Uid == uid).Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user