mirror of
https://github.com/LOOHP/Limbo.git
synced 2026-06-07 21:41:43 +00:00
refactor: get mappings from jar rather than file
This commit is contained in:
@@ -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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user