Skip to content

Commit

Permalink
[6.2.0][dev] 修复 @awake 在缺少参数时直接报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Bkm016 committed Oct 1, 2024
1 parent 9252eeb commit d2bd6c4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package taboolib.common.platform
import org.tabooproject.reflex.ClassMethod
import org.tabooproject.reflex.ReflexClass
import taboolib.common.LifeCycle
import taboolib.common.TabooLib
import taboolib.common.inject.ClassVisitor
import taboolib.common.platform.function.warning

class ClassVisitorAwake(private val lifeCycle: LifeCycle) : ClassVisitor(0) {

override fun visit(method: ClassMethod, owner: ReflexClass) {
if (method.getAnnotationIfPresent(Awake::class.java)?.enumName("value") == lifeCycle.name) {
val enumName = method.getAnnotationIfPresent(Awake::class.java)?.enumName("value", "") ?: return
if (enumName == "") {
warning("Missing parameter in @Awake annotation: ${owner.name}#${method.name}")
return
}
if (enumName == lifeCycle.name) {
val instance = findInstance(owner)
if (instance != null) {
method.invoke(instance)
Expand Down

0 comments on commit d2bd6c4

Please sign in to comment.