|
1 | 1 | package org.mcphackers.mcp.tasks; |
2 | 2 |
|
| 3 | +import java.io.BufferedWriter; |
| 4 | +import java.io.FileWriter; |
3 | 5 | import java.net.URI; |
4 | 6 | import java.nio.file.Files; |
5 | 7 | import java.nio.file.Path; |
@@ -67,20 +69,34 @@ public void doTask() throws Exception { |
67 | 69 | chosenVersion = MCP.input.nextLine().toLowerCase(); |
68 | 70 | MCP.logger.print(new Ansi().fgDefault()); |
69 | 71 | } |
| 72 | + |
| 73 | + FileUtil.createDirectories(Paths.get(MCPConfig.CONF)); |
| 74 | + try(BufferedWriter writer = new BufferedWriter(new FileWriter(MCPConfig.VERSION))) { |
| 75 | + writer.write(chosenVersion); |
| 76 | + } |
| 77 | + |
70 | 78 | long startTime = System.currentTimeMillis(); |
71 | 79 | MCP.logger.info(" Downloading mappings"); |
72 | | - FileUtil.createDirectories(Paths.get(MCPConfig.CONF)); |
73 | | - VersionsParser.downloadVersion(chosenVersion); |
| 80 | + FileUtil.downloadFile(VersionsParser.downloadVersion(chosenVersion), Paths.get(MCPConfig.CONF, "conf.zip")); |
| 81 | + FileUtil.unzip(Paths.get(MCPConfig.CONF, "conf.zip"), Paths.get(MCPConfig.CONF), true); |
74 | 82 |
|
75 | 83 | // Create Eclipse workspace |
76 | 84 | MCP.logger.info(" Setting up workspace"); |
77 | 85 | FileUtil.deleteDirectoryIfExists(Paths.get("eclipse")); |
78 | | - int workspaceVersion = VersionsParser.getWorkspace(chosenVersion); |
79 | | - FileUtil.copyDirectory(Paths.get("versions", "workspace", "eclipse_" + workspaceVersion), Paths.get("eclipse")); |
| 86 | + FileUtil.copyDirectory(Paths.get("versions", "workspace", "eclipse"), Paths.get("eclipse")); |
80 | 87 |
|
81 | 88 | // Create Intellij workspace |
82 | 89 | String[] projects = { "Client", "Server" }; |
83 | 90 | for (String project : projects) { |
| 91 | + Path launch = Paths.get("eclipse", ".metadata", ".plugins", "org.eclipse.debug.core", ".launches", project + ".launch"); |
| 92 | + if (Files.exists(launch)) { |
| 93 | + List<String> lines = Files.readAllLines(launch); |
| 94 | + String replace = "-Dhttp.proxyPort=%s"; |
| 95 | + for (int i = 0; i < lines.size(); i++) { |
| 96 | + lines.set(i, lines.get(i).replace(replace, String.format(replace, VersionsParser.getProxyPort(chosenVersion)))); |
| 97 | + } |
| 98 | + Files.write(launch, lines); |
| 99 | + } |
84 | 100 | Path imlPath = Paths.get("eclipse", project, project + ".iml"); |
85 | 101 | if (Files.exists(imlPath)) { |
86 | 102 | List<String> lines = Files.readAllLines(imlPath); |
|
0 commit comments