mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Added more function in MethodFinder, ConstructorFinder, FieldFinder
This commit is contained in:
@@ -16,6 +16,8 @@ class FieldFinder internal constructor(override val hookInstance: YukiMemberHook
|
||||
|
||||
> `Field` 查找类。
|
||||
|
||||
可通过指定类型查找指定变量或一组变量。
|
||||
|
||||
### ~~classSet [field]~~ <!-- {docsify-ignore} -->
|
||||
|
||||
**变更记录**
|
||||
@@ -58,7 +60,7 @@ var type: Any?
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型,默认模糊查找并取第一个匹配的 `Field`。
|
||||
可不填写类型。
|
||||
|
||||
### modifiers [method]
|
||||
|
||||
@@ -78,7 +80,7 @@ inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
可不设置筛选条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -110,7 +112,7 @@ fun name(value: String): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -128,7 +130,7 @@ inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 名称条件。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -146,7 +148,7 @@ fun type(value: Any): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
!> 可不填写类型,默认模糊查找并取第一个匹配的 `Field`。
|
||||
!> 可不填写类型。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -166,16 +168,92 @@ fun superClass(isOnlySuperClass: Boolean)
|
||||
|
||||
!> 若当前 `classSet` 的父类较多可能会耗时,API 会自动循环到父类继承是 `Any` 前的最后一个类。
|
||||
|
||||
### RemedyPlan [class]
|
||||
|
||||
```kotlin
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
#### field [method]
|
||||
|
||||
```kotlin
|
||||
inline fun field(initiate: FieldFinder.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建需要重新查找的 `Field`。
|
||||
|
||||
你可以添加多个备选 `Field`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
#### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
##### onFind [method]
|
||||
|
||||
```kotlin
|
||||
fun onFind(initiate: HashSet<Field>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以方便地对重查找的 `Field` 实现 `onFind` 方法。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.onFind {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val e: Throwable?)
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
继承到接口 `BaseResult`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 查找结果实现类。
|
||||
@@ -212,22 +290,28 @@ field {
|
||||
get(instance).string()
|
||||
get(instance).cast<CustomClass>()
|
||||
get().boolean()
|
||||
all(instance)
|
||||
give()
|
||||
giveAll()
|
||||
onNoSuchField {}
|
||||
}
|
||||
```
|
||||
|
||||
#### get [method]
|
||||
|
||||
```kotlin
|
||||
fun get(instance: Any?): Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量实例处理类。
|
||||
> 获得 `Field` 实例处理类。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
**功能示例**
|
||||
|
||||
@@ -251,6 +335,36 @@ field {
|
||||
}.get().set("something")
|
||||
```
|
||||
|
||||
#### all [method]
|
||||
|
||||
```kotlin
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Field`,其变量所在实例用法与 `get` 相同。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.self
|
||||
}
|
||||
```
|
||||
|
||||
#### give [method]
|
||||
|
||||
```kotlin
|
||||
@@ -263,7 +377,104 @@ fun give(): Field?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量本身。
|
||||
> 得到 `Field` 本身。
|
||||
|
||||
若有多个 Field 结果只会返回第一个。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
#### giveAll [method]
|
||||
|
||||
```kotlin
|
||||
fun giveAll(): HashSet<Field>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Field` 本身数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Field` 实例。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
#### wait [method]
|
||||
|
||||
```kotlin
|
||||
fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### waitAll [method]
|
||||
|
||||
```kotlin
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查询条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### remedys [method]
|
||||
|
||||
```kotlin
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建 `Field` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种 `Field` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchField` 捕获异常二次查找 `Field`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.remedys {
|
||||
field {
|
||||
// Your code here.
|
||||
}
|
||||
field {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### onNoSuchField [method]
|
||||
|
||||
@@ -277,7 +488,7 @@ fun onNoSuchField(result: (Throwable) -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到变量时。
|
||||
> 监听找不到 `Field` 时。
|
||||
|
||||
#### ignoredError [method]
|
||||
|
||||
@@ -298,17 +509,37 @@ fun ignoredError(): Result
|
||||
#### Instance [class]
|
||||
|
||||
```kotlin
|
||||
inner class Instance internal constructor(private val instance: Any?, val self: Any?)
|
||||
inner class Instance internal constructor(private val instance: Any?, private val field: Field?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
新增 `field` 参数
|
||||
|
||||
移动 `self` 参数到类变量
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 实例变量处理类。
|
||||
|
||||
##### self [field]
|
||||
|
||||
```kotlin
|
||||
val self: Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获取当前 `Field` 自身的实例化对象。
|
||||
|
||||
##### cast [method]
|
||||
|
||||
```kotlin
|
||||
@@ -327,7 +558,7 @@ fun <T> cast(): T?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量实例。
|
||||
> 得到当前 `Field` 实例。
|
||||
|
||||
##### byte [method]
|
||||
|
||||
@@ -341,7 +572,7 @@ fun byte(): Byte?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Byte 实例。
|
||||
> 得到当前 `Field` Byte 实例。
|
||||
|
||||
##### int [method]
|
||||
|
||||
@@ -361,7 +592,7 @@ fun int(): Int
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Int 实例。
|
||||
> 得到当前 `Field` Int 实例。
|
||||
|
||||
##### long [method]
|
||||
|
||||
@@ -381,7 +612,7 @@ fun long(): Long
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Long 实例。
|
||||
> 得到当前 `Field` Long 实例。
|
||||
|
||||
##### short [method]
|
||||
|
||||
@@ -400,7 +631,7 @@ fun short(): Short
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Short 实例。
|
||||
> 得到当前 `Field` Short 实例。
|
||||
|
||||
##### double [method]
|
||||
|
||||
@@ -420,7 +651,7 @@ fun double(): Double
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Double 实例。
|
||||
> 得到当前 `Field` Double 实例。
|
||||
|
||||
##### float [method]
|
||||
|
||||
@@ -439,7 +670,7 @@ fun float(): Float
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Float 实例。
|
||||
> 得到当前 `Field` Float 实例。
|
||||
|
||||
##### string [method]
|
||||
|
||||
@@ -459,7 +690,7 @@ fun string(): String
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 String 实例。
|
||||
> 得到当前 `Field` String 实例。
|
||||
|
||||
##### char [method]
|
||||
|
||||
@@ -473,7 +704,7 @@ fun char(): Char
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Char 实例。
|
||||
> 得到当前 `Field` Char 实例。
|
||||
|
||||
##### boolean [method]
|
||||
|
||||
@@ -493,7 +724,7 @@ fun boolean(): Boolean
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Boolean 实例。
|
||||
> 得到当前 `Field` Boolean 实例。
|
||||
|
||||
##### any [method]
|
||||
|
||||
@@ -512,7 +743,7 @@ fun any(): Any?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Any 实例。
|
||||
> 得到当前 `Field` Any 实例。
|
||||
|
||||
##### array [method]
|
||||
|
||||
@@ -526,7 +757,7 @@ inline fun <reified T> array(): Array<T>
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Array 实例。
|
||||
> 得到当前 `Field` Array 实例。
|
||||
|
||||
##### list [method]
|
||||
|
||||
@@ -540,7 +771,7 @@ inline fun <reified T> list(): List<T>
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 List 实例。
|
||||
> 得到当前 `Field` List 实例。
|
||||
|
||||
##### set [method]
|
||||
|
||||
@@ -554,7 +785,7 @@ fun set(any: Any?)
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例。
|
||||
> 设置当前 `Field` 实例。
|
||||
|
||||
##### setTrue [method]
|
||||
|
||||
@@ -567,7 +798,7 @@ fun setTrue()
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例为 `true`。
|
||||
> 设置当前 `Field` 实例为 `true`。
|
||||
|
||||
!> 请确保实例对象类型为 `Boolean`。
|
||||
|
||||
@@ -583,7 +814,7 @@ fun setFalse()
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例为 `false`。
|
||||
> 设置当前 `Field` 实例为 `false`。
|
||||
|
||||
!> 请确保实例对象类型为 `Boolean`。
|
||||
|
||||
@@ -599,4 +830,4 @@ fun setNull()
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例为 `null`。
|
||||
> 设置当前 `Field` 实例为 `null`。
|
Reference in New Issue
Block a user