mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 17:11:39 +03:00
[FEATURE] ClientProfile libraries
This commit is contained in:
parent
54c4604885
commit
9091c838e4
3 changed files with 114 additions and 13 deletions
|
@ -38,8 +38,6 @@ public final class ClientProfile implements Comparable<ClientProfile> {
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private List<String> updateExclusions;
|
private List<String> updateExclusions;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private List<String> updateShared;
|
|
||||||
@LauncherNetworkAPI
|
|
||||||
private List<String> updateVerify;
|
private List<String> updateVerify;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private Set<OptionalFile> updateOptional;
|
private Set<OptionalFile> updateOptional;
|
||||||
|
@ -52,6 +50,8 @@ public final class ClientProfile implements Comparable<ClientProfile> {
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private List<String> clientArgs;
|
private List<String> clientArgs;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
|
private List<ClientProfileLibrary> libraries;
|
||||||
|
@LauncherNetworkAPI
|
||||||
private List<String> compatClasses;
|
private List<String> compatClasses;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private Map<String, String> properties;
|
private Map<String, String> properties;
|
||||||
|
@ -83,12 +83,42 @@ public final class ClientProfile implements Comparable<ClientProfile> {
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private String mainClass;
|
private String mainClass;
|
||||||
|
|
||||||
|
public static class ClientProfileLibrary {
|
||||||
|
public final String zone;
|
||||||
|
public final String name;
|
||||||
|
public final String path;
|
||||||
|
|
||||||
|
public ClientProfileLibrary(String zone, String name, String path) {
|
||||||
|
this.zone = zone;
|
||||||
|
this.name = name;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileLibrary(String name, String path) {
|
||||||
|
this.zone = "libraries";
|
||||||
|
this.name = name;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileLibrary(String name) {
|
||||||
|
this.zone = "libraries";
|
||||||
|
this.name = name;
|
||||||
|
this.path = convertMavenNameToPath(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertMavenNameToPath(String name) {
|
||||||
|
String[] mavenIdSplit = name.split(":");
|
||||||
|
return String.format("%s/%s/%s/%s-%s.jar", mavenIdSplit[0].replaceAll("\\.", "/"),
|
||||||
|
mavenIdSplit[1], mavenIdSplit[2], mavenIdSplit[1], mavenIdSplit[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfile() {
|
public ClientProfile() {
|
||||||
update = new ArrayList<>();
|
update = new ArrayList<>();
|
||||||
updateExclusions = new ArrayList<>();
|
updateExclusions = new ArrayList<>();
|
||||||
updateShared = new ArrayList<>();
|
|
||||||
updateVerify = new ArrayList<>();
|
updateVerify = new ArrayList<>();
|
||||||
updateOptional = new HashSet<>();
|
updateOptional = new HashSet<>();
|
||||||
|
libraries = new ArrayList<>();
|
||||||
jvmArgs = new ArrayList<>();
|
jvmArgs = new ArrayList<>();
|
||||||
classPath = new ArrayList<>();
|
classPath = new ArrayList<>();
|
||||||
altClassPath = new ArrayList<>();
|
altClassPath = new ArrayList<>();
|
||||||
|
@ -102,12 +132,12 @@ public ClientProfile() {
|
||||||
runtimeInClientConfig = RuntimeInClientConfig.NONE;
|
runtimeInClientConfig = RuntimeInClientConfig.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientProfile(List<String> update, List<String> updateExclusions, List<String> updateShared, List<String> updateVerify, Set<OptionalFile> updateOptional, List<String> jvmArgs, List<String> classPath, List<String> altClassPath, List<String> clientArgs, List<String> compatClasses, Map<String, String> properties, List<ServerProfile> servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) {
|
public ClientProfile(List<String> update, List<String> updateExclusions, List<String> updateVerify, Set<OptionalFile> updateOptional, List<ClientProfileLibrary> libraries, List<String> jvmArgs, List<String> classPath, List<String> altClassPath, List<String> clientArgs, List<String> compatClasses, Map<String, String> properties, List<ServerProfile> servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) {
|
||||||
this.update = update;
|
this.update = update;
|
||||||
this.updateExclusions = updateExclusions;
|
this.updateExclusions = updateExclusions;
|
||||||
this.updateShared = updateShared;
|
|
||||||
this.updateVerify = updateVerify;
|
this.updateVerify = updateVerify;
|
||||||
this.updateOptional = updateOptional;
|
this.updateOptional = updateOptional;
|
||||||
|
this.libraries = libraries;
|
||||||
this.jvmArgs = jvmArgs;
|
this.jvmArgs = jvmArgs;
|
||||||
this.classPath = classPath;
|
this.classPath = classPath;
|
||||||
this.altClassPath = altClassPath;
|
this.altClassPath = altClassPath;
|
||||||
|
@ -264,10 +294,6 @@ public OptionalFile getOptionalFile(String file) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getShared() {
|
|
||||||
return updateShared;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getServerPort() {
|
public int getServerPort() {
|
||||||
ServerProfile profile = getDefaultServerProfile();
|
ServerProfile profile = getDefaultServerProfile();
|
||||||
return profile == null ? 25565 : profile.serverPort;
|
return profile == null ? 25565 : profile.serverPort;
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
public class ClientProfileBuilder {
|
public class ClientProfileBuilder {
|
||||||
private List<String> update = new ArrayList<>();
|
private List<String> update = new ArrayList<>();
|
||||||
private List<String> updateExclusions = new ArrayList<>();
|
private List<String> updateExclusions = new ArrayList<>();
|
||||||
private List<String> updateShared = new ArrayList<>();
|
|
||||||
private List<String> updateVerify = new ArrayList<>();
|
private List<String> updateVerify = new ArrayList<>();
|
||||||
private Set<OptionalFile> updateOptional = new HashSet<>();
|
private Set<OptionalFile> updateOptional = new HashSet<>();
|
||||||
|
private List<ClientProfile.ClientProfileLibrary> libraries = new ArrayList<>();
|
||||||
private List<String> jvmArgs = new ArrayList<>();
|
private List<String> jvmArgs = new ArrayList<>();
|
||||||
private List<String> classPath = new ArrayList<>();
|
private List<String> classPath = new ArrayList<>();
|
||||||
private List<String> altClassPath = new ArrayList<>();
|
private List<String> altClassPath = new ArrayList<>();
|
||||||
|
@ -42,13 +42,18 @@ public ClientProfileBuilder setUpdate(List<String> update) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder update(String value) {
|
||||||
|
this.update.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setUpdateExclusions(List<String> updateExclusions) {
|
public ClientProfileBuilder setUpdateExclusions(List<String> updateExclusions) {
|
||||||
this.updateExclusions = updateExclusions;
|
this.updateExclusions = updateExclusions;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setUpdateShared(List<String> updateShared) {
|
public ClientProfileBuilder updateExclusions(String value) {
|
||||||
this.updateShared = updateShared;
|
this.updateExclusions.add(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,26 +62,76 @@ public ClientProfileBuilder setUpdateVerify(List<String> updateVerify) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder updateVerify(String value) {
|
||||||
|
this.updateVerify.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder setLibraries(List<ClientProfile.ClientProfileLibrary> libraries) {
|
||||||
|
this.libraries = libraries;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder library(ClientProfile.ClientProfileLibrary library) {
|
||||||
|
this.libraries.add(library);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder library(String zone, String name, String path) {
|
||||||
|
this.libraries.add(new ClientProfile.ClientProfileLibrary(zone, name, path));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder library(String name, String path) {
|
||||||
|
this.libraries.add(new ClientProfile.ClientProfileLibrary(name, path));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder library(String name) {
|
||||||
|
this.libraries.add(new ClientProfile.ClientProfileLibrary(name));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setUpdateOptional(Set<OptionalFile> updateOptional) {
|
public ClientProfileBuilder setUpdateOptional(Set<OptionalFile> updateOptional) {
|
||||||
this.updateOptional = updateOptional;
|
this.updateOptional = updateOptional;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder optional(OptionalFile value) {
|
||||||
|
this.updateOptional.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setJvmArgs(List<String> jvmArgs) {
|
public ClientProfileBuilder setJvmArgs(List<String> jvmArgs) {
|
||||||
this.jvmArgs = jvmArgs;
|
this.jvmArgs = jvmArgs;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder jvmArgs(String value) {
|
||||||
|
this.jvmArgs.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setClassPath(List<String> classPath) {
|
public ClientProfileBuilder setClassPath(List<String> classPath) {
|
||||||
this.classPath = classPath;
|
this.classPath = classPath;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder classPath(String value) {
|
||||||
|
this.classPath.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setAltClassPath(List<String> altClassPath) {
|
public ClientProfileBuilder setAltClassPath(List<String> altClassPath) {
|
||||||
this.altClassPath = altClassPath;
|
this.altClassPath = altClassPath;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder altClassPath(String value) {
|
||||||
|
this.altClassPath.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setClientArgs(List<String> clientArgs) {
|
public ClientProfileBuilder setClientArgs(List<String> clientArgs) {
|
||||||
this.clientArgs = clientArgs;
|
this.clientArgs = clientArgs;
|
||||||
return this;
|
return this;
|
||||||
|
@ -87,16 +142,31 @@ public ClientProfileBuilder setCompatClasses(List<String> compatClasses) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder compatClasses(String value) {
|
||||||
|
this.compatClasses.add(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setProperties(Map<String, String> properties) {
|
public ClientProfileBuilder setProperties(Map<String, String> properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder property(String key, String value) {
|
||||||
|
this.properties.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setServers(List<ClientProfile.ServerProfile> servers) {
|
public ClientProfileBuilder setServers(List<ClientProfile.ServerProfile> servers) {
|
||||||
this.servers = servers;
|
this.servers = servers;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientProfileBuilder server(ClientProfile.ServerProfile serverProfile) {
|
||||||
|
this.servers.add(serverProfile);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientProfileBuilder setSecurityManagerConfig(ClientProfile.SecurityManagerConfig securityManagerConfig) {
|
public ClientProfileBuilder setSecurityManagerConfig(ClientProfile.SecurityManagerConfig securityManagerConfig) {
|
||||||
this.securityManagerConfig = securityManagerConfig;
|
this.securityManagerConfig = securityManagerConfig;
|
||||||
return this;
|
return this;
|
||||||
|
@ -193,6 +263,6 @@ public ClientProfileBuilder setMainClass(String mainClass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientProfile createClientProfile() {
|
public ClientProfile createClientProfile() {
|
||||||
return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass);
|
return new ClientProfile(update, updateExclusions, updateVerify, updateOptional, libraries, jvmArgs, classPath, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,6 +59,11 @@ public Diff diff(HashedDir other, FileNameMatcher matcher) {
|
||||||
return new Diff(mismatch, extra);
|
return new Diff(mismatch, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Diff diffWithoutExtra(HashedDir other, FileNameMatcher matcher) {
|
||||||
|
HashedDir mismatch = sideDiff(other, matcher, new LinkedList<>(), true);
|
||||||
|
return new Diff(mismatch, null);
|
||||||
|
}
|
||||||
|
|
||||||
public Diff compare(HashedDir other, FileNameMatcher matcher) {
|
public Diff compare(HashedDir other, FileNameMatcher matcher) {
|
||||||
HashedDir mismatch = sideDiff(other, matcher, new LinkedList<>(), true);
|
HashedDir mismatch = sideDiff(other, matcher, new LinkedList<>(), true);
|
||||||
HashedDir extra = other.sideDiff(this, matcher, new LinkedList<>(), false);
|
HashedDir extra = other.sideDiff(this, matcher, new LinkedList<>(), false);
|
||||||
|
|
Loading…
Reference in a new issue