mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-02-02 04:25:27 +03:00
Merge branch 'feature/profile-uuid' into dev
This commit is contained in:
commit
5b59d6ba35
12 changed files with 243 additions and 199 deletions
|
@ -343,8 +343,8 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
publicKey = (RSAPublicKey) pair.getPublic();
|
||||
privateKey = (RSAPrivateKey) pair.getPrivate();
|
||||
|
||||
// Write key pair files
|
||||
LogHelper.info("Writing RSA keypair files");
|
||||
// Write key pair list
|
||||
LogHelper.info("Writing RSA keypair list");
|
||||
IOHelper.write(publicKeyFile, publicKey.getEncoded());
|
||||
IOHelper.write(privateKeyFile, privateKey.getEncoded());
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public boolean allowDelete() {
|
|||
}
|
||||
|
||||
public void tryUnpack() throws IOException {
|
||||
LogHelper.info("Unpacking launcher native guard files and runtime");
|
||||
LogHelper.info("Unpacking launcher native guard list and runtime");
|
||||
UnpackHelper.unpackZipNoCheck("guard.zip", server.launcherBinary.guardDir);
|
||||
UnpackHelper.unpackZipNoCheck("runtime.zip", server.launcherBinary.runtimeDir);
|
||||
}
|
||||
|
|
|
@ -43,15 +43,16 @@ var options = {
|
|||
for(var j = 0; j < listSize; j++)
|
||||
{
|
||||
var mark = input.readBoolean();
|
||||
var modType = OptionalFile.readType(input);
|
||||
var modFile = input.readString(0);
|
||||
if(mark)
|
||||
{
|
||||
profile.markOptional(modFile);
|
||||
profile.markOptional(modFile,modType);
|
||||
LogHelper.debug("Load options %s marked",modFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile.unmarkOptional(modFile);
|
||||
profile.unmarkOptional(modFile,modType);
|
||||
LogHelper.debug("Load options %s unmarked",modFile);
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +70,8 @@ var options = {
|
|||
output.writeInt(profile.getSortIndex());
|
||||
list.forEach(function(modFile,j,arr2) {
|
||||
output.writeBoolean(modFile.mark);
|
||||
output.writeString(modFile.file, 0);
|
||||
modFile.writeType(output);
|
||||
output.writeString(modFile.name, 0);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -96,16 +98,19 @@ var options = {
|
|||
var profile = profilesList[serverHolder.old];
|
||||
var list = profile.getOptional();
|
||||
var checkBoxList = new java.util.ArrayList;
|
||||
var dModsIds = [];
|
||||
|
||||
list.forEach(function(modFile) {
|
||||
dModsIds.push(modFile.string);
|
||||
|
||||
var modName = modFile.file, modDescription = "", subLevel = 1;
|
||||
if(modFile.isAdminOnly && !loginData.permissions.canAdmin)
|
||||
var modName = modFile.name, modDescription = "", subLevel = 1;
|
||||
if(!modFile.isVisible)
|
||||
{
|
||||
LogHelper.debug("optionalMod %s hidden",modFile.name);
|
||||
return;
|
||||
if(modFile.name != null)//Есть ли у модификации имя?
|
||||
modName = modFile.name;
|
||||
}
|
||||
|
||||
if(modFile.permissions != 0 && ((loginData.permissions.toLong() & modFile.permissions) != 0))
|
||||
{
|
||||
LogHelper.debug("optionalMod %s permissions deny",modFile.name);
|
||||
return;
|
||||
}
|
||||
if(modFile.info != null) //Есть ли описание?
|
||||
modDescription = modFile.info;
|
||||
if(modFile.subTreeLevel != null && modFile.subTreeLevel > 1)//Это суб-модификация?
|
||||
|
@ -121,18 +126,17 @@ var options = {
|
|||
var isSelected = event.getSource().isSelected();
|
||||
if(isSelected)
|
||||
{
|
||||
profile.markOptional(modFile.file);
|
||||
LogHelper.debug("Selected mod %s", modFile.file);
|
||||
profile.markOptional(modFile);
|
||||
LogHelper.debug("Selected mod %s", modFile.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile.unmarkOptional(modFile.file);
|
||||
LogHelper.debug("Unselected mod %s", modFile.file);
|
||||
profile.unmarkOptional(modFile);
|
||||
LogHelper.debug("Unselected mod %s", modFile.name);
|
||||
}
|
||||
options.update();
|
||||
});
|
||||
checkBoxList.add(testMod);
|
||||
|
||||
if(modDescription != "") { //Добавляем описание?
|
||||
textDescr = new javafx.scene.text.Text(modDescription);
|
||||
if(subLevel > 1) {
|
||||
|
|
|
@ -44,6 +44,7 @@ var StreamObjectAdapter = StreamObjectAdapterClass.static;
|
|||
var SignedBytesHolder = SignedBytesHolderClass.static;
|
||||
var SignedObjectHolder = SignedObjectHolderClass.static;
|
||||
var EnumSerializer = EnumSerializerClass.static;
|
||||
var OptionalFile = OptionalFileClass.static;
|
||||
|
||||
// Helper class API imports
|
||||
var CommonHelper = CommonHelperClass.static;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
import java.net.URL;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
|
@ -68,12 +67,6 @@ public static final class Params extends StreamObject {
|
|||
@LauncherAPI
|
||||
public final PlayerProfile pp;
|
||||
@LauncherAPI
|
||||
public final Set<ClientProfile.OptionalFile> updateOptional;
|
||||
@LauncherAPI
|
||||
public final Set<ClientProfile.OptionalArgs> optionalClientArgs;
|
||||
@LauncherAPI
|
||||
public final Set<ClientProfile.OptionalArgs> optionalClassPath;
|
||||
@LauncherAPI
|
||||
public final String accessToken;
|
||||
@LauncherAPI
|
||||
public final boolean autoEnter;
|
||||
|
@ -93,18 +86,6 @@ public static final class Params extends StreamObject {
|
|||
public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfile pp, String accessToken,
|
||||
boolean autoEnter, boolean fullScreen, int ram, int width, int height) {
|
||||
this.launcherDigest = launcherDigest.clone();
|
||||
this.updateOptional = new HashSet<>();
|
||||
this.optionalClientArgs = new HashSet<>();
|
||||
this.optionalClassPath = new HashSet<>();
|
||||
for (ClientProfile.OptionalFile s : Launcher.profile.getOptional()) {
|
||||
if (s.mark) updateOptional.add(s);
|
||||
}
|
||||
for (ClientProfile.OptionalArgs s : Launcher.profile.getOptionalClientArgs()) {
|
||||
if (s.mark) optionalClientArgs.add(s);
|
||||
}
|
||||
for (ClientProfile.OptionalArgs s : Launcher.profile.getOptionalClassPath()) {
|
||||
if (s.mark) optionalClassPath.add(s);
|
||||
}
|
||||
// Client paths
|
||||
this.assetDir = assetDir;
|
||||
this.clientDir = clientDir;
|
||||
|
@ -126,31 +107,6 @@ public Params(HInput input) throws Exception {
|
|||
// Client paths
|
||||
assetDir = IOHelper.toPath(input.readString(0));
|
||||
clientDir = IOHelper.toPath(input.readString(0));
|
||||
updateOptional = new HashSet<>();
|
||||
optionalClientArgs = new HashSet<>();
|
||||
optionalClassPath = new HashSet<>();
|
||||
int len = input.readLength(128);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String file = input.readString(512);
|
||||
boolean mark = input.readBoolean();
|
||||
updateOptional.add(new ClientProfile.OptionalFile(file, mark));
|
||||
}
|
||||
len = input.readLength(256);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int len2 = input.readLength(16);
|
||||
boolean mark = input.readBoolean();
|
||||
String[] optArgs = new String[len];
|
||||
for (int j = 0; j < len2; ++j) optArgs[j] = input.readString(512);
|
||||
optionalClientArgs.add(new ClientProfile.OptionalArgs(optArgs, mark));
|
||||
}
|
||||
len = input.readLength(256);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int len2 = input.readLength(16);
|
||||
boolean mark = input.readBoolean();
|
||||
String[] optArgs = new String[len];
|
||||
for (int j = 0; j < len2; ++j) optArgs[j] = input.readString(512);
|
||||
optionalClassPath.add(new ClientProfile.OptionalArgs(optArgs, mark));
|
||||
}
|
||||
// Client params
|
||||
pp = new PlayerProfile(input);
|
||||
byte[] encryptedAccessToken = input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH);
|
||||
|
@ -170,24 +126,6 @@ public void write(HOutput output) throws IOException {
|
|||
// Client paths
|
||||
output.writeString(assetDir.toString(), 0);
|
||||
output.writeString(clientDir.toString(), 0);
|
||||
output.writeLength(updateOptional.size(), 128);
|
||||
for (ClientProfile.OptionalFile s : updateOptional) {
|
||||
output.writeString(s.file, 512);
|
||||
output.writeBoolean(s.mark);
|
||||
}
|
||||
output.writeLength(optionalClientArgs.size(), 256);
|
||||
for (ClientProfile.OptionalArgs s : optionalClientArgs) {
|
||||
output.writeLength(s.args.length, 16);
|
||||
output.writeBoolean(s.mark);
|
||||
for (String f : s.args) output.writeString(f, 512);
|
||||
}
|
||||
output.writeLength(optionalClassPath.size(), 256);
|
||||
for (ClientProfile.OptionalArgs s : optionalClassPath) {
|
||||
output.writeLength(s.args.length, 16);
|
||||
output.writeBoolean(s.mark);
|
||||
for (String f : s.args) output.writeString(f, 512);
|
||||
}
|
||||
// Client params
|
||||
pp.write(output);
|
||||
try {
|
||||
output.writeByteArray(SecurityHelper.encrypt(Launcher.getConfig().secretKeyClient.getBytes(), accessToken.getBytes()), SecurityHelper.CRYPTO_MAX_LENGTH);
|
||||
|
@ -284,9 +222,7 @@ private static void addClientArgs(Collection<String> args, ClientProfile profile
|
|||
Collections.addAll(args, "--server", profile.getServerAddress());
|
||||
Collections.addAll(args, "--port", Integer.toString(profile.getServerPort()));
|
||||
}
|
||||
for (ClientProfile.OptionalArgs optionalArgs : params.optionalClientArgs) {
|
||||
if (optionalArgs.mark) Collections.addAll(args, optionalArgs.args);
|
||||
}
|
||||
profile.pushOptionalClientArgs(args);
|
||||
// Add window size args
|
||||
if (params.fullScreen)
|
||||
Collections.addAll(args, "--fullscreen", Boolean.toString(true));
|
||||
|
@ -425,11 +361,7 @@ public static Process launch(
|
|||
// Add classpath and main class
|
||||
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
|
||||
Collections.addAll(args, profile.getJvmArgs());
|
||||
if (profile.getOptionalJVMArgs() != null) {
|
||||
for (ClientProfile.OptionalArgs addArgs : profile.getOptionalJVMArgs()) {
|
||||
if (addArgs.mark) Collections.addAll(args, addArgs.args);
|
||||
}
|
||||
}
|
||||
profile.pushOptionalJvmArgs(args);
|
||||
Collections.addAll(args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path
|
||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||
if (wrapper)
|
||||
|
@ -512,14 +444,12 @@ public static void main(String... args) throws Throwable {
|
|||
for (Path classpathURL : classPath) {
|
||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||
}
|
||||
for (ClientProfile.OptionalArgs optionalArgs : params.optionalClassPath) {
|
||||
if (!optionalArgs.mark) continue;
|
||||
LinkedList<Path> optionalClassPath = resolveClassPathList(params.clientDir, optionalArgs.args);
|
||||
profile.pushOptionalClassPath(cp -> {
|
||||
LinkedList<Path> optionalClassPath = resolveClassPathList(params.clientDir, cp);
|
||||
for (Path classpathURL : optionalClassPath) {
|
||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath());
|
||||
classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader());
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
|
@ -535,10 +465,11 @@ public static void main(String... args) throws Throwable {
|
|||
// Verify current state of all dirs
|
||||
//verifyHDir(IOHelper.JVM_DIR, jvmHDir.object, null, digest);
|
||||
HashedDir hdir = clientHDir.object;
|
||||
for (ClientProfile.OptionalFile s : Launcher.profile.getOptional()) {
|
||||
if (params.updateOptional.contains(s)) s.mark = true;
|
||||
else hdir.removeR(s.file);
|
||||
}
|
||||
//for (OptionalFile s : Launcher.profile.getOptional()) {
|
||||
// if (params.updateOptional.contains(s)) s.mark = true;
|
||||
// else hdir.removeR(s.file);
|
||||
//}
|
||||
Launcher.profile.pushOptionalFile(hdir,false);
|
||||
verifyHDir(params.assetDir, assetHDir.object, assetMatcher, digest);
|
||||
verifyHDir(params.clientDir, hdir, clientMatcher, digest);
|
||||
Launcher.modulesManager.postInitModules();
|
||||
|
@ -574,10 +505,11 @@ public void launchLocal(SignedObjectHolder<HashedDir> assetHDir, SignedObjectHol
|
|||
// Verify current state of all dirs
|
||||
//verifyHDir(IOHelper.JVM_DIR, jvmHDir.object, null, digest);
|
||||
HashedDir hdir = clientHDir.object;
|
||||
for (ClientProfile.OptionalFile s : Launcher.profile.getOptional()) {
|
||||
if (params.updateOptional.contains(s)) s.mark = true;
|
||||
else hdir.removeR(s.file);
|
||||
}
|
||||
//for (OptionalFile s : Launcher.profile.getOptional()) {
|
||||
// if (params.updateOptional.contains(s)) s.mark = true;
|
||||
// else hdir.removeR(s.file);
|
||||
//}
|
||||
Launcher.profile.pushOptionalFile(hdir,false);
|
||||
verifyHDir(params.assetDir, assetHDir.object, assetMatcher, digest);
|
||||
verifyHDir(params.clientDir, hdir, clientMatcher, digest);
|
||||
Launcher.modulesManager.postInitModules();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.profiles.Texture;
|
||||
import ru.gravit.launcher.profiles.optional.OptionalFile;
|
||||
import ru.gravit.launcher.request.*;
|
||||
import ru.gravit.launcher.request.auth.AuthRequest;
|
||||
import ru.gravit.launcher.request.auth.CheckServerRequest;
|
||||
|
@ -95,6 +96,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
|
|||
bindings.put("SignedBytesHolderClass", SignedBytesHolder.class);
|
||||
bindings.put("SignedObjectHolderClass", SignedObjectHolder.class);
|
||||
bindings.put("EnumSerializerClass", EnumSerializer.class);
|
||||
bindings.put("OptionalFileClass", OptionalFile.class);
|
||||
|
||||
// Set helper class bindings
|
||||
bindings.put("CommonHelperClass", CommonHelper.class);
|
||||
|
|
|
@ -224,7 +224,7 @@ private void deleteExtraDir(Path subDir, HashedDir subHDir, boolean flag) throws
|
|||
String name = mapEntry.getKey();
|
||||
Path path = subDir.resolve(name);
|
||||
|
||||
// Delete files and dirs based on type
|
||||
// Delete list and dirs based on type
|
||||
HashedEntry entry = mapEntry.getValue();
|
||||
HashedEntry.Type entryType = entry.getType();
|
||||
switch (entryType) {
|
||||
|
@ -308,7 +308,7 @@ protected SignedObjectHolder<HashedDir> requestDo(HInput input, HOutput output)
|
|||
// Get diff between local and remote dir
|
||||
SignedObjectHolder<HashedDir> remoteHDirHolder = new SignedObjectHolder<>(input, config.publicKey, HashedDir::new);
|
||||
HashedDir hackHackedDir = remoteHDirHolder.object;
|
||||
Launcher.profile.pushOptional(hackHackedDir, !Launcher.profile.isUpdateFastCheck());
|
||||
Launcher.profile.pushOptionalFile(hackHackedDir, !Launcher.profile.isUpdateFastCheck());
|
||||
HashedDir.Diff diff = hackHackedDir.diff(localDir, matcher);
|
||||
totalSize = diff.mismatch.size();
|
||||
boolean compress = input.readBoolean();
|
||||
|
|
|
@ -46,6 +46,7 @@ public ClientPermissions(long data) {
|
|||
canUSR3 = (data & (1 << 4)) != 0;
|
||||
canBot = (data & (1 << 5)) != 0;
|
||||
}
|
||||
@LauncherAPI
|
||||
public long toLong()
|
||||
{
|
||||
long result = 0;
|
||||
|
|
|
@ -3,10 +3,14 @@
|
|||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.hasher.FileNameMatcher;
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
import ru.gravit.launcher.profiles.optional.OptionalFile;
|
||||
import ru.gravit.launcher.profiles.optional.OptionalType;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public final class ClientProfile implements Comparable<ClientProfile> {
|
||||
|
@ -79,66 +83,6 @@ public String toString() {
|
|||
@LauncherAPI
|
||||
private int serverPort;
|
||||
|
||||
public static class OptionalFile {
|
||||
@LauncherAPI
|
||||
public String file;
|
||||
@LauncherAPI
|
||||
public boolean mark;
|
||||
@LauncherAPI
|
||||
public String name;
|
||||
@LauncherAPI
|
||||
public String info;
|
||||
@LauncherAPI
|
||||
public String[] dependenciesFile;
|
||||
@LauncherAPI
|
||||
public String[] conflictFile;
|
||||
@LauncherAPI
|
||||
public transient OptionalFile[] dependencies;
|
||||
@LauncherAPI
|
||||
public transient OptionalFile[] conflict;
|
||||
@LauncherAPI
|
||||
public int subTreeLevel = 1;
|
||||
@LauncherAPI
|
||||
public boolean isAdminOnly = false;
|
||||
@LauncherAPI
|
||||
public transient Set<OptionalFile> dependenciesCount;
|
||||
|
||||
public OptionalFile(String file, boolean mark) {
|
||||
this.file = file;
|
||||
this.mark = mark;
|
||||
}
|
||||
|
||||
public OptionalFile(String file) {
|
||||
this.file = file;
|
||||
this.mark = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
OptionalFile that = (OptionalFile) o;
|
||||
return Objects.equals(file, that.file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static class OptionalArgs {
|
||||
@LauncherAPI
|
||||
public boolean mark;
|
||||
@LauncherAPI
|
||||
public String[] args;
|
||||
|
||||
public OptionalArgs(String[] args, boolean mark) {
|
||||
this.mark = mark;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
// Updater and client watch service
|
||||
@LauncherAPI
|
||||
private final List<String> update = new ArrayList<>();
|
||||
|
@ -165,12 +109,6 @@ public OptionalArgs(String[] args, boolean mark) {
|
|||
private final List<String> clientArgs = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<String> whitelist = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<OptionalArgs> optionalJVMArgs = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<OptionalArgs> optionalClientArgs = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<OptionalArgs> optionalClassPath = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int compareTo(ClientProfile o) {
|
||||
|
@ -192,21 +130,6 @@ public String[] getClassPath() {
|
|||
return classPath.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public List<OptionalArgs> getOptionalJVMArgs() {
|
||||
return optionalJVMArgs;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public List<OptionalArgs> getOptionalClientArgs() {
|
||||
return optionalClientArgs;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public List<OptionalArgs> getOptionalClassPath() {
|
||||
return optionalClassPath;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public String[] getClientArgs() {
|
||||
return clientArgs.toArray(new String[0]);
|
||||
|
@ -269,22 +192,22 @@ public void updateOptionalGraph() {
|
|||
if (file.dependenciesFile != null) {
|
||||
file.dependencies = new OptionalFile[file.dependenciesFile.length];
|
||||
for (int i = 0; i < file.dependenciesFile.length; ++i) {
|
||||
file.dependencies[i] = getOptionalFile(file.dependenciesFile[i]);
|
||||
file.dependencies[i] = getOptionalFile(file.dependenciesFile[i].name, file.dependenciesFile[i].type);
|
||||
}
|
||||
}
|
||||
if (file.conflictFile != null) {
|
||||
file.conflict = new OptionalFile[file.conflictFile.length];
|
||||
for (int i = 0; i < file.conflictFile.length; ++i) {
|
||||
file.conflict[i] = getOptionalFile(file.conflictFile[i]);
|
||||
file.conflict[i] = getOptionalFile(file.conflictFile[i].name, file.conflictFile[i].type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public OptionalFile getOptionalFile(String file) {
|
||||
public OptionalFile getOptionalFile(String file, OptionalType type) {
|
||||
for (OptionalFile f : updateOptional)
|
||||
if (f.file.equals(file)) return f;
|
||||
if (f.type.equals(type) && f.name.equals(file)) return f;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -294,10 +217,11 @@ public Collection<String> getShared() {
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void markOptional(String opt) {
|
||||
if (!updateOptional.contains(new OptionalFile(opt)))
|
||||
throw new SecurityException(String.format("Optional mod %s not found in optionalList", opt));
|
||||
OptionalFile file = getOptionalFile(opt);
|
||||
public void markOptional(String name, OptionalType type) {
|
||||
OptionalFile file = getOptionalFile(name, type);
|
||||
if (file == null) {
|
||||
throw new SecurityException(String.format("Optional %s not found in optionalList", name));
|
||||
}
|
||||
markOptional(file);
|
||||
}
|
||||
|
||||
|
@ -321,10 +245,11 @@ public void markOptional(OptionalFile file) {
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void unmarkOptional(String opt) {
|
||||
if (!updateOptional.contains(new OptionalFile(opt)))
|
||||
throw new SecurityException(String.format("Optional mod %s not found in optionalList", opt));
|
||||
OptionalFile file = getOptionalFile(opt);
|
||||
public void unmarkOptional(String name, OptionalType type) {
|
||||
OptionalFile file = getOptionalFile(name, type);
|
||||
if (file == null) {
|
||||
throw new SecurityException(String.format("Optional %s not found in optionalList", name));
|
||||
}
|
||||
unmarkOptional(file);
|
||||
}
|
||||
|
||||
|
@ -353,12 +278,45 @@ public void unmarkOptional(OptionalFile file) {
|
|||
}
|
||||
}
|
||||
|
||||
public void pushOptional(HashedDir dir, boolean digest) {
|
||||
public void pushOptionalFile(HashedDir dir, boolean digest) {
|
||||
for (OptionalFile opt : updateOptional) {
|
||||
if (!opt.mark) dir.removeR(opt.file);
|
||||
if (opt.type.equals(OptionalType.FILE) && !opt.mark) {
|
||||
for (String file : opt.list)
|
||||
dir.removeR(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pushOptionalJvmArgs(Collection<String> jvmArgs1)
|
||||
{
|
||||
for (OptionalFile opt : updateOptional) {
|
||||
if (opt.type.equals(OptionalType.JVMARGS) && opt.mark) {
|
||||
jvmArgs1.addAll(Arrays.asList(opt.list));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void pushOptionalClientArgs(Collection<String> clientArgs1)
|
||||
{
|
||||
for (OptionalFile opt : updateOptional) {
|
||||
if (opt.type.equals(OptionalType.CLIENTARGS) && opt.mark) {
|
||||
clientArgs1.addAll(Arrays.asList(opt.list));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void pushOptionalClassPath(pushOptionalClassPathCallback callback) throws IOException
|
||||
{
|
||||
for (OptionalFile opt : updateOptional) {
|
||||
if (opt.type.equals(OptionalType.CLASSPATH) && opt.mark) {
|
||||
callback.run(opt.list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@FunctionalInterface
|
||||
public interface pushOptionalClassPathCallback
|
||||
{
|
||||
void run(String[] opt) throws IOException;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public int getServerPort() {
|
||||
return serverPort;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package ru.gravit.launcher.profiles.optional;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
|
||||
public class OptionalDepend {
|
||||
@LauncherAPI
|
||||
public String name;
|
||||
@LauncherAPI
|
||||
public OptionalType type;
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
package ru.gravit.launcher.profiles.optional;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class OptionalFile {
|
||||
@LauncherAPI
|
||||
public String[] list;
|
||||
@LauncherAPI
|
||||
public OptionalType type;
|
||||
@LauncherAPI
|
||||
public boolean mark;
|
||||
@LauncherAPI
|
||||
public boolean visible = true;
|
||||
@LauncherAPI
|
||||
public String name;
|
||||
@LauncherAPI
|
||||
public String info;
|
||||
@LauncherAPI
|
||||
public OptionalDepend[] dependenciesFile;
|
||||
@LauncherAPI
|
||||
public OptionalDepend[] conflictFile;
|
||||
@LauncherAPI
|
||||
public transient OptionalFile[] dependencies;
|
||||
@LauncherAPI
|
||||
public transient OptionalFile[] conflict;
|
||||
@LauncherAPI
|
||||
public int subTreeLevel = 1;
|
||||
@LauncherAPI
|
||||
public long permissions = 0L;
|
||||
@LauncherAPI
|
||||
public transient Set<OptionalFile> dependenciesCount;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
OptionalFile that = (OptionalFile) o;
|
||||
return Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
@LauncherAPI
|
||||
public OptionalType getType() {
|
||||
return OptionalType.FILE;
|
||||
}
|
||||
@LauncherAPI
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@LauncherAPI
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
@LauncherAPI
|
||||
public boolean isMark() {
|
||||
return mark;
|
||||
}
|
||||
@LauncherAPI
|
||||
public long getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
@LauncherAPI
|
||||
public void writeType(HOutput output) throws IOException
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
||||
case FILE:
|
||||
output.writeInt(1);
|
||||
break;
|
||||
case CLASSPATH:
|
||||
output.writeInt(2);
|
||||
break;
|
||||
case JVMARGS:
|
||||
output.writeInt(3);
|
||||
break;
|
||||
case CLIENTARGS:
|
||||
output.writeInt(4);
|
||||
break;
|
||||
default:
|
||||
output.writeInt(5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@LauncherAPI
|
||||
public static OptionalType readType(HInput input) throws IOException
|
||||
{
|
||||
int t = input.readInt();
|
||||
OptionalType type;
|
||||
switch(t)
|
||||
{
|
||||
case 1:
|
||||
type = OptionalType.FILE;
|
||||
break;
|
||||
case 2:
|
||||
type = OptionalType.CLASSPATH;
|
||||
break;
|
||||
case 3:
|
||||
type = OptionalType.JVMARGS;
|
||||
break;
|
||||
case 4:
|
||||
type = OptionalType.CLIENTARGS;
|
||||
break;
|
||||
default:
|
||||
LogHelper.error("readType failed. Read int %d",t);
|
||||
type = OptionalType.FILE;
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package ru.gravit.launcher.profiles.optional;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
|
||||
@LauncherAPI
|
||||
public enum OptionalType
|
||||
{
|
||||
@LauncherAPI
|
||||
FILE,
|
||||
@LauncherAPI
|
||||
CLASSPATH,
|
||||
@LauncherAPI
|
||||
JVMARGS,
|
||||
@LauncherAPI
|
||||
CLIENTARGS
|
||||
}
|
Loading…
Reference in a new issue