diff --git a/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java b/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java index 6f0a66781..d94cc2fc1 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java @@ -1,11 +1,8 @@ package net.mamoe.mirai; -import net.mamoe.mirai.event.MiraiEventHook; -import net.mamoe.mirai.event.events.server.ServerDisableEvent; - /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ public final class MiraiMain { private static MiraiServer server; diff --git a/mirai-core/src/main/java/net/mamoe/mirai/contact/Contact.kt b/mirai-core/src/main/java/net/mamoe/mirai/contact/Contact.kt index 5d8ffcaf7..a8b154e60 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/contact/Contact.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/contact/Contact.kt @@ -3,7 +3,7 @@ package net.mamoe.mirai.contact /** * A contact is a QQ account or a QQ Group. * - * @author Him188moe @ Mirai Project + * @author Him188moe */ abstract class Contact(val number: Int) { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/contact/Lazy.kt b/mirai-core/src/main/java/net/mamoe/mirai/contact/Lazy.kt index 0fa154d91..cecd6001c 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/contact/Lazy.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/contact/Lazy.kt @@ -7,6 +7,10 @@ fun Int.asGroup(): Group = Instances.groups.stream().filter { t: Group? -> t?.nu fun String.withImage(id: String, type: String) = "{$id}.$type" +fun String.withAt(qq: Int) = qq.asQQ().at() + +fun String.withAt(qq: QQ) = qq.at() + object Instances { var qqs = arrayListOf() var groups = arrayListOf() diff --git a/mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt b/mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt index 58ab34b0c..0d51307a0 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/contact/QQ.kt @@ -1,7 +1,7 @@ package net.mamoe.mirai.contact /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ class QQ(number: Int) : Contact(number) { init { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/event/events/robot/RobotEvents.kt b/mirai-core/src/main/java/net/mamoe/mirai/event/events/robot/RobotEvents.kt index 65219239a..129424b72 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/event/events/robot/RobotEvents.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/event/events/robot/RobotEvents.kt @@ -4,7 +4,7 @@ import net.mamoe.mirai.event.events.MiraiEvent import net.mamoe.mirai.network.Robot /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ class RobotLoginEvent(val robot: Robot) : MiraiEvent() 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 69fd9cb5b..59a7c5caa 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 @@ -5,7 +5,7 @@ import java.util.* import java.util.stream.Collectors /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ interface Protocol { companion object { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt index 2b6cb617a..81a9cdbc0 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/Robot.kt @@ -25,7 +25,7 @@ import java.net.InetSocketAddress /** * [number] is a QQ number. * - * @author Him188moe @ Mirai Project + * @author Him188moe */ class Robot(val number: Int, private val password: String) { private var sequence: Int = 0 diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java index 8c6fec9cb..e225f0c2d 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java @@ -1,7 +1,7 @@ package net.mamoe.mirai.network.packet; /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ public interface Packet { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java index 1619fdb51..a9e48582b 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java @@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketUtil.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketUtil.java index 37b60e499..3d5243f7d 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketUtil.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketUtil.java @@ -1,7 +1,7 @@ package net.mamoe.mirai.network.packet; /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ public final class PacketUtil { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.kt index f8580e48c..50db3e66d 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.kt @@ -11,7 +11,7 @@ import java.net.InetAddress import java.security.MessageDigest /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @ExperimentalUnsignedTypes abstract class ClientPacket : ByteArrayDataOutputStream(), Packet { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientSendMessagePacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientSendMessagePacket.kt index 85244ef9b..42ab6ff77 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientSendMessagePacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientSendMessagePacket.kt @@ -1,7 +1,7 @@ package net.mamoe.mirai.network.packet.client /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @ExperimentalUnsignedTypes class ClientSendMessagePacket : ClientPacket() { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginPacket.kt index d09ccfb8d..b53d026cf 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginPacket.kt @@ -11,7 +11,7 @@ import net.mamoe.mirai.util.hexToBytes /** * Password submission (0836_622) * - * @author Him188moe @ Mirai Project + * @author Him188moe */ @PacketId("08 36 31 03") @ExperimentalUnsignedTypes @@ -120,7 +120,7 @@ class ClientLoginSucceedConfirmationPacket( } /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @ExperimentalUnsignedTypes private fun ClientPacket.writePart1(qq: Int, password: String, loginTime: Int, loginIP: String, tgtgtKey: ByteArray, token0825: ByteArray) { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginVerificationCodePacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginVerificationCodePacket.kt index dbfbbaf4b..06d5d936f 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginVerificationCodePacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientLoginVerificationCodePacket.kt @@ -10,7 +10,7 @@ import net.mamoe.mirai.util.ByteArrayDataOutputStream import net.mamoe.mirai.util.TEACryptor /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @PacketId("00 BA 31 01") @ExperimentalUnsignedTypes diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientServerRedirectionPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientServerRedirectionPacket.kt index 8820241f5..dfabce150 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientServerRedirectionPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/login/ClientServerRedirectionPacket.kt @@ -13,7 +13,7 @@ import java.io.IOException /** * Server redirection (0825 response) * - * @author Him188moe @ Mirai Project + * @author Him188moe */ @ExperimentalUnsignedTypes @PacketId("08 25 31 02") @@ -24,7 +24,7 @@ class ClientServerRedirectionPacket(private val serverIP: String, private val qq this.writeHex(Protocol.fixVer) this.writeHex(Protocol.redirectionKey) - //TEA 加密 + this.write(TEACryptor.encrypt(object : ClientPacket() { @Throws(IOException::class) override fun encode() { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientHeartbeatPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientHeartbeatPacket.kt index 7c29900d7..94d8f69b6 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientHeartbeatPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientHeartbeatPacket.kt @@ -10,7 +10,7 @@ import net.mamoe.mirai.util.TEACryptor import java.io.IOException /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @ExperimentalUnsignedTypes @PacketId("00 58")//todo check diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientTouchPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientTouchPacket.kt index a5169fecb..25b0734d1 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientTouchPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/touch/ClientTouchPacket.kt @@ -16,7 +16,7 @@ import java.io.IOException * * @see net.mamoe.mirai.network.packet.server.ServerTouchResponsePacket * - * @author Him188moe @ Mirai Project + * @author Him188moe */ @ExperimentalUnsignedTypes @PacketId("08 25 31 01") @@ -35,7 +35,7 @@ class ClientTouchPacket : ClientPacket() { this.writeHex(Protocol._0825key) - //TEA 加密 + this.write(TEACryptor.CRYPTOR_0825KEY.encrypt(object : ByteArrayDataOutputStream() { @Throws(IOException::class) override fun toByteArray(): ByteArray { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt index fc27b2985..16f56b5ea 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt @@ -10,7 +10,7 @@ import net.mamoe.mirai.util.toHexString import java.io.DataInputStream /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ abstract class ServerPacket(val input: DataInputStream) : Packet { @@ -91,4 +91,33 @@ fun DataInputStream.readVarString(length:Int): String{ } -fun ByteArray.dataInputStream(): DataInputStream = DataInputStream(this.inputStream()) \ No newline at end of file +fun ByteArray.dataInputStream(): DataInputStream = DataInputStream(this.inputStream()) + +/** + * Reset and skip(position) + */ +infix fun DataInputStream.goto(position: N): DataInputStream { + this.reset() + this.skip(position.toLong()); + return this +} + +fun DataInputStream.readNBytes(position: N, length: Int): ByteArray { + this.goto(position) + return this.readNBytes(length) +} + +fun DataInputStream.readInt(position: N): Int { + this.goto(position) + return this.readInt(); +} + +fun DataInputStream.readByte(position: N): Byte { + this.goto(position) + return this.readByte(); +} + +fun DataInputStream.readShort(position: N): Short { + this.goto(position) + return this.readShort(); +} \ No newline at end of file diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseFailedPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseFailedPacket.kt index 7cf34dc0a..9ace468ed 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseFailedPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseFailedPacket.kt @@ -4,7 +4,7 @@ import net.mamoe.mirai.network.packet.server.ServerPacket import java.io.DataInputStream /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ class ServerLoginResponseFailedPacket(val state: State, input: DataInputStream) : ServerPacket(input) { enum class State { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseResendPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseResendPacket.kt index 80d084dcd..2d72644ed 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseResendPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseResendPacket.kt @@ -5,7 +5,7 @@ import net.mamoe.mirai.network.packet.server.ServerPacket import java.io.DataInputStream /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ @PacketId("08 36 31 03") class ServerLoginResponseResendPacket(input: DataInputStream, val flag: Flag) : ServerPacket(input) { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseSuccessPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseSuccessPacket.kt index 41bff8951..5aea7a595 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseSuccessPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseSuccessPacket.kt @@ -11,8 +11,8 @@ import net.mamoe.mirai.util.toHexString import java.io.DataInputStream /** - * @author Him188moe @ Mirai Project - * @author NaturalHG @ Mirai Project + * @author Him188moe + * @author NaturalHG */ class ServerLoginResponseSuccessPacket(input: DataInputStream, val packetDataLength: Int) : ServerPacket(input) { lateinit var _0828_rec_decr_key: ByteArray//16 bytes| diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt index bca380659..9a9254f35 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt @@ -4,7 +4,7 @@ import net.mamoe.mirai.network.packet.server.ServerPacket import java.io.DataInputStream /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ class ServerLoginResponseVerificationCodePacket(input: DataInputStream) : ServerPacket(input) { var verifyCodeLength: Int = 0 diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/security/ServerSessionKeyResponsePacketEncrypted.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/security/ServerSessionKeyResponsePacketEncrypted.kt index ac50d20fd..831968cf0 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/security/ServerSessionKeyResponsePacketEncrypted.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/security/ServerSessionKeyResponsePacketEncrypted.kt @@ -8,7 +8,7 @@ import java.io.DataInputStream /** * Dispose_0828 * - * @author Him188moe @ Mirai Project + * @author Him188moe */ class ServerSessionKeyResponsePacket(inputStream: DataInputStream) : ServerPacket(inputStream) { lateinit var sessionKey: ByteArray @@ -39,7 +39,7 @@ class ServerSessionKeyResponsePacket(inputStream: DataInputStream) : ServerPacke /** * Encrypted using []0828_rec_decr_key], decrypting in Robot * - * @author Him188moe @ Mirai Project + * @author Him188moe */ class ServerSessionKeyResponsePacketEncrypted(inputStream: DataInputStream) : ServerPacket(inputStream) { override fun decode() { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/touch/ServerTouchResponsePacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/touch/ServerTouchResponsePacket.kt index 9cdcdd2ce..3dc633306 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/touch/ServerTouchResponsePacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/touch/ServerTouchResponsePacket.kt @@ -11,7 +11,7 @@ import java.io.DataInputStream * @see net.mamoe.mirai.network.packet.client.login.ClientServerRedirectionPacket * @see net.mamoe.mirai.network.packet.client.login.ClientPasswordSubmissionPacket * - * @author Him188moe @ Mirai Project + * @author Him188moe */ class ServerTouchResponsePacket(private val type: Type, inputStream: DataInputStream) : ServerPacket(inputStream) { var serverIP: String? = null; diff --git a/mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt b/mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt index e92d8e9fe..8f401d8b7 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/util/Utils.kt @@ -7,7 +7,7 @@ import java.util.* import java.util.zip.CRC32 /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ object Utils { fun toHexString(byteArray: ByteArray, separator: String = " "): String = byteArray.joinToString(separator) { diff --git a/mirai-core/src/test/java/NetworkTest.java b/mirai-core/src/test/java/NetworkTest.java index 8fd3f5e0e..aa475522c 100644 --- a/mirai-core/src/test/java/NetworkTest.java +++ b/mirai-core/src/test/java/NetworkTest.java @@ -1,5 +1,5 @@ /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ public class NetworkTest { public static void main(String[] args) { diff --git a/mirai-native/src/main/java/net/mamoe/mirai/util/TeaEncryption.java b/mirai-native/src/main/java/net/mamoe/mirai/util/TeaEncryption.java index f14480377..d09be5855 100644 --- a/mirai-native/src/main/java/net/mamoe/mirai/util/TeaEncryption.java +++ b/mirai-native/src/main/java/net/mamoe/mirai/util/TeaEncryption.java @@ -1,7 +1,7 @@ package net.mamoe.mirai.util; /** - * @author Him188moe @ Mirai Project + * @author Him188moe */ public final class TeaEncryption {