using System; using StardewModdingAPI.Framework.Networking; namespace StardewModdingAPI.Events { /// Event arguments for an event. public class ModMessageReceivedEventArgs : EventArgs { /********* ** Properties *********/ /// The underlying message model. private readonly ModMessageModel Message; /********* ** Accessors *********/ /// The unique ID of the player from whose computer the message was sent. public long FromPlayerID => this.Message.FromPlayerID; /// The unique ID of the mod which sent the message. public string FromModID => this.Message.FromModID; /// A message type which can be used to decide whether it's the one you want to handle, like SetPlayerLocation. This doesn't need to be globally unique, so mods should check the . public string Type => this.Message.Type; /********* ** Public methods *********/ /// Construct an instance. /// The received message. internal ModMessageReceivedEventArgs(ModMessageModel message) { this.Message = message; } /// Read the message data into the given model type. /// The message model type. public TModel ReadAs() { return this.Message.Data.ToObject(); } } }