Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Map loadMap(String name) {
- File mapFile = new File(TurfWars.instance.getDataFolder(), "maps/" + name + ".json");
- JsonObject jsonMap = new JsonObject();
- try {
- JsonParser parser = new JsonParser();
- JsonElement jsonElement = parser.parse(new FileReader(mapFile));
- jsonMap = jsonElement.getAsJsonObject();
- } catch (FileNotFoundException e) {
- } catch (IOException ioe) {
- }
- Location r1 = ConfigUtils.getLocationFromJson(jsonMap, "R1");
- Location r2 = ConfigUtils.getLocationFromJson(jsonMap, "R2");
- Location b1 = ConfigUtils.getLocationFromJson(jsonMap, "B1");
- Location b2 = ConfigUtils.getLocationFromJson(jsonMap, "B2");
- Location specSpawn = ConfigUtils.getLocationFromJson(jsonMap, "spectators");
- JsonObject blueSpawns = jsonMap.getAsJsonObject("blueSpawns");
- JsonObject redSpawns = jsonMap.getAsJsonObject("redSpawns");
- ArrayList<Location> redList = new ArrayList<>();
- ArrayList<Location> blueList = new ArrayList<>();
- if (blueSpawns != null)
- for (java.util.Map.Entry<String, JsonElement> entry : blueSpawns.entrySet())
- blueList.add(ConfigUtils.getLocationFromJson(blueSpawns, entry.getKey()));
- if (redSpawns != null)
- for (java.util.Map.Entry<String, JsonElement> entry : redSpawns.entrySet())
- redList.add(ConfigUtils.getLocationFromJson(redSpawns, entry.getKey()));
- Map map = new Map(name, blueList, redList, specSpawn, r1, r2, b1, b2);
- if (map.isComplete())
- TurfLogger.log(" Registered map: " + name + " (Complete!)");
- else
- TurfLogger.log(" Registered map but disabled: " + name + " (incomplete!)");
- maps.put(map, jsonMap);
- return map;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement