diff --git a/FunGame.Server/Controllers/DataRequestController.cs b/FunGame.Server/Controllers/DataRequestController.cs index 0e7c097..8bbc6f2 100644 --- a/FunGame.Server/Controllers/DataRequestController.cs +++ b/FunGame.Server/Controllers/DataRequestController.cs @@ -1631,7 +1631,7 @@ namespace Milimoe.FunGame.Server.Controller Guid itemGuid = DataRequest.GetDictionaryJsonObject(requestData, "itemGuid"); long userid = DataRequest.GetDictionaryJsonObject(requestData, "userid"); Character[] targets = DataRequest.GetDictionaryJsonObject(requestData, "targets") ?? []; - long useCount = DataRequest.GetDictionaryJsonObject(requestData, "useCount"); + int useCount = DataRequest.GetDictionaryJsonObject(requestData, "useCount"); GeneralEventArgs eventArgs = new(itemGuid, userid, targets, useCount); FunGameSystem.ServerPluginLoader?.OnBeforeUseItemEvent(this, eventArgs); @@ -1646,13 +1646,12 @@ namespace Milimoe.FunGame.Server.Controller User? user = SQLHelper.GetUserById(userid, true); if (user != null && user.Inventory.Items.FirstOrDefault(i => i.Guid == itemGuid) is Item item) { - // 暂定标准实现是传这两个参数,作用目标和使用数量 + // 暂定标准实现是传这个参数,作用目标 Dictionary args = new() { - { "targets", targets }, - { "useCount", useCount } + { "targets", targets } }; - bool used = item.UseItem(user, args); + bool used = item.UseItem(user, useCount, args); if (used) { SQLHelper.UpdateInventory(user.Inventory); diff --git a/FunGame.Server/Services/General.cs b/FunGame.Server/Services/General.cs index efe0dcc..b58af5e 100644 --- a/FunGame.Server/Services/General.cs +++ b/FunGame.Server/Services/General.cs @@ -72,6 +72,7 @@ namespace Milimoe.FunGame.Server.Services { Console.WriteLine("\r" + GetPrefix(InvokeMessageType.Error, LogLevel.Error) + e.Message + "\n" + e.StackTrace); Type(); + TXTHelper.AppendErrorLog(e); } public static void Write(string msg, InvokeMessageType type = InvokeMessageType.System, LogLevel level = LogLevel.Info, bool useLevel = true) diff --git a/FunGame.WebAPI/Services/CustomConsoleFormatter.cs b/FunGame.WebAPI/Services/CustomConsoleFormatter.cs index 451b8f4..708aeb8 100644 --- a/FunGame.WebAPI/Services/CustomConsoleFormatter.cs +++ b/FunGame.WebAPI/Services/CustomConsoleFormatter.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Console; +using Milimoe.FunGame.Core.Api.Utility; namespace Milimoe.FunGame.WebAPI.Services { @@ -20,6 +21,11 @@ namespace Milimoe.FunGame.WebAPI.Services textWriter.WriteLine($"{colorLevel}{timestamp} {level}/[{category}] {message}"); } textWriter.Write("\x1b[0m\r> "); + + if (logEntry.Exception != null) + { + TXTHelper.AppendErrorLog(logEntry.Exception); + } } private static string GetColorCode(LogLevel logLevel)