mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-12-10 23:33:42 +08:00
Added more function in MethodFinder, ConstructorFinder, FieldFinder
This commit is contained in:
@@ -16,6 +16,8 @@ class ConstructorFinder internal constructor(override val hookInstance: YukiMemb
|
||||
|
||||
> `Constructor` 查找类。
|
||||
|
||||
可通过指定类型查找指定构造方法或一组构造方法。
|
||||
|
||||
### paramCount [field]
|
||||
|
||||
```kotlin
|
||||
@@ -112,6 +114,24 @@ fun paramCount(num: Int): IndexTypeCondition
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### paramCount [method]
|
||||
|
||||
```kotlin
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### superClass [method]
|
||||
|
||||
```kotlin
|
||||
@@ -160,7 +180,7 @@ inline fun constructor(initiate: ConstructorFinder.() -> Unit)
|
||||
|
||||
> 创建需要重新查找的 `Constructor`。
|
||||
|
||||
你可以添加多个备选构造方法,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
你可以添加多个备选 `Constructor`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
#### Result [class]
|
||||
|
||||
@@ -179,13 +199,17 @@ inner class Result internal constructor()
|
||||
##### onFind [method]
|
||||
|
||||
```kotlin
|
||||
fun onFind(initiate: Constructor<*>.() -> Unit)
|
||||
fun onFind(initiate: HashSet<Constructor<*>>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.1` `新增`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
`initiate` 参数 `Constructor` 变为 `HashSet<Constructor>`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
@@ -207,13 +231,17 @@ constructor {
|
||||
### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val e: Throwable?)
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
继承到接口 `BaseResult`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 查找结果实现类。
|
||||
@@ -247,6 +275,7 @@ constructor {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get().call()
|
||||
all()
|
||||
remedys {}
|
||||
onNoSuchConstructor {}
|
||||
}
|
||||
@@ -266,6 +295,8 @@ fun get(): Instance
|
||||
|
||||
> 获得 `Constructor` 实例处理类。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 请使用 `wait` 回调结果方法。
|
||||
|
||||
**功能示例**
|
||||
@@ -300,6 +331,36 @@ constructor {
|
||||
}.get().newInstance<TestClass>("param1", "param2")
|
||||
```
|
||||
|
||||
#### all [method]
|
||||
|
||||
```kotlin
|
||||
fun all(): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Constructor` 实例结果并在 `isBindToHooker` 时设置到 `hookInstance`。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Constructor`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.all().forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
#### give [method]
|
||||
|
||||
```kotlin
|
||||
@@ -314,6 +375,28 @@ fun give(): Constructor<*>?
|
||||
|
||||
> 得到构造方法本身。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
#### giveAll [method]
|
||||
|
||||
```kotlin
|
||||
fun giveAll(): HashSet<Constructor<*>>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Constructor` 本身数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Constructor` 实例。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
#### wait [method]
|
||||
|
||||
```kotlin
|
||||
@@ -328,6 +411,28 @@ fun wait(initiate: Instance.() -> Unit)
|
||||
|
||||
> 获得 `Constructor` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### waitAll [method]
|
||||
|
||||
```kotlin
|
||||
fun waitAll(initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查询条件匹配的多个 `Constructor` 实例结果。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
@@ -348,11 +453,11 @@ inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建构造方法重查找功能。
|
||||
> 创建 `Constructor` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种构造方法可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找构造方法。
|
||||
当你遇到一种 `Constructor` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找 `Constructor`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
@@ -387,7 +492,7 @@ inline fun onNoSuchConstructor(result: (Throwable) -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到构造方法时。
|
||||
> 监听找不到 `Constructor` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
@@ -410,13 +515,17 @@ fun ignoredError(): Result
|
||||
#### Instance [class]
|
||||
|
||||
```kotlin
|
||||
inner class Instance internal constructor()
|
||||
inner class Instance internal constructor(private val constructor: Constructor<*>?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.2` `新增`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
新增 `constructor` 参数
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 实例处理类。
|
||||
@@ -433,7 +542,7 @@ fun call(vararg param: Any?): Any?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行构造方法创建目标实例,不指定目标实例类型。
|
||||
> 执行 `Constructor` 创建目标实例,不指定目标实例类型。
|
||||
|
||||
##### newInstance [method]
|
||||
|
||||
@@ -447,4 +556,4 @@ fun <T> newInstance(vararg param: Any?): T?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行构造方法创建目标实例 ,指定 `T` 目标实例类型。
|
||||
> 执行 `Constructor` 创建目标实例 ,指定 `T` 目标实例类型。
|
||||
Reference in New Issue
Block a user