Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
869bddc859 |
No files matched your search
+1
-61
@@ -1,63 +1,3 @@
|
||||
### 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
|
||||
@@ -101,4 +41,4 @@ bin/
|
||||
|
||||
|
||||
### cache ###
|
||||
cache/
|
||||
cache/
|
||||
+1
-1
@@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
group = 'com.nexia'
|
||||
version = '1.0.4'
|
||||
version = '1.0.3'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -38,13 +38,14 @@ public class Main {
|
||||
|
||||
os = OS.LINUX;
|
||||
|
||||
if (System.getProperty("os.name").contains("win")) {
|
||||
if(System.getProperty("os.name").startsWith("Windows")){
|
||||
os = OS.WINDOWS;
|
||||
System.setProperty("javax.net.ssl.trustStoreType", "WINDOWS-ROOT");
|
||||
} else if (System.getProperty("os.name").contains("mac")) {
|
||||
os = OS.MAC;
|
||||
}
|
||||
|
||||
if(System.getProperty("os.name").startsWith("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://archive.org/download/1-16-combat-4_202404/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", "https://piston-data.mojang.com/experiments/combat/2557b99d95588505e988886220779087d7d6b1e9/1_16_combat-3.zip"));
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ 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)));
|
||||
|
||||
@@ -57,8 +56,9 @@ public class InstallerHelper {
|
||||
buttonInstall.setEnabled(false);
|
||||
try {
|
||||
launch();
|
||||
} catch (Exception ex) {
|
||||
InstallerUtils.showError(ex);
|
||||
} catch (IOException | RuntimeException ex) {
|
||||
InstallerUtils.showError(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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,9 +6,11 @@ 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.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,10 +31,10 @@ public class InstallerUtils {
|
||||
|
||||
if (Main.os.equals(Main.OS.LINUX) && !Files.exists(dir)) {
|
||||
// https://github.com/flathub/com.mojang.Minecraft
|
||||
final Path flatpak = homeDir.resolve(".var").resolve("app").resolve("com.mojang.Minecraft").resolve(".minecraft");
|
||||
final Path flatpack = homeDir.resolve(".var").resolve("app").resolve("com.mojang.Minecraft").resolve(".minecraft");
|
||||
|
||||
if (Files.exists(flatpak)) {
|
||||
dir = flatpak;
|
||||
if (Files.exists(flatpack)) {
|
||||
dir = flatpack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,40 +43,6 @@ 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;
|
||||
|
||||
@@ -100,7 +68,34 @@ public class InstallerUtils {
|
||||
}
|
||||
}
|
||||
|
||||
downloadVanilla(mcDir, gameVersion);
|
||||
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();
|
||||
|
||||
if (InstallerHelper.createProfile.isSelected()) {
|
||||
if (launcherType == null) {
|
||||
@@ -111,7 +106,7 @@ public class InstallerUtils {
|
||||
}
|
||||
showDone(gameVersion);
|
||||
} catch (Exception e) {
|
||||
InstallerUtils.showError(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
InstallerHelper.buttonInstall.setEnabled(true);
|
||||
}
|
||||
@@ -138,15 +133,10 @@ 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,
|
||||
error,
|
||||
Main.BUNDLE.getString("installer.title"),
|
||||
JOptionPane.OK_CANCEL_OPTION,
|
||||
JOptionPane.ERROR_MESSAGE,
|
||||
|
||||
@@ -69,7 +69,8 @@ public class Utils {
|
||||
t.addSuppressed(t2);
|
||||
}
|
||||
|
||||
InstallerUtils.showError(t);
|
||||
InstallerUtils.showError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@ package com.nexia.installer.util.fabric;
|
||||
|
||||
import com.nexia.installer.InstallerGUI;
|
||||
import com.nexia.installer.Main;
|
||||
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 com.nexia.installer.util.*;
|
||||
import mjson.Json;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -22,7 +18,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
public class FabricInstallerHelper extends InstallerHelper {
|
||||
public static JButton buttonInstall;
|
||||
@@ -53,10 +49,9 @@ public class FabricInstallerHelper extends InstallerHelper {
|
||||
}
|
||||
|
||||
addRow(panel, c, "installer.prompt.select.location",
|
||||
installLocation = new JTextField(23),
|
||||
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)));
|
||||
|
||||
@@ -71,8 +66,9 @@ public class FabricInstallerHelper extends InstallerHelper {
|
||||
buttonInstall.setEnabled(false);
|
||||
try {
|
||||
launch();
|
||||
} catch (Exception ex) {
|
||||
InstallerUtils.showError(ex);
|
||||
} catch (IOException | RuntimeException ex) {
|
||||
InstallerUtils.showError(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -80,7 +76,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/" + Objects.requireNonNull(getJarFile()).getName());
|
||||
Process process = Runtime.getRuntime().exec("java -jar cache/" + getJarFile().getName());
|
||||
while(process.isAlive()) {
|
||||
buttonFabric.setEnabled(false);
|
||||
}
|
||||
@@ -95,63 +91,52 @@ 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"));
|
||||
}
|
||||
|
||||
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) { }
|
||||
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();
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
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();
|
||||
buttonInstall.setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,12 +153,12 @@ public class FabricInstallerHelper extends InstallerHelper {
|
||||
return new File(cacheDir.toFile(), fileName);
|
||||
}
|
||||
|
||||
if(Objects.requireNonNull(cacheDir.toFile().listFiles()).length == 0) {
|
||||
if(cacheDir.toFile().listFiles().length == 0) {
|
||||
Files.delete(cacheDir);
|
||||
return getJarFile();
|
||||
}
|
||||
|
||||
for(File file : Objects.requireNonNull(cacheDir.toFile().listFiles())) {
|
||||
for(File file : cacheDir.toFile().listFiles()) {
|
||||
if(file.getName().equals(fileName)) {
|
||||
return file;
|
||||
} else {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 244 KiB After Width: | Height: | Size: 2.7 MiB |
@@ -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 "Restart Program" to restart the program.\nIt would be appreciated if you sent a screenshot of this error to the developers.
|
||||
installer.prompt.install.error=An error has occurred, click "OK" to restart the program or click "Cancel" to continue.
|
||||
|
||||
installer.button.fabric=Open the Fabric Installer
|
||||
installer.tab.vanilla=Vanilla
|
||||
|
||||
Reference in new issue
Block a user