[FIX] Фикс инициализации Guard и ClassCastException

This commit is contained in:
Gravit 2019-09-01 20:07:23 +07:00
parent 988d220f35
commit 49e26d0d29
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 11 additions and 2 deletions

View file

@ -113,13 +113,13 @@ public void start(String... args) throws Throwable {
}
};
}
LauncherGuardManager.initGuard(false);
if(UpdateRequest.getController() == null) UpdateRequest.setController(new LauncherUpdateController());
Objects.requireNonNull(args, "args");
if (started.getAndSet(true))
throw new IllegalStateException("Launcher has been already started");
LauncherEngine.modulesManager.invokeEvent(new ClientEngineInitPhase(this));
runtimeProvider.preLoad();
LauncherGuardManager.initGuard(false);
FunctionalBridge.getHWID = CommonHelper.newThread("GetHWID Thread", true, FunctionalBridge::getHWID);
FunctionalBridge.getHWID.start();
LogHelper.debug("Dir: %s", DirBridge.dir);

View file

@ -7,6 +7,7 @@
import javax.net.ssl.SSLException;
import pro.gravit.launcher.events.ExceptionEvent;
import pro.gravit.launcher.events.request.ErrorRequestEvent;
import pro.gravit.launcher.request.Request;
import pro.gravit.launcher.request.RequestException;
@ -67,6 +68,10 @@ public WebSocketEvent get() throws InterruptedException, ExecutionException {
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result;
throw new ExecutionException(new RequestException(errorRequestEvent.error));
}
if (event.result.getType().equals("exception")) {
ExceptionEvent error = (ExceptionEvent) event.result;
throw new ExecutionException(new RequestException(String.format("LaunchServer fatal error: %s: %s", error.clazz, error.message)));
}
return result;
}
@ -80,10 +85,14 @@ public WebSocketEvent get(long timeout, TimeUnit unit) throws InterruptedExcepti
}
WebSocketEvent result = event.result;
waitEventHandler.requests.remove(event);
if (event.result.getType().equals("error") || event.result.getType().equals("exception")) {
if (event.result.getType().equals("error")) {
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result;
throw new ExecutionException(new RequestException(errorRequestEvent.error));
}
if (event.result.getType().equals("exception")) {
ExceptionEvent error = (ExceptionEvent) event.result;
throw new ExecutionException(new RequestException(String.format("LaunchServer fatal error: %s: %s", error.clazz, error.message)));
}
return result;
}
}