VoidLoader/VoidLoader/pipeline/head There was a failure building this commit
Signed-off-by: Faumaray <faumaray@gmail.com>
47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
package ru.faumaray.adapters;
|
|
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.Optional;
|
|
|
|
import ru.faumaray.LaunchInfo;
|
|
import ru.faumaray.LauncherAdapter;
|
|
|
|
public class GenericLauncherAdapter implements LauncherAdapter {
|
|
@Override
|
|
public Optional<LaunchInfo> findLaunchInfo(String version, Path gameDir, String[] args) {
|
|
// As a last resort, try scanning known patterns under gameDir or its siblings
|
|
|
|
// Try gameDir/versions/<version>/<version>.jar
|
|
Path versions = gameDir.resolve("versions");
|
|
Path verFolder = versions.resolve(version);
|
|
Path jar = verFolder.resolve(version + ".jar");
|
|
if (Files.exists(jar)) {
|
|
LaunchInfo li = new LaunchInfo();
|
|
li.mcJar = jar;
|
|
li.mainClass = "net.minecraft.client.main.Main";
|
|
// also include all .jar files under gameDir/libraries
|
|
Path libs = gameDir.resolve("libraries");
|
|
if (Files.isDirectory(libs)) {
|
|
try {
|
|
Files.walk(libs).forEach(p -> {
|
|
if (p.toString().endsWith(".jar")) {
|
|
li.libraryPaths.add(p);
|
|
}
|
|
});
|
|
} catch (Exception e) {
|
|
// ignore
|
|
}
|
|
}
|
|
return Optional.of(li);
|
|
}
|
|
|
|
// Optionally, scan siblings or parent directories
|
|
Path parent = gameDir.getParent();
|
|
if (parent != null) {
|
|
return findLaunchInfo(version, parent, args);
|
|
}
|
|
return Optional.empty();
|
|
}
|
|
}
|