-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from YongAn404/master
数据库修复和数据获取优化
- Loading branch information
Showing
3 changed files
with
22 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
using HelpSense.API.Serialization; | ||
using LiteDB; | ||
using System.Collections.Generic; | ||
|
||
namespace HelpSense.API | ||
{ | ||
public static class API | ||
{ | ||
public static List<string> TimerHidden { get; } = []; | ||
public static Dictionary<string, PlayerLog> PlayerDataDic = []; | ||
|
||
public static bool TryGetLog(string id, out PlayerLog log) | ||
{ | ||
log = Plugin.Instance.Database.GetCollection<PlayerLog>("Players")?.FindById(id); | ||
return log != null; | ||
using LiteDatabase database = new(Plugin.Instance.Config.SavePath); | ||
if (PlayerDataDic.TryGetValue(id,out log)) | ||
{ | ||
return true; | ||
} | ||
log = database.GetCollection<PlayerLog>("Players")?.FindById(id); | ||
if (log != null) | ||
{ | ||
PlayerDataDic.Add(id, log); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters