Remove useless duplicated code in ForgeInit.kt
This commit is contained in:
parent
2b49238ee7
commit
530ecb36cb
|
@ -11,12 +11,13 @@ import org.apache.logging.log4j.Logger
|
|||
import java.lang.reflect.Modifier
|
||||
|
||||
abstract class Snowy {
|
||||
protected fun Class<*>.isValidForButtonCollection(): Boolean = (!((Modifier.isAbstract(javaClass.modifiers)) || javaClass.annotations.any { it is ButtonInfo && it.ignored }))
|
||||
protected fun Class<*>.isValidForButtonCollection(): Boolean =
|
||||
!Modifier.isAbstract(modifiers) && declaredAnnotations.any { it is ButtonInfo && !it.ignored }
|
||||
private val displayInitMessage: Boolean by Configuration
|
||||
companion object {
|
||||
val MissingComponent: TranslatableComponent = object: TranslatableComponent(null) { override fun getString(): String = "MISSING_COMPONENT" }
|
||||
@JvmStatic
|
||||
protected val FeaturePackage: String = "fr.username404.snowygui.gui.feature"
|
||||
protected val FeaturePackage: String = ButtonInfo::class.java.packageName
|
||||
lateinit var annotatedButtons: Set<Class<out ButtonImpl>>
|
||||
fun onEvent(e: Any, lambda: argsLambda) = useKey(e.toString()).add(lambda)
|
||||
@JvmField
|
||||
|
|
|
@ -4,7 +4,6 @@ import fr.username404.snowygui.Snowy
|
|||
import fr.username404.snowygui.config.SnowyConfigScreen
|
||||
import fr.username404.snowygui.config.configScreenParent
|
||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo
|
||||
import net.minecraftforge.fml.ExtensionPoint
|
||||
import net.minecraftforge.fml.ModList
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
|
@ -34,13 +33,7 @@ class ForgeInit: Snowy() {
|
|||
.flatMap { obj: Set<ModFileScanData.ClassData?> -> obj.stream() }
|
||||
.filter { data: ModFileScanData.ClassData? ->
|
||||
(data!!.javaClass.getDeclaredField("clazz").apply { isAccessible = true }.get(data) as Type).className.let { classname ->
|
||||
classname.startsWith(FeaturePackage).let {
|
||||
it && with(Class.forName(classname)) {
|
||||
isValidForButtonCollection() && declaredAnnotations.any { annotation ->
|
||||
annotation is ButtonInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
classname.startsWith(FeaturePackage) && Class.forName(classname).isValidForButtonCollection()
|
||||
}
|
||||
}
|
||||
.map { Class.forName((it!!.javaClass.getDeclaredField("clazz").apply { isAccessible = true }.get(it) as Type).className).asSubclass(ButtonImpl::class.java)}
|
||||
|
|
Loading…
Reference in New Issue