diff options
Diffstat (limited to 'src/SMAPI/Framework/Networking/MultiplayerPeer.cs')
-rw-r--r-- | src/SMAPI/Framework/Networking/MultiplayerPeer.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/SMAPI/Framework/Networking/MultiplayerPeer.cs b/src/SMAPI/Framework/Networking/MultiplayerPeer.cs index 3923700f..b37c1e89 100644 --- a/src/SMAPI/Framework/Networking/MultiplayerPeer.cs +++ b/src/SMAPI/Framework/Networking/MultiplayerPeer.cs @@ -37,10 +37,10 @@ namespace StardewModdingAPI.Framework.Networking public GamePlatform? Platform { get; } /// <inheritdoc /> - public ISemanticVersion GameVersion { get; } + public ISemanticVersion? GameVersion { get; } /// <inheritdoc /> - public ISemanticVersion ApiVersion { get; } + public ISemanticVersion? ApiVersion { get; } /// <inheritdoc /> public IEnumerable<IMultiplayerPeerMod> Mods { get; } @@ -55,11 +55,12 @@ namespace StardewModdingAPI.Framework.Networking /// <param name="model">The metadata to copy.</param> /// <param name="sendMessage">A method which sends a message to the peer.</param> /// <param name="isHost">Whether this is a connection to the host player.</param> - public MultiplayerPeer(long playerID, int? screenID, RemoteContextModel model, Action<OutgoingMessage> sendMessage, bool isHost) + public MultiplayerPeer(long playerID, int? screenID, RemoteContextModel? model, Action<OutgoingMessage> sendMessage, bool isHost) { this.PlayerID = playerID; this.ScreenID = screenID; this.IsHost = isHost; + if (model != null) { this.Platform = model.Platform; @@ -67,13 +68,16 @@ namespace StardewModdingAPI.Framework.Networking this.ApiVersion = model.ApiVersion; this.Mods = model.Mods.Select(mod => new MultiplayerPeerMod(mod)).ToArray(); } + else + this.Mods = Array.Empty<IMultiplayerPeerMod>(); + this.SendMessageImpl = sendMessage; } /// <inheritdoc /> - public IMultiplayerPeerMod GetMod(string id) + public IMultiplayerPeerMod? GetMod(string? id) { - if (string.IsNullOrWhiteSpace(id) || this.Mods == null || !this.Mods.Any()) + if (string.IsNullOrWhiteSpace(id) || !this.Mods.Any()) return null; id = id.Trim(); |