summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Patching
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework/Patching')
-rw-r--r--src/SMAPI/Framework/Patching/GamePatcher.cs10
-rw-r--r--src/SMAPI/Framework/Patching/IHarmonyPatch.cs8
-rw-r--r--src/SMAPI/Framework/Patching/PatchHelper.cs2
3 files changed, 19 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/Patching/GamePatcher.cs b/src/SMAPI/Framework/Patching/GamePatcher.cs
index f82159d0..82d7b9c8 100644
--- a/src/SMAPI/Framework/Patching/GamePatcher.cs
+++ b/src/SMAPI/Framework/Patching/GamePatcher.cs
@@ -1,5 +1,9 @@
using System;
+#if HARMONY_2
+using HarmonyLib;
+#else
using Harmony;
+#endif
namespace StardewModdingAPI.Framework.Patching
{
@@ -27,7 +31,11 @@ namespace StardewModdingAPI.Framework.Patching
/// <param name="patches">The patches to apply.</param>
public void Apply(params IHarmonyPatch[] patches)
{
- HarmonyInstance harmony = HarmonyInstance.Create("io.smapi");
+#if HARMONY_2
+ Harmony harmony = new Harmony("SMAPI");
+#else
+ HarmonyInstance harmony = HarmonyInstance.Create("SMAPI");
+#endif
foreach (IHarmonyPatch patch in patches)
{
try
diff --git a/src/SMAPI/Framework/Patching/IHarmonyPatch.cs b/src/SMAPI/Framework/Patching/IHarmonyPatch.cs
index cb42f40e..922243fa 100644
--- a/src/SMAPI/Framework/Patching/IHarmonyPatch.cs
+++ b/src/SMAPI/Framework/Patching/IHarmonyPatch.cs
@@ -1,4 +1,8 @@
+#if HARMONY_2
+using HarmonyLib;
+#else
using Harmony;
+#endif
namespace StardewModdingAPI.Framework.Patching
{
@@ -10,6 +14,10 @@ namespace StardewModdingAPI.Framework.Patching
/// <summary>Apply the Harmony patch.</summary>
/// <param name="harmony">The Harmony instance.</param>
+#if HARMONY_2
+ void Apply(Harmony harmony);
+#else
void Apply(HarmonyInstance harmony);
+#endif
}
}
diff --git a/src/SMAPI/Framework/Patching/PatchHelper.cs b/src/SMAPI/Framework/Patching/PatchHelper.cs
index 4cb436f0..d1aa0185 100644
--- a/src/SMAPI/Framework/Patching/PatchHelper.cs
+++ b/src/SMAPI/Framework/Patching/PatchHelper.cs
@@ -1,3 +1,4 @@
+#if !HARMONY_2
using System;
using System.Collections.Generic;
@@ -32,3 +33,4 @@ namespace StardewModdingAPI.Framework.Patching
}
}
}
+#endif