Last active
August 15, 2018 19:10
-
-
Save MiniDigger/0a6e5783f2511cc3d07dec45ace48f2c to your computer and use it in GitHub Desktop.
UpdateBungeeLanguageProperties
This file contains hidden or 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
import com.google.gson.Gson; | |
import java.io.PrintWriter; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.time.LocalDateTime; | |
import java.time.format.DateTimeFormatter; | |
import java.util.LinkedHashMap; | |
import java.util.Map; | |
import java.util.Properties; | |
class UpdateBungeeLanguageProperties { | |
public static void main(String[] args) throws Exception { | |
Path oldPropertiesFile = Paths.get("C:\\Users\\Martin\\Desktop\\en_us.properties.old"); | |
Path newJsonFile = Paths.get("C:\\Users\\Martin\\Desktop\\en_us.json"); | |
Path outputPropertiesFile = Paths.get("C:\\Users\\Martin\\Desktop\\en_us.properties"); | |
Gson gson = new Gson(); | |
Map json = gson.fromJson(Files.newBufferedReader(newJsonFile), Map.class); | |
LinkedHashMap<Object, Object> newProperties = new LinkedHashMap<>(json); | |
Properties oldProperties = new Properties(); | |
oldProperties.load(Files.newInputStream(oldPropertiesFile)); | |
newProperties.put("LEGACY_SEPARATOR","------------------- SEPARATING LEGACY STUFF -------------------"); | |
oldProperties.entrySet().stream() | |
.filter(e -> !newProperties.containsKey(e.getKey())) | |
.forEach(e -> newProperties.put(e.getKey(), e.getValue())); | |
PrintWriter writer = new PrintWriter(Files.newBufferedWriter(outputPropertiesFile)); | |
writer.println("# (c) 2018 Mojang AB"); | |
writer.println("# Generated on " + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME)); | |
writer.println("# Using this gist: https://gist.github.com/MiniDigger/0a6e5783f2511cc3d07dec45ace48f2c"); | |
newProperties.forEach((k, v)->writer.println(k + "=" + v)); | |
writer.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment