fix: change Fabric to use meta api to install
This commit is contained in:
parent
6b9c43b3c2
commit
e02cd9e044
12 changed files with 327 additions and 264 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"java.home": "C:\\Program Files\\Amazon Corretto\\jdk11.0.3_7"
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
## 3.2.8.0
|
||||
## 3.2.8.1
|
||||
|
||||
- Update minimum Java to Java 8
|
||||
- Add in Discord rich presence integration
|
||||
- Fix post launch error check dialog not being displayed correctly
|
||||
- Fix fabric not installing correctly
|
||||
- Fix Forge requiring all libraries even if they're clientreq=false
|
||||
- Add in more detection for out of memory errors on launch
|
||||
- Change Fabric to use meta api to install
|
||||
|
|
|
@ -14,7 +14,7 @@ sourceCompatibility = '1.8'
|
|||
targetCompatibility = '1.8'
|
||||
|
||||
group = 'com.atlauncher'
|
||||
version = '3.2.8.0'
|
||||
version = '3.2.8.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.io.File;
|
|||
import java.util.Date;
|
||||
|
||||
import com.atlauncher.adapter.ColorTypeAdapter;
|
||||
import com.atlauncher.data.loaders.fabric.FabricMetaLauncherMeta;
|
||||
import com.atlauncher.data.loaders.fabric.FabricMetaLauncherMetaTypeAdapter;
|
||||
import com.atlauncher.data.mojang.DateTypeAdapter;
|
||||
import com.atlauncher.data.mojang.Downloads;
|
||||
import com.atlauncher.data.mojang.DownloadsTypeAdapter;
|
||||
|
@ -43,6 +45,7 @@ public final class Gsons {
|
|||
public static final Gson DEFAULT_ALT = new GsonBuilder().registerTypeAdapterFactory(new EnumTypeAdapterFactory())
|
||||
.registerTypeAdapter(Date.class, new DateTypeAdapter())
|
||||
.registerTypeAdapter(MojangArguments.class, new MojangArgumentsTypeAdapter())
|
||||
.registerTypeAdapter(FabricMetaLauncherMeta.class, new FabricMetaLauncherMetaTypeAdapter())
|
||||
.registerTypeAdapter(Downloads.class, new DownloadsTypeAdapter())
|
||||
.registerTypeAdapter(File.class, new FileTypeAdapter())
|
||||
.registerTypeAdapter(MojangStatus.class, new MojangStatusTypeAdapter()).create();
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
package com.atlauncher.data;
|
||||
|
||||
public class Constants {
|
||||
public static final LauncherVersion VERSION = new LauncherVersion(3, 2, 8, 0);
|
||||
public static final LauncherVersion VERSION = new LauncherVersion(3, 2, 8, 1);
|
||||
public static final String LAUNCHER_NAME = "ATLauncher";
|
||||
public static final String DISCORD_CLIENT_ID = "589393213723246592";
|
||||
public static final String API_BASE_URL = "https://api.atlauncher.com/v1/launcher/";
|
||||
public static final String PASTE_CHECK_URL = "https://paste.atlauncher.com";
|
||||
public static final String PASTE_API_URL = "https://paste.atlauncher.com/api/create";
|
||||
public static final String FORGE_MAVEN = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/";
|
||||
public static final String FABRIC_MAVEN = "https://maven.fabricmc.net/";
|
||||
public static final String LEGACY_JAVA_FIXER_URL = "https://files.minecraftforge.net/LegacyJavaFixer/legacyjavafixer-1.0.jar";
|
||||
public static final String LEGACY_JAVA_FIXER_MD5 = "12c337cb2445b56b097e7c25a5642710";
|
||||
public static final Server[] SERVERS = new Server[] {
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* ATLauncher - https://github.com/ATLauncher/ATLauncher
|
||||
* Copyright (C) 2013-2019 ATLauncher
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.atlauncher.data.loaders.fabric;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.atlauncher.annot.Json;
|
||||
|
||||
@Json
|
||||
public class FabricInstallProfile {
|
||||
private Map<String, List<String>> arguments;
|
||||
private String mainClass;
|
||||
private List<Library> libraries;
|
||||
|
||||
public Map<String, List<String>> getArguments() {
|
||||
return this.arguments;
|
||||
}
|
||||
|
||||
public String getMainClass() {
|
||||
return this.mainClass;
|
||||
}
|
||||
|
||||
public List<Library> getLibraries() {
|
||||
return this.libraries;
|
||||
}
|
||||
}
|
|
@ -17,19 +17,22 @@
|
|||
*/
|
||||
package com.atlauncher.data.loaders.fabric;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.Gsons;
|
||||
|
@ -41,15 +44,9 @@ import com.atlauncher.utils.Utils;
|
|||
import com.atlauncher.workers.InstanceInstaller;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
public class FabricLoader implements Loader {
|
||||
protected String yarn;
|
||||
protected String loader;
|
||||
protected String minecraft;
|
||||
protected FabricMetaVersion version;
|
||||
protected File tempDir;
|
||||
protected InstanceInstaller instanceInstaller;
|
||||
|
||||
|
@ -59,27 +56,24 @@ public class FabricLoader implements Loader {
|
|||
this.tempDir = tempDir;
|
||||
this.instanceInstaller = instanceInstaller;
|
||||
|
||||
if (metadata.containsKey("yarn") && metadata.containsKey("loader")) {
|
||||
this.yarn = (String) metadata.get("yarn");
|
||||
this.loader = (String) metadata.get("loader");
|
||||
if (metadata.containsKey("loader")) {
|
||||
this.version = this.getVersion((String) metadata.get("loader"));
|
||||
} else if ((boolean) metadata.get("latest")) {
|
||||
LogManager.debug("Downloading latest Fabric version");
|
||||
FabricMetaVersion latestVersion = this.getLatestVersion();
|
||||
this.yarn = latestVersion.getMappings().getVersion();
|
||||
this.loader = latestVersion.getLoader().getVersion();
|
||||
this.version = this.getLatestVersion();
|
||||
}
|
||||
}
|
||||
|
||||
public List<FabricMetaVersion> getLoaders() {
|
||||
try {
|
||||
Downloadable loaderVersions = new Downloadable(
|
||||
"https://meta.fabricmc.net/v1/versions/loader/" + this.minecraft, false);
|
||||
String.format("https://meta.fabricmc.net/v2/versions/loader/%s", this.minecraft), false);
|
||||
|
||||
String contents = loaderVersions.getContents();
|
||||
|
||||
java.lang.reflect.Type type = new TypeToken<List<FabricMetaVersion>>() {
|
||||
}.getType();
|
||||
return Gsons.DEFAULT.fromJson(contents, type);
|
||||
return Gsons.DEFAULT_ALT.fromJson(contents, type);
|
||||
} catch (Throwable e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
|
@ -87,6 +81,24 @@ public class FabricLoader implements Loader {
|
|||
return null;
|
||||
}
|
||||
|
||||
public FabricMetaVersion getLoader(String version) {
|
||||
try {
|
||||
Downloadable loaderVersion = new Downloadable(
|
||||
String.format("https://meta.fabricmc.net/v2/versions/loader/%s/%s", this.minecraft, version),
|
||||
false);
|
||||
|
||||
return Gsons.DEFAULT_ALT.fromJson(loaderVersion.getContents(), FabricMetaVersion.class);
|
||||
} catch (Throwable e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public FabricMetaVersion getVersion(String version) {
|
||||
return this.getLoader(version);
|
||||
}
|
||||
|
||||
public FabricMetaVersion getLatestVersion() {
|
||||
List<FabricMetaVersion> loaders = this.getLoaders();
|
||||
|
||||
|
@ -97,197 +109,60 @@ public class FabricLoader implements Loader {
|
|||
return loaders.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadAndExtractInstaller() {
|
||||
File saveTo = new File(App.settings.getLoadersDir(),
|
||||
String.format("fabric-loader-%s-%s-vanilla-profile.zip", this.yarn, this.loader));
|
||||
|
||||
try {
|
||||
HashableDownloadable download = new HashableDownloadable(
|
||||
String.format("https://fabricmc.net/download/vanilla/?yarn=%s&loader=%s",
|
||||
URLEncoder.encode(this.yarn, "UTF-8"), URLEncoder.encode(this.loader, "UTF-8")),
|
||||
saveTo, instanceInstaller);
|
||||
|
||||
if (download.needToDownload()) {
|
||||
this.instanceInstaller.addTotalDownloadedBytes(download.getFilesize());
|
||||
download.download(true);
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
|
||||
this.tempDir.mkdir();
|
||||
Utils.unzip(saveTo, this.tempDir);
|
||||
}
|
||||
|
||||
public FabricInstallProfile getInstallProfile() {
|
||||
FabricInstallProfile installProfile = null;
|
||||
|
||||
try {
|
||||
installProfile = Gsons.DEFAULT.fromJson(
|
||||
new FileReader(new File(this.tempDir, String.format(
|
||||
"fabric-loader-%1$s_yarn-%2$s/fabric-loader-%1$s_yarn-%2$s.json", this.yarn, this.loader))),
|
||||
FabricInstallProfile.class);
|
||||
} catch (Throwable e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
|
||||
return installProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Downloadable> getDownloadableLibraries() {
|
||||
List<Downloadable> librariesToDownload = new ArrayList<>();
|
||||
List<Library> libraries = new ArrayList<>();
|
||||
|
||||
// We use Fabric installer for servers, so we don't need to worry about
|
||||
// libraries
|
||||
if (!this.instanceInstaller.isServer()) {
|
||||
File librariesDirectory = this.instanceInstaller.isServer() ? this.instanceInstaller.getLibrariesDirectory()
|
||||
: App.settings.getGameLibrariesDir();
|
||||
libraries.add(new Library(this.version.getLoader().getMaven()));
|
||||
libraries.add(new Library(this.version.getIntermediary().getMaven()));
|
||||
|
||||
FabricInstallProfile installProfile = this.getInstallProfile();
|
||||
for (Library library : libraries) {
|
||||
String libraryPath = Utils.convertMavenIdentifierToPath(library.getName());
|
||||
File downloadTo = new File(App.settings.getGameLibrariesDir(), libraryPath);
|
||||
|
||||
for (Library library : installProfile.getLibraries()) {
|
||||
String libraryPath = Utils.convertMavenIdentifierToPath(library.getName());
|
||||
File downloadTo = new File(App.settings.getGameLibrariesDir(), libraryPath);
|
||||
File finalDownloadTo = new File(librariesDirectory, libraryPath);
|
||||
String url = library.getUrl() + Utils.convertMavenIdentifierToPath(library.getName());
|
||||
|
||||
String url = library.getUrl() + Utils.convertMavenIdentifierToPath(library.getName());
|
||||
|
||||
librariesToDownload.add(new HashableDownloadable(url, downloadTo, instanceInstaller, finalDownloadTo));
|
||||
}
|
||||
librariesToDownload.add(new HashableDownloadable(url, downloadTo, instanceInstaller));
|
||||
}
|
||||
|
||||
return librariesToDownload;
|
||||
}
|
||||
|
||||
public String getInstallerVersion() {
|
||||
Downloadable installerVersions = new Downloadable(
|
||||
"https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml", false);
|
||||
|
||||
try {
|
||||
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
|
||||
.parse(new InputSource(new StringReader(installerVersions.getContents())));
|
||||
|
||||
Node rootElement = document.getFirstChild();
|
||||
NodeList rootList = rootElement.getChildNodes();
|
||||
for (int i = 0; i < rootList.getLength(); i++) {
|
||||
Node child = rootList.item(i);
|
||||
if (child.getNodeName().equals("versioning")) {
|
||||
NodeList versioningList = child.getChildNodes();
|
||||
for (int j = 0; j < versioningList.getLength(); j++) {
|
||||
Node versionChild = versioningList.item(j);
|
||||
if (versionChild.getNodeName().equals("release")) {
|
||||
return versionChild.getTextContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runProcessors() {
|
||||
if (this.instanceInstaller.isServer()) {
|
||||
this.instanceInstaller.getMinecraftJar()
|
||||
.renameTo(new File(this.instanceInstaller.getRootDirectory(), "server.jar"));
|
||||
|
||||
Utils.delete(this.instanceInstaller.getLibrariesDirectory()); // no libraries here
|
||||
|
||||
String installerVersion = this.getInstallerVersion();
|
||||
|
||||
if (installerVersion == null) {
|
||||
LogManager.error("Failed to find innstaller version for Fabric");
|
||||
instanceInstaller.cancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
LogManager.debug("Downloading installer version " + installerVersion + " for Fabric");
|
||||
|
||||
File installerFile = new File(App.settings.getLoadersDir(),
|
||||
String.format("fabric-installer-%s-%s.jar", this.yarn, this.loader));
|
||||
|
||||
Downloadable installerDownload = new HashableDownloadable(
|
||||
String.format("https://maven.fabricmc.net/net/fabricmc/fabric-installer/%s/fabric-installer-%s.jar",
|
||||
installerVersion),
|
||||
installerFile, this.instanceInstaller);
|
||||
|
||||
if (installerDownload.needToDownload()) {
|
||||
installerDownload.download();
|
||||
}
|
||||
|
||||
try {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
String path = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
|
||||
arguments.add(path);
|
||||
arguments.add("-jar");
|
||||
arguments.add("\"" + installerFile.getAbsolutePath() + "\"");
|
||||
arguments.add("server");
|
||||
arguments.add("-dir");
|
||||
arguments.add("\"" + this.instanceInstaller.getRootDirectory().getAbsolutePath() + "\"");
|
||||
arguments.add("-mappings");
|
||||
arguments.add("\"" + this.yarn + "\"");
|
||||
arguments.add("-loader");
|
||||
arguments.add("\"" + this.loader + "\"");
|
||||
LogManager.debug("Running Fabric installer with arguments " + arguments.toString());
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(arguments);
|
||||
processBuilder.directory(this.instanceInstaller.getRootDirectory().getAbsoluteFile());
|
||||
processBuilder.redirectErrorStream(true);
|
||||
Process process = processBuilder.start();
|
||||
InputStream is = process.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
LogManager.debug("Fabric installer output: " + line);
|
||||
}
|
||||
|
||||
LogManager.debug("Finished running Fabric installer");
|
||||
} catch (Throwable e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLibraries() {
|
||||
FabricInstallProfile installProfile = this.getInstallProfile();
|
||||
List<String> libraries = new ArrayList<>();
|
||||
|
||||
// We use Fabric installer for servers, so we don't need to worry about
|
||||
// libraries
|
||||
if (!this.instanceInstaller.isServer()) {
|
||||
for (Library library : installProfile.getLibraries()) {
|
||||
libraries.add(Utils.convertMavenIdentifierToPath(library.getName()));
|
||||
}
|
||||
libraries.add(Utils.convertMavenIdentifierToPath(this.version.getLoader().getMaven()));
|
||||
libraries.add(Utils.convertMavenIdentifierToPath(this.version.getIntermediary().getMaven()));
|
||||
|
||||
for (Library library : this.version.getLauncherMeta().getLibraries(this.instanceInstaller.isServer())) {
|
||||
libraries.add(Utils.convertMavenIdentifierToPath(library.getName()));
|
||||
}
|
||||
|
||||
return libraries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getArguments() {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
private List<File> getLibraryFiles() {
|
||||
List<File> libraryFiles = new ArrayList<>();
|
||||
List<Library> libraries = new ArrayList<>();
|
||||
|
||||
if (this.getInstallProfile().getArguments() != null
|
||||
|| this.getInstallProfile().getArguments().containsKey("game")
|
||||
|| this.getInstallProfile().getArguments().get("game").size() != 0) {
|
||||
for (String argument : this.getInstallProfile().getArguments().get("game")) {
|
||||
arguments.add(argument);
|
||||
}
|
||||
libraries.add(new Library(this.version.getLoader().getMaven()));
|
||||
libraries.add(new Library(this.version.getIntermediary().getMaven()));
|
||||
libraries.addAll(this.version.getLauncherMeta().getLibraries(this.instanceInstaller.isServer()));
|
||||
|
||||
File librariesDirectory = App.settings.getGameLibrariesDir();
|
||||
|
||||
for (Library library : libraries) {
|
||||
libraryFiles.add(new File(librariesDirectory, Utils.convertMavenIdentifierToPath(library.getName())));
|
||||
}
|
||||
|
||||
return arguments;
|
||||
return libraryFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainClass() {
|
||||
return this.getInstallProfile().getMainClass();
|
||||
return this.version.getLauncherMeta().getMainClass(this.instanceInstaller.isServer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -295,15 +170,101 @@ public class FabricLoader implements Loader {
|
|||
return "fabric-server-launch.jar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useMinecraftLibraries() {
|
||||
// We use Fabric installer for servers, so we don't need to worry about
|
||||
// libraries
|
||||
return !this.instanceInstaller.isServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useMinecraftArguments() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadAndExtractInstaller() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runProcessors() {
|
||||
if (!this.instanceInstaller.isServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeServerLaunchJar();
|
||||
}
|
||||
|
||||
private void makeServerLaunchJar() {
|
||||
File file = new File(this.instanceInstaller.getRootDirectory(), "fabric-server-launch.jar");
|
||||
if (file.exists()) {
|
||||
Utils.delete(file);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
|
||||
|
||||
List<File> libraryFiles = this.getLibraryFiles();
|
||||
|
||||
Set<String> addedEntries = new HashSet<>();
|
||||
{
|
||||
addedEntries.add("META-INF/MANIFEST.MF");
|
||||
zipOutputStream.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
|
||||
|
||||
Manifest manifest = new Manifest();
|
||||
manifest.getMainAttributes().put(new Attributes.Name("Manifest-Version"), "1.0");
|
||||
manifest.getMainAttributes().put(new Attributes.Name("Main-Class"),
|
||||
"net.fabricmc.loader.launch.server.FabricServerLauncher");
|
||||
manifest.write(zipOutputStream);
|
||||
|
||||
zipOutputStream.closeEntry();
|
||||
|
||||
addedEntries.add("fabric-server-launch.properties");
|
||||
zipOutputStream.putNextEntry(new ZipEntry("fabric-server-launch.properties"));
|
||||
zipOutputStream.write(("launch.mainClass="
|
||||
+ this.version.getLauncherMeta().getMainClass(this.instanceInstaller.isServer()) + "\n")
|
||||
.getBytes(StandardCharsets.UTF_8));
|
||||
zipOutputStream.closeEntry();
|
||||
|
||||
byte[] buffer = new byte[32768];
|
||||
|
||||
for (File f : libraryFiles) {
|
||||
try (FileInputStream is = new FileInputStream(f); JarInputStream jis = new JarInputStream(is)) {
|
||||
JarEntry entry;
|
||||
while ((entry = jis.getNextJarEntry()) != null) {
|
||||
if (!addedEntries.contains(entry.getName())) {
|
||||
JarEntry newEntry = new JarEntry(entry.getName());
|
||||
zipOutputStream.putNextEntry(newEntry);
|
||||
|
||||
int r;
|
||||
while ((r = jis.read(buffer, 0, buffer.length)) >= 0) {
|
||||
zipOutputStream.write(buffer, 0, r);
|
||||
}
|
||||
|
||||
zipOutputStream.closeEntry();
|
||||
addedEntries.add(entry.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zipOutputStream.close();
|
||||
outputStream.close();
|
||||
|
||||
FileOutputStream propertiesOutputStream = new FileOutputStream(
|
||||
new File(this.instanceInstaller.getRootDirectory(), "fabric-server-launcher.properties"));
|
||||
propertiesOutputStream.write(("serverJar=" + this.instanceInstaller.getMinecraftJar().getName() + "\n")
|
||||
.getBytes(StandardCharsets.UTF_8));
|
||||
propertiesOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getArguments() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useMinecraftLibraries() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,26 +17,11 @@
|
|||
*/
|
||||
package com.atlauncher.data.loaders.fabric;
|
||||
|
||||
public class FabricMetaMappings {
|
||||
private String gameVersion;
|
||||
private String seperator;
|
||||
private int build;
|
||||
public class FabricMetaIntermediary {
|
||||
private String maven;
|
||||
private String version;
|
||||
private boolean stable;
|
||||
|
||||
public String getGameVersion() {
|
||||
return this.gameVersion;
|
||||
}
|
||||
|
||||
public String getSeperator() {
|
||||
return this.seperator;
|
||||
}
|
||||
|
||||
public int getBuild() {
|
||||
return this.build;
|
||||
}
|
||||
|
||||
public String getMaven() {
|
||||
return this.maven;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* ATLauncher - https://github.com/ATLauncher/ATLauncher
|
||||
* Copyright (C) 2013-2019 ATLauncher
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.atlauncher.data.loaders.fabric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FabricMetaLauncherMeta {
|
||||
private String version;
|
||||
private Map<String, String> mainClass;
|
||||
private Map<String, List<Library>> libraries;
|
||||
|
||||
FabricMetaLauncherMeta(String version, Map<String, String> mainClass, Map<String, List<Library>> libraries) {
|
||||
this.version = version;
|
||||
this.mainClass = mainClass;
|
||||
this.libraries = libraries;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getMainClass(boolean isServer) {
|
||||
if (isServer) {
|
||||
return this.mainClass.get("server");
|
||||
} else {
|
||||
return this.mainClass.get("client");
|
||||
}
|
||||
}
|
||||
|
||||
public List<Library> getLibraries(boolean isServer) {
|
||||
List<Library> libraries = new ArrayList<>();
|
||||
|
||||
libraries.addAll(this.libraries.get("common"));
|
||||
|
||||
if (isServer) {
|
||||
libraries.addAll(this.libraries.get("server"));
|
||||
} else {
|
||||
libraries.addAll(this.libraries.get("client"));
|
||||
}
|
||||
|
||||
return libraries;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* ATLauncher - https://github.com/ATLauncher/ATLauncher
|
||||
* Copyright (C) 2013-2019 ATLauncher
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.atlauncher.data.loaders.fabric;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.atlauncher.Gsons;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
public class FabricMetaLauncherMetaTypeAdapter implements JsonDeserializer<FabricMetaLauncherMeta> {
|
||||
@Override
|
||||
public FabricMetaLauncherMeta deserialize(JsonElement json, Type type, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
String version;
|
||||
Map<String, String> mainClass = new HashMap<>();
|
||||
Map<String, List<Library>> libraries = new HashMap<>();
|
||||
|
||||
final JsonObject rootJsonObject = json.getAsJsonObject();
|
||||
version = rootJsonObject.get("version").getAsString();
|
||||
|
||||
if (rootJsonObject.get("mainClass").isJsonObject()) {
|
||||
final JsonObject mainClassObject = rootJsonObject.getAsJsonObject("mainClass");
|
||||
|
||||
mainClass.put("client", mainClassObject.get("client").getAsString());
|
||||
mainClass.put("server", mainClassObject.get("server").getAsString());
|
||||
} else {
|
||||
String mainClassString = rootJsonObject.get("mainClass").getAsString();
|
||||
|
||||
mainClass.put("client", mainClassString);
|
||||
mainClass.put("server", mainClassString);
|
||||
}
|
||||
|
||||
final JsonObject librariesObject = rootJsonObject.getAsJsonObject("libraries");
|
||||
|
||||
List<Library> clientLibraries = new ArrayList<>();
|
||||
final JsonArray clientLibrariesArray = librariesObject.getAsJsonArray("client");
|
||||
for (JsonElement library : clientLibrariesArray) {
|
||||
clientLibraries.add(Gsons.DEFAULT_ALT.fromJson(library, Library.class));
|
||||
}
|
||||
libraries.put("client", clientLibraries);
|
||||
|
||||
List<Library> commonLibraries = new ArrayList<>();
|
||||
final JsonArray commonLibrariesArray = librariesObject.getAsJsonArray("common");
|
||||
for (JsonElement library : commonLibrariesArray) {
|
||||
commonLibraries.add(Gsons.DEFAULT_ALT.fromJson(library, Library.class));
|
||||
}
|
||||
libraries.put("common", commonLibraries);
|
||||
|
||||
List<Library> serverLibraries = new ArrayList<>();
|
||||
final JsonArray serverLibrariesArray = librariesObject.getAsJsonArray("server");
|
||||
for (JsonElement library : serverLibrariesArray) {
|
||||
serverLibraries.add(Gsons.DEFAULT_ALT.fromJson(library, Library.class));
|
||||
}
|
||||
libraries.put("server", serverLibraries);
|
||||
|
||||
return new FabricMetaLauncherMeta(version, mainClass, libraries);
|
||||
}
|
||||
}
|
|
@ -19,13 +19,18 @@ package com.atlauncher.data.loaders.fabric;
|
|||
|
||||
public class FabricMetaVersion {
|
||||
private FabricMetaLoader loader;
|
||||
private FabricMetaMappings mappings;
|
||||
private FabricMetaIntermediary intermediary;
|
||||
private FabricMetaLauncherMeta launcherMeta;
|
||||
|
||||
public FabricMetaLoader getLoader() {
|
||||
return this.loader;
|
||||
}
|
||||
|
||||
public FabricMetaMappings getMappings() {
|
||||
return this.mappings;
|
||||
public FabricMetaIntermediary getIntermediary() {
|
||||
return this.intermediary;
|
||||
}
|
||||
|
||||
public FabricMetaLauncherMeta getLauncherMeta() {
|
||||
return this.launcherMeta;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,22 @@
|
|||
package com.atlauncher.data.loaders.fabric;
|
||||
|
||||
import com.atlauncher.annot.Json;
|
||||
import com.atlauncher.data.Constants;
|
||||
|
||||
@Json
|
||||
public class Library {
|
||||
private String name;
|
||||
private String url;
|
||||
|
||||
public Library(String name, String url) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Library(String name) {
|
||||
this(name, Constants.FABRIC_MAVEN);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue