Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File versionJsonFile = new File(versionTarget, VersionInfo.getVersionTarget() + ".json");
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- Writer writer = new OutputStreamWriter(bos, Charsets.UTF_8);
- PrettyJsonFormatter.fieldOrderPreservingPrettyJsonFormatter().format(versionJson, writer);
- writer.close();
- byte[] output = bos.toByteArray();
- List<AppendInfo> lst = Lists.newArrayList();
- Iterator var23 = VersionInfo.getOptionals().iterator();
- while(var23.hasNext()) {
- OptionalLibrary opt = (OptionalLibrary)var23.next();
- if (optionals.apply(opt.getArtifact()) && opt.isInjected()) {
- lst.add(new ClientInstall.AppendInfo(opt.getArtifact(), opt.getMaven()));
- }
- }
- var23 = transforms.iterator();
- while(var23.hasNext()) {
- TransformInfo info = (TransformInfo)var23.next();
- if (info.append) {
- lst.add(new ClientInstall.AppendInfo(info.output.getDescriptor(), info.maven));
- }
- }
- if (lst.size() > 0) {
- BufferedReader reader = new BufferedReader(new StringReader(new String(output, Charsets.UTF_8)));
- bos = new ByteArrayOutputStream();
- PrintWriter printer = new PrintWriter(new OutputStreamWriter(bos, Charsets.UTF_8));
- String line = null;
- String prefix = null;
- boolean added = false;
- while(true) {
- while((line = reader.readLine()) != null) {
- if (added) {
- printer.println(line);
- } else {
- if (line.contains("\"libraries\": [")) {
- prefix = line.substring(0, line.indexOf(34));
- } else if (prefix != null && line.startsWith(prefix + "]")) {
- printer.println(prefix + "\t,");
- for(int x = 0; x < lst.size(); ++x) {
- ClientInstall.AppendInfo info = (ClientInstall.AppendInfo)lst.get(x);
- printer.println(prefix + "\t{");
- printer.println(prefix + "\t\t\"name\": \"" + info.artifact + "\"" + info.maven == null ? "" : ",");
- if (info.maven != null) {
- printer.println(prefix + "\t\t\"url\": \"" + info.maven + "\"");
- }
- if (x < lst.size() - 1) {
- printer.println(prefix + "\t},");
- } else {
- printer.println(prefix + "\t}");
- }
- }
- added = true;
- }
- printer.println(line);
- }
- }
- printer.close();
- output = bos.toByteArray();
- break;
- }
- }
- Files.write(output, versionJsonFile);
- } catch (Exception var33) {
- JOptionPane.showMessageDialog(null, "There was a problem writing the launcher version data, is it write protected?", "Error", 0);
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement