diff --git a/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt b/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt index 8963b017..d5dc5c61 100644 --- a/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt +++ b/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt @@ -36,13 +36,18 @@ private fun Class<*>.findAnnotationRecursively( } object PatchExtensions { - val Class>.patchName: String - get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName + val Class>.patchName: String get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName val Class>.version get() = recursiveAnnotation(Version::class)?.version val Class>.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include val Class>.description get() = recursiveAnnotation(Description::class)?.description val Class>.dependencies get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Dependencies::class)?.dependencies val Class>.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages + + @JvmStatic + fun Class>.dependsOn(patch: Class>): Boolean { + if (this.patchName == patch.patchName) throw IllegalArgumentException("thisval and patch may not be the same") + return this.dependencies?.any { it.java.patchName == this@dependsOn.patchName } == true + } } object MethodFingerprintExtensions {