mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-30 01:40:29 +08:00
Kotlin coroutine
This commit is contained in:
parent
2d366d49a9
commit
f459891cf8
mirai-core/src/main/java/net/mamoe/mirai/message
@ -104,6 +104,12 @@ abstract class Message {
|
||||
* @return message connected
|
||||
*/
|
||||
open fun concat(tail: Message): MessageChain {
|
||||
if (tail is MessageChain) {
|
||||
return MessageChain(this).let {
|
||||
tail.list.forEach { child -> it.concat(child) }
|
||||
it
|
||||
}
|
||||
}
|
||||
return MessageChain(this, Objects.requireNonNull(tail))
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,9 @@ import java.util.stream.Stream
|
||||
class MessageChain : Message {
|
||||
override val type: Int = MessageId.CHAIN
|
||||
|
||||
/**
|
||||
* Elements will not be instances of [MessageChain]
|
||||
*/
|
||||
val list: MutableList<Message> = Collections.synchronizedList(LinkedList<Message>())
|
||||
|
||||
constructor(head: Message, tail: Message) {
|
||||
@ -58,6 +61,10 @@ class MessageChain : Message {
|
||||
}
|
||||
|
||||
override fun concat(tail: Message): MessageChain {
|
||||
if (tail is MessageChain) {
|
||||
tail.list.forEach { child -> this.concat(child) }
|
||||
return this
|
||||
}
|
||||
this.list.add(tail)
|
||||
clearToStringCache()
|
||||
return this
|
||||
|
Loading…
Reference in New Issue
Block a user