Update of mappings.json when in the .jar it is different.

This commit is contained in:
Louis 2022-06-11 15:11:51 +02:00 committed by GitHub
parent 7902520968
commit 0250d1b564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -206,13 +206,19 @@ public class Limbo {
String mappingName = "mapping.json";
File mappingFile = new File(internalDataFolder, mappingName);
InputStream mappingStreamIn = getClass().getClassLoader().getResourceAsStream(mappingName);
try {
if (!mappingFile.exists()) {
try (InputStream in = getClass().getClassLoader().getResourceAsStream(mappingName)) {
Files.copy(in, mappingFile.toPath());
} catch (IOException e) {
e.printStackTrace();
Files.copy(mappingStreamIn, mappingFile.toPath());
} else {
if (Files.newInputStream(mappingFile.toPath()) != mappingStreamIn) {
mappingFile.delete();
Files.copy(mappingStreamIn, mappingFile.toPath());
}
}
} catch (IOException e){
e.printStackTrace();
}
console.sendMessage("Loading packet id mappings from mapping.json ...");