diff --git a/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java b/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java index 27a9c2c47..0eb3bcbf4 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java @@ -8,8 +8,8 @@ import net.mamoe.mirai.network.Robot; import net.mamoe.mirai.task.MiraiTaskManager; import net.mamoe.mirai.utils.LoggerTextFormat; import net.mamoe.mirai.utils.MiraiLogger; -import net.mamoe.mirai.utils.config.MiraiConfig; -import net.mamoe.mirai.utils.config.MiraiMapSection; +import net.mamoe.mirai.utils.setting.MiraiSetting; +import net.mamoe.mirai.utils.setting.MiraiSettingMapSection; import java.io.File; import java.io.IOException; @@ -40,7 +40,7 @@ public class MiraiServer { @Getter MiraiLogger logger; - MiraiConfig setting; + MiraiSetting setting; protected MiraiServer(){ @@ -77,12 +77,12 @@ public class MiraiServer { if(!setting.exists()){ this.initSetting(setting); }else { - this.setting = new MiraiConfig(setting); + this.setting = new MiraiSetting(setting); } getLogger().info("Success"); /* - MiraiMapSection qqs = this.setting.getMapSection("qq"); + MiraiSettingMapSection qqs = this.setting.getMapSection("qq"); qqs.forEach((a,p) -> { this.getLogger().info(LoggerTextFormat.SKY_BLUE + "Finding available ports between " + "1-65536"); try { @@ -134,10 +134,10 @@ public class MiraiServer { } catch (IOException e) { e.printStackTrace(); } - this.setting = new MiraiConfig(setting); - MiraiMapSection network = this.setting.getMapSection("network"); + this.setting = new MiraiSetting(setting); + MiraiSettingMapSection network = this.setting.getMapSection("network"); - MiraiMapSection qqs = this.setting.getMapSection("qq"); + MiraiSettingMapSection qqs = this.setting.getMapSection("qq"); Scanner scanner = new Scanner(System.in); getLogger().info(LoggerTextFormat.SKY_BLUE + "input one " + LoggerTextFormat.RED + " QQ number " + LoggerTextFormat.SKY_BLUE + "for default robot"); getLogger().info(LoggerTextFormat.SKY_BLUE + "输入用于默认机器人的QQ号"); diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfigSection.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfigSection.java deleted file mode 100644 index 1103901fa..000000000 --- a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfigSection.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.mamoe.mirai.utils.config; - -import org.ini4j.Profile; - -import java.io.Closeable; -import java.util.Map; - -public interface MiraiConfigSection extends Closeable { - void saveAsSection(Profile.Section section); -} - - diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfig.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSetting.java similarity index 71% rename from mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfig.java rename to mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSetting.java index 20b26be7f..4f93da511 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiConfig.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSetting.java @@ -1,16 +1,12 @@ -package net.mamoe.mirai.utils.config; +package net.mamoe.mirai.utils.setting; import org.ini4j.Config; import org.ini4j.Ini; -import org.ini4j.Profile; import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; /** @@ -19,15 +15,15 @@ import java.util.concurrent.ConcurrentHashMap; * Support MAP and LIST * Thread safe */ -public class MiraiConfig { +public class MiraiSetting { private File file; private Ini ini; - private volatile Map cacheSection = new ConcurrentHashMap<>(); + private volatile Map cacheSection = new ConcurrentHashMap<>(); - public MiraiConfig(File file){ + public MiraiSetting(File file){ if(!file.getName().contains(".")){ file = new File(file.getParent() + file.getName() + ".ini"); } @@ -46,31 +42,31 @@ public class MiraiConfig { } } - public void setSection(String key, MiraiConfigSection section){ + public void setSection(String key, MiraiSettingSection section){ cacheSection.put(key, section); } - public MiraiMapSection getMapSection(String key){ + public MiraiSettingMapSection getMapSection(String key){ if(!cacheSection.containsKey(key)) { - MiraiMapSection section = new MiraiMapSection(); + MiraiSettingMapSection section = new MiraiSettingMapSection(); if(ini.containsKey(key)){ section.putAll(ini.get(key)); } cacheSection.put(key, section); } - return (MiraiMapSection) cacheSection.get(key); + return (MiraiSettingMapSection) cacheSection.get(key); } - public MiraiListSection getListSection(String key){ + public MiraiSettingListSection getListSection(String key){ if(!cacheSection.containsKey(key)) { - MiraiListSection section = new MiraiListSection(); + MiraiSettingListSection section = new MiraiSettingListSection(); if(ini.containsKey(key)){ section.addAll(ini.get(key).values()); } cacheSection.put(key, section); } - return (MiraiListSection) cacheSection.get(key); + return (MiraiSettingListSection) cacheSection.get(key); } diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiListSection.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingListSection.java similarity index 87% rename from mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiListSection.java rename to mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingListSection.java index c974a545b..9f5bed37a 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiListSection.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingListSection.java @@ -1,17 +1,16 @@ -package net.mamoe.mirai.utils.config; +package net.mamoe.mirai.utils.setting; import org.ini4j.Profile; import java.io.IOException; -import java.util.Map; import java.util.Vector; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -public class MiraiListSection extends Vector implements MiraiConfigSection{ +public class MiraiSettingListSection extends Vector implements MiraiSettingSection { private Lock lock = new ReentrantLock(); @SuppressWarnings("unchecked") diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiMapSection.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingMapSection.java similarity index 93% rename from mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiMapSection.java rename to mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingMapSection.java index 080e0506e..efebc4e53 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/utils/config/MiraiMapSection.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingMapSection.java @@ -1,4 +1,4 @@ -package net.mamoe.mirai.utils.config; +package net.mamoe.mirai.utils.setting; import org.ini4j.Profile; @@ -9,7 +9,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -public class MiraiMapSection extends ConcurrentHashMap implements MiraiConfigSection { +public class MiraiSettingMapSection extends ConcurrentHashMap implements MiraiSettingSection { @SuppressWarnings("unchecked") public T get(String key, T defaultValue) { diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingSection.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingSection.java new file mode 100644 index 000000000..bd65ce5e9 --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/setting/MiraiSettingSection.java @@ -0,0 +1,11 @@ +package net.mamoe.mirai.utils.setting; + +import org.ini4j.Profile; + +import java.io.Closeable; + +public interface MiraiSettingSection extends Closeable { + void saveAsSection(Profile.Section section); +} + + diff --git a/mirai-core/src/test/java/PacketTest.kt b/mirai-core/src/test/java/PacketTest.kt index a26b376cb..bcd087adf 100644 --- a/mirai-core/src/test/java/PacketTest.kt +++ b/mirai-core/src/test/java/PacketTest.kt @@ -1,3 +1,4 @@ +import net.mamoe.mirai.network.packet.client.login.ClientPasswordSubmissionPacket import net.mamoe.mirai.network.packet.server.login.ServerLoginResponseVerificationCodePacket import net.mamoe.mirai.util.hexToBytes import net.mamoe.mirai.util.toHexString @@ -33,6 +34,7 @@ fun main(){ System.out.println("gender: " + packet.gender) */ + /* val data = "FB 01 04 03 33 00 01 00 BA 02 03 2C 13 00 05 01 00 00 01 23 00 38 F5 C3 CF F4 B4 27 C5 8F 9B D3 ED 18 73 7D E9 CB 43 1F 57 43 BE D3 1B 9A F5 26 2B F4 D9 43 14 9A ED 3B C3 6C E5 7F 4E B0 0C BA 55 57 18 06 78 E1 13 A7 B2 A8 7F 47 E1 1C 02 BC 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 00 00 00 82 00 00 00 35 08 03 00 00 00 BA 12 C3 02 00 00 00 04 67 41 4D 41 00 00 B1 8F 0B FC 61 05 00 00 00 01 73 52 47 42 00 AE CE 1C E9 00 00 00 6C 50 4C 54 45 F6 F8 F4 E3 EE FD E5 FD FF EE FD F0 F6 F9 E7 F7 F9 EC F4 FE FF F7 F7 F9 F5 F4 FF EC F7 FF E6 F4 E0 F5 FC F8 49 5B 8F CB DB FA BB C9 F5 2B 40 7C D6 E6 FF FD FB FF ED F1 F0 2A 43 B3 D6 F6 FF FC F1 FC 1C 38 91 A7 BD F6 63 74 BD 70 8B CC 34 4F A5 DE F3 F1 75 88 E7 A4 B7 D3 73 82 A1 8C A3 DC F3 FB D8 4D 68 B9 94 A8 FB 8D 9C B6 CB 42 B0 8E 00 00 0A 6F 49 44 41 54 58 C3 B4 57 89 76 EB 2A 12 14 20 B1 09 10 42 68 DF 2C FB FF FF 71 0A 79 49 E2 E4 CE CC 79 37 8F 13 59 B6 72 EC 2E AA BB AB 9A 2C FB 61 89 8F 95 E5 79 A9 70 CB B2 22 C7 2A 65 DB 5E 72 21 F1 A9 90 B2 28 C4 F9 AF 5F 5F 05 30 9C 28 D2 4B C6 58 F9 8C 92 17 39 13 6D 9B FF EB 10 8A 3B 0F 2F 10 52 64 45 51 64 42 A6 37 79 21 DA FC F2 6F 40 08 9F AE B7 9C A4 C8 27 31 F2 C4 50 A4 D4 9C F9 01 BC A2 90 0F 08 E1 2F AE 1F E3 7E 7D 24 52 F4 67 2C 91 02 E3 CA 13 2F 78 97 00 86 DF 4E C4 23 56 F1 F8 7B 10 90 42 3D D2 93 EE 27 04 F1 80 F0 4B 99 10 4F 62 5E D9 2D EE 57 8A F1 A0 E1 64 20 2B 55 F9 C8 C3 67 08 F8 81 7F F2 F7 BE FD 67 1D 9E 9B 4F EB 89 25 21 28 19 63 09 5D A9 94 2A 59 AA 87 B3 32 4E 84 FF 3C 13 8F AF 06 F1 29 FD E2 C1 02 54 E0 8C 5E 5C 2E A5 72 43 65 F4 E5 72 61 5C 4A 45 81 41 97 79 0A 9E FF 62 22 C2 EB 7E 42 48 45 80 2B 0F 58 B9 66 D6 1C 63 75 D3 97 BC F4 08 0F 08 5C 6B 8D CC 14 1F 10 C4 5F B4 C3 37 66 EE E5 78 CF 42 12 05 CD F5 4D 29 EB 36 AD 19 82 CF 76 35 C6 86 B2 94 A7 36 FC 62 39 BE A8 B8 D7 02 78 08 8F 66 E4 44 45 DF BB AB A3 34 92 14 DF 54 C6 32 1D 00 21 7F 41 08 7F C9 7F F8 28 88 4F B5 90 89 3A 21 90 9E DF E8 DE 34 4D 8C D1 EF C6 AC 6B 7F 74 8E B1 FA 84 90 7F B0 F0 CF 5A E2 27 4C AF 8E 28 EF 24 48 B2 AF B1 9A 96 3E F6 43 75 38 6F 29 5D 1A C7 59 78 87 F0 1B B2 F0 95 05 3C 93 B2 26 B6 9F BA 18 AB AE 59 EC 88 17 17 A9 8F 4B B3 CE 60 A1 CD F2 CB 03 42 10 7F D9 06 1F 76 80 8E 4F 6D 9F 56 99 05 25 A5 DD AA EB 62 7A 6F 87 E6 B8 0E 5D 33 C6 99 C6 C4 02 24 EB 74 8C 87 98 64 F8 5E A9 9E 1E F7 72 FB FF B3 21 8A A4 00 01 00 28 F9 59 C5 E6 34 43 53 95 C8 17 2E 62 78 BF E8 27 BF 20 BA 11 5A 74 D1 7C D0 95 6C F6 A3 41 D2 84 BD 7D F6 64 BC 27 40 50 01 15 00 10 44 98 EB B8 30 3B DE 7D 2B CC 4C 41 B3 1C 92 86" val s = DataInputStream(data.hexToBytes().inputStream()) val packet = ServerLoginResponseVerificationCodePacket(s,(data.length+1)/3) @@ -43,4 +45,8 @@ fun main(){ File(System.getProperty("user.dir") + "/5.png").createNewFile() packet.verifyCode.inputStream().transferTo(FileOutputStream(System.getProperty("user.dir") + "/5.png")) + */ + + val packet = ClientPasswordSubmissionPacket(1994701021,"xiaoqqq",131513,"123.123.123.123","tgtgtKey".toByteArray(),"".toByteArray()) + packet.encodeToByteArray().toUByteArray().toHexString(" ") } \ No newline at end of file