summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModHelper.cs6
-rw-r--r--src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs31
-rw-r--r--src/SMAPI/Framework/SGame.cs3
3 files changed, 39 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs
index b5758d21..1f37a1be 100644
--- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs
@@ -45,6 +45,9 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <summary>An API for managing console commands.</summary>
public ICommandHelper ConsoleCommands { get; }
+ /// <summary>Provides multiplayer utilities.</summary>
+ public IMultiplayerHelper Multiplayer { get; }
+
/// <summary>An API for reading translations stored in the mod's <c>i18n</c> folder, with one file per locale (like <c>en.json</c>) containing a flat key => value structure. Translations are fetched with locale fallback, so missing translations are filled in from broader locales (like <c>pt-BR.json</c> &lt; <c>pt.json</c> &lt; <c>default.json</c>).</summary>
public ITranslationHelper Translation { get; }
@@ -66,7 +69,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <param name="deprecationManager">Manages deprecation warnings.</param>
/// <exception cref="ArgumentNullException">An argument is null or empty.</exception>
/// <exception cref="InvalidOperationException">The <paramref name="modDirectory"/> path does not exist on disk.</exception>
- public ModHelper(string modID, string modDirectory, JsonHelper jsonHelper, IContentHelper contentHelper, ICommandHelper commandHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, ITranslationHelper translationHelper, IEnumerable<IContentPack> contentPacks, Func<string, IManifest, IContentPack> createContentPack, DeprecationManager deprecationManager)
+ public ModHelper(string modID, string modDirectory, JsonHelper jsonHelper, IContentHelper contentHelper, ICommandHelper commandHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, IMultiplayerHelper multiplayer, ITranslationHelper translationHelper, IEnumerable<IContentPack> contentPacks, Func<string, IManifest, IContentPack> createContentPack, DeprecationManager deprecationManager)
: base(modID)
{
// validate directory
@@ -82,6 +85,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
this.ModRegistry = modRegistry ?? throw new ArgumentNullException(nameof(modRegistry));
this.ConsoleCommands = commandHelper ?? throw new ArgumentNullException(nameof(commandHelper));
this.Reflection = reflectionHelper ?? throw new ArgumentNullException(nameof(reflectionHelper));
+ this.Multiplayer = multiplayer ?? throw new ArgumentNullException(nameof(multiplayer));
this.Translation = translationHelper ?? throw new ArgumentNullException(nameof(translationHelper));
this.ContentPacks = contentPacks.ToArray();
this.CreateContentPack = createContentPack;
diff --git a/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs b/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs
new file mode 100644
index 00000000..7a8da1d0
--- /dev/null
+++ b/src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs
@@ -0,0 +1,31 @@
+namespace StardewModdingAPI.Framework.ModHelpers
+{
+ /// <summary>Provides multiplayer utilities.</summary>
+ internal class MultiplayerHelper : BaseHelper, IMultiplayerHelper
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>SMAPI's core multiplayer utility.</summary>
+ private readonly SMultiplayer Multiplayer;
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="modID">The unique ID of the relevant mod.</param>
+ /// <param name="multiplayer">SMAPI's core multiplayer utility.</param>
+ public MultiplayerHelper(string modID, SMultiplayer multiplayer)
+ : base(modID)
+ {
+ this.Multiplayer = multiplayer;
+ }
+
+ /// <summary>Get a new multiplayer ID.</summary>
+ public long GetNewID()
+ {
+ return this.Multiplayer.getNewID();
+ }
+ }
+}
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs
index 7578473b..b206879c 100644
--- a/src/SMAPI/Framework/SGame.cs
+++ b/src/SMAPI/Framework/SGame.cs
@@ -126,6 +126,9 @@ namespace StardewModdingAPI.Framework
/// <summary>SMAPI's content manager.</summary>
public ContentCore ContentCore { get; private set; }
+ /// <summary>The game's core multiplayer utility.</summary>
+ public SMultiplayer Multiplayer => (SMultiplayer)Game1.multiplayer;
+
/// <summary>Whether SMAPI should log more information about the game context.</summary>
public bool VerboseLogging { get; set; }