aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-23 11:39:30 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-23 11:39:30 +0900
commit17b3b9ce29495b554d38c1de4af38904be0fcc23 (patch)
tree117e3c2a4d2ab1f2a3a770527a22b533f647a45d /src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java
parent46a86f18ebd62a3771ca4fcb7d1cf17f69b80c73 (diff)
downloadSkyblock-Dungeons-Guide-17b3b9ce29495b554d38c1de4af38904be0fcc23.tar.gz
Skyblock-Dungeons-Guide-17b3b9ce29495b554d38c1de4af38904be0fcc23.tar.bz2
Skyblock-Dungeons-Guide-17b3b9ce29495b554d38c1de4af38904be0fcc23.zip
room data!
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.java41
1 files changed, 41 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
new file mode 100644
index 00000000..a382273c
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java
@@ -0,0 +1,41 @@
+package kr.syeyoung.dungeonsguide.dungeon.roomfinder;
+
+import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo;
+
+import java.util.*;
+
+public class DungeonRoomInfoRegistry {
+ private static List<DungeonRoomInfo> registered = new ArrayList<DungeonRoomInfo>();
+ private static Map<Short, List<DungeonRoomInfo>> shapeMap = new HashMap<Short, List<DungeonRoomInfo>>();
+ private static Map<UUID, DungeonRoomInfo> uuidMap = new HashMap<UUID, DungeonRoomInfo>();
+
+ public static void register(DungeonRoomInfo dungeonRoomInfo) {
+ if (dungeonRoomInfo == null) throw new NullPointerException("what the fak parameter is noll?");
+ dungeonRoomInfo.setRegistered(true);
+ registered.add(dungeonRoomInfo);
+ uuidMap.put(dungeonRoomInfo.getUuid(), dungeonRoomInfo);
+ List<DungeonRoomInfo> roomInfos = shapeMap.get(dungeonRoomInfo.getShape());
+ if (roomInfos == null) roomInfos = new ArrayList<DungeonRoomInfo>();
+ roomInfos.add(dungeonRoomInfo);
+ shapeMap.put(dungeonRoomInfo.getShape(), roomInfos);
+ }
+
+
+ public static List<DungeonRoomInfo> getByShape(Short shape) {
+ List<DungeonRoomInfo> dungeonRoomInfos = shapeMap.get(shape);
+ return dungeonRoomInfos == null ? Collections.<DungeonRoomInfo>emptyList() : dungeonRoomInfos;
+ }
+
+ public static DungeonRoomInfo getByUUID(UUID uid) {
+ return uuidMap.get(uid);
+ }
+
+ public static void unregister(DungeonRoomInfo dungeonRoomInfo) {
+ if (!dungeonRoomInfo.isRegistered()) throw new IllegalStateException("what tha fak? that is not registered one");
+ if (!uuidMap.containsKey(dungeonRoomInfo.getUuid())) throw new IllegalStateException("what tha fak? that is not registered one, but you desperately wanted to trick this program");
+ dungeonRoomInfo.setRegistered(false);
+ registered.remove(dungeonRoomInfo);
+ shapeMap.get(dungeonRoomInfo.getShape()).remove(dungeonRoomInfo);
+ uuidMap.remove(dungeonRoomInfo.getUuid());
+ }
+}