mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-04-30 21:34:25 +02:00
refactor: convert Patch to abstract class
BREAKING CHANGE: Patch class is now an abstract class. You must implement it. You can use anonymous implements, like done in the tests.
This commit is contained in:
parent
428f7f4dec
commit
cb9b1b9416
@ -1,9 +1,5 @@
|
||||
package net.revanced.patcher.patch
|
||||
|
||||
class Patch(val patchName: String, val fn: () -> PatchResult) {
|
||||
fun execute(): PatchResult {
|
||||
return fn()
|
||||
}
|
||||
abstract class Patch(val patchName: String) {
|
||||
abstract fun execute(): PatchResult
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.revanced.patcher
|
||||
|
||||
import net.revanced.patcher.patch.Patch
|
||||
import net.revanced.patcher.patch.PatchResult
|
||||
import net.revanced.patcher.patch.PatchResultSuccess
|
||||
import net.revanced.patcher.signature.Signature
|
||||
import net.revanced.patcher.util.ExtraTypes
|
||||
@ -46,7 +47,8 @@ internal class PatcherTest {
|
||||
val patcher = Patcher(testData, testSigs)
|
||||
|
||||
patcher.addPatches(
|
||||
Patch ("TestPatch") {
|
||||
object : Patch("TestPatch") {
|
||||
override fun execute(): PatchResult {
|
||||
// Get the method from the resolver cache
|
||||
val mainMethod = patcher.cache.methods["mainMethod"]
|
||||
// Get the instruction list
|
||||
@ -101,7 +103,8 @@ internal class PatcherTest {
|
||||
// You can also return PatchResultError with a message.
|
||||
// If an exception is thrown inside this function,
|
||||
// a PatchResultError will be returned with the error message.
|
||||
PatchResultSuccess()
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user