forked from BLOCKFANTASY/LOOHP-Limbo
refactor: get mappings from jar rather than file
This commit is contained in:
parent
6e12d17cd4
commit
f48c48e6e5
|
|
@ -214,19 +214,15 @@ public final class Limbo {
|
||||||
internalDataFolder.mkdirs();
|
internalDataFolder.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
String mappingName = "mapping.json";
|
|
||||||
File mappingFile = new File(internalDataFolder, mappingName);
|
|
||||||
if (!mappingFile.exists()) {
|
|
||||||
try (InputStream in = getClass().getClassLoader().getResourceAsStream(mappingName)) {
|
|
||||||
Files.copy(in, mappingFile.toPath());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.sendMessage("Loading packet id mappings from mapping.json ...");
|
console.sendMessage("Loading packet id mappings from mapping.json ...");
|
||||||
|
|
||||||
InputStreamReader reader = new InputStreamReader(Files.newInputStream(mappingFile.toPath()), StandardCharsets.UTF_8);
|
InputStream mappingStream = getClass().getClassLoader().getResourceAsStream("mapping.json");
|
||||||
|
if (mappingStream == null) {
|
||||||
|
console.sendMessage("Failed to load mapping.json from jar!");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputStreamReader reader = new InputStreamReader(mappingStream, StandardCharsets.UTF_8);
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(reader);
|
JSONObject json = (JSONObject) new JSONParser().parse(reader);
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue