15 Commits
Author SHA1 Message Date
NotCoded 9efd960153 fix not being able to download fabric from the launcher (technically) 2024-08-07 17:58:11 +02:00
NotCoded 76852b00fc actually fix size changing when moving tabs 2024-08-02 13:25:20 +02:00
NotCoded 951016e39d woahh
- change combat test 8 to archive.org link
- improve error showing to user
- make install location and button not change sizes when moving tabs
2024-08-02 13:19:42 +02:00
NotCoded e3442033df no more null!! 2024-05-25 21:09:49 +02:00
NotCoded 29209c45d9 bump version 2024-05-25 20:54:23 +02:00
NotCoded 49899f08f2 fix path not getting recognized on mac 2024-05-25 20:53:19 +02:00
NotCoded a3caa6045c update icon & .gitignore 2024-05-04 20:20:15 +02:00
NotCoded e637cf19a8 Merge branch 'main' into dev 2024-03-27 11:44:56 +01:00
NotCoded 7c7356be7e add new images 2024-03-27 11:41:46 +01:00
NotCoded 58bca1826f tweaks to http in utils 2024-03-26 22:36:52 +01:00
NotCoded b473234383 change cts 8 download link 2024-03-26 22:29:15 +01:00
NotCoded eed3cc1921 add icon to taskbar, add view cts modlist as option in fabric when done installing 2024-03-26 21:44:58 +01:00
NotCoded 3cdad232b9 errors get shown now 2024-03-07 21:14:31 +01:00
NotCoded efe491ca2d bump version + remove unnecessary stuff 2024-03-07 20:48:51 +01:00
NotCoded 9f005185bc Update README.md 2023-10-24 07:21:14 +02:00
20 changed files with 259 additions and 140 deletions

No files matched your search

