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