mirror of
https://github.com/BillyCool/MariesWonderland.git
synced 2026-03-27 17:22:21 +01:00
Implement master db and basic user store
This commit is contained in:
24
src/Data/UserDataStore.cs
Normal file
24
src/Data/UserDataStore.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace MariesWonderland.Data;
|
||||
|
||||
public class UserDataStore
|
||||
{
|
||||
private readonly Dictionary<long, DarkUserMemoryDatabase> _users = new();
|
||||
|
||||
public DarkUserMemoryDatabase GetOrCreate(long playerId)
|
||||
{
|
||||
if (!_users.TryGetValue(playerId, out var db))
|
||||
{
|
||||
db = new DarkUserMemoryDatabase();
|
||||
_users[playerId] = db;
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
public bool TryGet(long playerId, out DarkUserMemoryDatabase db)
|
||||
=> _users.TryGetValue(playerId, out db!);
|
||||
|
||||
public void Set(long playerId, DarkUserMemoryDatabase db)
|
||||
=> _users[playerId] = db;
|
||||
|
||||
public IReadOnlyDictionary<long, DarkUserMemoryDatabase> All => _users;
|
||||
}
|
||||
Reference in New Issue
Block a user