diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-24 16:15:00 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-24 16:15:00 +0900 |
commit | 8c45dda66cf5f37066f02c22ceb36509d0ac35c2 (patch) | |
tree | 9d0bb9f80653b39f3529790d5f9bfa2b9658f60b /src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java | |
parent | 0593c1b6390ddf7c92c6a5ddab3e31c5f6e59e7d (diff) | |
download | Skyblock-Dungeons-Guide-8c45dda66cf5f37066f02c22ceb36509d0ac35c2.tar.gz Skyblock-Dungeons-Guide-8c45dda66cf5f37066f02c22ceb36509d0ac35c2.tar.bz2 Skyblock-Dungeons-Guide-8c45dda66cf5f37066f02c22ceb36509d0ac35c2.zip |
save and edit generic roomdata
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java | 31 |
1 files changed, 31 insertions, 0 deletions
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 a382273c..d9df6a8d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -2,6 +2,7 @@ package kr.syeyoung.dungeonsguide.dungeon.roomfinder; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import java.io.*; import java.util.*; public class DungeonRoomInfoRegistry { @@ -38,4 +39,34 @@ public class DungeonRoomInfoRegistry { shapeMap.get(dungeonRoomInfo.getShape()).remove(dungeonRoomInfo); uuidMap.remove(dungeonRoomInfo.getUuid()); } + + public static void saveAll(File dir) { + dir.mkdirs(); + for (DungeonRoomInfo dungeonRoomInfo : registered) { + try { + FileOutputStream fos = new FileOutputStream(new File(dir, dungeonRoomInfo.getUuid().toString() + ".roomdata")); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(dungeonRoomInfo); + oos.flush(); + oos.close(); + } catch (Exception e) {e.printStackTrace();} + } + } + + public static void loadAll(File dir) { + registered.clear(); + shapeMap.clear(); + uuidMap.clear(); + for (File f: dir.listFiles()) { + if (!f.isFile() || !f.getName().endsWith(".roomdata")) continue; + try { + FileInputStream fis = new FileInputStream(f); + ObjectInputStream ois = new ObjectInputStream(fis); + DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); + ois.close(); + fis.close(); + register(dri); + } catch (Exception e) {e.printStackTrace();} + } + } } |