From 70dc6cf63c9a735322dde55ffca46e1f6cddfcfe Mon Sep 17 00:00:00 2001 From: Him188moe <Him188> Date: Fri, 6 Sep 2019 22:10:35 +0800 Subject: [PATCH] Updated sth --- .../src/main/java/net/mamoe/mirai/event/AsyncEventKt.kt | 6 +++++- .../src/main/java/net/mamoe/mirai/event/MiraiEventKt.kt | 2 +- .../main/java/net/mamoe/mirai/message/defaults/Face.java | 2 ++ .../src/main/java/net/mamoe/mirai/network/Protocol.kt | 2 -- mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt | 8 ++++++-- mirai-core/src/test/java/HexComparator.java | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/mirai-core/src/main/java/net/mamoe/mirai/event/AsyncEventKt.kt b/mirai-core/src/main/java/net/mamoe/mirai/event/AsyncEventKt.kt index 32490d42a..10008103d 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/event/AsyncEventKt.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/event/AsyncEventKt.kt @@ -9,6 +9,10 @@ fun <E : AsyncEvent> E.broadcastAsync(callback: Consumer<E>): CompletableFuture< return MiraiEventManager.getInstance().broadcastEventAsync(this, callback) } -fun <E : AsyncEvent> E.broadcastAsync(callback: Runnable): CompletableFuture<out AsyncEvent> { +fun <E : AsyncEvent> E.broadcastAsync(callback: Runnable): CompletableFuture<E> { return MiraiEventManager.getInstance().broadcastEventAsync(this, callback) +} + +fun <E : AsyncEvent> E.broadcastAsyncSmart(): CompletableFuture<E> { + return MiraiEventManager.getInstance().broadcastEventAsync(this) } \ No newline at end of file diff --git a/mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventKt.kt b/mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventKt.kt index d4441bb62..8183738b0 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventKt.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventKt.kt @@ -2,7 +2,7 @@ package net.mamoe.mirai.event -fun <E : MiraiEvent> E.broadcast(): E { +fun <E : MiraiEvent> E.broadcastSmart(): E { MiraiEventManager.getInstance().broadcastEvent(this as MiraiEvent) return this } \ No newline at end of file diff --git a/mirai-core/src/main/java/net/mamoe/mirai/message/defaults/Face.java b/mirai-core/src/main/java/net/mamoe/mirai/message/defaults/Face.java index b1708fd11..3311de4e5 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/message/defaults/Face.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/message/defaults/Face.java @@ -4,6 +4,8 @@ import net.mamoe.mirai.message.FaceID; import net.mamoe.mirai.message.Message; /** + * QQ 自带表情 + * * @author Him188moe */ public final class Face extends Message { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt index d639dffa7..dea09bf68 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt @@ -51,8 +51,6 @@ object Protocol { const val key00BA = "C1 9C B8 C8 7B 8C 81 BA 9E 9E 7A 89 E1 7A EC 94" const val key00BAFix = "69 20 D1 14 74 F5 B3 93 E4 D5 02 B3 71 1A CD 2A" - const val encryptKey = "“BA 42 FF 01 CF B4 FF D2 12 F0 6E A7 1B 7C B3 08”" - /** * 0836_622_fix2 */ diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt b/mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt index 9f6d6b347..bcf62f885 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/Utils.kt @@ -8,7 +8,9 @@ import java.lang.reflect.Field import java.util.* import java.util.zip.CRC32 +@JvmSynthetic fun ByteArray.toHexString(): String = toHexString(" ") + fun ByteArray.toHexString(separator: String = " "): String = this.joinToString(separator) { var ret = it.toString(16).toUpperCase() if (ret.length == 1) { @@ -20,12 +22,12 @@ fun ByteArray.toHexString(separator: String = " "): String = this.joinToString(s @ExperimentalUnsignedTypes fun ByteArray.toUHexString(separator: String = " "): String = this.toUByteArray().toUHexString(separator) -fun ByteArray.__toUHexString(separator: String = " "): String = this.toUByteArray().toUHexString(separator) - @ExperimentalUnsignedTypes +@JvmSynthetic fun ByteArray.toUHexString(): String = this.toUByteArray().toUHexString() @ExperimentalUnsignedTypes +@JvmSynthetic fun UByteArray.toUHexString(separator: String = " "): String { return this.joinToString(separator) { var ret = it.toString(16).toUpperCase() @@ -37,6 +39,7 @@ fun UByteArray.toUHexString(separator: String = " "): String { } @ExperimentalUnsignedTypes +@JvmSynthetic fun UByteArray.toUHexString(): String = this.toUHexString(" ") @ExperimentalUnsignedTypes @@ -75,6 +78,7 @@ fun getRandomByteArray(length: Int): ByteArray { return bytes.toByteArray() } +@JvmSynthetic operator fun File.plus(child: String): File = File(this, child) private const val GTK_BASE_VALUE: Int = 5381 diff --git a/mirai-core/src/test/java/HexComparator.java b/mirai-core/src/test/java/HexComparator.java index e3a1571ca..51f6677e2 100644 --- a/mirai-core/src/test/java/HexComparator.java +++ b/mirai-core/src/test/java/HexComparator.java @@ -50,7 +50,7 @@ public class HexComparator { @SuppressWarnings({"unused", "NonAsciiCharacters"}) private static class TestConsts { - private static final String 牛逼 = UtilsKt.__toUHexString("牛逼".getBytes(), " "); + private static final String 牛逼 = UtilsKt.toUHexString("牛逼".getBytes(), " "); private static final String _1994701021 = ClientPacketKt.toHexString(1994701021, " "); private static final String _1040400290 = ClientPacketKt.toHexString(1040400290, " "); private static final String _580266363 = ClientPacketKt.toHexString(580266363, " ");