mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-06 08:00:10 +08:00
update
This commit is contained in:
parent
de239cffb3
commit
31bb236e21
@ -1,9 +1,7 @@
|
|||||||
package net.mamoe.mirai.util
|
package net.mamoe.mirai.util
|
||||||
|
|
||||||
import net.mamoe.mirai.network.Protocol
|
import net.mamoe.mirai.network.Protocol
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.DataInputStream
|
|
||||||
import java.io.DataOutputStream
|
import java.io.DataOutputStream
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -89,24 +87,22 @@ fun getCrc32(key: ByteArray): Int = CRC32().let { it.update(key); it.value.toInt
|
|||||||
*/
|
*/
|
||||||
@Throws(SecurityException::class)
|
@Throws(SecurityException::class)
|
||||||
fun Any.getAllDeclaredFields(): List<Field> {
|
fun Any.getAllDeclaredFields(): List<Field> {
|
||||||
val clazz: Class<out Any> = this.javaClass;
|
var clazz: Class<*> = this.javaClass;
|
||||||
val list = LinkedList<Field>()
|
val list = LinkedList<Field>()
|
||||||
loop@ do {
|
loop@ do {
|
||||||
list.addAll(listOf(*clazz.declaredFields))
|
|
||||||
if (this.javaClass == DataOutputStream::class) {
|
if (!clazz.name.contains("net.mamoe")) {
|
||||||
continue
|
break@loop
|
||||||
}
|
}
|
||||||
|
|
||||||
when (this.javaClass) {
|
list.addAll(clazz.declaredFields.filter { (it.name == "Companion" || it.name == "input").not() }.toList())
|
||||||
DataOutputStream::class, ByteArrayDataOutputStream::class, DataInputStream::class, ByteArrayInputStream::class -> {
|
|
||||||
break@loop;
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//clazz = clazz.superclass!!
|
if (clazz.superclass == null) {
|
||||||
} while (clazz != Any::class.java)
|
break
|
||||||
|
}
|
||||||
|
clazz = clazz.superclass
|
||||||
|
|
||||||
|
} while (clazz != Object::javaClass)
|
||||||
|
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user