diff --git a/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt index aaff43832d..42a462e348 100644 --- a/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/strava/subscription/patch/UnlockSubscriptionPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.strava.subscription.patch +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -7,7 +8,6 @@ import app.revanced.patcher.annotation.Package import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFingerprint @@ -15,15 +15,9 @@ import app.revanced.patches.strava.subscription.fingerprints.GetSubscribedFinger @Name("Unlock subscription features") @Description("Unlocks \"Matched Runs\" and \"Segment Efforts\".") @Compatibility([Package("com.strava", ["320.12"])]) -class UnlockSubscriptionPatch : BytecodePatch( - listOf(GetSubscribedFingerprint) -) { - override fun execute(context: BytecodeContext) { - val result = GetSubscribedFingerprint.result - ?: throw PatchException("Fingerprint not found") - val patternScanResult = result.scanResult.patternScanResult - ?: throw PatchException("Fingerprint pattern not found") - - result.mutableMethod.replaceInstruction(patternScanResult.startIndex, "const/4 v0, 0x1") - } -} +class UnlockSubscriptionPatch : BytecodePatch(listOf(GetSubscribedFingerprint)) { + override fun execute(context: BytecodeContext) = GetSubscribedFingerprint.result?.let { result -> + val isSubscribedIndex = result.scanResult.patternScanResult!!.startIndex + result.mutableMethod.replaceInstruction(isSubscribedIndex, "const/4 v0, 0x1") + } ?: throw GetSubscribedFingerprint.exception +} \ No newline at end of file