Override toString

This commit is contained in:
Him188 2019-11-08 20:01:56 +08:00
parent ad04b0ae48
commit 552d596c11
2 changed files with 6 additions and 2 deletions

View File

@ -296,7 +296,7 @@ internal class TIMBotNetworkHandler internal constructor(override inline val bot
it::class.annotations.filterIsInstance<NoLog>().any() it::class.annotations.filterIsInstance<NoLog>().any()
} }
}?.let { }?.let {
bot.logger.verbose("Packet sent: ${it::class.simpleName ?: "[OutgoingPacket]"}") bot.logger.verbose("Packet sent: ${it.packetId}")
} }
PacketSentEvent(bot, packet).broadcast() PacketSentEvent(bot, packet).broadcast()

View File

@ -6,6 +6,7 @@ import net.mamoe.mirai.network.protocol.tim.packet.action.*
import net.mamoe.mirai.network.protocol.tim.packet.event.EventPacketFactory import net.mamoe.mirai.network.protocol.tim.packet.event.EventPacketFactory
import net.mamoe.mirai.network.protocol.tim.packet.event.FriendOnlineStatusChangedPacket import net.mamoe.mirai.network.protocol.tim.packet.event.FriendOnlineStatusChangedPacket
import net.mamoe.mirai.network.protocol.tim.packet.login.* import net.mamoe.mirai.network.protocol.tim.packet.login.*
import net.mamoe.mirai.utils.io.toUHexString
/** /**
@ -29,6 +30,7 @@ interface PacketId {
object NullPacketId : PacketId { object NullPacketId : PacketId {
override val factory: PacketFactory<*, *> get() = error("uninitialized") override val factory: PacketFactory<*, *> get() = error("uninitialized")
override val value: UShort get() = error("uninitialized") override val value: UShort get() = error("uninitialized")
override fun toString(): String = "NullPacketId"
} }
/** /**
@ -36,6 +38,7 @@ object NullPacketId : PacketId {
*/ */
inline class UnknownPacketId(override inline val value: UShort) : PacketId { inline class UnknownPacketId(override inline val value: UShort) : PacketId {
override val factory: PacketFactory<*, *> get() = UnknownPacketFactory override val factory: PacketFactory<*, *> get() = UnknownPacketFactory
override fun toString(): String = "UnknownPacketId(${value.toUHexString()})"
} }
object IgnoredPacketIds : List<IgnoredPacketId> by { object IgnoredPacketIds : List<IgnoredPacketId> by {
@ -45,6 +48,7 @@ object IgnoredPacketIds : List<IgnoredPacketId> by {
inline class IgnoredPacketId constructor(override val value: UShort) : PacketId { inline class IgnoredPacketId constructor(override val value: UShort) : PacketId {
override val factory: PacketFactory<*, *> get() = IgnoredPacketFactory override val factory: PacketFactory<*, *> get() = IgnoredPacketFactory
override fun toString(): String = "IgnoredPacketId(${value.toUHexString()})"
} }
/** /**
@ -78,5 +82,5 @@ enum class KnownPacketId(override inline val value: UShort, override inline val
; ;
override fun toString(): String = factory.let { it::class.simpleName } ?: this.name override fun toString(): String = factory::class.simpleName ?: this.name
} }