Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.

Commit fcbd221

Browse files
authored
[FIX] Support 5.6.1 (GravitLauncher#4)
* Update launcher deps * Updated module to 5.6.1 * init fix
1 parent 783702f commit fcbd221

4 files changed

Lines changed: 73 additions & 71 deletions

File tree

MyHttp_module/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
# Ignore Gradle build output directory
55
build
6-
6+
bin
77
.idea

MyHttp_module/app/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ repositories {
2222

2323
dependencies {
2424
// This dependency is used by the application.
25-
implementation("pro.gravit.launcher:launcher-core:5.5.3-SNAPSHOT")
26-
implementation("pro.gravit.launcher:launcher-ws-api:5.5.3-SNAPSHOT")
27-
implementation("pro.gravit.launcher:launchserver-api:5.5.3-SNAPSHOT")
25+
implementation("pro.gravit.launcher:launcher-core:5.6.1")
26+
implementation("pro.gravit.launcher:launchserver-api:5.6.1")
27+
implementation("pro.gravit.launcher:launcher-ws-api:5.6.1")
2828
implementation("com.google.code.gson:gson:2.8.9")
2929
implementation("org.apache.logging.log4j:log4j-api:2.20.0")
3030
}
@@ -48,4 +48,4 @@ java {
4848

4949
tasks.jar {
5050
manifest.attributes["Module-Main-Class"] = "pro.gravit.launchermodules.myhttp.MyHttpModule"
51-
}
51+
}

MyHttp_module/app/src/main/java/pro/gravit/launchermodules/myhttp/MyHttpAuthCoreProvider.java

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
import org.apache.logging.log4j.LogManager;
1313
import org.apache.logging.log4j.Logger;
1414

15-
import pro.gravit.launcher.ClientPermissions;
16-
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
17-
import pro.gravit.launcher.profiles.Texture;
18-
import pro.gravit.launcher.request.auth.AuthRequest;
19-
import pro.gravit.launcher.request.auth.details.AuthPasswordDetails;
20-
import pro.gravit.launcher.request.auth.details.AuthTotpDetails;
21-
import pro.gravit.launcher.request.auth.password.Auth2FAPassword;
22-
import pro.gravit.launcher.request.auth.password.AuthPlainPassword;
23-
import pro.gravit.launcher.request.auth.password.AuthTOTPPassword;
24-
import pro.gravit.launcher.request.secure.HardwareReportRequest;
15+
import pro.gravit.launcher.base.ClientPermissions;
16+
import pro.gravit.launcher.base.events.request.GetAvailabilityAuthRequestEvent;
17+
import pro.gravit.launcher.base.profiles.Texture;
18+
import pro.gravit.launcher.base.request.auth.AuthRequest;
19+
import pro.gravit.launcher.base.request.auth.details.AuthPasswordDetails;
20+
import pro.gravit.launcher.base.request.auth.details.AuthTotpDetails;
21+
import pro.gravit.launcher.base.request.auth.password.Auth2FAPassword;
22+
import pro.gravit.launcher.base.request.auth.password.AuthPlainPassword;
23+
import pro.gravit.launcher.base.request.auth.password.AuthTOTPPassword;
24+
import pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo;
2525
import pro.gravit.launchserver.HttpRequester;
2626
import pro.gravit.launchserver.LaunchServer;
2727
import pro.gravit.launchserver.auth.AuthException;
28+
import pro.gravit.launchserver.auth.AuthProviderPair;
2829
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
2930
import pro.gravit.launchserver.auth.core.User;
3031
import pro.gravit.launchserver.auth.core.UserSession;
@@ -178,7 +179,8 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c
178179
}
179180

180181
@Override
181-
public void init(LaunchServer server) {
182+
public void init(LaunchServer server, AuthProviderPair pair) {
183+
super.init(server, pair);
182184
requester = new HttpRequester();
183185
}
184186

@@ -249,31 +251,6 @@ public MyHttpUserHardware getHardwareInfoByPublicKey(byte[] publicKey) {
249251
return null;
250252
}
251253

252-
@Override
253-
public MyHttpUserHardware getHardwareInfoByData(HardwareReportRequest.HardwareInfo info) {
254-
HttpHelper.HttpOptional<MyHttpUserHardware, HttpRequester.SimpleError> response = null;
255-
try {
256-
response = requester.send(requester.post(getHardwareInfoByDataUrl, new HardwareInfoRequest(info), bearerToken), MyHttpUserHardware.class);
257-
} catch (Throwable e) {
258-
logger.error("getHardwareInfoByData", e);
259-
}
260-
261-
if (response != null && response.statusCode() == 200) {
262-
MyHttpUserHardware userHardware = response.result();
263-
logger.debug("Successfully got UserHardware {} by info", userHardware.id);
264-
return userHardware;
265-
}
266-
267-
// HTTP 204 meaning NO CONTENT, that usually means no data found, but request processed successfully
268-
if (response != null && response.statusCode() == 204) {
269-
logger.debug("UserHardware not found by publicKey");
270-
return null;
271-
}
272-
273-
logger.debug("Something went wrong while getting UserHardware by info");
274-
return null;
275-
}
276-
277254
@Override
278255
public MyHttpUserHardware getHardwareInfoById(String id) {
279256
HttpHelper.HttpOptional<MyHttpUserHardware, HttpRequester.SimpleError> response = null;
@@ -299,27 +276,6 @@ public MyHttpUserHardware getHardwareInfoById(String id) {
299276
return null;
300277
}
301278

302-
@Override
303-
public MyHttpUserHardware createHardwareInfo(HardwareReportRequest.HardwareInfo info, byte[] publicKey) {
304-
HttpHelper.HttpOptional<MyHttpUserHardware, HttpRequester.SimpleError> response = null;
305-
try {
306-
response = requester.send(requester.post(createHardwareInfoUrl, new HardwareInfoRequest(info, publicKey), bearerToken), MyHttpUserHardware.class);
307-
} catch (Throwable e) {
308-
logger.error("createHardwareInfo", e);
309-
}
310-
311-
if (response != null && response.isSuccessful()) {
312-
MyHttpUserHardware userHardware = response.result();
313-
logger.debug("Successfully created UserHardware");
314-
return userHardware;
315-
}
316-
317-
logger.debug("Something went wrong while creating UserHardware");
318-
319-
// shouldn't actually happen
320-
throw new SecurityException("Please contact administrator");
321-
}
322-
323279
@Override
324280
public void connectUserAndHardware(UserSession userSession, UserHardware hardware) {
325281
HttpHelper.HttpOptional<MyHttpSimpleResponse, HttpRequester.SimpleError> response = null;
@@ -420,8 +376,8 @@ public record RefreshTokenRequest(String refreshToken) {}
420376

421377
public record GetUserByAccessTokenRequest(String accessToken) {}
422378

423-
public record HardwareInfoRequest(HardwareReportRequest.HardwareInfo info, byte[] publicKey, String id) {
424-
HardwareInfoRequest(HardwareReportRequest.HardwareInfo info) {
379+
public record HardwareInfoRequest(HardwareInfo info, byte[] publicKey, String id) {
380+
HardwareInfoRequest(HardwareInfo info) {
425381
this(info, null, null);
426382
}
427383

@@ -433,7 +389,7 @@ public record HardwareInfoRequest(HardwareReportRequest.HardwareInfo info, byte[
433389
this(null, null, id);
434390
}
435391

436-
HardwareInfoRequest(HardwareReportRequest.HardwareInfo info, byte[] publicKey) {
392+
HardwareInfoRequest(HardwareInfo info, byte[] publicKey) {
437393
this(info, publicKey, null);
438394
}
439395
}
@@ -537,10 +493,10 @@ public Map<String, Texture> getUserAssets() {
537493
}
538494
}
539495

540-
public record MyHttpUserHardware(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, String id, boolean banned) implements UserHardware {
496+
public record MyHttpUserHardware(HardwareInfo hardwareInfo, byte[] publicKey, String id, boolean banned) implements UserHardware {
541497

542498
@Override
543-
public HardwareReportRequest.HardwareInfo getHardwareInfo() {
499+
public HardwareInfo getHardwareInfo() {
544500
return hardwareInfo;
545501
}
546502

@@ -562,4 +518,50 @@ public boolean isBanned() {
562518

563519
public record MyHttpSimpleResponse(String message) {
564520
}
521+
522+
@Override
523+
public UserHardware getHardwareInfoByData(HardwareInfo info) {
524+
HttpHelper.HttpOptional<MyHttpUserHardware, HttpRequester.SimpleError> response = null;
525+
try {
526+
response = requester.send(requester.post(getHardwareInfoByDataUrl, new HardwareInfoRequest(info), bearerToken), MyHttpUserHardware.class);
527+
} catch (Throwable e) {
528+
logger.error("getHardwareInfoByData", e);
529+
}
530+
531+
if (response != null && response.statusCode() == 200) {
532+
MyHttpUserHardware userHardware = response.result();
533+
logger.debug("Successfully got UserHardware {} by info", userHardware.id);
534+
return userHardware;
535+
}
536+
537+
// HTTP 204 meaning NO CONTENT, that usually means no data found, but request processed successfully
538+
if (response != null && response.statusCode() == 204) {
539+
logger.debug("UserHardware not found by publicKey");
540+
return null;
541+
}
542+
543+
logger.debug("Something went wrong while getting UserHardware by info");
544+
return null;
545+
}
546+
547+
@Override
548+
public UserHardware createHardwareInfo(HardwareInfo info, byte[] publicKey) {
549+
HttpHelper.HttpOptional<MyHttpUserHardware, HttpRequester.SimpleError> response = null;
550+
try {
551+
response = requester.send(requester.post(createHardwareInfoUrl, new HardwareInfoRequest(info, publicKey), bearerToken), MyHttpUserHardware.class);
552+
} catch (Throwable e) {
553+
logger.error("createHardwareInfo", e);
554+
}
555+
556+
if (response != null && response.isSuccessful()) {
557+
MyHttpUserHardware userHardware = response.result();
558+
logger.debug("Successfully created UserHardware");
559+
return userHardware;
560+
}
561+
562+
logger.debug("Something went wrong while creating UserHardware");
563+
564+
// shouldn't actually happen
565+
throw new SecurityException("Please contact administrator");
566+
}
565567
}

MyHttp_module/app/src/main/java/pro/gravit/launchermodules/myhttp/MyHttpModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package pro.gravit.launchermodules.myhttp;
22

3-
import pro.gravit.launcher.modules.LauncherInitContext;
4-
import pro.gravit.launcher.modules.LauncherModule;
5-
import pro.gravit.launcher.modules.LauncherModuleInfo;
6-
import pro.gravit.launcher.modules.events.PreConfigPhase;
3+
import pro.gravit.launcher.base.modules.LauncherInitContext;
4+
import pro.gravit.launcher.base.modules.LauncherModule;
5+
import pro.gravit.launcher.base.modules.LauncherModuleInfo;
6+
import pro.gravit.launcher.base.modules.events.PreConfigPhase;
77
import pro.gravit.launchserver.LaunchServer;
88
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
99
import pro.gravit.utils.Version;

0 commit comments

Comments
 (0)