mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
fix: Delegate PatchBundleLoader
by mutable set of patches
This commit is contained in:
parent
d49e4ee5ea
commit
9a109c129b
1 changed files with 7 additions and 3 deletions
|
@ -28,12 +28,17 @@ typealias PatchClass = KClass<out Patch<*>>
|
||||||
*
|
*
|
||||||
* @param getBinaryClassNames A function that returns the binary names of all classes in a patch bundle.
|
* @param getBinaryClassNames A function that returns the binary names of all classes in a patch bundle.
|
||||||
* @param classLoader The [ClassLoader] to use for loading the classes.
|
* @param classLoader The [ClassLoader] to use for loading the classes.
|
||||||
|
* @param patchBundles A set of patches to initialize this instance with.
|
||||||
*/
|
*/
|
||||||
sealed class PatchBundleLoader private constructor(
|
sealed class PatchBundleLoader private constructor(
|
||||||
classLoader: ClassLoader,
|
classLoader: ClassLoader,
|
||||||
patchBundles: Array<out File>,
|
patchBundles: Array<out File>,
|
||||||
getBinaryClassNames: (patchBundle: File) -> List<String>,
|
getBinaryClassNames: (patchBundle: File) -> List<String>,
|
||||||
) : PatchSet by mutableSetOf() {
|
// This constructor parameter is unfortunately necessary,
|
||||||
|
// so that a reference to the mutable set is present in the constructor to be able to add patches to it.
|
||||||
|
// because the instance itself is a PatchSet, which is immutable, that is delegated by the parameter.
|
||||||
|
private val patchSet: MutableSet<Patch<*>> = mutableSetOf()
|
||||||
|
) : PatchSet by patchSet {
|
||||||
private val logger = Logger.getLogger(PatchBundleLoader::class.java.name)
|
private val logger = Logger.getLogger(PatchBundleLoader::class.java.name)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -46,8 +51,7 @@ sealed class PatchBundleLoader private constructor(
|
||||||
}.filter {
|
}.filter {
|
||||||
it.name != null
|
it.name != null
|
||||||
}.let { patches ->
|
}.let { patches ->
|
||||||
@Suppress("UNCHECKED_CAST")
|
patchSet.addAll(patches)
|
||||||
(this as MutableSet<Patch<*>>).addAll(patches)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue