|
14 | 14 | import com.google.common.io.Files; |
15 | 15 | import com.google.gson.JsonArray; |
16 | 16 | import com.google.gson.JsonPrimitive; |
| 17 | +import me.cubxity.asm.LaunchWrapperPatcher; |
17 | 18 | import org.apache.commons.io.FileUtils; |
18 | 19 |
|
19 | 20 | import java.io.File; |
|
32 | 33 | * Created by Cubxity on 06/07/2018 |
33 | 34 | */ |
34 | 35 | public class Installer { |
35 | | - public static final int API_VERSION = 1; |
| 36 | + public static final int API_VERSION = 2; |
36 | 37 |
|
37 | 38 | private final InstallerConfig config; |
38 | 39 |
|
@@ -257,6 +258,34 @@ public void install() { |
257 | 258 | return; |
258 | 259 | } |
259 | 260 |
|
| 261 | + File launchWrapper = new File(libraries, "net" + sep + "minecraft" + sep + "launchwrapper" + sep + "1.7" + sep + "launchwrapper-1.7.jar"); |
| 262 | + launchWrapper.getParentFile().mkdirs(); |
| 263 | + if (!launchWrapper.exists()) { |
| 264 | + phrase = Phrase.DOWNLOAD_LAUNCHER; |
| 265 | + try { |
| 266 | + DownloadTask dl = new DownloadTask("https://libraries.minecraft.net/net/minecraft/launchwrapper/1.7/launchwrapper-1.7.jar", launchWrapper.getParentFile().getAbsolutePath()); |
| 267 | + dl.addPropertyChangeListener(evt -> { |
| 268 | + if (evt.getNewValue() instanceof Integer) |
| 269 | + callback.accept(new StatusCallback(Phrase.DOWNLOAD_COMPONENTS, "Downloading LaunchWrapper (" + evt.getNewValue() + "%)", null)); |
| 270 | + }); |
| 271 | + dl.execute(); |
| 272 | + dl.get(); |
| 273 | + } catch (Exception ex) { |
| 274 | + callback.accept(new ErrorCallback(ex, phrase, "Failed to download LaunchWrapper, " + ex.getMessage())); |
| 275 | + return; |
| 276 | + } |
| 277 | + } |
| 278 | + |
| 279 | + File customLaunchWrapper = new File(launchWrapper.getParentFile().getParentFile(), "Hyperium" + sep + "launchwrapper-Hyperium.jar"); |
| 280 | + customLaunchWrapper.getParentFile().mkdir(); |
| 281 | + phrase = Phrase.PATCH_LAUNCHER; |
| 282 | + try { |
| 283 | + LaunchWrapperPatcher.patch(launchWrapper, "cc/hyperium/utils/CrashHandler", "handle", "(Ljava/lang/Exception;)V", customLaunchWrapper); |
| 284 | + } catch (Exception ex) { |
| 285 | + callback.accept(new ErrorCallback(ex, phrase, "Failed to patch LaunchWrapper: " + ex.getMessage())); |
| 286 | + return; |
| 287 | + } |
| 288 | + |
260 | 289 | phrase = Phrase.CREATE_PROFILE; |
261 | 290 | callback.accept(new StatusCallback(phrase, "Creating profile", null)); |
262 | 291 | if (mmc) { |
@@ -350,7 +379,8 @@ public void install() { |
350 | 379 | ); |
351 | 380 | libs.add( |
352 | 381 | new JsonHolder() |
353 | | - .put("name", "net.minecraft:launchwrapper:1.7") |
| 382 | + .put("name", "net.minecraft:launchwrapper:Hyperium") |
| 383 | + .put("MMC-hint", "local") |
354 | 384 | .getObject() |
355 | 385 | ); |
356 | 386 | if (of) |
@@ -397,7 +427,7 @@ public void install() { |
397 | 427 | lib.put("name", config.getVersion().getName().equals("LOCAL") ? "cc.hyperium:Hyperium:LOCAL" : config.getVersion().getArtifactId()); |
398 | 428 | JsonArray libs = json.optJSONArray("libraries"); |
399 | 429 | libs.add(lib.getObject()); |
400 | | - libs.add(new JsonHolder().put("name", "net.minecraft:launchwrapper:1.7").getObject()); |
| 430 | + libs.add(new JsonHolder().put("name", "net.minecraft:launchwrapper:Hyperium").getObject()); |
401 | 431 | if (of) |
402 | 432 | libs.add(new JsonHolder().put("name", "optifine:OptiFine:1.8.9_HD_U_I7").getObject()); |
403 | 433 | json.put("libraries", libs); |
|
0 commit comments