From e58417f4fa0bdf240056521bd2b381b939adb9fc Mon Sep 17 00:00:00 2001 From: Kyle873 Date: Fri, 9 Jun 2023 21:40:00 -0400 Subject: [PATCH 1/4] fixes and improvements to give command --- GameServer/Commands/GiveCommand.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/GameServer/Commands/GiveCommand.cs b/GameServer/Commands/GiveCommand.cs index ffaba95..c6c4be0 100644 --- a/GameServer/Commands/GiveCommand.cs +++ b/GameServer/Commands/GiveCommand.cs @@ -7,7 +7,7 @@ namespace PemukulPaku.GameServer.Commands { [CommandHandler("give", " [#] [id]", CommandType.Player, //example commands list - "gold 123456789","stigs 1", "weaps", "mats 999 2008", "valks", "outfits" + "gold 123456789", "stigs 1", "weaps", "mats 999 2008", "valks", "outfits" )] internal class GiveCommand : Command { @@ -22,7 +22,7 @@ namespace PemukulPaku.GameServer.Commands public override void Run(Player player, string[] args) { string action = args[0]; - int value = (args.Length > 1 && args[1] is not null) ? int.Parse(args[1]) : -1; + int? value = (args.Length >= 2 && args[1] is not null) ? int.Parse(args[1]) : null; switch (action) { @@ -91,14 +91,18 @@ namespace PemukulPaku.GameServer.Commands case "mats": case "matz": foreach (MaterialDataExcel materialData in MaterialData.GetInstance().All) - { - player.Equipment.AddMaterial(materialData.Id, value > 0 || value < -1 ? value : 9999); + { + player.Equipment.AddMaterial(materialData.Id, value is not null && value != 0 ? (int)value : materialData.QuantityLimit); } break; case "material-id": case "gold": - int materialId = args[2] is not null ? int.Parse(args[2]) : 100; - player.Equipment.AddMaterial(materialId, value > 0 || value < -1 ? value : 9999); + int materialId = args.Length >= 3 && args[2] is not null ? int.Parse(args[2]) : 100; + int? quantityLimit = MaterialData.GetInstance().All.FirstOrDefault(m => m.Id == materialId)?.QuantityLimit; + if (quantityLimit is not null) + { + player.Equipment.AddMaterial(materialId, value is not null && value != 0 ? (int)value : (int)quantityLimit); + } break; case "dress": case "outfits": From 13b8d319bfba754bf27584d19f37b23f6c5b9870 Mon Sep 17 00:00:00 2001 From: moraxs <98573765+moraxs@users.noreply.github.com> Date: Sat, 10 Jun 2023 13:40:02 +0800 Subject: [PATCH 2/4] update README_zh-CN.md and README_zh-TW.md (#7) * Update README_zh-CN.md * Update README_zh-CN.md * Update README_zh-CN.md * Update README_zh-CN.md * Update README_zh-CN.md * Update README_zh-CN.md * Update README_zh-TW.md * Update README_zh-TW.md * Update README_zh-TW.md * Update README_zh-TW.md --- Docs/README_zh-CN.md | 56 +++++++++---- Docs/README_zh-TW.md | 182 ++++++++++++++++++++++++++++--------------- 2 files changed, 159 insertions(+), 79 deletions(-) diff --git a/Docs/README_zh-CN.md b/Docs/README_zh-CN.md index 484ec02..fba2e2d 100644 --- a/Docs/README_zh-CN.md +++ b/Docs/README_zh-CN.md @@ -2,19 +2,19 @@
Discord - Server for Lesser Konwn Anime Games
-[EN](../README.md) [简中](Docs/README_zh-CN.md) [繁中](README_zh-TW.md) +[EN](../README.md) | [简中](Docs/README_zh-CN.md) | [繁中](README_zh-TW.md) # PemukulPaku A private server implementation for a third impact game but made in see sharp ## 快速开始 -**先决条件* -阅读文章的能力 -GitHub 账户 -[.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) +**前提条件* +* 阅读文章的能力 +* GitHub 账户 +* [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) 在命令行运行如下命令 ``` -dotnet dev-certs https +dotnet dev-certs https --trust ``` -[MongoDB](https://www.mongodb.com/try/download/community) +* [MongoDB](https://www.mongodb.com/try/download/community) **快速开始* 克隆存储库 ``` @@ -33,15 +33,41 @@ git clone https://github.com/rafi1212122/PemukulPaku.git ``` **运行服务* -1.运行 PemukulPaku.exe -**连结至服务器* -选择你想要的代理工具 (mitmproxy/Fiddler reccomended) -使用以下脚本之一进行代理配置:: -[mitmproxy](https://gist.github.com/rafi1212122/5cc76297d6cf6396de5fc572d1e55812#file-proxy-py) -[Fiddler](https://github.com/rafi1212122/PemukulPaku/wiki/Starting#connecting-to-the-server) +1.运行 PemukulPaku.exe +**在运行前请确保MongoDB服务已经正确启动** +**连接至服务器* +选择你想要的代理工具 (mitmproxy/Fiddler reccomended) +使用以下工具之一进行代理配置:: +[mitmproxy](https://mitmproxy.org/) +[Fiddler](https://github.com/rafi1212122/PemukulPaku/wiki/Starting#connecting-to-the-server) +若出现 ``为了账号安全,请重新输入密码``,可尝试使用mitmproxy +## 使用Fiddler +1.运行 Fiddler Classic, 开启解密http通信 ``Tools-options-Https-勾选Decrypt HTTPS traffic``并将端口设为任意未占用端口``Tools-options-Https-Connections`` +2.点击Fiddler Script,并填入以下内容 +``` +import System; +import System.Windows.Forms; +import Fiddler; +import System.Text.RegularExpressions; +class Handlers +{ +static function OnBeforeRequest(oS: Session) { + if(oS.host.EndsWith(".yuanshen.com") || oS.host.EndsWith(".hoyoverse.com") || oS.host.EndsWith(".starrails.com") || oS.host.EndsWith(".bhsr.com") || oS.host.EndsWith(".kurogame.com") || oS.host.EndsWith(".zenlesszonezero.com") || oS.host.EndsWith(".g3.proletariat.com") || oS.host.EndsWith("west.honkaiimpact3.com") || oS.host.EndsWith("westglobal01.honkaiimpact3.com") || oS.host.EndsWith(".os.honkaiimpact3.com") || oS.host.EndsWith("overseas01-appsflyer-report.honkaiimpact3.com") || oS.host.EndsWith(".mihoyo.com") || (oS.host.EndsWith("bh3.com") && !oS.host.Contains("bundle"))) { + oS.host = "localhost"; + } +} +} +``` +## 使用mitmproxy +1.从[这里](https://gist.github.com/rafi1212122/5cc76297d6cf6396de5fc572d1e55812#file-proxy-py)获取proxy.py +2.在proxy.py所在目录运行 `mitmdump -s proxy.py -k`命令 +3.设置系统代理为你所设置的端口,默认为 ``127.0.0.1:8080`` +4.信任CA证书 + * mitmproxy 的 CA 证书通常存放在 `%USERPROFILE%\ .mitmproxy` 或者浏览器访问 ``http://mitm.it``下载证书,如果你访问该地址后看到了 ``If you can see this, traffic is not passing through mitmproxy.``说明mitmproxy配置有误,请重新配置 + * 双击安装证书,或者运行 ``certutil -addstore root %USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.p12``命令 -了解更多[GitHub wiki](https://github.com/rafi1212122/PemukulPaku/wiki) +了解更多[GitHub wiki](https://github.com/rafi1212122/PemukulPaku/wiki) ## GM 命令 * **在哪里输入命令?**\ @@ -65,4 +91,4 @@ git clone https://github.com/rafi1212122/PemukulPaku.git 了解更多[development](https://github.com/rafi1212122/PemukulPaku/wiki/Development) ## 支持 -[Discord server](https://discord.gg/fbsRYc7bBA) or GitHub issue +加入[Discord server](https://discord.gg/fbsRYc7bBA) or 提交GitHub issue diff --git a/Docs/README_zh-TW.md b/Docs/README_zh-TW.md index 16ed039..d55e60e 100644 --- a/Docs/README_zh-TW.md +++ b/Docs/README_zh-TW.md @@ -3,49 +3,50 @@ -[EN](../README.md)|[簡中](README_zh-CN.md)|[繁中](Docs/README_zh-TW.md) +[EN](../README.md)|[簡中](README_zh-CN.md)|[繁中](README_zh-TW.md) -# PemukulPaku -A private server implementation for a third impact game but made in see sharp +# PemukulPaku -## 快速開始 +A private server implementation for a third impact game but made in see sharp -**先決條件* +##快速開始 -閱讀文章的能力 +**前提條件* -GitHub帳戶 +*閱讀文章的能力 -[.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) +* GitHub帳戶 -在命令列運行如下命令 +* [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) + +在命令列運行如下命令 ``` -dotnet dev-certs https +dotnet dev-certs https --trust ``` -[MongoDB](https://www.mongodb.com/try/download/community ) +* [MongoDB](https://www.mongodb.com/try/download/community) -**快速開始* +**快速開始* -尅隆存儲庫 +尅隆存儲庫 ``` -git clone https://github.com/rafi1212122/PemukulPaku.git +git clone https://github.com/rafi1212122/PemukulPaku.git ``` -從[這裡]下載最新action(https://github.com/rafi1212122/PemukulPaku/actions)下載最新action. +從[這裡](https://github.com/rafi1212122/PemukulPaku/actions)下載最新action. -進入PemukulPaku資料夾,將下載的action解壓到該資料夾下 - -下載資源檔[resources](***REMOVED*** +進入PemukulPaku資料夾,將下載的action解壓到該資料夾下 + +下載資源檔[resources](***REMOVED*** ``` @@ -62,69 +63,122 @@ git clone https://github.com/rafi1212122/PemukulPaku.git ``` -**運行服務* +**運行服務* -1.運行PemukulPaku.exe +1.運行PemukulPaku.exe -**連結至服務器* +**在運行前請確保MongoDB服務已經正確啟動** -選擇你想要的代理工具(mitmproxy/Fiddler reccomended) +**連接至服務器* -使用以下腳本之一進行代理配寘:: +選擇你想要的代理工具(mitmproxy/Fiddler reccomended) -[mitmproxy](https://gist.github.com/rafi1212122/5cc76297d6cf6396de5fc572d1e55812#file -proxy-py) +使用以下工具之一進行代理配寘:: -[Fiddler](https://github.com/rafi1212122/PemukulPaku/wiki/Starting#connecting -to-the-server) +[mitmproxy](https://mitmproxy.org/) + +[Fiddler](https://github.com/rafi1212122/PemukulPaku/wiki/Starting#connecting-to-the-server) + +若出現``為了帳號安全,請重新輸入密碼``,可嘗試使用mitmproxy + +##使用Fiddler + +1.運行Fiddler Classic,開啟解密http通信``Tools-options-Https-勾選Decrypt HTTPS traffic``並將埠設為任意未佔用埠``Tools-options-Https-Connections`` + +2.點擊Fiddler Script,並填入以下內容 + +``` + +import System; + +import System.Windows.Forms; + +import Fiddler; + +import System.Text.RegularExpressions; + +class Handlers + +{ + +static function OnBeforeRequest(oS: Session){ + +if(oS.host.EndsWith(".yuanshen.com")|| oS.host.EndsWith(".hoyoverse.com")|| oS.host.EndsWith(".starrails.com")|| oS.host.EndsWith(".bhsr.com")|| oS.host.EndsWith(".kurogame.com")|| oS.host.EndsWith(".zenlesszonezero.com")|| oS.host.EndsWith(".g3.proletariat.com")|| oS.host.EndsWith("west.honkaiimpact3.com")|| oS.host.EndsWith("westglobal01.honkaiimpact3.com")|| oS.host.EndsWith( ".os.honkaiimpact3.com")|| oS.host.EndsWith("overseas01-appsflyer-report.honkaiimpact3.com")|| oS.host.EndsWith(".mihoyo.com")||(oS.host.EndsWith("bh3.com")&&! oS.host.Contains("bundle"))){ + +oS.host ="localhost"; + +} + +} + +} + +``` + +##使用mitmproxy +1.從[這裡](https://gist.github.com/rafi1212122/5cc76297d6cf6396de5fc572d1e55812#file-proxy-py)獲取proxy.py -瞭解更多[GitHub wiki](https://github.com/rafi1212122/PemukulPaku/wiki) +2.在proxy.py所在目錄運行`mitmdump -s proxy.py -k`命令 + +3.設定系統代理為你所設定的埠,默認為``127.0.0.1:8080`` + +4.信任CA證書 + +* mitmproxy的CA證書通常存放在`%USERPROFILE%\ .mitmproxy`或者瀏覽器訪問`` http://mitm.it ``下載證書,如果你訪問該地址後看到了``If you can see this,traffic is not passing through mitmproxy.`` 說明mitmproxy配寘有誤,請重新配寘 + +*按兩下安裝證書,或者運行``certutil -addstore root %USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.p12``命令 -## GM命令 - -* **在哪裡輸入命令?**\ - -在控制台或者遊戲內聊天視窗 - -以下是可用的命令:: - -1. `level ` - -*設定玩家等級 - -*例如: - -* `level 88` - -2. `avatar <…>` - -*將角色添加到使用者帳戶或修改角色資訊 - -*例如: - -* `avatar add 713` - -* `avatar modify 713 Level 80` - -*請注意字母L是大寫的 - -3. `give `. - -*獲取所有角色,、武器、徽章、資料或服裝 - -*例如: - -- `give avatars` +瞭解更多[GitHub wiki](https://github.com/rafi1212122/PemukulPaku/wiki) -瞭解更多[development]( https://github.com/rafi1212122/PemukulPaku/wiki/Development) +## GM命令 + +* **在哪裡輸入命令?**\ + +在控制台或者遊戲內聊天視窗 + +以下是可用的命令:: + +1. `level ` + +*設定玩家等級 + +*例如: + +* `level 88` + +2. `avatar <…>` + +*將角色添加到使用者帳戶或修改角色資訊 + +*例如: + +* `avatar add 713` + +* `avatar modify 713 Level 80` + +*請注意字母L是大寫的 + +3. `give `. + +*獲取所有角色,、武器、徽章、資料或服裝 + +*例如: + +- `give avatars` -##支持 +瞭解更多[development](https://github.com/rafi1212122/PemukulPaku/wiki/Development) -[Discord server]( https://discord.gg/fbsRYc7bBA)or GitHub issue + + +##支持 + +加入[Discord server](https://discord.gg/fbsRYc7bBA)or提交GitHub issue From aed8d4805bc37da452218d712a583bc6ad16e0b0 Mon Sep 17 00:00:00 2001 From: Kyle873 Date: Sat, 10 Jun 2023 02:27:29 -0400 Subject: [PATCH 3/4] Optimized help command --- GameServer/Commands/HelpCommand.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/GameServer/Commands/HelpCommand.cs b/GameServer/Commands/HelpCommand.cs index 531bf71..a63da9e 100644 --- a/GameServer/Commands/HelpCommand.cs +++ b/GameServer/Commands/HelpCommand.cs @@ -1,5 +1,6 @@ using Common.Resources.Proto; using Common; +using System.Text; namespace PemukulPaku.GameServer.Commands { @@ -9,26 +10,26 @@ namespace PemukulPaku.GameServer.Commands { public override void Run(Session session, string[] args) { - RecvChatMsgNotify notify = new() { }; + RecvChatMsgNotify notify = new(); //hardcoding values is fun AND easy! - string msg = "Commands\n"; - msg += "command [optional]\n"; - //msg += "┌\n"; + StringBuilder msg = new("Commands\n"); + msg.Append("command [optional]\n"); + //msg.Append("┌\n"); foreach (Command Cmd in CommandFactory.Commands) { - if(Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Player) + if (Cmd.CmdType == CommandType.All || Cmd.CmdType == CommandType.Player) { - msg += "┝" + Cmd.Name + " " + Cmd.Description + "\n"; + msg.Append("┝" + Cmd.Name + " " + Cmd.Description + "\n"); if (Cmd.Examples is not null) { foreach (string Example in Cmd.Examples) { - msg += "│┕" + Example + "\n"; + msg.Append("│┕" + Example + "\n"); } } - } + } } - msg += ""; + msg.Append(""); //I really want to figure out how to grab from Chatroom.cs instead, but oh well. ChatMsg AiMsg = new() @@ -36,16 +37,16 @@ namespace PemukulPaku.GameServer.Commands Uid = 0, Nickname = "Ai-chan", Time = (uint)Global.GetUnixInSeconds(), - Msg = msg, - Content = new() { }, + Msg = msg.ToString(), + Content = new(), Channel = ChatMsg.MsgChannel.World, AvatarId = 3201, DressId = 593201, FrameId = 200001, CustomHeadId = 161080, - CheckResult = new() { NumberCheck = 0, ShieldType = 0, RewriteText = msg } + CheckResult = new() { NumberCheck = 0, ShieldType = 0, RewriteText = msg.ToString() } }; - AiMsg.Content.Items.Add(new() { MsgStr = msg }); + AiMsg.Content.Items.Add(new() { MsgStr = msg.ToString() }); notify.ChatMsgLists.Add(AiMsg); session.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify)); } @@ -54,7 +55,7 @@ namespace PemukulPaku.GameServer.Commands { foreach (Command Cmd in CommandFactory.Commands) { - Console.ForegroundColor= ConsoleColor.White; + Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" " + Cmd.Name); Console.ResetColor(); c.Trail(Cmd.Description); From dd1543c816d6164771aa7894cbd5f50610bf0046 Mon Sep 17 00:00:00 2001 From: Kyle873 Date: Sat, 10 Jun 2023 11:53:11 -0400 Subject: [PATCH 4/4] fixed regressions to give command, I am dum --- GameServer/Commands/GiveCommand.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GameServer/Commands/GiveCommand.cs b/GameServer/Commands/GiveCommand.cs index c6c4be0..61422a8 100644 --- a/GameServer/Commands/GiveCommand.cs +++ b/GameServer/Commands/GiveCommand.cs @@ -56,7 +56,7 @@ namespace PemukulPaku.GameServer.Commands if (weaponData.EvoId == 0) { Weapon weapon = player.Equipment.AddWeapon(weaponData.Id); - weapon.Level = value <= 0 ? (uint)weaponData.MaxLv : (uint)value; + weapon.Level = value is not null && value <= 0 ? (uint)weaponData.MaxLv : value is not null ? (uint)value : (uint)weaponData.MaxLv; } } break; @@ -65,7 +65,7 @@ namespace PemukulPaku.GameServer.Commands foreach (WeaponDataExcel weaponData in WeaponData.GetInstance().All) { Weapon weapon = player.Equipment.AddWeapon(weaponData.Id); - weapon.Level = value <= 0 ? (uint)weaponData.MaxLv : (uint)value; + weapon.Level = value is not null && value <= 0 ? (uint)weaponData.MaxLv : value is not null ? (uint)value : (uint)weaponData.MaxLv; } break; case "stigmata": @@ -75,7 +75,7 @@ namespace PemukulPaku.GameServer.Commands if (stigmataData.EvoId == 0) { Stigmata stigmata = player.Equipment.AddStigmata(stigmataData.Id); - stigmata.Level = value <= 0 ? (uint)stigmataData.MaxLv : (uint)value; + stigmata.Level = value is not null && value <= 0 ? (uint)stigmataData.MaxLv : value is not null ? (uint)value : (uint)stigmataData.MaxLv; } } break; @@ -84,7 +84,7 @@ namespace PemukulPaku.GameServer.Commands foreach (StigmataDataExcel stigmataData in StigmataData.GetInstance().All) { Stigmata stigmata = player.Equipment.AddStigmata(stigmataData.Id); - stigmata.Level = value <= 0 ? (uint)stigmataData.MaxLv : (uint)value; + stigmata.Level = value is not null && value <= 0 ? (uint)stigmataData.MaxLv : value is not null ? (uint)value : (uint)stigmataData.MaxLv; } break; case "materials":