-1
View File
@@ -1 +0,0 @@
*.gif filter=lfs diff=lfs merge=lfs -text
+61 -1
View File
@@ -1,3 +1,63 @@
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
@@ -41,4 +101,4 @@ bin/
### cache ###
cache/
cache/
+14 -3
View File
@@ -1,14 +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)*
![launcher_opened](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_opened.png)
It also allows you to **install fabric** for the Combat Test Snapshots that have it.
![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 Vanilla Tab](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_opened_vanilla.png)
![Launcher successfull installed box in Vanilla](https://raw.githubusercontent.com/nexia-cts/combat-test-installer/main/assets/launcher_installed_box_vanilla.png)
<br>
![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 not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
View File
Binary file not shown.
+1 -1
View File
@@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
group = 'com.nexia'
version = '1.0.2'
version = '1.0.4'
repositories {
mavenCentral()
@@ -6,6 +6,7 @@ import com.nexia.installer.util.fabric.FabricInstallerHelper;
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;
@@ -57,14 +58,29 @@ public class InstallerGUI extends JFrame {
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);
+3 -4
View File
@@ -38,13 +38,12 @@ public class Main {
os = OS.LINUX;
if(System.getProperty("os.name").startsWith("Windows")){
if (System.getProperty("os.name").contains("win")) {
os = OS.WINDOWS;
System.setProperty("javax.net.ssl.trustStoreType", "WINDOWS-ROOT");
}
if(System.getProperty("os.name").startsWith("mac"))
} else if (System.getProperty("os.name").contains("mac")) {
os = OS.MAC;
}
icon = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemClassLoader().getResource("icon.png"));
InstallerGUI.load();
@@ -6,23 +6,23 @@ import java.util.List;
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://archive.org/download/1-16-combat-4_202404/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;
@@ -52,12 +52,10 @@ public class VersionHandler {
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;
}
}
@@ -42,6 +42,7 @@ public class InstallerHelper {
installLocation = new JTextField(20),
selectFolderButton = new JButton());
selectFolderButton.setText("...");
// It looks better when the width is set to height, so.....
selectFolderButton.setPreferredSize(new Dimension(installLocation.getPreferredSize().height, installLocation.getPreferredSize().height));
selectFolderButton.addActionListener(e -> InstallerGUI.selectInstallLocation(() -> installLocation.getText(), s -> installLocation.setText(s)));
@@ -56,8 +57,8 @@ public class InstallerHelper {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (Exception ex) {
InstallerUtils.showError(ex);
}
});
@@ -108,8 +109,8 @@ public class InstallerHelper {
}
public void launch() throws IOException {
String stringGameVersion = (String) gameVersionComboBox.getSelectedItem();
assert stringGameVersion != null;
VersionHandler.GameVersion gameVersion = VersionHandler.identifyGameVersion(stringGameVersion);
if(gameVersion == null) return;
@@ -6,11 +6,9 @@ import com.nexia.installer.game.VersionHandler;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.*;
import java.text.MessageFormat;
import java.util.List;
@@ -31,10 +29,10 @@ public class InstallerUtils {
if (Main.os.equals(Main.OS.LINUX) && !Files.exists(dir)) {
// https://github.com/flathub/com.mojang.Minecraft
final Path flatpack = homeDir.resolve(".var").resolve("app").resolve("com.mojang.Minecraft").resolve(".minecraft");
final Path flatpak = homeDir.resolve(".var").resolve("app").resolve("com.mojang.Minecraft").resolve(".minecraft");
if (Files.exists(flatpack)) {
dir = flatpack;
if (Files.exists(flatpak)) {
dir = flatpak;
}
}
}
@@ -43,6 +41,40 @@ public class InstallerUtils {
return dir.toAbsolutePath().normalize();
}
public static void downloadVanilla(Path mcDir, VersionHandler.GameVersion gameVersion) throws IOException {
String alternativeCodeName = gameVersion.getCodeName().replaceAll("\\.", "_");
System.out.println("Installing " + gameVersion.getVersion() + " (" + gameVersion.getCodeName() + ")");
Path versionsDir = mcDir.resolve("versions");
if(!Files.exists(versionsDir)) Files.createDirectories(versionsDir);
Path profileDir = versionsDir.resolve(gameVersion.getCodeName());
Path profileJson = profileDir.resolve(gameVersion.getCodeName() + ".json");
Path aProfileDir = versionsDir.resolve(alternativeCodeName);
Path aProfileJson = aProfileDir.resolve(alternativeCodeName + ".json");
if(!Files.exists(profileDir)) Files.createDirectory(profileDir);
if(!Files.exists(profileJson)) Files.createFile(profileJson);
if(!Files.exists(aProfileDir)) Files.createDirectory(aProfileDir);
if(!Files.exists(aProfileJson)) Files.createFile(aProfileJson);
File zipFile = new File(versionsDir + "/" + gameVersion.getCodeName() + ".zip");
Utils.downloadFile(URI.create(gameVersion.getDownload().url).toURL(), zipFile.toPath());
Utils.extractZip(zipFile.toPath(), versionsDir);
Files.copy(aProfileJson, profileJson, StandardCopyOption.REPLACE_EXISTING);
//System.out.println(Utils.sha1String(zipFile.toPath()).equalsIgnoreCase(gameVersion.getDownload().sha1));
aProfileJson.toFile().delete();
aProfileDir.toFile().delete();
zipFile.delete();
}
public static void install(Path mcDir, VersionHandler.GameVersion gameVersion) {
if(mcDir == null || gameVersion == null) return;
@@ -68,34 +100,7 @@ public class InstallerUtils {
}
}
String alternativeCodeName = gameVersion.getCodeName().replaceAll("\\.", "_");
System.out.println("Installing " + gameVersion.getVersion() + " (" + gameVersion.getCodeName() + ")");
Path versionsDir = mcDir.resolve("versions");
Path profileDir = versionsDir.resolve(gameVersion.getCodeName());
Path profileJson = profileDir.resolve(gameVersion.getCodeName() + ".json");
Path aProfileDir = versionsDir.resolve(alternativeCodeName);
Path aProfileJson = aProfileDir.resolve(alternativeCodeName + ".json");
if(!Files.exists(profileDir)) Files.createDirectory(profileDir);
if(!Files.exists(profileJson)) Files.createFile(profileJson);
if(!Files.exists(aProfileDir)) Files.createDirectory(aProfileDir);
if(!Files.exists(aProfileJson)) Files.createFile(aProfileJson);
File zipFile = new File(versionsDir + "/" + gameVersion.getCodeName() + ".zip");
Utils.downloadFile(URI.create(gameVersion.getDownload().url).toURL(), zipFile.toPath());
Utils.extractZip(zipFile.toPath(), versionsDir);
Files.copy(aProfileJson, profileJson, StandardCopyOption.REPLACE_EXISTING);
aProfileJson.toFile().delete();
aProfileDir.toFile().delete();
zipFile.delete();
downloadVanilla(mcDir, gameVersion);
if (InstallerHelper.createProfile.isSelected()) {
if (launcherType == null) {
@@ -106,7 +111,7 @@ public class InstallerUtils {
}
showDone(gameVersion);
} catch (Exception e) {
e.printStackTrace();
InstallerUtils.showError(e);
} finally {
InstallerHelper.buttonInstall.setEnabled(true);
}
@@ -133,6 +138,34 @@ public class InstallerUtils {
return result == JOptionPane.YES_OPTION ? ProfileInstaller.LauncherType.MICROSOFT_STORE : ProfileInstaller.LauncherType.WIN32;
}
public static void showError(Throwable throwable) {
throwable.printStackTrace();
showError(throwable.getClass().getSimpleName() + ": " + throwable.getMessage());
}
public static void showError(String error) {
Object[] options = {"Restart Program"};
int result = JOptionPane.showOptionDialog(null,
Main.BUNDLE.getString("installer.prompt.install.error") + "\n\n" + 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,
@@ -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();
@@ -56,7 +58,7 @@ public class Utils {
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);
@@ -67,7 +69,7 @@ public class Utils {
t.addSuppressed(t2);
}
throw t;
InstallerUtils.showError(t);
}
}
@@ -76,6 +78,7 @@ public class Utils {
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();
@@ -136,7 +139,7 @@ public class Utils {
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.
}
}
}
@@ -2,7 +2,11 @@ package com.nexia.installer.util.fabric;
import com.nexia.installer.InstallerGUI;
import com.nexia.installer.Main;
import com.nexia.installer.util.*;
import com.nexia.installer.game.VersionHandler;
import com.nexia.installer.util.HttpAPI;
import com.nexia.installer.util.InstallerHelper;
import com.nexia.installer.util.InstallerUtils;
import com.nexia.installer.util.Utils;
import mjson.Json;
import javax.swing.*;
@@ -11,12 +15,14 @@ import java.awt.*;
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;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.List;
import java.util.Objects;
public class FabricInstallerHelper extends InstallerHelper {
public static JButton buttonInstall;
@@ -47,9 +53,10 @@ public class FabricInstallerHelper extends InstallerHelper {
}
addRow(panel, c, "installer.prompt.select.location",
installLocation = new JTextField(20),
installLocation = new JTextField(23),
selectFolderButton = new JButton());
selectFolderButton.setText("...");
// It looks better when the width is set to height, so.....
selectFolderButton.setPreferredSize(new Dimension(installLocation.getPreferredSize().height, installLocation.getPreferredSize().height));
selectFolderButton.addActionListener(e -> InstallerGUI.selectInstallLocation(() -> installLocation.getText(), s -> installLocation.setText(s)));
@@ -64,8 +71,8 @@ public class FabricInstallerHelper extends InstallerHelper {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (Exception ex) {
InstallerUtils.showError(ex);
}
});
@@ -73,7 +80,7 @@ public class FabricInstallerHelper extends InstallerHelper {
buttonFabric = new JButton(Main.BUNDLE.getString("installer.button.fabric")));
buttonFabric.addActionListener(e -> {
try {
Process process = Runtime.getRuntime().exec("java -jar cache/" + getJarFile().getName());
Process process = Runtime.getRuntime().exec("java -jar cache/" + Objects.requireNonNull(getJarFile()).getName());
while(process.isAlive()) {
buttonFabric.setEnabled(false);
}
@@ -88,52 +95,63 @@ public class FabricInstallerHelper extends InstallerHelper {
@Override
public void launch() throws IOException {
String stringGameVersion = (String) gameVersionComboBox.getSelectedItem();
assert stringGameVersion != null;
FabricVersionHandler.GameVersion gameVersion = FabricVersionHandler.identifyGameVersion(stringGameVersion);
if(gameVersion == null) return;
Path mcPath = Paths.get(installLocation.getText());
if (!Files.exists(mcPath)) {
throw new RuntimeException(Main.BUNDLE.getString("installer.exception.no.launcher.directory"));
}
System.out.println("Installing Fabric " + gameVersion.getVersion() + " (" + gameVersion.getCodeName() + ")");
String[] cmd2 = new String[]{"java", "-jar", "cache/" + getJarFile().getName(), "client", "-dir" + "\"" + mcPath.toAbsolutePath() + "\"", "-mcversion", gameVersion.codeName};
try {
Process process = Runtime.getRuntime().exec(cmd2);
BufferedInputStream successBufferedInputStream = new BufferedInputStream(process.getInputStream());
BufferedInputStream errorBufferedInputStream = new BufferedInputStream(process.getErrorStream());
synchronized (process) {
process.waitFor();
VersionHandler.GameVersion vanillaGameVersion = VersionHandler.identifyGameVersion(stringGameVersion);
if(vanillaGameVersion != null) {
// Fix not being able to download fabric from the launcher
Path versionsPath = mcPath.resolve("versions").resolve(vanillaGameVersion.getCodeName());
if(!Files.exists(versionsPath)) {
try {
InstallerUtils.downloadVanilla(mcPath, vanillaGameVersion);
} catch (Exception ignored) { }
}
boolean hasError = false;
if (errorBufferedInputStream.available() != 0) {
errorBufferedInputStream.close();
hasError = true;
}
if (process.exitValue() != 0) hasError = true;
if (successBufferedInputStream.available() == 0) hasError = true;
if(hasError) {
this.error();
} else {
this.showDone(gameVersion);
}
} catch (Exception ignored) {
this.error();
}
buttonInstall.setEnabled(true);
System.out.println("Installing Fabric " + gameVersion.getVersion() + " (" + gameVersion.getCodeName() + ")");
String[] cmd2 = new String[]{"java", "-jar", "cache/" + Objects.requireNonNull(getJarFile()).getName(), "client", "-dir" + "\"" + mcPath.toAbsolutePath() + "\"", "-mcversion", gameVersion.codeName};
new Thread(() -> {
try {
Process process = Runtime.getRuntime().exec(cmd2);
BufferedInputStream successBufferedInputStream = new BufferedInputStream(process.getInputStream());
BufferedInputStream errorBufferedInputStream = new BufferedInputStream(process.getErrorStream());
synchronized (process) {
process.waitFor();
}
boolean hasError = false;
if (errorBufferedInputStream.available() != 0) {
errorBufferedInputStream.close();
hasError = true;
}
if (process.exitValue() != 0) hasError = true;
if (successBufferedInputStream.available() == 0) hasError = true;
if(hasError) {
InstallerUtils.showError("The Fabric Installer has had an unknown error.");
} else {
this.showDone(gameVersion);
}
} catch (Exception e) {
InstallerUtils.showError(e);
} finally {
buttonInstall.setEnabled(true);
}
}).start();
}
@@ -150,12 +168,12 @@ public class FabricInstallerHelper extends InstallerHelper {
return new File(cacheDir.toFile(), fileName);
}
if(cacheDir.toFile().listFiles().length == 0) {
if(Objects.requireNonNull(cacheDir.toFile().listFiles()).length == 0) {
Files.delete(cacheDir);
return getJarFile();
}
for(File file : cacheDir.toFile().listFiles()) {
for(File file : Objects.requireNonNull(cacheDir.toFile().listFiles())) {
if(file.getName().equals(fileName)) {
return file;
} else {
@@ -170,7 +188,7 @@ public class FabricInstallerHelper extends InstallerHelper {
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");
@@ -183,8 +201,8 @@ public class FabricInstallerHelper extends InstallerHelper {
} 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"),
@@ -195,31 +213,14 @@ public class FabricInstallerHelper extends InstallerHelper {
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);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 244 KiB

+3 -2
View File
@@ -2,15 +2,16 @@ 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)
installer.title=Combat Test Installer
installer.option.create.profile=Create profile
installer.prompt.install.error=An error has occurred, click "OK" to restart the program or click "Cancel" to continue.
installer.prompt.install.error=An error has occurred, click "Restart Program" to restart the program.\nIt would be appreciated if you sent a screenshot of this error to the developers.
installer.button.fabric=Open the Fabric Installer
installer.tab.vanilla=Vanilla