mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-01 16:25:31 +08:00
Changed some function and add new function to demo
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -5,13 +5,14 @@
|
||||
<map>
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.4169230769230769" />
|
||||
<entry key="app_demo/src/main/res/layout/activity_main.xml" value="0.4375" />
|
||||
<entry key="demo-app/src/main/res/layout/activity_main.xml" value="0.4375" />
|
||||
<entry key="demo-module/src/main/res/layout/activity_main.xml" value="0.4375" />
|
||||
<entry key="demo/src/main/res/layout/activity_main.xml" value="0.4375" />
|
||||
<entry key="module_demo/src/main/res/layout/activity_main.xml" value="0.4375" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@@ -41,6 +41,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -30,28 +30,31 @@
|
||||
package com.highcapable.yukihookapi.demo_app.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.highcapable.yukihookapi.demo_app.R
|
||||
import com.highcapable.yukihookapi.demo_app.databinding.ActivityMainBinding
|
||||
import com.highcapable.yukihookapi.demo_app.utils.Main
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
findViewById<TextView>(R.id.app_demo_first_text).text = getFirstText()
|
||||
findViewById<TextView>(R.id.app_demo_second_text).text = secondText
|
||||
findViewById<TextView>(R.id.app_demo_third_text).text = Main("Feel real").getString()
|
||||
findViewById<TextView>(R.id.app_demo_fourth_text).text = getRegularText("Have fun day")
|
||||
findViewById<TextView>(R.id.app_demo_fifth_text).text = getDataText()
|
||||
findViewById<Button>(R.id.app_demo_button).setOnClickListener { toast() }
|
||||
ActivityMainBinding.inflate(layoutInflater).apply {
|
||||
setContentView(root)
|
||||
appDemoFirstText.text = getFirstText()
|
||||
appDemoSecondText.text = secondText
|
||||
appDemoThirdText.text = Main(string = "Feel real").getString()
|
||||
appDemoFourthText.text = getRegularText(string = "Have fun day")
|
||||
appDemoFifthText.text = getDataText()
|
||||
appDemoSixthText.text = getArray(arrayOf("apple", "banana")).let { "${it[0]}, ${it[1]}" }
|
||||
appDemoButton.setOnClickListener { toast() }
|
||||
}
|
||||
}
|
||||
|
||||
private val secondText = "This is a miracle"
|
||||
|
||||
private fun getArray(array: Array<String>) = array
|
||||
|
||||
private fun getFirstText() = "Hello World!"
|
||||
|
||||
private fun getRegularText(string: String) = string
|
||||
|
@@ -47,6 +47,14 @@
|
||||
android:text="sample"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_demo_sixth_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="sample"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/app_demo_button"
|
||||
android:layout_width="wrap_content"
|
||||
|
@@ -42,6 +42,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -32,6 +32,7 @@ import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
||||
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
||||
import com.highcapable.yukihookapi.hook.type.android.BundleClass
|
||||
import com.highcapable.yukihookapi.hook.type.java.StringArrayClass
|
||||
import com.highcapable.yukihookapi.hook.type.java.StringType
|
||||
import com.highcapable.yukihookapi.hook.type.java.UnitType
|
||||
import com.highcapable.yukihookapi.hook.xposed.proxy.YukiHookXposedInitProxy
|
||||
@@ -101,6 +102,19 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
}
|
||||
// 注入要 Hook 的方法
|
||||
injectMember {
|
||||
method {
|
||||
name = "getArray"
|
||||
param(StringArrayClass)
|
||||
returnType = StringArrayClass
|
||||
}
|
||||
// 在方法执行之前拦截
|
||||
beforeHook {
|
||||
// 设置 0 号 param
|
||||
args().array<String>()[0] = "peach"
|
||||
}
|
||||
}
|
||||
// 注入要 Hook 的方法
|
||||
injectMember {
|
||||
method {
|
||||
name = "toast"
|
||||
|
@@ -30,13 +30,10 @@
|
||||
package com.highcapable.yukihookapi.demo_module.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.highcapable.yukihookapi.demo_module.R
|
||||
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
||||
import com.highcapable.yukihookapi.demo_module.databinding.ActivityMainBinding
|
||||
import com.highcapable.yukihookapi.hook.factory.isModuleActive
|
||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||
@@ -45,17 +42,19 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
findViewById<TextView>(R.id.module_demo_text).text = "Module is Active -> $isModuleActive\n" +
|
||||
"Hook Framework -> ${YukiHookModuleStatus.executorName}\n" +
|
||||
"API Version -> ${YukiHookModuleStatus.executorVersion}"
|
||||
findViewById<EditText>(R.id.module_demo_edit_text).also {
|
||||
it.setText(modulePrefs.get(DataConst.TEST_KV_DATA))
|
||||
findViewById<Button>(R.id.module_demo_button).setOnClickListener { _ ->
|
||||
if (it.text.toString().isNotEmpty()) {
|
||||
modulePrefs.put(DataConst.TEST_KV_DATA, it.text.toString())
|
||||
Toast.makeText(applicationContext, "Saved", Toast.LENGTH_SHORT).show()
|
||||
} else Toast.makeText(applicationContext, "Please enter the text", Toast.LENGTH_SHORT).show()
|
||||
ActivityMainBinding.inflate(layoutInflater).apply {
|
||||
setContentView(root)
|
||||
moduleDemoText.text = "Module is Active -> $isModuleActive\n" +
|
||||
"Hook Framework -> ${YukiHookModuleStatus.executorName}\n" +
|
||||
"API Version -> ${YukiHookModuleStatus.executorVersion}"
|
||||
moduleDemoEditText.also {
|
||||
it.setText(modulePrefs.get(DataConst.TEST_KV_DATA))
|
||||
moduleDemoButton.setOnClickListener { _ ->
|
||||
if (it.text.toString().isNotEmpty()) {
|
||||
modulePrefs.put(DataConst.TEST_KV_DATA, it.text.toString())
|
||||
Toast.makeText(applicationContext, "Saved", Toast.LENGTH_SHORT).show()
|
||||
} else Toast.makeText(applicationContext, "Please enter the text", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -145,83 +145,6 @@ class FieldFinder(
|
||||
Instance(instance, self = null)
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到变量实例
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [T] or null
|
||||
*/
|
||||
fun <T> of(instance: Any? = null) = get(instance).self as? T?
|
||||
|
||||
/**
|
||||
* 得到变量的 [Int] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Int] 取不到返回 0
|
||||
*/
|
||||
fun ofInt(instance: Any? = null) = of(instance) ?: 0
|
||||
|
||||
/**
|
||||
* 得到变量的 [Long] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Long] 取不到返回 0L
|
||||
*/
|
||||
fun ofLong(instance: Any? = null) = of(instance) ?: 0L
|
||||
|
||||
/**
|
||||
* 得到变量的 [Short] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Short] 取不到返回 0
|
||||
*/
|
||||
fun ofShort(instance: Any? = null) = of<Short?>(instance) ?: 0
|
||||
|
||||
/**
|
||||
* 得到变量的 [Double] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Double] 取不到返回 0.0
|
||||
*/
|
||||
fun ofDouble(instance: Any? = null) = of(instance) ?: 0.0
|
||||
|
||||
/**
|
||||
* 得到变量的 [Float] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Float] 取不到返回 0f
|
||||
*/
|
||||
fun ofFloat(instance: Any? = null) = of(instance) ?: 0f
|
||||
|
||||
/**
|
||||
* 得到变量的 [String] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [String] 取不到返回 ""
|
||||
*/
|
||||
fun ofString(instance: Any? = null) = of(instance) ?: ""
|
||||
|
||||
/**
|
||||
* 得到变量的 [Boolean] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Boolean] 取不到返回 false
|
||||
*/
|
||||
fun ofBoolean(instance: Any? = null) = of(instance) ?: false
|
||||
|
||||
/**
|
||||
* 得到变量的 [Any] 实例
|
||||
* @param instance 变量所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [Any] or null
|
||||
*/
|
||||
fun ofAny(instance: Any? = null) = of<Any?>(instance)
|
||||
|
||||
/**
|
||||
* 得到变量本身
|
||||
* @return [Field] or null
|
||||
@@ -256,6 +179,106 @@ class FieldFinder(
|
||||
*/
|
||||
inner class Instance(private val instance: Any?, val self: Any?) {
|
||||
|
||||
/**
|
||||
* 得到变量实例
|
||||
* @return [T] or null
|
||||
*/
|
||||
fun <T> cast() = get(instance).self as? T?
|
||||
|
||||
/**
|
||||
* 得到变量的 [Byte] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回 null
|
||||
* @return [Byte] or null
|
||||
*/
|
||||
fun byte() = cast<Byte?>()
|
||||
|
||||
/**
|
||||
* 得到变量的 [Int] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Int] 取不到返回 0
|
||||
*/
|
||||
fun int() = cast() ?: 0
|
||||
|
||||
/**
|
||||
* 得到变量的 [Long] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Long] 取不到返回 0L
|
||||
*/
|
||||
fun long() = cast() ?: 0L
|
||||
|
||||
/**
|
||||
* 得到变量的 [Short] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Short] 取不到返回 0
|
||||
*/
|
||||
fun short() = cast<Short?>() ?: 0
|
||||
|
||||
/**
|
||||
* 得到变量的 [Double] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Double] 取不到返回 0.0
|
||||
*/
|
||||
fun double() = cast() ?: 0.0
|
||||
|
||||
/**
|
||||
* 得到变量的 [Float] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Float] 取不到返回 0f
|
||||
*/
|
||||
fun float() = cast() ?: 0f
|
||||
|
||||
/**
|
||||
* 得到变量的 [String] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [String] 取不到返回 ""
|
||||
*/
|
||||
fun string() = cast() ?: ""
|
||||
|
||||
/**
|
||||
* 得到变量的 [Char] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Char] 取不到返回 ' '
|
||||
*/
|
||||
fun char() = cast() ?: ' '
|
||||
|
||||
/**
|
||||
* 得到变量的 [Boolean] 实例
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回默认值
|
||||
* @return [Boolean] 取不到返回 false
|
||||
*/
|
||||
fun boolean() = cast() ?: false
|
||||
|
||||
/**
|
||||
* 得到变量的 [Any] 实例
|
||||
* @return [Any] or null
|
||||
*/
|
||||
fun any() = cast<Any?>()
|
||||
|
||||
/**
|
||||
* 得到变量的 [Array] 实例 - 每项类型 [T]
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回空数组
|
||||
* @return [Array] 取不到返回空数组
|
||||
*/
|
||||
inline fun <reified T> array() = cast() ?: arrayOf<T>()
|
||||
|
||||
/**
|
||||
* 得到变量的 [List] 实例 - 每项类型 [T]
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回空数组
|
||||
* @return [List] 取不到返回空数组
|
||||
*/
|
||||
inline fun <reified T> list() = cast() ?: listOf<T>()
|
||||
|
||||
/**
|
||||
* 设置变量实例
|
||||
* @param any 设置的实例内容
|
||||
|
@@ -360,6 +360,15 @@ class MethodFinder(
|
||||
*/
|
||||
fun <T> invoke(vararg param: Any?) = baseCall(*param) as? T?
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Byte] 返回值类型
|
||||
*
|
||||
* - ❗请确认目标变量的类型 - 发生错误会返回 null
|
||||
* @param param 方法参数
|
||||
* @return [Byte] or null
|
||||
*/
|
||||
fun byte(vararg param: Any?) = invoke<Byte?>(*param)
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Int] 返回值类型
|
||||
*
|
||||
@@ -367,7 +376,7 @@ class MethodFinder(
|
||||
* @param param 方法参数
|
||||
* @return [Int] 取不到返回 0
|
||||
*/
|
||||
fun callInt(vararg param: Any?) = invoke(*param) ?: 0
|
||||
fun int(vararg param: Any?) = invoke(*param) ?: 0
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Long] 返回值类型
|
||||
@@ -376,7 +385,7 @@ class MethodFinder(
|
||||
* @param param 方法参数
|
||||
* @return [Long] 取不到返回 0L
|
||||
*/
|
||||
fun callLong(vararg param: Any?) = invoke(*param) ?: 0L
|
||||
fun long(vararg param: Any?) = invoke(*param) ?: 0L
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Short] 返回值类型
|
||||
@@ -385,7 +394,7 @@ class MethodFinder(
|
||||
* @param param 方法参数
|
||||
* @return [Short] 取不到返回 0
|
||||
*/
|
||||
fun callShort(vararg param: Any?) = invoke<Short?>(*param) ?: 0
|
||||
fun short(vararg param: Any?) = invoke<Short?>(*param) ?: 0
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Double] 返回值类型
|
||||
@@ -394,7 +403,7 @@ class MethodFinder(
|
||||
* @param param 方法参数
|
||||
* @return [Double] 取不到返回 0.0
|
||||
*/
|
||||
fun callDouble(vararg param: Any?) = invoke(*param) ?: 0.0
|
||||
fun double(vararg param: Any?) = invoke(*param) ?: 0.0
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Float] 返回值类型
|
||||
@@ -403,14 +412,21 @@ class MethodFinder(
|
||||
* @param param 方法参数
|
||||
* @return [Float] 取不到返回 0f
|
||||
*/
|
||||
fun callFloat(vararg param: Any?) = invoke(*param) ?: 0f
|
||||
fun float(vararg param: Any?) = invoke(*param) ?: 0f
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [String] 返回值类型
|
||||
* @param param 方法参数
|
||||
* @return [String] 取不到返回 ""
|
||||
*/
|
||||
fun callString(vararg param: Any?) = invoke(*param) ?: ""
|
||||
fun string(vararg param: Any?) = invoke(*param) ?: ""
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Char] 返回值类型
|
||||
* @param param 方法参数
|
||||
* @return [Char] 取不到返回 ' '
|
||||
*/
|
||||
fun char(vararg param: Any?) = invoke(*param) ?: ' '
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Boolean] 返回值类型
|
||||
@@ -419,7 +435,23 @@ class MethodFinder(
|
||||
* @param param 方法参数
|
||||
* @return [Boolean] 取不到返回 false
|
||||
*/
|
||||
fun callBoolean(vararg param: Any?) = invoke(*param) ?: false
|
||||
fun boolean(vararg param: Any?) = invoke(*param) ?: false
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [Array] 返回值类型 - 每项类型 [T]
|
||||
*
|
||||
* - ❗请确认目标方法的返回值 - 发生错误会返回空数组
|
||||
* @return [Array] 取不到返回空数组
|
||||
*/
|
||||
inline fun <reified T> array(vararg param: Any?) = invoke(*param) ?: arrayOf<T>()
|
||||
|
||||
/**
|
||||
* 执行方法 - 指定 [List] 返回值类型 - 每项类型 [T]
|
||||
*
|
||||
* - ❗请确认目标方法的返回值 - 发生错误会返回空数组
|
||||
* @return [List] 取不到返回空数组
|
||||
*/
|
||||
inline fun <reified T> list(vararg param: Any?) = invoke(*param) ?: listOf<T>()
|
||||
|
||||
override fun toString() =
|
||||
"[${(memberInstance as? Method?)?.name ?: "<empty>"}] in [${instance?.javaClass?.name ?: "<empty>"}]"
|
||||
|
@@ -171,7 +171,15 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* 得到方法参数的实例对象 [T]
|
||||
* @return [T] or null
|
||||
*/
|
||||
fun <T> of() = runCatching { args[index] as? T? }.getOrNull()
|
||||
fun <T> cast() = runCatching { args[index] as? T? }.getOrNull()
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Byte]
|
||||
*
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回 null
|
||||
* @return [Byte] or null
|
||||
*/
|
||||
fun byte() = cast<Byte?>()
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Int]
|
||||
@@ -179,7 +187,7 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Int] 取不到返回 0
|
||||
*/
|
||||
fun ofInt() = of() ?: 0
|
||||
fun int() = cast() ?: 0
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Long]
|
||||
@@ -187,7 +195,7 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Long] 取不到返回 0L
|
||||
*/
|
||||
fun ofLong() = of() ?: 0L
|
||||
fun long() = cast() ?: 0L
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Short]
|
||||
@@ -195,7 +203,7 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Short] 取不到返回 0
|
||||
*/
|
||||
fun ofShort() = of<Short?>() ?: 0
|
||||
fun short() = cast<Short?>() ?: 0
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Double]
|
||||
@@ -203,7 +211,7 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Double] 取不到返回 0.0
|
||||
*/
|
||||
fun ofDouble() = of() ?: 0.0
|
||||
fun double() = cast() ?: 0.0
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Float]
|
||||
@@ -211,7 +219,7 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Float] 取不到返回 0f
|
||||
*/
|
||||
fun ofFloat() = of() ?: 0f
|
||||
fun float() = cast() ?: 0f
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [String]
|
||||
@@ -219,7 +227,15 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [String] 取不到返回 ""
|
||||
*/
|
||||
fun ofString() = of() ?: ""
|
||||
fun string() = cast() ?: ""
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Char]
|
||||
*
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Char] 取不到返回 ' '
|
||||
*/
|
||||
fun char() = cast() ?: ' '
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Boolean]
|
||||
@@ -227,7 +243,23 @@ class HookParam(private val wrapper: HookParamWrapper) {
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回默认值
|
||||
* @return [Boolean] 取不到返回 false
|
||||
*/
|
||||
fun ofBoolean() = of() ?: false
|
||||
fun boolean() = cast() ?: false
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [Array] - 每项类型 [T]
|
||||
*
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回空数组
|
||||
* @return [Array] 取不到返回空数组
|
||||
*/
|
||||
inline fun <reified T> array() = cast() ?: arrayOf<T>()
|
||||
|
||||
/**
|
||||
* 得到方法参数的实例对象 [List] - 每项类型 [T]
|
||||
*
|
||||
* - ❗请确认目标参数的类型 - 发生错误会返回空数组
|
||||
* @return [List] 取不到返回空数组
|
||||
*/
|
||||
inline fun <reified T> list() = cast() ?: listOf<T>()
|
||||
|
||||
/**
|
||||
* 设置方法参数的实例对象
|
||||
|
Reference in New Issue
Block a user