diff --git a/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt b/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt index f757a08..3b282c5 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt @@ -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())) + 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() diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt index a4f5098..b6d1f45 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt @@ -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) )