Client LuaCsForBarotrauma
BarotraumaShared/SharedSource/Networking/BanList.cs
1 #nullable enable
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 
6 namespace Barotrauma.Networking
7 {
8  #warning TODO: turn this into INetSerializableStruct
9  partial class BannedPlayer
10  {
11  public readonly string Name;
12  public readonly Either<Address, AccountId> AddressOrAccountId;
13 
14  public readonly string Reason;
15  public Option<SerializableDateTime> ExpirationTime;
16  public readonly UInt32 UniqueIdentifier;
17 
18  public bool MatchesClient(Client client)
19  {
20  if (client == null) { return false; }
21  if (AddressOrAccountId.TryGet(out AccountId bannedAccountId) && client.AccountId.TryUnwrap(out AccountId? accountId))
22  {
23  return bannedAccountId.Equals(accountId);
24  }
25  return false;
26  }
27  }
28 
29  partial class BanList
30  {
31  private readonly List<BannedPlayer> bannedPlayers;
32 
33  public IReadOnlyList<BannedPlayer> BannedPlayers => bannedPlayers;
34 
35  public IEnumerable<string> BannedNames
36  {
37  get { return bannedPlayers.Select(bp => bp.Name); }
38  }
39 
40  public IEnumerable<Either<Address, AccountId>> BannedAddresses
41  {
42  get { return bannedPlayers.Select(bp => bp.AddressOrAccountId); }
43  }
44 
45  partial void InitProjectSpecific();
46 
47 
48  public BanList()
49  {
50  bannedPlayers = new List<BannedPlayer>();
51  InitProjectSpecific();
52  }
53  }
54 }
IEnumerable< Either< Address, AccountId > > BannedAddresses
Option< AccountId > AccountId
The ID of the account used to authenticate this session. This value can be used as a persistent value...