2018-09-17 10:07:32 +03:00
|
|
|
package ru.gravit.launcher.profiles;
|
|
|
|
|
|
|
|
import ru.gravit.launcher.LauncherAPI;
|
|
|
|
import ru.gravit.launcher.hasher.FileNameMatcher;
|
2018-09-24 19:34:06 +03:00
|
|
|
import ru.gravit.launcher.hasher.HashedDir;
|
2019-01-22 07:18:48 +03:00
|
|
|
import ru.gravit.launcher.profiles.optional.OptionalFile;
|
|
|
|
import ru.gravit.launcher.profiles.optional.OptionalType;
|
2018-12-06 05:29:34 +03:00
|
|
|
import ru.gravit.utils.helper.IOHelper;
|
|
|
|
import ru.gravit.utils.helper.VerifyHelper;
|
2018-09-17 10:07:32 +03:00
|
|
|
|
2019-01-22 07:38:41 +03:00
|
|
|
import java.io.IOException;
|
2018-12-20 18:45:01 +03:00
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.util.*;
|
|
|
|
|
2018-12-23 18:50:31 +03:00
|
|
|
public final class ClientProfile implements Comparable<ClientProfile> {
|
2018-09-17 10:07:32 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public enum Version {
|
|
|
|
MC147("1.4.7", 51),
|
|
|
|
MC152("1.5.2", 61),
|
|
|
|
MC164("1.6.4", 78),
|
|
|
|
MC172("1.7.2", 4),
|
|
|
|
MC1710("1.7.10", 5),
|
|
|
|
MC189("1.8.9", 47),
|
|
|
|
MC194("1.9.4", 110),
|
|
|
|
MC1102("1.10.2", 210),
|
|
|
|
MC1112("1.11.2", 316),
|
|
|
|
MC1122("1.12.2", 340),
|
|
|
|
MC113("1.13", 393),
|
2018-11-03 17:35:47 +03:00
|
|
|
MC1131("1.13.1", 401),
|
2019-04-27 15:51:29 +03:00
|
|
|
MC1132("1.13.2", 402),
|
2019-04-27 15:24:20 +03:00
|
|
|
MC114("1.14", 477);
|
2018-09-17 10:07:32 +03:00
|
|
|
private static final Map<String, Version> VERSIONS;
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
static {
|
|
|
|
Version[] versionsValues = values();
|
|
|
|
VERSIONS = new HashMap<>(versionsValues.length);
|
|
|
|
for (Version version : versionsValues)
|
2018-09-22 17:33:00 +03:00
|
|
|
VERSIONS.put(version.name, version);
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
public static Version byName(String name) {
|
|
|
|
return VerifyHelper.getMapValue(VERSIONS, name, String.format("Unknown client version: '%s'", name));
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String name;
|
|
|
|
|
|
|
|
public final int protocol;
|
|
|
|
|
|
|
|
Version(String name, int protocol) {
|
|
|
|
this.name = name;
|
|
|
|
this.protocol = protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "Minecraft " + name;
|
|
|
|
}
|
|
|
|
}
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-12-02 15:21:27 +03:00
|
|
|
public static final boolean profileCaseSensitive = Boolean.getBoolean("launcher.clientProfile.caseSensitive");
|
2018-12-20 18:45:01 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher(
|
|
|
|
new String[0], new String[]{"indexes", "objects"}, new String[0]);
|
|
|
|
// Version
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-14 15:55:53 +03:00
|
|
|
private String version;
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private String assetIndex;
|
2018-12-24 10:51:13 +03:00
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
private String dir;
|
|
|
|
@LauncherAPI
|
|
|
|
private String assetDir;
|
2018-09-17 10:07:32 +03:00
|
|
|
// Client
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private int sortIndex;
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-14 15:55:53 +03:00
|
|
|
private String title;
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2019-01-10 02:40:47 +03:00
|
|
|
private String info;
|
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private String serverAddress;
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private int serverPort;
|
2018-11-08 15:30:16 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
// Updater and client watch service
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-09-24 19:34:06 +03:00
|
|
|
private final List<String> update = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-09-24 19:34:06 +03:00
|
|
|
private final List<String> updateExclusions = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-08 15:50:24 +03:00
|
|
|
private final List<String> updateShared = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-09-24 19:34:06 +03:00
|
|
|
private final List<String> updateVerify = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-27 10:09:13 +03:00
|
|
|
private final Set<OptionalFile> updateOptional = new HashSet<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private boolean updateFastCheck;
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private boolean useWhitelist;
|
2018-09-17 10:07:32 +03:00
|
|
|
// Client launcher
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-12-23 18:50:31 +03:00
|
|
|
private String mainClass;
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-14 15:55:53 +03:00
|
|
|
private final List<String> jvmArgs = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-14 15:55:53 +03:00
|
|
|
private final List<String> classPath = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-14 15:55:53 +03:00
|
|
|
private final List<String> clientArgs = new ArrayList<>();
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
2018-11-14 15:55:53 +03:00
|
|
|
private final List<String> whitelist = new ArrayList<>();
|
2018-09-17 10:07:32 +03:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(ClientProfile o) {
|
|
|
|
return Integer.compare(getSortIndex(), o.getSortIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public String getAssetIndex() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return assetIndex;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public FileNameMatcher getAssetUpdateMatcher() {
|
|
|
|
return getVersion().compareTo(Version.MC1710) >= 0 ? ASSET_MATCHER : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public String[] getClassPath() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return classPath.toArray(new String[0]);
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public String[] getClientArgs() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return clientArgs.toArray(new String[0]);
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public String getDir() {
|
|
|
|
return dir;
|
|
|
|
}
|
2018-12-24 10:58:28 +03:00
|
|
|
|
|
|
|
public void setDir(String dir) {
|
|
|
|
this.dir = dir;
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
|
2018-12-24 10:51:13 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public String getAssetDir() {
|
|
|
|
return assetDir;
|
|
|
|
}
|
2018-09-17 10:07:32 +03:00
|
|
|
|
|
|
|
@LauncherAPI
|
2018-09-24 19:34:06 +03:00
|
|
|
public FileNameMatcher getClientUpdateMatcher(/*boolean excludeOptional*/) {
|
|
|
|
String[] updateArray = update.toArray(new String[0]);
|
|
|
|
String[] verifyArray = updateVerify.toArray(new String[0]);
|
|
|
|
List<String> excludeList;
|
|
|
|
//if(excludeOptional)
|
|
|
|
//{
|
|
|
|
// excludeList = new ArrayList<>();
|
|
|
|
// excludeList.addAll(updateExclusions);
|
|
|
|
// excludeList.addAll(updateOptional);
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
excludeList = updateExclusions;
|
|
|
|
String[] exclusionsArray = excludeList.toArray(new String[0]);
|
2018-09-17 10:07:32 +03:00
|
|
|
return new FileNameMatcher(updateArray, verifyArray, exclusionsArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public String[] getJvmArgs() {
|
2018-11-14 15:48:59 +03:00
|
|
|
return jvmArgs.toArray(new String[0]);
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public String getMainClass() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return mainClass;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public String getServerAddress() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return serverAddress;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:05:20 +03:00
|
|
|
@LauncherAPI
|
2018-12-27 10:09:13 +03:00
|
|
|
public Set<OptionalFile> getOptional() {
|
2018-09-25 15:05:20 +03:00
|
|
|
return updateOptional;
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
|
2018-12-27 10:51:39 +03:00
|
|
|
@LauncherAPI
|
2019-01-15 06:35:39 +03:00
|
|
|
public void updateOptionalGraph() {
|
|
|
|
for (OptionalFile file : updateOptional) {
|
|
|
|
if (file.dependenciesFile != null) {
|
2018-12-27 10:51:39 +03:00
|
|
|
file.dependencies = new OptionalFile[file.dependenciesFile.length];
|
2019-01-15 06:35:39 +03:00
|
|
|
for (int i = 0; i < file.dependenciesFile.length; ++i) {
|
2019-01-22 07:18:48 +03:00
|
|
|
file.dependencies[i] = getOptionalFile(file.dependenciesFile[i].name, file.dependenciesFile[i].type);
|
2018-12-27 10:51:39 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
if (file.conflictFile != null) {
|
2018-12-27 10:51:39 +03:00
|
|
|
file.conflict = new OptionalFile[file.conflictFile.length];
|
2019-01-15 06:35:39 +03:00
|
|
|
for (int i = 0; i < file.conflictFile.length; ++i) {
|
2019-01-22 07:18:48 +03:00
|
|
|
file.conflict[i] = getOptionalFile(file.conflictFile[i].name, file.conflictFile[i].type);
|
2018-12-27 10:51:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-27 10:09:13 +03:00
|
|
|
@LauncherAPI
|
2019-01-22 07:18:48 +03:00
|
|
|
public OptionalFile getOptionalFile(String file, OptionalType type) {
|
2019-01-15 06:35:39 +03:00
|
|
|
for (OptionalFile f : updateOptional)
|
2019-01-22 07:18:48 +03:00
|
|
|
if (f.type.equals(type) && f.name.equals(file)) return f;
|
2018-12-27 10:09:13 +03:00
|
|
|
return null;
|
|
|
|
}
|
2018-11-08 15:30:16 +03:00
|
|
|
|
2018-12-20 12:37:46 +03:00
|
|
|
@LauncherAPI
|
2018-12-20 18:45:01 +03:00
|
|
|
public Collection<String> getShared() {
|
|
|
|
return updateShared;
|
|
|
|
}
|
2018-12-20 12:37:46 +03:00
|
|
|
|
2018-09-24 19:34:06 +03:00
|
|
|
@LauncherAPI
|
2019-01-22 07:18:48 +03:00
|
|
|
public void markOptional(String name, OptionalType type) {
|
2019-01-22 07:38:41 +03:00
|
|
|
OptionalFile file = getOptionalFile(name, type);
|
|
|
|
if (file == null) {
|
2019-01-22 07:18:48 +03:00
|
|
|
throw new SecurityException(String.format("Optional %s not found in optionalList", name));
|
|
|
|
}
|
2018-12-27 10:51:39 +03:00
|
|
|
markOptional(file);
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
|
2018-12-27 10:51:39 +03:00
|
|
|
@LauncherAPI
|
2019-01-15 06:35:39 +03:00
|
|
|
public void markOptional(OptionalFile file) {
|
2018-12-27 10:51:39 +03:00
|
|
|
|
2019-01-15 06:35:39 +03:00
|
|
|
if (file.mark) return;
|
2018-12-27 10:51:39 +03:00
|
|
|
file.mark = true;
|
2019-01-15 06:35:39 +03:00
|
|
|
if (file.dependencies != null) {
|
|
|
|
for (OptionalFile dep : file.dependencies) {
|
|
|
|
if (dep.dependenciesCount == null) dep.dependenciesCount = new HashSet<>();
|
2018-12-27 10:51:39 +03:00
|
|
|
dep.dependenciesCount.add(file);
|
|
|
|
markOptional(dep);
|
|
|
|
}
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
if (file.conflict != null) {
|
|
|
|
for (OptionalFile conflict : file.conflict) {
|
2018-12-27 10:51:39 +03:00
|
|
|
unmarkOptional(conflict);
|
|
|
|
}
|
|
|
|
}
|
2018-09-24 19:34:06 +03:00
|
|
|
}
|
2018-11-08 15:30:16 +03:00
|
|
|
|
2018-09-24 19:34:06 +03:00
|
|
|
@LauncherAPI
|
2019-01-22 07:18:48 +03:00
|
|
|
public void unmarkOptional(String name, OptionalType type) {
|
2019-01-22 07:38:41 +03:00
|
|
|
OptionalFile file = getOptionalFile(name, type);
|
|
|
|
if (file == null) {
|
2019-01-22 07:18:48 +03:00
|
|
|
throw new SecurityException(String.format("Optional %s not found in optionalList", name));
|
|
|
|
}
|
2018-12-27 10:51:39 +03:00
|
|
|
unmarkOptional(file);
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
|
2018-12-27 10:51:39 +03:00
|
|
|
@LauncherAPI
|
2019-01-15 06:35:39 +03:00
|
|
|
public void unmarkOptional(OptionalFile file) {
|
|
|
|
if (!file.mark) return;
|
2018-12-27 10:51:39 +03:00
|
|
|
file.mark = false;
|
2019-01-15 06:35:39 +03:00
|
|
|
if (file.dependenciesCount != null) {
|
|
|
|
for (OptionalFile f : file.dependenciesCount) {
|
2019-04-24 09:29:04 +03:00
|
|
|
if(f.isPreset) continue;
|
2018-12-27 10:51:39 +03:00
|
|
|
unmarkOptional(f);
|
|
|
|
}
|
|
|
|
file.dependenciesCount.clear();
|
|
|
|
file.dependenciesCount = null;
|
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
if (file.dependencies != null) {
|
|
|
|
for (OptionalFile f : file.dependencies) {
|
|
|
|
if (!f.mark) continue;
|
2019-03-03 12:35:43 +03:00
|
|
|
if (f.dependenciesCount == null) {
|
2018-12-27 10:51:39 +03:00
|
|
|
unmarkOptional(f);
|
2019-01-15 06:35:39 +03:00
|
|
|
} else if (f.dependenciesCount.size() <= 1) {
|
2018-12-27 10:51:39 +03:00
|
|
|
f.dependenciesCount.clear();
|
|
|
|
f.dependenciesCount = null;
|
|
|
|
unmarkOptional(f);
|
2019-03-03 12:35:43 +03:00
|
|
|
}
|
2018-12-27 10:51:39 +03:00
|
|
|
}
|
|
|
|
}
|
2018-09-24 19:34:06 +03:00
|
|
|
}
|
2018-11-08 15:30:16 +03:00
|
|
|
|
2019-01-22 07:38:41 +03:00
|
|
|
public void pushOptionalFile(HashedDir dir, boolean digest) {
|
2018-12-27 10:09:13 +03:00
|
|
|
for (OptionalFile opt : updateOptional) {
|
2019-01-22 07:38:41 +03:00
|
|
|
if (opt.type.equals(OptionalType.FILE) && !opt.mark) {
|
|
|
|
for (String file : opt.list)
|
2019-01-22 07:18:48 +03:00
|
|
|
dir.removeR(file);
|
|
|
|
}
|
2018-09-24 19:34:06 +03:00
|
|
|
}
|
|
|
|
}
|
2018-11-08 15:30:16 +03:00
|
|
|
|
2019-04-03 16:27:40 +03:00
|
|
|
public void pushOptionalJvmArgs(Collection<String> jvmArgs1) {
|
2019-01-22 07:38:41 +03:00
|
|
|
for (OptionalFile opt : updateOptional) {
|
|
|
|
if (opt.type.equals(OptionalType.JVMARGS) && opt.mark) {
|
|
|
|
jvmArgs1.addAll(Arrays.asList(opt.list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 16:27:40 +03:00
|
|
|
|
|
|
|
public void pushOptionalClientArgs(Collection<String> clientArgs1) {
|
2019-01-22 07:38:41 +03:00
|
|
|
for (OptionalFile opt : updateOptional) {
|
|
|
|
if (opt.type.equals(OptionalType.CLIENTARGS) && opt.mark) {
|
|
|
|
clientArgs1.addAll(Arrays.asList(opt.list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 16:27:40 +03:00
|
|
|
|
|
|
|
public void pushOptionalClassPath(pushOptionalClassPathCallback callback) throws IOException {
|
2019-01-22 07:38:41 +03:00
|
|
|
for (OptionalFile opt : updateOptional) {
|
|
|
|
if (opt.type.equals(OptionalType.CLASSPATH) && opt.mark) {
|
|
|
|
callback.run(opt.list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 16:27:40 +03:00
|
|
|
|
2019-01-22 07:38:41 +03:00
|
|
|
@FunctionalInterface
|
2019-04-03 16:27:40 +03:00
|
|
|
public interface pushOptionalClassPathCallback {
|
2019-01-22 07:38:41 +03:00
|
|
|
void run(String[] opt) throws IOException;
|
|
|
|
}
|
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public int getServerPort() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return serverPort;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public InetSocketAddress getServerSocketAddress() {
|
|
|
|
return InetSocketAddress.createUnresolved(getServerAddress(), getServerPort());
|
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public int getSortIndex() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return sortIndex;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public String getTitle() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return title;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
2019-01-10 02:40:47 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public String getInfo() {
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public Version getVersion() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return Version.byName(version);
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public boolean isUpdateFastCheck() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return updateFastCheck;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
2018-09-22 17:33:00 +03:00
|
|
|
public boolean isWhitelistContains(String username) {
|
2018-12-02 15:21:27 +03:00
|
|
|
if (!useWhitelist) return true;
|
|
|
|
return whitelist.stream().anyMatch(profileCaseSensitive ? e -> e.equals(username) : e -> e.equalsIgnoreCase(username));
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public void setTitle(String title) {
|
2018-11-14 15:55:53 +03:00
|
|
|
this.title = title;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
2019-01-10 02:40:47 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public void setInfo(String info) {
|
|
|
|
this.info = info;
|
|
|
|
}
|
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public void setVersion(Version version) {
|
2018-11-14 15:55:53 +03:00
|
|
|
this.version = version.name;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-11-14 15:55:53 +03:00
|
|
|
return title;
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@LauncherAPI
|
|
|
|
public void verify() {
|
|
|
|
// Version
|
|
|
|
getVersion();
|
|
|
|
IOHelper.verifyFileName(getAssetIndex());
|
|
|
|
|
|
|
|
// Client
|
|
|
|
VerifyHelper.verify(getTitle(), VerifyHelper.NOT_EMPTY, "Profile title can't be empty");
|
2019-01-10 02:40:47 +03:00
|
|
|
VerifyHelper.verify(getInfo(), VerifyHelper.NOT_EMPTY, "Profile info can't be empty");
|
2018-09-17 10:07:32 +03:00
|
|
|
VerifyHelper.verify(getServerAddress(), VerifyHelper.NOT_EMPTY, "Server address can't be empty");
|
|
|
|
VerifyHelper.verifyInt(getServerPort(), VerifyHelper.range(0, 65535), "Illegal server port: " + getServerPort());
|
|
|
|
|
|
|
|
// Client launcher
|
|
|
|
VerifyHelper.verify(getTitle(), VerifyHelper.NOT_EMPTY, "Main class can't be empty");
|
2019-04-03 16:27:40 +03:00
|
|
|
for (String s : classPath) {
|
|
|
|
if (s == null) throw new IllegalArgumentException("Found null entry in classPath");
|
2019-03-10 15:01:14 +03:00
|
|
|
}
|
2019-04-03 16:27:40 +03:00
|
|
|
for (String s : jvmArgs) {
|
|
|
|
if (s == null) throw new IllegalArgumentException("Found null entry in jvmArgs");
|
2019-03-10 15:01:14 +03:00
|
|
|
}
|
2019-04-03 16:27:40 +03:00
|
|
|
for (String s : clientArgs) {
|
|
|
|
if (s == null) throw new IllegalArgumentException("Found null entry in clientArgs");
|
2019-03-10 15:01:14 +03:00
|
|
|
}
|
2019-04-03 16:27:40 +03:00
|
|
|
for (OptionalFile f : updateOptional) {
|
|
|
|
if (f == null) throw new IllegalArgumentException("Found null entry in updateOptional");
|
|
|
|
if (f.name == null) throw new IllegalArgumentException("Optional: name must not be null");
|
|
|
|
if (f.list == null) throw new IllegalArgumentException("Optional: list must not be null");
|
2019-03-10 15:01:14 +03:00
|
|
|
}
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
2019-01-15 06:35:39 +03:00
|
|
|
|
2019-01-07 08:01:15 +03:00
|
|
|
@Override
|
2019-01-15 06:35:39 +03:00
|
|
|
public int hashCode() {
|
|
|
|
final int prime = 31;
|
|
|
|
int result = 1;
|
|
|
|
result = prime * result + ((assetDir == null) ? 0 : assetDir.hashCode());
|
|
|
|
result = prime * result + ((assetIndex == null) ? 0 : assetIndex.hashCode());
|
|
|
|
result = prime * result + ((classPath == null) ? 0 : classPath.hashCode());
|
|
|
|
result = prime * result + ((clientArgs == null) ? 0 : clientArgs.hashCode());
|
|
|
|
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
|
|
|
|
result = prime * result + ((jvmArgs == null) ? 0 : jvmArgs.hashCode());
|
|
|
|
result = prime * result + ((mainClass == null) ? 0 : mainClass.hashCode());
|
|
|
|
result = prime * result + ((serverAddress == null) ? 0 : serverAddress.hashCode());
|
|
|
|
result = prime * result + serverPort;
|
|
|
|
result = prime * result + sortIndex;
|
2019-01-10 02:40:47 +03:00
|
|
|
result = prime * result + ((title == null) ? 0 : title.hashCode());
|
|
|
|
result = prime * result + ((info == null) ? 0 : info.hashCode());
|
2019-01-15 06:35:39 +03:00
|
|
|
result = prime * result + ((update == null) ? 0 : update.hashCode());
|
|
|
|
result = prime * result + ((updateExclusions == null) ? 0 : updateExclusions.hashCode());
|
|
|
|
result = prime * result + (updateFastCheck ? 1231 : 1237);
|
|
|
|
result = prime * result + ((updateOptional == null) ? 0 : updateOptional.hashCode());
|
|
|
|
result = prime * result + ((updateShared == null) ? 0 : updateShared.hashCode());
|
|
|
|
result = prime * result + ((updateVerify == null) ? 0 : updateVerify.hashCode());
|
|
|
|
result = prime * result + (useWhitelist ? 1231 : 1237);
|
|
|
|
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
|
|
|
result = prime * result + ((whitelist == null) ? 0 : whitelist.hashCode());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj)
|
|
|
|
return true;
|
|
|
|
if (obj == null)
|
|
|
|
return false;
|
|
|
|
if (getClass() != obj.getClass())
|
|
|
|
return false;
|
|
|
|
ClientProfile other = (ClientProfile) obj;
|
|
|
|
if (assetDir == null) {
|
|
|
|
if (other.assetDir != null)
|
|
|
|
return false;
|
|
|
|
} else if (!assetDir.equals(other.assetDir))
|
|
|
|
return false;
|
|
|
|
if (assetIndex == null) {
|
|
|
|
if (other.assetIndex != null)
|
|
|
|
return false;
|
|
|
|
} else if (!assetIndex.equals(other.assetIndex))
|
|
|
|
return false;
|
|
|
|
if (classPath == null) {
|
|
|
|
if (other.classPath != null)
|
|
|
|
return false;
|
|
|
|
} else if (!classPath.equals(other.classPath))
|
|
|
|
return false;
|
|
|
|
if (clientArgs == null) {
|
|
|
|
if (other.clientArgs != null)
|
|
|
|
return false;
|
|
|
|
} else if (!clientArgs.equals(other.clientArgs))
|
|
|
|
return false;
|
|
|
|
if (dir == null) {
|
|
|
|
if (other.dir != null)
|
|
|
|
return false;
|
|
|
|
} else if (!dir.equals(other.dir))
|
|
|
|
return false;
|
|
|
|
if (jvmArgs == null) {
|
|
|
|
if (other.jvmArgs != null)
|
|
|
|
return false;
|
|
|
|
} else if (!jvmArgs.equals(other.jvmArgs))
|
|
|
|
return false;
|
|
|
|
if (mainClass == null) {
|
|
|
|
if (other.mainClass != null)
|
|
|
|
return false;
|
|
|
|
} else if (!mainClass.equals(other.mainClass))
|
|
|
|
return false;
|
|
|
|
if (serverAddress == null) {
|
|
|
|
if (other.serverAddress != null)
|
|
|
|
return false;
|
|
|
|
} else if (!serverAddress.equals(other.serverAddress))
|
|
|
|
return false;
|
|
|
|
if (serverPort != other.serverPort)
|
|
|
|
return false;
|
|
|
|
if (sortIndex != other.sortIndex)
|
|
|
|
return false;
|
|
|
|
if (title == null) {
|
2019-01-10 02:40:47 +03:00
|
|
|
if (other.title != null)
|
|
|
|
return false;
|
|
|
|
} else if (!title.equals(other.title))
|
|
|
|
return false;
|
|
|
|
if (info == null) {
|
|
|
|
if (other.info != null)
|
|
|
|
return false;
|
|
|
|
} else if (!info.equals(other.info))
|
|
|
|
return false;
|
2019-01-15 06:35:39 +03:00
|
|
|
if (update == null) {
|
|
|
|
if (other.update != null)
|
|
|
|
return false;
|
|
|
|
} else if (!update.equals(other.update))
|
|
|
|
return false;
|
|
|
|
if (updateExclusions == null) {
|
|
|
|
if (other.updateExclusions != null)
|
|
|
|
return false;
|
|
|
|
} else if (!updateExclusions.equals(other.updateExclusions))
|
|
|
|
return false;
|
|
|
|
if (updateFastCheck != other.updateFastCheck)
|
|
|
|
return false;
|
|
|
|
if (updateOptional == null) {
|
|
|
|
if (other.updateOptional != null)
|
|
|
|
return false;
|
|
|
|
} else if (!updateOptional.equals(other.updateOptional))
|
|
|
|
return false;
|
|
|
|
if (updateShared == null) {
|
|
|
|
if (other.updateShared != null)
|
|
|
|
return false;
|
|
|
|
} else if (!updateShared.equals(other.updateShared))
|
|
|
|
return false;
|
|
|
|
if (updateVerify == null) {
|
|
|
|
if (other.updateVerify != null)
|
|
|
|
return false;
|
|
|
|
} else if (!updateVerify.equals(other.updateVerify))
|
|
|
|
return false;
|
|
|
|
if (useWhitelist != other.useWhitelist)
|
|
|
|
return false;
|
|
|
|
if (version == null) {
|
|
|
|
if (other.version != null)
|
|
|
|
return false;
|
|
|
|
} else if (!version.equals(other.version))
|
|
|
|
return false;
|
|
|
|
if (whitelist == null) {
|
2019-01-15 06:32:46 +03:00
|
|
|
return other.whitelist == null;
|
2019-01-15 06:35:39 +03:00
|
|
|
} else return whitelist.equals(other.whitelist);
|
2019-01-15 06:32:46 +03:00
|
|
|
}
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|