7 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
12 changed files with 176 additions and 97 deletions

No files matched your search

-1
View File
@@ -1 +0,0 @@
.gitea/CODEOWNERS linguist-detectable=false
-3
View File
@@ -1,3 +0,0 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+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/
+1 -1
View File
@@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
group = 'com.nexia'
version = '1.0.3'
version = '1.0.4'
repositories {
mavenCentral()
+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();
@@ -10,7 +10,7 @@ public class VersionHandler {
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", "https://notcoded.needs.rest/r/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", "https://piston-data.mojang.com/experiments/combat/2557b99d95588505e988886220779087d7d6b1e9/1_16_combat-3.zip"));
@@ -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,9 +57,8 @@ public class InstallerHelper {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException | RuntimeException ex) {
InstallerUtils.showError(ex.getMessage());
ex.printStackTrace();
} catch (Exception ex) {
InstallerUtils.showError(ex);
}
});
@@ -109,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,10 +138,15 @@ 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,
error,
Main.BUNDLE.getString("installer.prompt.install.error") + "\n\n" + error,
Main.BUNDLE.getString("installer.title"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE,
@@ -69,8 +69,7 @@ public class Utils {
t.addSuppressed(t2);
}
InstallerUtils.showError(t.getMessage());
t.printStackTrace();
InstallerUtils.showError(t);
}
}
@@ -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.*;
@@ -18,7 +22,7 @@ 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;
@@ -49,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)));
@@ -66,9 +71,8 @@ public class FabricInstallerHelper extends InstallerHelper {
buttonInstall.setEnabled(false);
try {
launch();
} catch (IOException | RuntimeException ex) {
InstallerUtils.showError(ex.getMessage());
ex.printStackTrace();
} catch (Exception ex) {
InstallerUtils.showError(ex);
}
});
@@ -76,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);
}
@@ -91,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) {
InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.error"));
} else {
this.showDone(gameVersion);
}
} catch (Exception ignored) {
InstallerUtils.showError(Main.BUNDLE.getString("installer.prompt.install.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();
}
@@ -153,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 {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 244 KiB

+1 -1
View File
@@ -11,7 +11,7 @@ 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