[FEATURE] ClientProfile libraries

This commit is contained in:
Gravita 2021-11-18 16:46:32 +07:00
parent 54c4604885
commit 9091c838e4
3 changed files with 114 additions and 13 deletions

View file

@ -38,8 +38,6 @@ public final class ClientProfile implements Comparable<ClientProfile> {
@LauncherNetworkAPI
private List<String> updateExclusions;
@LauncherNetworkAPI
private List<String> updateShared;
@LauncherNetworkAPI
private List<String> updateVerify;
@LauncherNetworkAPI
private Set<OptionalFile> updateOptional;
@ -52,6 +50,8 @@ public final class ClientProfile implements Comparable<ClientProfile> {
@LauncherNetworkAPI
private List<String> clientArgs;
@LauncherNetworkAPI
private List<ClientProfileLibrary> libraries;
@LauncherNetworkAPI
private List<String> compatClasses;
@LauncherNetworkAPI
private Map<String, String> properties;
@ -83,12 +83,42 @@ public final class ClientProfile implements Comparable<ClientProfile> {
@LauncherNetworkAPI
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() {
update = new ArrayList<>();
updateExclusions = new ArrayList<>();
updateShared = new ArrayList<>();
updateVerify = new ArrayList<>();
updateOptional = new HashSet<>();
libraries = new ArrayList<>();
jvmArgs = new ArrayList<>();
classPath = new ArrayList<>();
altClassPath = new ArrayList<>();
@ -102,12 +132,12 @@ public ClientProfile() {
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.updateExclusions = updateExclusions;
this.updateShared = updateShared;
this.updateVerify = updateVerify;
this.updateOptional = updateOptional;
this.libraries = libraries;
this.jvmArgs = jvmArgs;
this.classPath = classPath;
this.altClassPath = altClassPath;
@ -264,10 +294,6 @@ public OptionalFile getOptionalFile(String file) {
return null;
}
public Collection<String> getShared() {
return updateShared;
}
public int getServerPort() {
ServerProfile profile = getDefaultServerProfile();
return profile == null ? 25565 : profile.serverPort;

View file

@ -7,9 +7,9 @@
public class ClientProfileBuilder {
private List<String> update = new ArrayList<>();
private List<String> updateExclusions = new ArrayList<>();
private List<String> updateShared = new ArrayList<>();
private List<String> updateVerify = new ArrayList<>();
private Set<OptionalFile> updateOptional = new HashSet<>();
private List<ClientProfile.ClientProfileLibrary> libraries = new ArrayList<>();
private List<String> jvmArgs = new ArrayList<>();
private List<String> classPath = new ArrayList<>();
private List<String> altClassPath = new ArrayList<>();
@ -42,13 +42,18 @@ public ClientProfileBuilder setUpdate(List<String> update) {
return this;
}
public ClientProfileBuilder update(String value) {
this.update.add(value);
return this;
}
public ClientProfileBuilder setUpdateExclusions(List<String> updateExclusions) {
this.updateExclusions = updateExclusions;
return this;
}
public ClientProfileBuilder setUpdateShared(List<String> updateShared) {
this.updateShared = updateShared;
public ClientProfileBuilder updateExclusions(String value) {
this.updateExclusions.add(value);
return this;
}
@ -57,26 +62,76 @@ public ClientProfileBuilder setUpdateVerify(List<String> updateVerify) {
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) {
this.updateOptional = updateOptional;
return this;
}
public ClientProfileBuilder optional(OptionalFile value) {
this.updateOptional.add(value);
return this;
}
public ClientProfileBuilder setJvmArgs(List<String> jvmArgs) {
this.jvmArgs = jvmArgs;
return this;
}
public ClientProfileBuilder jvmArgs(String value) {
this.jvmArgs.add(value);
return this;
}
public ClientProfileBuilder setClassPath(List<String> classPath) {
this.classPath = classPath;
return this;
}
public ClientProfileBuilder classPath(String value) {
this.classPath.add(value);
return this;
}
public ClientProfileBuilder setAltClassPath(List<String> altClassPath) {
this.altClassPath = altClassPath;
return this;
}
public ClientProfileBuilder altClassPath(String value) {
this.altClassPath.add(value);
return this;
}
public ClientProfileBuilder setClientArgs(List<String> clientArgs) {
this.clientArgs = clientArgs;
return this;
@ -87,16 +142,31 @@ public ClientProfileBuilder setCompatClasses(List<String> compatClasses) {
return this;
}
public ClientProfileBuilder compatClasses(String value) {
this.compatClasses.add(value);
return this;
}
public ClientProfileBuilder setProperties(Map<String, String> properties) {
this.properties = properties;
return this;
}
public ClientProfileBuilder property(String key, String value) {
this.properties.put(key, value);
return this;
}
public ClientProfileBuilder setServers(List<ClientProfile.ServerProfile> servers) {
this.servers = servers;
return this;
}
public ClientProfileBuilder server(ClientProfile.ServerProfile serverProfile) {
this.servers.add(serverProfile);
return this;
}
public ClientProfileBuilder setSecurityManagerConfig(ClientProfile.SecurityManagerConfig securityManagerConfig) {
this.securityManagerConfig = securityManagerConfig;
return this;
@ -193,6 +263,6 @@ public ClientProfileBuilder setMainClass(String mainClass) {
}
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);
}
}

View file

@ -59,6 +59,11 @@ public Diff diff(HashedDir other, FileNameMatcher matcher) {
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) {
HashedDir mismatch = sideDiff(other, matcher, new LinkedList<>(), true);
HashedDir extra = other.sideDiff(this, matcher, new LinkedList<>(), false);