From 87e89fd42ca44400a3d3d3d5477cd1525b24d91a Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Tue, 8 Dec 2020 14:54:17 +0900 Subject: authentication stuff and network loading --- .../roomfinder/DungeonRoomInfoRegistry.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java index d9df6a8d..383aea08 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -1,8 +1,17 @@ package kr.syeyoung.dungeonsguide.dungeon.roomfinder; +import jdk.internal.util.xml.impl.Input; +import kr.syeyoung.dungeonsguide.Authenticator; +import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; import java.io.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.util.*; public class DungeonRoomInfoRegistry { @@ -41,6 +50,7 @@ public class DungeonRoomInfoRegistry { } public static void saveAll(File dir) { + if (!DungeonsGuide.DEBUG) return; dir.mkdirs(); for (DungeonRoomInfo dungeonRoomInfo : registered) { try { @@ -53,14 +63,19 @@ public class DungeonRoomInfoRegistry { } } - public static void loadAll(File dir) { + public static void loadAll() throws BadPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException { registered.clear(); shapeMap.clear(); uuidMap.clear(); - for (File f: dir.listFiles()) { - if (!f.isFile() || !f.getName().endsWith(".roomdata")) continue; + Authenticator authenticator = DungeonsGuide.getDungeonsGuide().getAuthenticator(); + InputStream inputStream = authenticator.getInputStream("roomdata/datas.txt"); + BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); + String name; + while ((name = br.readLine()) != null) { + System.out.println("Trying to load "+name); + if (name.endsWith(".roomdata")) continue; try { - FileInputStream fis = new FileInputStream(f); + InputStream fis = authenticator.getInputStream(name); ObjectInputStream ois = new ObjectInputStream(fis); DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); ois.close(); -- cgit