Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 KB | None | 0 0
  1. public void save(Map<String, Dungeon> dungeons) {
  2.         if (config == null){
  3.             FileConfiguration config = new YamlConfiguration();
  4.         }
  5.         if (config.contains("dungeons")) {
  6.             config.set("dungeons", null);
  7.         } else {
  8.             config.createSection("dungeons");
  9.         }
  10.         ConfigurationSection dungeonsSection = config.getConfigurationSection("dungeons");
  11.         for (Dungeon dungeon : dungeons.values()) {
  12.             ConfigurationSection dungeonSection = dungeonsSection.createSection(dungeon.getName());
  13.             dungeonSection.set("world", dungeon.getWorld().getName());
  14.             dungeonSection.set("displayName", dungeon.getDisplayName());
  15.             dungeonSection.set("firstRoom", dungeon.getFirstRoom().getName());
  16.  
  17.             ConfigurationSection roomsSection = dungeonSection.createSection("rooms");
  18.             for (Room room : dungeon.getRooms().values()) {
  19.                 ConfigurationSection roomSection = roomsSection.createSection(room.getName());
  20.                 roomSection.set("start", serializeVector(room.getStart().toVector()));
  21.                 roomSection.set("min", serializeVector(room.getMin()));
  22.                 roomSection.set("max", serializeVector(room.getMax()));
  23.                 roomSection.set("nextRoom", room.getNextRoom().getName());
  24.  
  25.                 ConfigurationSection doorsSection = roomSection.createSection("doors");
  26.                 doorsSection.set("material", room.getDoor().getMaterial().toString());
  27.                 doorsSection.set("min", serializeVector(room.getDoor().getMin()));
  28.                 doorsSection.set("max", serializeVector(room.getDoor().getMax()));
  29.  
  30.                 ConfigurationSection spawnersSection = roomSection.createSection("spawners");
  31.                 for (int s = 1; s <= room.getSpawners().size(); s++) {
  32.                     Spawner spawner = room.getSpawners().get(s);
  33.                     ConfigurationSection spawnerSection = spawnersSection.createSection(String.valueOf(s));
  34.                     spawnerSection.set("spawnPoint", serializeVector(spawner.getLocation()));
  35.                     spawnerSection.set("mobType", spawner.getMobType().toString());
  36.                     spawnerSection.set("quantity", spawner.getQuantity());
  37.                 }
  38.             }
  39.         }
  40.         try {
  41.             config.save(file);
  42.         } catch (IOException exception) {
  43.             exception.printStackTrace();
  44.         }
  45.  
  46.  
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement