Compare commits

...

8 Commits

Author SHA1 Message Date
Henry 847106f1fb
Linux XDG folder support (#518) 2024-01-02 23:23:57 +00:00
Henry 93f60488fa
Prevent Forge's Log4j configuration from being overridden (#513) 2024-01-02 21:03:06 +00:00
Henry Le Grys b5fe175650 Add support for NeoForge 2024-01-02 20:58:51 +00:00
Henry Le Grys 11808457fe Fix launcher trying to download processor outputs
Fix for forge 1.20.4; the generated client jar is specified as a library
because it goes on the classpath now.
2024-01-02 20:22:23 +00:00
Ch. König 5712eb1dfb
rewritten xdg folder fetcher.
tries old dotfolder first
2023-09-20 10:12:17 +02:00
Ch. König 9428dbbe7b
Linux XDG folder support 2023-09-13 19:50:49 +02:00
DaPorkchop_ 5668e567a1
move vanilla jar to the end of the classpath
this emulates the behavior of the vanilla launcher. it's important because if the vanilla jar is first, Log4j will always auto-detect the vanilla log4j.xml instead of Forge's.
2023-08-04 18:14:14 +02:00
DaPorkchop_ 31a13115fb
copy logging config from loader version manifest 2023-08-04 18:14:09 +02:00
9 changed files with 72 additions and 9 deletions

View File

@ -194,9 +194,21 @@ public class Bootstrap {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
return new File(getFileChooseDefaultDir(), getProperties().getProperty("homeFolderWindows"));
} else {
return new File(System.getProperty("user.home"), getProperties().getProperty("homeFolder"));
}
File dotFolder = new File(System.getProperty("user.home"), getProperties().getProperty("homeFolder"));
String xdgFolderName = getProperties().getProperty("homeFolderLinux");
if (osName.contains("linux") && !dotFolder.exists() && !xdgFolderName.isEmpty()) {
String xdgDataHome = System.getenv("XDG_DATA_HOME");
if (xdgDataHome.isEmpty()) {
xdgDataHome = System.getProperty("user.home") + "/.local/share";
}
return new File(xdgDataHome, xdgFolderName);
}
return dotFolder;
}
private static boolean isPortableMode() {

View File

@ -5,6 +5,7 @@
#
homeFolderWindows=Example Launcher
homeFolderLinux=example_launcher
homeFolder=.examplelauncher
launcherClass=com.skcraft.launcher.Launcher
latestUrl=http://update.skcraft.com/quark/launcher/latest.json
latestUrl=http://update.skcraft.com/quark/launcher/latest.json

View File

@ -164,7 +164,7 @@ public class PackageBuilder {
if (basicProfile.isLegacy()) {
processor = new OldForgeLoaderProcessor();
} else if (basicProfile.getProfile().equalsIgnoreCase("forge")) {
} else {
processor = new ModernForgeLoaderProcessor();
}
} else if (BuilderUtils.getZipEntry(jarFile, "fabric-installer.json") != null) {

View File

@ -73,6 +73,12 @@ public class ModernForgeLoaderProcessor implements ILoaderProcessor {
}
}
// Copy logging config
SidedData<VersionManifest.LoggingConfig> loggingConfig = info.getLogging();
if (loggingConfig != null) {
version.setLogging(loggingConfig);
}
// Copy main class
String mainClass = info.getMainClass();
if (mainClass != null) {
@ -150,6 +156,22 @@ public class ModernForgeLoaderProcessor implements ILoaderProcessor {
// Add loader manifest to the map
manifest.getLoaders().put(loaderName, new LoaderManifest(profile.getLibraries(), profile.getData(), extraFiles));
// Find name of final patched library and mark it as excluded from download
// TODO: we should generalize this to all process outputs, really
SidedData<String> finalJars = profile.getData().get("PATCHED");
if (finalJars != null) {
String libraryName = finalJars.getClient();
libraryName = libraryName.substring(1, libraryName.length() - 1);
for (Library lib : result.getLoaderLibraries()) {
if (lib.matches(libraryName)) {
lib.setGenerated(true);
log.info(String.format("Setting generated flag on library '%s'", lib.getName()));
break;
}
}
}
// Add processors
manifest.getTasks().addAll(profile.toProcessorEntries(loaderName));
}

View File

@ -140,7 +140,6 @@ public class Runner implements Callable<Process>, ProgressObservable {
}
progress = new DefaultProgress(0.9, SharedLocale.tr("runner.collectingArgs"));
builder.classPath(getJarPath());
builder.setMainClass(versionManifest.getMainClass());
addWindowArgs();
@ -232,6 +231,9 @@ public class Runner implements Callable<Process>, ProgressObservable {
tr("runner.missingLibrary", instance.getTitle(), library.getName()));
}
}
// The official launcher puts the vanilla jar at the end of the classpath, we'll do the same
builder.classPath(getJarPath());
}
/**
@ -307,7 +309,7 @@ public class Runner implements Callable<Process>, ProgressObservable {
}
}
if (versionManifest.getLogging() != null) {
if (versionManifest.getLogging() != null && versionManifest.getLogging().getClient() != null) {
log.info("Logging config present, log4j2 bug likely mitigated");
VersionManifest.LoggingConfig config = versionManifest.getLogging().getClient();

View File

@ -19,7 +19,7 @@ public class LoaderManifest {
public Library findLibrary(String name) {
for (Library library : getLibraries()) {
if (library.getName().equals(name)) {
if (library.matches(name)) {
return library;
}
}

View File

@ -12,6 +12,7 @@ import com.google.common.base.Splitter;
import com.skcraft.launcher.model.minecraft.GameArgument;
import com.skcraft.launcher.model.minecraft.Library;
import com.skcraft.launcher.model.minecraft.MinecraftArguments;
import com.skcraft.launcher.model.minecraft.VersionManifest;
import lombok.Data;
import java.util.List;
@ -23,6 +24,7 @@ public class VersionInfo {
private MinecraftArguments arguments;
private String mainClass;
private List<Library> libraries;
private SidedData<VersionManifest.LoggingConfig> logging;
@JsonIgnore private transient boolean overridingArguments;

View File

@ -8,6 +8,7 @@ package com.skcraft.launcher.model.minecraft;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
@ -33,7 +34,8 @@ public class Library {
private String comment;
// Custom
private boolean locallyAvailable;
@JsonInclude(value = JsonInclude.Include.NON_DEFAULT)
private boolean generated;
public boolean matches(Environment environment) {
boolean allow = false;
@ -201,6 +203,12 @@ public class Library {
}
public void setName(String name) {
int classifierPos = name.indexOf("@");
if (classifierPos != -1) {
// Take off classifiers
name = name.substring(0, classifierPos);
}
this.name = name;
// [DEEP SIGH]
@ -226,6 +234,20 @@ public class Library {
}
}
/**
* Classifier-independent library name check
* @param mavenName Maven name of a library, possibly with a classifier
* @return True if this library is named 'mavenName'.
*/
public boolean matches(String mavenName) {
int classifierPos = mavenName.indexOf('@');
if (classifierPos != -1) {
mavenName = mavenName.substring(0, classifierPos);
}
return this.name.equals(mavenName);
}
public static String mavenNameToPath(String mavenName) {
List<String> split = Splitter.on(':').splitToList(mavenName);
int size = split.size();

View File

@ -249,6 +249,8 @@ public abstract class BaseUpdater {
}
for (Library library : allLibraries) {
if (library.isGenerated()) continue; // Skip generated libraries.
if (library.matches(environment)) {
checkInterrupted();
@ -282,7 +284,7 @@ public abstract class BaseUpdater {
}
// Use our custom logging config depending on what the manifest specifies
if (versionManifest.getLogging() != null) {
if (versionManifest.getLogging() != null && versionManifest.getLogging().getClient() != null) {
VersionManifest.LoggingConfig config = versionManifest.getLogging().getClient();
VersionManifest.Artifact file = config.getFile();