John Guerra
09/20/2020, 4:59 PMinternal abstract val packetTypes: List<KClass<*>>
Cause there's times where it'd look like this:
override val packetTypes = listOf(
PacketPlayInFlying::class,
PacketPlayInFlying.PacketPlayInPosition::class,
PacketPlayInFlying.PacketPlayInPositionLook::class,
PacketPlayInFlying.PacketPlayInLook::class
)
Which honestly isn't always very pretty to look at. If I only add PacketPlayInFlying::class
to the list then the other classes won't be retrieved. I have to manually add each one so they can be detected.Christopher Elías
09/20/2020, 9:23 PMMichael de Kaste
09/21/2020, 7:33 AMPacketPlayInFlying::class.nestedClasses + PacketPlayInFlying::class
sealed class Foo{
data class Bar1(val string: String) : Foo()
data class Bar2(val int: Int) : Foo()
}
val list: List<Any> = listOf(Foo.Bar1(""), Foo.Bar1(" "), Foo.Bar1(" "), Foo.Bar2(0), Foo.Bar2(1))
fun main(){
list.filter { it::class == Foo::class }.forEach(::println) //Prints none
list.filterIsInstance(Foo::class.java).forEach(::println) //Prints all
}