diff options
-rw-r--r-- | docs/release-notes.md | 3 | ||||
-rw-r--r-- | src/SMAPI/Framework/SGame.cs | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index cf084856..5368251e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,6 +1,9 @@ ← [README](README.md) # Release notes +## Upcoming release +* Fixed mods receiving their own message broadcasts. + ## 3.3.1 Released 22 February 2020 for Stardew Valley 1.4.1 or later. diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index 6b9c1365..b2d92ce8 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -226,8 +226,12 @@ namespace StardewModdingAPI.Framework /// <param name="message">The message to deliver to applicable mods.</param> private void OnModMessageReceived(ModMessageModel message) { - // raise events for applicable mods + // get mod IDs to notify HashSet<string> modIDs = new HashSet<string>(message.ToModIDs ?? this.ModRegistry.GetAll().Select(p => p.Manifest.UniqueID), StringComparer.InvariantCultureIgnoreCase); + if (message.FromPlayerID == Game1.player?.UniqueMultiplayerID) + modIDs.Remove(message.FromModID); // don't send a broadcast back to the sender + + // raise events this.Events.ModMessageReceived.RaiseForMods(new ModMessageReceivedEventArgs(message), mod => mod != null && modIDs.Contains(mod.Manifest.UniqueID)); } |