Skip to content

Commit 5c4aeae

Browse files
author
IMS212
committed
3.0.1
1 parent 2589c01 commit 5c4aeae

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Version and packaging info
5-
version=3.0.0-pre4
5+
version=3.0.1
66
maven_group=net.hypercubemc
77
archives_base_name=Iris-Installer
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/net/hypercubemc/iris_installer/InstallerMeta.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,18 @@ public static JSONObject readJsonFromUrl(String url) throws IOException {
5858

5959
public static class Version {
6060
boolean outdated;
61+
boolean snapshot;
6162
String name;
6263

6364
public Version(HashMap<String, Object> jsonObject) {
6465
this.name = (String) jsonObject.get("name");
66+
this.snapshot = (boolean) jsonObject.get("snapshot");
6567
this.outdated = (boolean) jsonObject.get("outdated");
6668
}
69+
70+
@Override
71+
public String toString() {
72+
return name;
73+
}
6774
}
6875
}

src/main/java/net/hypercubemc/iris_installer/NewInstaller.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
import java.util.concurrent.ExecutionException;
2222
import java.util.zip.ZipEntry;
2323
import java.util.zip.ZipInputStream;
24-
import javax.swing.ImageIcon;
25-
import javax.swing.JFileChooser;
26-
import javax.swing.JOptionPane;
27-
import javax.swing.SwingWorker;
24+
import javax.swing.*;
25+
2826
import net.fabricmc.installer.Main;
2927
import net.fabricmc.installer.util.MetaHandler;
3028
import net.fabricmc.installer.util.Reference;
@@ -36,11 +34,12 @@
3634
* @author ims
3735
*/
3836
@SuppressWarnings("serial")
39-
public class NewInstaller extends javax.swing.JFrame {
37+
public class NewInstaller extends JFrame {
4038

4139
private static boolean dark = false;
4240
private boolean installAsMod;
4341
private String outdatedPlaceholder = "Warning: We have ended support for <version>.";
42+
private String snapshotPlaceholder = "Warning: <version> is a snapshot build and may";
4443
private String BASE_URL = "https://raw.githubusercontent.com/IrisShaders/Iris-Installer-Files/master/";
4544
private boolean finishedSuccessfulInstall;
4645
private InstallerMeta.Version selectedVersion;
@@ -231,9 +230,9 @@ private void initComponents() {
231230

232231
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
233232
setIconImage(new ImageIcon(Objects.requireNonNull(Utils.class.getClassLoader().getResource("iris_profile_icon.png"))).getImage());
234-
setMaximumSize(new java.awt.Dimension(480, 550));
235-
setMinimumSize(new java.awt.Dimension(480, 550));
236-
setPreferredSize(new java.awt.Dimension(480, 550));
233+
setMaximumSize(new java.awt.Dimension(480, 600));
234+
setMinimumSize(new java.awt.Dimension(480, 600));
235+
setPreferredSize(new java.awt.Dimension(480, 600));
237236
setResizable(false);
238237
getContentPane().setLayout(new java.awt.GridBagLayout());
239238

@@ -403,8 +402,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
403402
installButton.setFont(installButton.getFont().deriveFont((float)16));
404403
installButton.setText("Install");
405404
installButton.setToolTipText("");
406-
installButton.setMargin(new java.awt.Insets(10, 65, 10, 65));
407-
installButton.setMaximumSize(new java.awt.Dimension(300, 45));
405+
installButton.setMargin(new java.awt.Insets(10, 70, 10, 70));
406+
installButton.setMaximumSize(new java.awt.Dimension(320, 45));
408407
installButton.setMinimumSize(new java.awt.Dimension(173, 45));
409408
installButton.addMouseListener(new java.awt.event.MouseAdapter() {
410409
public void mouseClicked(java.awt.event.MouseEvent evt) {
@@ -444,6 +443,13 @@ private void gameVersionListItemStateChanged(java.awt.event.ItemEvent evt) {//GE
444443
outdatedText1.setText(outdatedPlaceholder.replace("<version>", selectedVersion.name));
445444
betaSelection.setVisible(false);
446445
outdatedText1.setVisible(true);
446+
outdatedText2.setText("The Iris version you get will most likely be outdated.");
447+
outdatedText2.setVisible(true);
448+
} else if (selectedVersion.snapshot) {
449+
outdatedText1.setText(snapshotPlaceholder.replace("<version>", selectedVersion.name));
450+
betaSelection.setVisible(false);
451+
outdatedText1.setVisible(true);
452+
outdatedText2.setText("lose support at any time.");
447453
outdatedText2.setVisible(true);
448454
} else {
449455
if (INSTALLER_META.hasBeta()) {
@@ -471,7 +477,7 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
471477
String profileName = installAsMod ? "Fabric Loader " : "Iris & Sodium for ";
472478
VanillaLauncherIntegration.Icon profileIcon = installAsMod ? VanillaLauncherIntegration.Icon.FABRIC : VanillaLauncherIntegration.Icon.IRIS;
473479
String loaderVersion = installAsMod ? Main.LOADER_META.getLatestVersion(false).getVersion() : Utils.readTextFile(loaderVersionUrl);
474-
boolean success = VanillaLauncherIntegration.installToLauncher(getVanillaGameDir(), getInstallDir(), profileName + selectedVersion.name, selectedVersion.name, loaderName, loaderVersion, profileIcon);
480+
boolean success = VanillaLauncherIntegration.installToLauncher(this, getVanillaGameDir(), getInstallDir(), profileName + selectedVersion.name, selectedVersion.name, loaderName, loaderVersion, profileIcon);
475481
if (!success) {
476482
System.out.println("Failed to install to launcher, canceling!");
477483
return;
@@ -489,6 +495,8 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
489495
}
490496

491497
installButton.setText("Downloading...");
498+
//installButton.setMargin(new java.awt.Insets(10, 90, 10, 90));
499+
492500
installButton.setEnabled(false);
493501
progressBar.setForeground(new Color(76, 135, 200));
494502
progressBar.setValue(0);
@@ -606,6 +614,8 @@ private void installButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIR
606614

607615
if (installSuccess) {
608616
installButton.setText("Completed!");
617+
//installButton.setMargin(new java.awt.Insets(10, 80, 10, 80));
618+
609619
progressBar.setForeground(new Color(39, 195, 75));
610620
installButton.setEnabled(true);
611621
finishedSuccessfulInstall = true;

src/main/java/net/hypercubemc/iris_installer/VanillaLauncherIntegration.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
import net.fabricmc.installer.client.ProfileInstaller;
55
import net.fabricmc.installer.util.Reference;
66
import net.fabricmc.installer.util.Utils;
7+
import org.json.JSONException;
78
import org.json.JSONObject;
89

910
import javax.swing.*;
11+
import java.awt.*;
1012
import java.io.IOException;
1113
import java.io.InputStream;
1214
import java.net.URL;
1315
import java.nio.file.Files;
1416
import java.nio.file.Path;
1517
import java.util.*;
18+
import java.util.List;
1619
import java.util.stream.Collectors;
1720

1821
public class VanillaLauncherIntegration {
19-
public static boolean installToLauncher(Path vanillaGameDir, Path instanceDir, String profileName, String gameVersion, String loaderName, String loaderVersion, Icon icon) throws IOException {
22+
public static boolean installToLauncher(Component parent, Path vanillaGameDir, Path instanceDir, String profileName, String gameVersion, String loaderName, String loaderVersion, Icon icon) throws IOException {
2023
String versionId = String.format("%s-%s-%s", loaderName, loaderVersion, gameVersion);
2124

2225
ProfileInstaller.LauncherType launcherType = System.getProperty("os.name").contains("Windows") ? getLauncherType(vanillaGameDir) : /* Return standalone if we aren't on Windows.*/ ProfileInstaller.LauncherType.WIN32;
@@ -25,7 +28,7 @@ public static boolean installToLauncher(Path vanillaGameDir, Path instanceDir, S
2528
return false;
2629
}
2730
installVersion(vanillaGameDir, gameVersion, loaderName, loaderVersion, launcherType);
28-
installProfile(vanillaGameDir, instanceDir, profileName, versionId, icon, launcherType);
31+
installProfile(parent, vanillaGameDir, instanceDir, profileName, versionId, icon, launcherType);
2932
return true;
3033
}
3134

@@ -69,7 +72,7 @@ private static void editVersionJson(Json profileJson) {
6972
json.getOrDefault("arguments", Json.array()).asJsonMap().getOrDefault("jvm", Json.array()).asJsonList().add(factory.string("-Diris.installer=true"));
7073
}
7174

72-
private static void installProfile(Path mcDir, Path instanceDir, String profileName, String versionId, Icon icon, ProfileInstaller.LauncherType launcherType) throws IOException {
75+
private static void installProfile(Component parent, Path mcDir, Path instanceDir, String profileName, String versionId, Icon icon, ProfileInstaller.LauncherType launcherType) throws IOException {
7376
Path launcherProfiles = mcDir.resolve(launcherType.profileJsonName);
7477
if (!Files.exists(launcherProfiles)) {
7578
System.out.println("Could not find launcher_profiles");
@@ -78,7 +81,14 @@ private static void installProfile(Path mcDir, Path instanceDir, String profileN
7881

7982
System.out.println("Creating profile");
8083

81-
JSONObject jsonObject = new JSONObject(Utils.readString(launcherProfiles));
84+
JSONObject jsonObject = null;
85+
86+
try {
87+
jsonObject = new JSONObject(Utils.readString(launcherProfiles));
88+
} catch (JSONException e) {
89+
JOptionPane.showMessageDialog(parent, "Failed to add profile, you might not have logged into the launcher.");
90+
return;
91+
}
8292

8393
JSONObject profiles = jsonObject.getJSONObject("profiles");
8494

0 commit comments

Comments
 (0)