Use java reflection instead of kotlin-reflect in ButtonImpl.kt and reintroduce the alphabetical ordering of buttons
This commit is contained in:
parent
f4979bfa94
commit
7fd3e3f641
|
@ -10,10 +10,10 @@ import fr.username404.snowygui.misc.AddKeyMaps
|
|||
import io.github.config4k.getValue
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
import kotlin.reflect.full.hasAnnotation
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
abstract class Snowy {
|
||||
protected fun Class<*>.isValidForButtonCollection(): Boolean = (!(kotlin.isAbstract || kotlin.hasAnnotation<Ignored>()))
|
||||
protected fun Class<*>.isValidForButtonCollection(): Boolean = (!((Modifier.isAbstract(javaClass.modifiers)) || javaClass.isAnnotationPresent(Ignored::class.java)))
|
||||
private val displayInitMessage: Boolean by obtained
|
||||
companion object {
|
||||
val Gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()
|
||||
|
|
|
@ -33,7 +33,9 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||
}
|
||||
}.entries.forEach { entry ->
|
||||
with(entry) {
|
||||
value.forEach {
|
||||
value.sortedWith(
|
||||
compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }
|
||||
).forEach {
|
||||
key?.buttons!!.add(it)
|
||||
}
|
||||
}
|
||||
|
@ -44,9 +46,11 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||
((try {
|
||||
it.getConstructor().newInstance()
|
||||
} catch (e: NoSuchMethodException) {
|
||||
it.getDeclaredField("INSTANCE").get(null)
|
||||
}) as ButtonImpl)
|
||||
}.filterNot {
|
||||
try {
|
||||
it.getDeclaredField("INSTANCE").get(null)
|
||||
} catch (e: NoSuchFieldException) {}
|
||||
}) as? ButtonImpl)
|
||||
}.filterNotNull().filterNot {
|
||||
(it.info.parent == Category.RISKY) && !riskyCheats
|
||||
}.plus(Configuration.macros)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue