Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void save(Map<String, Dungeon> dungeons) {
- if (config == null){
- FileConfiguration config = new YamlConfiguration();
- }
- if (config.contains("dungeons")) {
- config.set("dungeons", null);
- } else {
- config.createSection("dungeons");
- }
- ConfigurationSection dungeonsSection = config.getConfigurationSection("dungeons");
- for (Dungeon dungeon : dungeons.values()) {
- ConfigurationSection dungeonSection = dungeonsSection.createSection(dungeon.getName());
- dungeonSection.set("world", dungeon.getWorld().getName());
- dungeonSection.set("displayName", dungeon.getDisplayName());
- dungeonSection.set("firstRoom", dungeon.getFirstRoom().getName());
- ConfigurationSection roomsSection = dungeonSection.createSection("rooms");
- for (Room room : dungeon.getRooms().values()) {
- ConfigurationSection roomSection = roomsSection.createSection(room.getName());
- roomSection.set("start", serializeVector(room.getStart().toVector()));
- roomSection.set("min", serializeVector(room.getMin()));
- roomSection.set("max", serializeVector(room.getMax()));
- roomSection.set("nextRoom", room.getNextRoom().getName());
- ConfigurationSection doorsSection = roomSection.createSection("doors");
- doorsSection.set("material", room.getDoor().getMaterial().toString());
- doorsSection.set("min", serializeVector(room.getDoor().getMin()));
- doorsSection.set("max", serializeVector(room.getDoor().getMax()));
- ConfigurationSection spawnersSection = roomSection.createSection("spawners");
- for (int s = 1; s <= room.getSpawners().size(); s++) {
- Spawner spawner = room.getSpawners().get(s);
- ConfigurationSection spawnerSection = spawnersSection.createSection(String.valueOf(s));
- spawnerSection.set("spawnPoint", serializeVector(spawner.getLocation()));
- spawnerSection.set("mobType", spawner.getMobType().toString());
- spawnerSection.set("quantity", spawner.getQuantity());
- }
- }
- }
- try {
- config.save(file);
- } catch (IOException exception) {
- exception.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement