Created
August 25, 2020 23:40
-
-
Save Camotoy/ab15a9f159032708d7476632f1658b3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object2IntMap<String> map = new Object2IntOpenHashMap<>(); | |
Path baseDir = Paths.get(".").toAbsolutePath(); | |
try (InputStream stream = Files.newInputStream(baseDir.resolve("biomes.json"))) { | |
JsonNode biomes; | |
try { | |
biomes = GeyserConnector.JSON_MAPPER.readTree(stream); | |
} catch (Exception e) { | |
throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.toolbox.fail.runtime_java"), e); | |
} | |
Iterator<Map.Entry<String, JsonNode>> biomesIterator = biomes.fields(); | |
// Populate the existing biomes | |
while (biomesIterator.hasNext()) { | |
Map.Entry<String, JsonNode> entry = biomesIterator.next(); | |
map.put(entry.getKey(), entry.getValue().intValue()); | |
} | |
// Add any new biomes | |
for (Biome biome : Biome.values()) { | |
if (!biomes.has(biome.toString())) { | |
System.out.println("NEW BIOME! " + biome.toString()); | |
int value = biome.ordinal(); | |
if (value > 50) { | |
value += 77; | |
} | |
map.put(biome.toString(), value); | |
} | |
} | |
} catch (NoSuchFileException e) { | |
// | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
try (OutputStream outputStream = Files.newOutputStream(baseDir.resolve("biomes.json"), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE)) { | |
GeyserConnector.JSON_MAPPER.writer(new DefaultPrettyPrinter()).writeValue(outputStream, map); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment