Skip to content

Commit

Permalink
Merge pull request #3 from nexia-cts/dev
Browse files Browse the repository at this point in the history
- Bump version to 1.0.3
- Update Combat Test 8 download link to use working one
- Add Icon to Taskbar
- Change 'Install Vanilla' option to 'View CTS Mod List' when done installing Fabric
- Errors get shown now
- Change README to add updated images
- Remove showcase.gif
  • Loading branch information
not-coded authored Mar 27, 2024
2 parents 9f00518 + e637cf1 commit 869bddc
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 61 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# Combat Test Installer

The combat test installer allows you to install the combat test snapshots made by jeb_, such as [Combat Test 8c](https://minecraft.wiki/w/Java_Edition_Combat_Test_8c) *(latest)*, or [1.14.3 - Combat Test](https://minecraft.wiki/w/Java_Edition_1.14.3_-_Combat_Test) *(first)*

It also allows you to install fabric for the Combat Test Snapshots that have it.
It also allows you to **install fabric** for the Combat Test Snapshots that have it.

<br>

![Launcher opened in Vanilla Tab](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_opened_vanilla.png)

![launcher_opened](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_opened.png)
![Launcher successfull installed box in Vanilla](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_installed_box_vanilla.png)

![launcher_installed_box](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_installed_box.png)
<br>

![showcase](https://media.githubusercontent.com/media/nexia-cts/combat-test-installer/main/assets/showcase.gif)
![Launcher opened in Fabric Tab](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_opened_fabric.png)

![Launcher successfull installed box in Vanilla](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_installed_box_fabric.png)

# Credits

[Fabric Installer](https://github.com/FabricMC/fabric-installer/)

# License

Licensed under the [Apache License 2.0](https://github.com/nexia-cts/combat-test-installer/blob/main/LICENSE).
Binary file removed assets/launcher_installed_box.png
Binary file not shown.
Binary file added assets/launcher_installed_box_fabric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/launcher_installed_box_vanilla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/launcher_opened.png
Binary file not shown.
Binary file added assets/launcher_opened_fabric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/launcher_opened_vanilla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions assets/showcase.gif

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

group = 'com.nexia'
version = '1.0.2'
version = '1.0.3'

repositories {
mavenCentral()
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/nexia/installer/InstallerGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.lang.reflect.Method;
import java.util.function.Consumer;
import java.util.function.Supplier;

Expand Down Expand Up @@ -57,14 +58,29 @@ public static void load() throws UnsupportedLookAndFeelException, ClassNotFoundE

gui.setContentPane(gui.pane);


gui.updateSize(true);
gui.setTitle(Main.BUNDLE.getString("installer.title"));

gui.setIconImage(Main.icon);
gui.setTaskBarImage(Main.icon);

gui.setLocationRelativeTo(null);
gui.setVisible(true);
}

private void setTaskBarImage(Image image) {
try {
// Only supported in Java 9 +
Class<?> taskbarClass = Class.forName("java.awt.Taskbar");
Method getTaskbar = taskbarClass.getDeclaredMethod("getTaskbar");
Method setIconImage = taskbarClass.getDeclaredMethod("setIconImage", Image.class);
Object taskbar = getTaskbar.invoke(null);
setIconImage.invoke(taskbar, image);
} catch (Exception e) {
// Ignored, running on Java 8
}
}

private void updateSize(boolean updateMinimum) {
if (updateMinimum) setMinimumSize(null);
setPreferredSize(null);
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/com/nexia/installer/game/VersionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
public class VersionHandler {
public static List<GameVersion> versions = new ArrayList<>();

public static GameVersion CombatTest8c = new GameVersion("Combat Test 8c", "1.16_combat-6", new Download("f76157734ee0611fbef7d636156f20fa67c34514", 7463, "https://www.rizecookey.net/dl/file/combat-test-patched/1_16_combat-6.zip"));
public static GameVersion CombatTest8c = new GameVersion("Combat Test 8c", "1.16_combat-6", new Download("f76157734ee0611fbef7d636156f20fa67c34514", "https://www.rizecookey.net/dl/file/combat-test-patched/1_16_combat-6.zip"));

public static GameVersion CombatTest8b = new GameVersion("Combat Test 8b", "1.16_combat-5", new Download("9b2b984d635d373564b50803807225c75d7fd447", 7044, "https://launcher.mojang.com/experiments/combat/9b2b984d635d373564b50803807225c75d7fd447/1_16_combat-5.zip"));
public static GameVersion CombatTest8b = new GameVersion("Combat Test 8b", "1.16_combat-5", new Download("9b2b984d635d373564b50803807225c75d7fd447", "https://launcher.mojang.com/experiments/combat/9b2b984d635d373564b50803807225c75d7fd447/1_16_combat-5.zip"));

public static GameVersion CombatTest8 = new GameVersion("Combat Test 8", "1.16_combat-4", new Download("b4306b421183bd084b2831bd8d33a5db05ae9f9c", 7046, "https://cdn.discordapp.com/attachments/369990015096455168/947864881028272198/1_16_combat-4.zip"));
public static GameVersion CombatTest8 = new GameVersion("Combat Test 8", "1.16_combat-4", new Download("b4306b421183bd084b2831bd8d33a5db05ae9f9c", "https://notcoded.needs.rest/r/1_16_combat-4.zip"));

public static GameVersion CombatTest7c = new GameVersion("Combat Test 7c", "1.16_combat-3", new Download("2557b99d95588505e988886220779087d7d6b1e9", 7049, "https://piston-data.mojang.com/experiments/combat/2557b99d95588505e988886220779087d7d6b1e9/1_16_combat-3.zip"));
public static GameVersion CombatTest7c = new GameVersion("Combat Test 7c", "1.16_combat-3", new Download("2557b99d95588505e988886220779087d7d6b1e9", "https://piston-data.mojang.com/experiments/combat/2557b99d95588505e988886220779087d7d6b1e9/1_16_combat-3.zip"));

public static GameVersion CombatTest7b = new GameVersion("Combat Test 7b", "1.16_combat-2", new Download("43266ea8f2c20601d9fb264d5aa85df8052abc9e", 7051, "https://archive.org/download/Combat_Test_7ab/1_16_combat-2.zip"));
public static GameVersion CombatTest7 = new GameVersion("Combat Test 7", "1.16_combat-1", new Download("47bb5be6cb3ba215539ee97dfae66724c73c3dd5", 7045, "https://archive.org/download/Combat_Test_7ab/1_16_combat-1.zip"));
public static GameVersion CombatTest7b = new GameVersion("Combat Test 7b", "1.16_combat-2", new Download("43266ea8f2c20601d9fb264d5aa85df8052abc9e", "https://archive.org/download/Combat_Test_7ab/1_16_combat-2.zip"));
public static GameVersion CombatTest7 = new GameVersion("Combat Test 7", "1.16_combat-1", new Download("47bb5be6cb3ba215539ee97dfae66724c73c3dd5", "https://archive.org/download/Combat_Test_7ab/1_16_combat-1.zip"));

public static GameVersion CombatTest6 = new GameVersion("Combat Test 6", "1.16_combat-0", new Download("5a8ceec8681ed96ab6ecb9607fb5d19c8a755559", 7049, "https://piston-data.mojang.com/experiments/combat/5a8ceec8681ed96ab6ecb9607fb5d19c8a755559/1_16_combat-0.zip"));
public static GameVersion CombatTest5 = new GameVersion("Combat Test 5", "1.15_combat-6", new Download("52263d42a626b40c947e523128f7a195ec5af76a", 7061, "https://piston-data.mojang.com/experiments/combat/52263d42a626b40c947e523128f7a195ec5af76a/1_15_combat-6.zip"));
public static GameVersion CombatTest4 = new GameVersion("Combat Test 4", "1.15_combat-1", new Download("ac11ea96f3bb2fa2b9b76ab1d20cacb1b1f7ef60", 7059, "https://piston-data.mojang.com/experiments/combat/ac11ea96f3bb2fa2b9b76ab1d20cacb1b1f7ef60/1_15_combat-1.zip"));
public static GameVersion CombatTest3 = new GameVersion("Combat Test 3", "1.14_combat-3", new Download("0f209c9c84b81c7d4c88b4632155b9ae550beb89", 6433, "https://piston-data.mojang.com/experiments/combat/0f209c9c84b81c7d4c88b4632155b9ae550beb89/1_14_combat-3.zip"));
public static GameVersion CombatTest2 = new GameVersion("Combat Test 2", "1.14_combat-0", new Download("d164bb6ecc5fca9ac02878c85f11befae61ac1ca", 6287, "https://piston-data.mojang.com/experiments/combat/d164bb6ecc5fca9ac02878c85f11befae61ac1ca/1_14_combat-0.zip"));
public static GameVersion CombatTest1 = new GameVersion("1.14.3 - Combat Test", "1.14_combat-212796", new Download("610f5c9874ba8926d5ae1bcce647e5f0e6e7c889",4843, "https://piston-data.mojang.com/experiments/combat/610f5c9874ba8926d5ae1bcce647e5f0e6e7c889/1_14_combat-212796.zip"));
public static GameVersion CombatTest6 = new GameVersion("Combat Test 6", "1.16_combat-0", new Download("5a8ceec8681ed96ab6ecb9607fb5d19c8a755559", "https://piston-data.mojang.com/experiments/combat/5a8ceec8681ed96ab6ecb9607fb5d19c8a755559/1_16_combat-0.zip"));
public static GameVersion CombatTest5 = new GameVersion("Combat Test 5", "1.15_combat-6", new Download("52263d42a626b40c947e523128f7a195ec5af76a", "https://piston-data.mojang.com/experiments/combat/52263d42a626b40c947e523128f7a195ec5af76a/1_15_combat-6.zip"));
public static GameVersion CombatTest4 = new GameVersion("Combat Test 4", "1.15_combat-1", new Download("ac11ea96f3bb2fa2b9b76ab1d20cacb1b1f7ef60", "https://piston-data.mojang.com/experiments/combat/ac11ea96f3bb2fa2b9b76ab1d20cacb1b1f7ef60/1_15_combat-1.zip"));
public static GameVersion CombatTest3 = new GameVersion("Combat Test 3", "1.14_combat-3", new Download("0f209c9c84b81c7d4c88b4632155b9ae550beb89", "https://piston-data.mojang.com/experiments/combat/0f209c9c84b81c7d4c88b4632155b9ae550beb89/1_14_combat-3.zip"));
public static GameVersion CombatTest2 = new GameVersion("Combat Test 2", "1.14_combat-0", new Download("d164bb6ecc5fca9ac02878c85f11befae61ac1ca", "https://piston-data.mojang.com/experiments/combat/d164bb6ecc5fca9ac02878c85f11befae61ac1ca/1_14_combat-0.zip"));
public static GameVersion CombatTest1 = new GameVersion("1.14.3 - Combat Test", "1.14_combat-212796", new Download("610f5c9874ba8926d5ae1bcce647e5f0e6e7c889", "https://piston-data.mojang.com/experiments/combat/610f5c9874ba8926d5ae1bcce647e5f0e6e7c889/1_14_combat-212796.zip"));

public static class GameVersion {
String version;
Expand Down Expand Up @@ -52,12 +52,10 @@ public Download getDownload() {

public static class Download {
public final String sha1;
public final long size;
public final String url;

public Download(String sha1, long size, String url) {
public Download(String sha1, String url) {
this.sha1 = sha1;
this.size = size;
this.url = url;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/nexia/installer/util/InstallerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public JPanel setPanel(InstallerGUI gui) {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (IOException | RuntimeException ex) {
InstallerUtils.showError(ex.getMessage());
ex.printStackTrace();
}
});

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/nexia/installer/util/InstallerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ public static ProfileInstaller.LauncherType showLauncherTypeSelection() {
return result == JOptionPane.YES_OPTION ? ProfileInstaller.LauncherType.MICROSOFT_STORE : ProfileInstaller.LauncherType.WIN32;
}

public static void showError(String error) {
Object[] options = {"Restart Program"};
int result = JOptionPane.showOptionDialog(null,
error,
Main.BUNDLE.getString("installer.title"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]
);

if(result == JOptionPane.OK_OPTION) {
try {
InstallerGUI.instance.dispose();
Main.main(new String[]{});
} catch (Exception ignored) {
System.exit(0);
}
}

}

private static void showDone(VersionHandler.GameVersion gameVersion) {
Object[] options = {"OK", "Install Fabric"};
int result = JOptionPane.showOptionDialog(null,
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/nexia/installer/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Utils {

public static final DateFormat ISO_8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

public static String userAgent = "Mozilla/5.0 (compatible; combat-test-installer; +https://github.com/nexia-cts/combat-test-installer)";

public static void extractZip(Path file, Path path) throws IOException {
ZipInputStream zipIn = new ZipInputStream(Files.newInputStream(Paths.get(file.toString())));
ZipEntry entry = zipIn.getNextEntry();
Expand Down Expand Up @@ -56,7 +58,7 @@ public static void writeToFile(Path path, String string) throws IOException {
Files.write(path, string.getBytes(StandardCharsets.UTF_8));
}

public static void downloadFile(URL url, Path path) throws IOException {
public static void downloadFile(URL url, Path path) {
try (InputStream in = openUrl(url)) {
Files.createDirectories(path.getParent());
Files.copy(in, path, StandardCopyOption.REPLACE_EXISTING);
Expand All @@ -67,7 +69,8 @@ public static void downloadFile(URL url, Path path) throws IOException {
t.addSuppressed(t2);
}

throw t;
InstallerUtils.showError(t.getMessage());
t.printStackTrace();
}
}

Expand All @@ -76,6 +79,7 @@ public static void downloadFile(URL url, Path path) throws IOException {
private static InputStream openUrl(URL url) throws IOException {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setRequestProperty("User-Agent", userAgent);
conn.setConnectTimeout(HTTP_TIMEOUT_MS);
conn.setReadTimeout(HTTP_TIMEOUT_MS);
conn.connect();
Expand Down Expand Up @@ -136,7 +140,7 @@ public static String getProfileIcon() {

return "data:image/png;base64," + Base64.getEncoder().encodeToString(Arrays.copyOf(ret, offset));
} catch (IOException e) {
return "furnace"; // Fallback to furnace icon if we cant load Nexia icon.
return "furnace"; // Fallback to default icon if we cant load the icon.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -64,8 +66,9 @@ public JPanel setPanel(InstallerGUI gui) {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (IOException | RuntimeException ex) {
InstallerUtils.showError(ex.getMessage());
ex.printStackTrace();
}
});

Expand Down Expand Up @@ -124,13 +127,13 @@ public void launch() throws IOException {
if (successBufferedInputStream.available() == 0) hasError = true;

if(hasError) {
this.error();
InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error"));
} else {
this.showDone(gameVersion);
}

} catch (Exception ignored) {
this.error();
InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error"));
}

buttonInstall.setEnabled(true);
Expand Down Expand Up @@ -170,7 +173,7 @@ private File getJarFile() throws IOException {

private String getFabricVersion() {

String version = "0.11.1";
String version = "1.0.0";

try {
String response = HttpAPI.get("https://api.github.com/repos/rizecookey/fabric-installer/releases/latest");
Expand All @@ -183,8 +186,8 @@ private String getFabricVersion() {
} catch (Exception ignored) { return version; }
}

private void showDone(FabricVersionHandler.GameVersion gameVersion) {
Object[] options = {"OK", "Install Vanilla"};
private void showDone(FabricVersionHandler.GameVersion gameVersion) throws URISyntaxException, IOException {
Object[] options = {"OK", "View CTS Mod List"};
int result = JOptionPane.showOptionDialog(null,
MessageFormat.format(Main.BUNDLE.getString("installer.prompt.install.done.fabric"), gameVersion.getVersion()),
Main.BUNDLE.getString("installer.title"),
Expand All @@ -195,31 +198,14 @@ private void showDone(FabricVersionHandler.GameVersion gameVersion) {
options[0]
);

if(result == JOptionPane.NO_OPTION) InstallerGUI.instance.pane.setSelectedComponent(InstallerGUI.instance.vanilla);
}

private void error() {
Object[] options = {"OK", "Cancel"};
int result = JOptionPane.showOptionDialog(null,
MessageFormat.format(Main.BUNDLE.getString("installer.prompt.install.error"), ""),
Main.BUNDLE.getString("installer.title"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]
);

if(result == JOptionPane.OK_OPTION) {
try {
InstallerGUI.instance.dispose();
Main.main(new String[]{});
} catch (Exception ignored) {
System.exit(0);
if(result == JOptionPane.NO_OPTION) {
URI url = new URI("https://github.com/nexia-cts/cts-mod-list");
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(url);
} else {
throw new UnsupportedOperationException("Failed to open " + url.toURL());
}
}

buttonInstall.setEnabled(true);
}
}

3 changes: 2 additions & 1 deletion src/main/resources/lang/installer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ installer.prompt.game.version=Minecraft Version:
installer.prompt.select.location=Select Install Location:
installer.button.install=Install
installer.prompt.install.done={0} has been installed, if you want to install fabric then click on the "Install Fabric" button.
installer.prompt.install.done.fabric={0} has been installed, if you want to install vanilla then click on the "Install Vanilla" button.
installer.prompt.install.done.fabric={0} has been installed, if you want mods for fabric then you should check out the CTS Mod List by clicking on the "View CTS Mod List" button.
installer.exception.no.launcher.directory=No launcher directory found!
installer.exception.no.launcher.profile=No launcher profile.json found!
installer.prompt.launcher.type.body=The Combat Test Installer has detected 2 different installations of the Minecraft Launcher, which launcher do you wish to install the Combat Tests to?\n\n- Select Microsoft Store if you are playing Minecraft through the Xbox App or the Windows Store.\n- Select Standalone if you downloaded the Minecraft launcher directly from the Minecraft.net website.\n\nIf you are unsure try the Microsoft Store option first, you can always re-run the installer.
installer.prompt.launcher.type.xbox=Microsoft Store / Xbox
installer.prompt.launcher.type.win32=Standalone (Win32)
Expand Down

0 comments on commit 869bddc

Please sign in to comment.