diff --git a/Command/Command/Cmd/CommandMail.cs b/Command/Command/Cmd/CommandMail.cs index 952ae889..dfa3335c 100644 --- a/Command/Command/Cmd/CommandMail.cs +++ b/Command/Command/Cmd/CommandMail.cs @@ -14,17 +14,55 @@ public class CommandMail : ICommand return; } - if (arg.Args.Count < 5) + if (arg.Args.Count < 7) + { + await arg.SendMsg(I18nManager.Translate("Game.Command.Notice.InvalidArguments")); + return; + } + + if (!(arg.Args.Contains("_TITLE") && arg.Args.Contains("_CONTENT"))) { await arg.SendMsg(I18nManager.Translate("Game.Command.Notice.InvalidArguments")); return; } var sender = arg.Args[0]; - var title = arg.Args[1]; - var content = arg.Args[2]; - var templateId = int.Parse(arg.Args[3]); - var expiredDay = int.Parse(arg.Args[4]); + var templateId = int.Parse(arg.Args[1]); + var expiredDay = int.Parse(arg.Args[2]); + + var title = ""; + var content = ""; + + var flagTitle = false; + var flagContent = false; + foreach (var text in arg.Args) + { + if (text == "_TITLE") + { + flagTitle = true; + continue; + } + + if (text == "_CONTENT") + { + flagContent = true; + continue; + } + + if (flagTitle && !flagContent) + { + title += text + " "; + } + + + if (flagTitle && flagContent) + { + content += text + " "; + } + } + + content = content[..^1]; + title = title[..^1]; await arg.Target.Player!.MailManager!.SendMail(sender, title, content, templateId, expiredDay); diff --git a/Common/Internationalization/Message/LanguageCHS.cs b/Common/Internationalization/Message/LanguageCHS.cs index 83b11b46..d85d93c7 100644 --- a/Common/Internationalization/Message/LanguageCHS.cs +++ b/Common/Internationalization/Message/LanguageCHS.cs @@ -383,7 +383,7 @@ public class SceneTextCHS public class MailTextCHS { public string Desc => "管理玩家的邮件"; - public string Usage => "用法:/mail send [发送名称] [标题] [内容] [模板ID] [过期天数]"; + public string Usage => "用法:/mail [发送名称] [模板ID] [过期天数] _TITLE [标题] _CONTENT [内容]"; public string MailSent => "邮件已发送!"; public string MailSentWithAttachment => "带附件的邮件已发送!"; } diff --git a/Common/Internationalization/Message/LanguageCHT.cs b/Common/Internationalization/Message/LanguageCHT.cs index 9f02fb09..16d6f8b1 100644 --- a/Common/Internationalization/Message/LanguageCHT.cs +++ b/Common/Internationalization/Message/LanguageCHT.cs @@ -383,7 +383,7 @@ public class SceneTextCHT public class MailTextCHT { public string Desc => "管理玩家的郵件"; - public string Usage => "用法:/mail send [發送名稱] [標題] [內容] [模板ID] [過期天數]"; + public string Usage => "用法:/mail [發送名稱] [模板ID] [過期天數] _TITLE [標題] _CONTENT [內容]"; public string MailSent => "郵件已發送!"; public string MailSentWithAttachment => "帶附件的郵件已發送!"; } diff --git a/Common/Internationalization/Message/LanguageEN.cs b/Common/Internationalization/Message/LanguageEN.cs index 16e58268..e98a64e6 100644 --- a/Common/Internationalization/Message/LanguageEN.cs +++ b/Common/Internationalization/Message/LanguageEN.cs @@ -394,7 +394,7 @@ public class MailTextEN { public string Desc => "Manage player's mails"; - public string Usage => "Usage: /mail send [senderName] [title] [content] [templateId] [expiryDays]"; + public string Usage => "Usage: /mail [senderName] [templateId] [expiryDays] _TITLE [title] _CONTENT [content]"; public string MailSent => "Mail has been sent!"; public string MailSentWithAttachment => "Mail with attachments has been sent!"; diff --git a/GameServer/Game/Mail/MailManager.cs b/GameServer/Game/Mail/MailManager.cs index 76280db9..e8cd61c9 100644 --- a/GameServer/Game/Mail/MailManager.cs +++ b/GameServer/Game/Mail/MailManager.cs @@ -22,6 +22,12 @@ public class MailManager(PlayerInstance player) : BasePlayerManager(player) return MailData.MailList.Find(x => x.MailID == mailId); } + public void DeleteMail(int mailId) + { + var index = MailData.MailList.FindIndex(x => x.MailID == mailId); + MailData.MailList.RemoveAt(index); + } + public async ValueTask SendMail(string sender, string title, string content, int templateId, int expiredDay = 30) { var mail = new MailInfo diff --git a/GameServer/Server/Packet/Recv/Mail/HandlerDelMailCsReq.cs b/GameServer/Server/Packet/Recv/Mail/HandlerDelMailCsReq.cs new file mode 100644 index 00000000..4d118a04 --- /dev/null +++ b/GameServer/Server/Packet/Recv/Mail/HandlerDelMailCsReq.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.Mail; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.Mail; + +[Opcode(CmdIds.DelMailCsReq)] +public class HandlerDelMailCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + var req = DelMailCsReq.Parser.ParseFrom(data); + + foreach (var id in req.IdList) + { + connection.Player!.MailManager?.DeleteMail((int)id); + } + + await connection.SendPacket(new PacketDelMailScRsp([..req.IdList])); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/Avatar/PacketGetMultiPathAvatarInfoScRsp.cs b/GameServer/Server/Packet/Send/Avatar/PacketGetMultiPathAvatarInfoScRsp.cs index 4b368be1..33e7b411 100644 --- a/GameServer/Server/Packet/Send/Avatar/PacketGetMultiPathAvatarInfoScRsp.cs +++ b/GameServer/Server/Packet/Send/Avatar/PacketGetMultiPathAvatarInfoScRsp.cs @@ -17,7 +17,7 @@ public class PacketGetMultiPathAvatarInfoScRsp : BasePacket var avatar = player.AvatarManager!.GetAvatar(multiPathAvatar.BaseAvatarID); if (avatar != null) { - proto.BasicTypeIdList.Add((uint)avatar.AvatarId); + proto.BasicTypeIdList.Add((uint)avatar.PathId); var pathId = avatar.PathId > 0 ? avatar.PathId : avatar.AvatarId; if (pathId == 8001) if (player.Data.CurrentGender != Gender.Man) diff --git a/GameServer/Server/Packet/Send/Mail/PacketDelMailScRsp.cs b/GameServer/Server/Packet/Send/Mail/PacketDelMailScRsp.cs new file mode 100644 index 00000000..e41b3777 --- /dev/null +++ b/GameServer/Server/Packet/Send/Mail/PacketDelMailScRsp.cs @@ -0,0 +1,17 @@ +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.Mail; + +public class PacketDelMailScRsp : BasePacket +{ + public PacketDelMailScRsp(List ids) : base(CmdIds.DelMailScRsp) + { + var proto = new DelMailScRsp + { + IdList = { ids } + }; + + SetData(proto); + } +} \ No newline at end of file