1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 23:31:13 -05:00

Adding Mute for IW4x (#257)

* Adding Mute for IW4x
This commit is contained in:
Amos
2022-08-26 18:09:33 +01:00
committed by GitHub
parent 423cc57986
commit c8d94ec57b
6 changed files with 208 additions and 0 deletions

View File

@ -0,0 +1,38 @@
using Data.Models.Client;
using SharedLibraryCore.Interfaces;
using static System.Enum;
namespace Mute;
public class DataManager
{
public DataManager(IMetaServiceV2 metaService)
{
_metaService = metaService;
}
private readonly IMetaServiceV2 _metaService;
public async Task<MuteState> ReadPersistentData(EFClient client)
{
var clientMuteState = client.GetAdditionalProperty<MuteState?>(Plugin.MuteKey) ??
Parse<MuteState>((await _metaService.GetPersistentMeta(Plugin.MuteKey, client.ClientId))?
.Value ?? nameof(MuteState.Unmuted));
client.SetAdditionalProperty(Plugin.MuteKey, clientMuteState);
return clientMuteState;
}
public async Task WritePersistentData(EFClient client, MuteState state)
{
await _metaService.SetPersistentMeta(Plugin.MuteKey, state.ToString(), client.ClientId);
client.SetAdditionalProperty(Plugin.MuteKey, state);
}
}
public enum MuteState
{
Muted,
Unmuting,
Unmuted
}