diff options
Diffstat (limited to 'src/SMAPI/Framework/Networking/ModMessageModel.cs')
-rw-r--r-- | src/SMAPI/Framework/Networking/ModMessageModel.cs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/Networking/ModMessageModel.cs b/src/SMAPI/Framework/Networking/ModMessageModel.cs index 4f694f9c..01672714 100644 --- a/src/SMAPI/Framework/Networking/ModMessageModel.cs +++ b/src/SMAPI/Framework/Networking/ModMessageModel.cs @@ -1,4 +1,5 @@ using System.Linq; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace StardewModdingAPI.Framework.Networking @@ -13,41 +14,39 @@ namespace StardewModdingAPI.Framework.Networking ** Origin ****/ /// <summary>The unique ID of the player who broadcast the message.</summary> - public long FromPlayerID { get; set; } + public long FromPlayerID { get; } /// <summary>The unique ID of the mod which broadcast the message.</summary> - public string FromModID { get; set; } + public string FromModID { get; } /**** ** Destination ****/ /// <summary>The players who should receive the message.</summary> - public long[] ToPlayerIDs { get; set; } + public long[]? ToPlayerIDs { get; init; } /// <summary>The mods which should receive the message, or <c>null</c> for all mods.</summary> - public string[] ToModIDs { get; set; } + public string[]? ToModIDs { get; } /// <summary>A message type which receiving mods can use to decide whether it's the one they want to handle, like <c>SetPlayerLocation</c>. This doesn't need to be globally unique, since mods should check the originating mod ID.</summary> - public string Type { get; set; } + public string Type { get; } /// <summary>The custom mod data being broadcast.</summary> - public JToken Data { get; set; } + public JToken Data { get; } /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> - public ModMessageModel() { } - - /// <summary>Construct an instance.</summary> /// <param name="fromPlayerID">The unique ID of the player who broadcast the message.</param> /// <param name="fromModID">The unique ID of the mod which broadcast the message.</param> /// <param name="toPlayerIDs">The players who should receive the message, or <c>null</c> for all players.</param> /// <param name="toModIDs">The mods which should receive the message, or <c>null</c> for all mods.</param> /// <param name="type">A message type which receiving mods can use to decide whether it's the one they want to handle, like <c>SetPlayerLocation</c>. This doesn't need to be globally unique, since mods should check the originating mod ID.</param> /// <param name="data">The custom mod data being broadcast.</param> - public ModMessageModel(long fromPlayerID, string fromModID, long[] toPlayerIDs, string[] toModIDs, string type, JToken data) + [JsonConstructor] + public ModMessageModel(long fromPlayerID, string fromModID, long[]? toPlayerIDs, string[]? toModIDs, string type, JToken data) { this.FromPlayerID = fromPlayerID; this.FromModID = fromModID; |