-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b94b60
commit 3381af2
Showing
6 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
project/module-core/src/main/kotlin/cn/fd/utilities/core/api/kether/KetherLoaderF.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cc.trixey.invero.core.script.loader | ||
|
||
import cn.fd.utilities.core.api.kether.KetherParserF | ||
import taboolib.common.LifeCycle | ||
import taboolib.common.inject.ClassVisitor | ||
import taboolib.common.platform.Awake | ||
import taboolib.library.reflex.ClassMethod | ||
import taboolib.module.kether.KetherLoader.Companion.registerParser | ||
import taboolib.module.kether.ScriptActionParser | ||
import java.util.function.Supplier | ||
|
||
/** | ||
* @author 蛟龙 | ||
* @since 2023/7/29 12:16 | ||
*/ | ||
@Awake | ||
class KetherLoaderF : ClassVisitor(0) { | ||
|
||
override fun visit(method: ClassMethod, clazz: Class<*>, instance: Supplier<*>?) { | ||
if (method.isAnnotationPresent(KetherParserF::class.java) && method.returnType == ScriptActionParser::class.java) { | ||
val parser = (if (instance == null) method.invokeStatic() else method.invoke(instance.get())) | ||
val annotation = method.getAnnotation(KetherParserF::class.java) | ||
val value = annotation.property<Array<String>>("name") ?: emptyArray() | ||
|
||
registerParser(parser as ScriptActionParser<*>, value, "fdutilities", true) | ||
} | ||
} | ||
|
||
override fun getLifeCycle(): LifeCycle { | ||
return LifeCycle.LOAD | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
project/module-core/src/main/kotlin/cn/fd/utilities/core/api/kether/KetherParserF.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cn.fd.utilities.core.api.kether | ||
|
||
/** | ||
* @author 蛟龙 | ||
* @since 2023/7/29 12:11 | ||
*/ | ||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class KetherParserF( | ||
val name: Array<String> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
kotlin("plugin.serialization") version "1.8.21" | ||
} | ||
|
||
dependencies { | ||
serialization() | ||
compileModule("module-core") | ||
compileModule("module-common") | ||
installTaboo("platform-bukkit") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
dependencies { | ||
compileModule("module-core") | ||
compileModule("module-common") | ||
compileModule("runtime-bukkit") | ||
installTaboo("platform-bukkit") | ||
} |