Skip to content

Commit

Permalink
Update KetherParser
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFloodDragon committed Jul 29, 2023
1 parent 5b94b60 commit 3381af2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val taboolibModules = setOf(
"common",
"common-5",
"module-nms",
// "module-nms-util",
"module-nms-util",
"module-kether",
"module-configuration",
"module-lang",
Expand Down
9 changes: 8 additions & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ fun RepositoryHandler.projectRepositories() {
mavenCentral()
}

/**
* KotlinJson序列化工具
*/
fun DependencyHandler.serialization() {
add("compileOnly", "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
}

/**
* NMS依赖
*/
Expand Down Expand Up @@ -85,7 +92,7 @@ fun DependencyHandler.compileAll() {
/**
* 依赖Taboolib模块——仅编译时
* @param module Taboolib模块名称
* @param version Taboolib模块版本,默认为Taboolib班恩
* @param version Taboolib模块版本,默认为Taboolib版本
*/
fun DependencyHandler.installTaboo(vararg module: String, version: String = taboolibVersion) = module.forEach {
add("compileOnly", "io.izzel.taboolib:$it:$version")
Expand Down
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
}

}
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>
)
10 changes: 10 additions & 0 deletions project/module-itemstack/build.gradle.kts
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")
}
2 changes: 2 additions & 0 deletions project/module-script/build.gradle.kts
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")
}

0 comments on commit 3381af2

Please sign in to comment.