aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java31
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();}
+ }
+ }
}