Table of Contents

Class UserDataService

Namespace
Uncreated.Warfare.Players
Assembly
Uncreated.Warfare.dll
public class UserDataService : IUserDataService, IDisposable
Inheritance
UserDataService
Implements
Inherited Members
Extension Methods

Constructors

UserDataService(IUserDataDbContext)

public UserDataService(IUserDataDbContext dbContext)

Parameters

dbContext IUserDataDbContext

Methods

AddOrUpdateAsync(ulong, Action<WarfareUserData, IDbContext>, CancellationToken)

Update a WarfareUserData object. Any added HWIDs and IP addresses need to be added using the IDbContext argument and any updated need to be updated using it.

public Task<WarfareUserData> AddOrUpdateAsync(ulong steam64, Action<WarfareUserData, IDbContext> update, CancellationToken token = default)

Parameters

steam64 ulong
update Action<WarfareUserData, IDbContext>
token CancellationToken

Returns

Task<WarfareUserData>

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetDiscordIdAsync(ulong, CancellationToken)

Get a player's Discord ID, or 0 if their Discord is not linked.

public Task<ulong> GetDiscordIdAsync(ulong steam64, CancellationToken token = default)

Parameters

steam64 ulong
token CancellationToken

Returns

Task<ulong>

GetDiscordIdsAsync(IReadOnlyList<ulong>, CancellationToken)

Get a set of players' Discord IDs, or 0 if their Discord is not linked.

public Task<ulong[]> GetDiscordIdsAsync(IReadOnlyList<ulong> steam64s, CancellationToken token = default)

Parameters

steam64s IReadOnlyList<ulong>
token CancellationToken

Returns

Task<ulong[]>

An array in the same order as the input, with 0s in the place of unlinked IDs.

GetSteam64Async(ulong, CancellationToken)

Get a player's Steam64 ID from their Discord ID, or 0 if their Discord is not linked.

public Task<ulong> GetSteam64Async(ulong discordId, CancellationToken token = default)

Parameters

discordId ulong
token CancellationToken

Returns

Task<ulong>

GetSteam64sAsync(IReadOnlyList<ulong>, CancellationToken)

Get a player's Steam64 ID from their Discord ID, or 0 if their Discord is not linked.

public Task<ulong[]> GetSteam64sAsync(IReadOnlyList<ulong> discordIds, CancellationToken token = default)

Parameters

discordIds IReadOnlyList<ulong>
token CancellationToken

Returns

Task<ulong[]>

An array in the same order as the input, with 0s in the place of unlinked IDs.

GetUsernamesAsync(ulong, CancellationToken)

Get a player's usernames from their Steam64 ID.

public Task<PlayerNames> GetUsernamesAsync(ulong steam64, CancellationToken token = default)

Parameters

steam64 ulong
token CancellationToken

Returns

Task<PlayerNames>

ReadAsync(IEnumerable<ulong>, CancellationToken)

Get multiple players' user data in bulk if they've joined. Not necessarily returned in the same order as it was inputted.

public Task<IReadOnlyList<WarfareUserData>> ReadAsync(IEnumerable<ulong> steam64, CancellationToken token = default)

Parameters

steam64 IEnumerable<ulong>
token CancellationToken

Returns

Task<IReadOnlyList<WarfareUserData>>

ReadAsync(ulong, CancellationToken)

Get a single player's user data if they've joined.

public Task<WarfareUserData?> ReadAsync(ulong steam64, CancellationToken token = default)

Parameters

steam64 ulong
token CancellationToken

Returns

Task<WarfareUserData>

ReadFromDiscordIdAsync(ulong, CancellationToken)

Get a single player's user data if they've joined from their Discord ID if it's linked.

public Task<WarfareUserData?> ReadFromDiscordIdAsync(ulong discordId, CancellationToken token = default)

Parameters

discordId ulong
token CancellationToken

Returns

Task<WarfareUserData>

SearchFirstPlayerAsync(string, PlayerNameType, bool, CancellationToken)

Search all players that have ever joined by their usernames, and return the best match.

public Task<PlayerNames> SearchFirstPlayerAsync(string input, PlayerNameType prioritizedName, bool byLastJoined, CancellationToken token = default)

Parameters

input string
prioritizedName PlayerNameType

The type of name to prioritize.

byLastJoined bool

If they should be ordered by the last time they joined. Exact matches will still be prioritized.

token CancellationToken

Returns

Task<PlayerNames>

SearchPlayersAsync(string, PlayerNameType, bool, ICollection<PlayerNames>, int, CancellationToken)

Search all players that have ever joined by their usernames, and add them to a collection as they're found.

public Task<int> SearchPlayersAsync(string input, PlayerNameType prioritizedName, bool byLastJoined, ICollection<PlayerNames> output, int limit = -1, CancellationToken token = default)

Parameters

input string
prioritizedName PlayerNameType

The type of name to prioritize.

byLastJoined bool

If they should be ordered by the last time they joined. Exact matches will still be prioritized.

output ICollection<PlayerNames>

Collection to add matches to.

limit int

Maximum number of names to find.

token CancellationToken

Returns

Task<int>

Number of results.