mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Фикс UpdateRequest, алгоритм обхода HashedDir, реализация joinServerRequest/CheckServerRequest
This commit is contained in:
parent
50adbac117
commit
08f7a98dbb
5 changed files with 61 additions and 5 deletions
|
@ -449,7 +449,6 @@ public static void main(String... args) throws Throwable {
|
||||||
Launcher.modulesManager.initModules();
|
Launcher.modulesManager.initModules();
|
||||||
// Verify ClientLauncher sign and classpath
|
// Verify ClientLauncher sign and classpath
|
||||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||||
//Warning - experimental.
|
|
||||||
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
||||||
for (Path classpathURL : classPath) {
|
for (Path classpathURL : classPath) {
|
||||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||||
import ru.gravit.launcher.request.Request;
|
import ru.gravit.launcher.request.Request;
|
||||||
import ru.gravit.launcher.request.RequestType;
|
import ru.gravit.launcher.request.RequestType;
|
||||||
|
import ru.gravit.launcher.request.ResultInterface;
|
||||||
|
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||||
|
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||||
import ru.gravit.launcher.serialize.HInput;
|
import ru.gravit.launcher.serialize.HInput;
|
||||||
import ru.gravit.launcher.serialize.HOutput;
|
import ru.gravit.launcher.serialize.HOutput;
|
||||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||||
|
@ -15,7 +18,7 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public final class CheckServerRequest extends Request<CheckServerRequestEvent> {
|
public final class CheckServerRequest extends Request<CheckServerRequestEvent> implements RequestInterface {
|
||||||
private final String username;
|
private final String username;
|
||||||
private final String serverID;
|
private final String serverID;
|
||||||
|
|
||||||
|
@ -31,6 +34,12 @@ public CheckServerRequest(String username, String serverID) {
|
||||||
this(null, username, serverID);
|
this(null, username, serverID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CheckServerRequestEvent requestWebSockets() throws Exception
|
||||||
|
{
|
||||||
|
return (CheckServerRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getLegacyType() {
|
public Integer getLegacyType() {
|
||||||
return RequestType.CHECK_SERVER.getNumber();
|
return RequestType.CHECK_SERVER.getNumber();
|
||||||
|
@ -51,4 +60,9 @@ protected CheckServerRequestEvent requestDo(HInput input, HOutput output) throws
|
||||||
readError(input);
|
readError(input);
|
||||||
return input.readBoolean() ? new CheckServerRequestEvent(new PlayerProfile(input)) : null;
|
return input.readBoolean() ? new CheckServerRequestEvent(new PlayerProfile(input)) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "checkServer";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
import ru.gravit.launcher.events.request.JoinServerRequestEvent;
|
import ru.gravit.launcher.events.request.JoinServerRequestEvent;
|
||||||
import ru.gravit.launcher.request.Request;
|
import ru.gravit.launcher.request.Request;
|
||||||
import ru.gravit.launcher.request.RequestType;
|
import ru.gravit.launcher.request.RequestType;
|
||||||
|
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||||
|
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||||
import ru.gravit.launcher.serialize.HInput;
|
import ru.gravit.launcher.serialize.HInput;
|
||||||
import ru.gravit.launcher.serialize.HOutput;
|
import ru.gravit.launcher.serialize.HOutput;
|
||||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||||
|
@ -13,7 +15,7 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public final class JoinServerRequest extends Request<JoinServerRequestEvent> {
|
public final class JoinServerRequest extends Request<JoinServerRequestEvent> implements RequestInterface {
|
||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
private final String username;
|
private final String username;
|
||||||
|
@ -28,6 +30,11 @@ public JoinServerRequest(LauncherConfig config, String username, String accessTo
|
||||||
this.serverID = VerifyHelper.verifyServerID(serverID);
|
this.serverID = VerifyHelper.verifyServerID(serverID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JoinServerRequestEvent requestWebSockets() throws IOException, InterruptedException {
|
||||||
|
return (JoinServerRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||||
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public JoinServerRequest(String username, String accessToken, String serverID) {
|
public JoinServerRequest(String username, String accessToken, String serverID) {
|
||||||
this(null, username, accessToken, serverID);
|
this(null, username, accessToken, serverID);
|
||||||
|
@ -50,4 +57,8 @@ protected JoinServerRequestEvent requestDo(HInput input, HOutput output) throws
|
||||||
return new JoinServerRequestEvent(input.readBoolean());
|
return new JoinServerRequestEvent(input.readBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "joinServer";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,8 +206,8 @@ public UpdateRequestEvent requestWebSockets() throws Exception {
|
||||||
Launcher.profile.pushOptionalFile(e.hdir, !Launcher.profile.isUpdateFastCheck());
|
Launcher.profile.pushOptionalFile(e.hdir, !Launcher.profile.isUpdateFastCheck());
|
||||||
HashedDir.Diff diff = e.hdir.diff(localDir, matcher);
|
HashedDir.Diff diff = e.hdir.diff(localDir, matcher);
|
||||||
final List<String> adds = new ArrayList<>();
|
final List<String> adds = new ArrayList<>();
|
||||||
diff.mismatch.map().entrySet().stream().filter(e1 -> e1.getValue().getType().equals(HashedEntry.Type.FILE)).forEach(a -> {
|
diff.mismatch.walk(IOHelper.CROSS_SEPARATOR, (path, name, entry) -> {
|
||||||
adds.add(a.getKey());
|
if(entry.getType() == HashedEntry.Type.FILE) adds.add(path.replaceAll(" ","%20"));
|
||||||
});
|
});
|
||||||
totalSize = diff.mismatch.size();
|
totalSize = diff.mismatch.size();
|
||||||
startTime = Instant.now();
|
startTime = Instant.now();
|
||||||
|
|
|
@ -335,4 +335,36 @@ public void write(HOutput output) throws IOException {
|
||||||
entry.write(output);
|
entry.write(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void walk(CharSequence separator, WalkCallback callback)
|
||||||
|
{
|
||||||
|
String append = "";
|
||||||
|
walk(append,separator, callback, true);
|
||||||
|
}
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface WalkCallback
|
||||||
|
{
|
||||||
|
void walked(String path, String name, HashedEntry entry);
|
||||||
|
}
|
||||||
|
private void walk(String append, CharSequence separator, WalkCallback callback , boolean noSeparator)
|
||||||
|
{
|
||||||
|
for(Map.Entry<String, HashedEntry> entry : map.entrySet())
|
||||||
|
{
|
||||||
|
HashedEntry e = entry.getValue();
|
||||||
|
if(e.getType() == Type.FILE)
|
||||||
|
{
|
||||||
|
if(noSeparator)
|
||||||
|
callback.walked(append + entry.getKey(), entry.getKey(), e);
|
||||||
|
else
|
||||||
|
callback.walked(append + separator + entry.getKey(), entry.getKey(), e);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String newAppend;
|
||||||
|
if(noSeparator) newAppend = append + entry.getKey();
|
||||||
|
else newAppend = append + separator + entry.getKey();
|
||||||
|
callback.walked(newAppend, entry.getKey(), e);
|
||||||
|
((HashedDir)e).walk(newAppend, separator, callback, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue