mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-12-05 08:09:03 +00:00
添加错误日志记录;添加物品使用次数参数
This commit is contained in:
parent
a641e8ce6f
commit
a989b8b56d
@ -1631,7 +1631,7 @@ namespace Milimoe.FunGame.Server.Controller
|
||||
Guid itemGuid = DataRequest.GetDictionaryJsonObject<Guid>(requestData, "itemGuid");
|
||||
long userid = DataRequest.GetDictionaryJsonObject<long>(requestData, "userid");
|
||||
Character[] targets = DataRequest.GetDictionaryJsonObject<Character[]>(requestData, "targets") ?? [];
|
||||
long useCount = DataRequest.GetDictionaryJsonObject<long>(requestData, "useCount");
|
||||
int useCount = DataRequest.GetDictionaryJsonObject<int>(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<string, object> 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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user