2019-06-02 05:03:08 +03:00
|
|
|
package pro.gravit.launchserver.manangers;
|
2019-04-20 01:03:06 +03:00
|
|
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
2021-11-09 10:12:31 +03:00
|
|
|
import marcono1234.gson.recordadapter.RecordTypeAdapterFactory;
|
2021-04-14 13:22:07 +03:00
|
|
|
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
2019-06-02 05:03:08 +03:00
|
|
|
import pro.gravit.launcher.managers.GsonManager;
|
2019-08-26 13:24:19 +03:00
|
|
|
import pro.gravit.launcher.modules.events.PreGsonPhase;
|
2023-04-20 15:06:12 +03:00
|
|
|
import pro.gravit.launcher.profiles.ClientProfile;
|
2020-09-12 09:41:58 +03:00
|
|
|
import pro.gravit.launcher.profiles.optional.actions.OptionalAction;
|
2021-06-18 07:34:32 +03:00
|
|
|
import pro.gravit.launcher.profiles.optional.triggers.OptionalTrigger;
|
2019-07-01 12:59:47 +03:00
|
|
|
import pro.gravit.launcher.request.JsonResultSerializeAdapter;
|
2019-07-01 13:46:49 +03:00
|
|
|
import pro.gravit.launcher.request.WebSocketEvent;
|
2019-09-27 03:31:19 +03:00
|
|
|
import pro.gravit.launcher.request.auth.AuthRequest;
|
2021-04-14 13:22:07 +03:00
|
|
|
import pro.gravit.launcher.request.auth.GetAvailabilityAuthRequest;
|
2021-05-16 16:07:44 +03:00
|
|
|
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
|
2021-05-19 22:18:01 +03:00
|
|
|
import pro.gravit.launchserver.auth.password.PasswordVerifier;
|
2019-06-02 05:03:08 +03:00
|
|
|
import pro.gravit.launchserver.auth.protect.ProtectHandler;
|
|
|
|
import pro.gravit.launchserver.auth.texture.TextureProvider;
|
|
|
|
import pro.gravit.launchserver.components.Component;
|
2019-08-26 13:24:19 +03:00
|
|
|
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
2019-07-01 12:59:47 +03:00
|
|
|
import pro.gravit.launchserver.socket.WebSocketService;
|
2020-06-22 07:20:42 +03:00
|
|
|
import pro.gravit.launchserver.socket.response.UnknownResponse;
|
2019-07-01 13:46:49 +03:00
|
|
|
import pro.gravit.launchserver.socket.response.WebSocketServerResponse;
|
2019-06-02 05:03:08 +03:00
|
|
|
import pro.gravit.utils.UniversalJsonAdapter;
|
2019-04-20 01:03:06 +03:00
|
|
|
|
|
|
|
public class LaunchServerGsonManager extends GsonManager {
|
2019-08-26 13:24:19 +03:00
|
|
|
private final LaunchServerModulesManager modulesManager;
|
|
|
|
|
|
|
|
public LaunchServerGsonManager(LaunchServerModulesManager modulesManager) {
|
|
|
|
this.modulesManager = modulesManager;
|
|
|
|
}
|
|
|
|
|
2019-04-20 01:03:06 +03:00
|
|
|
@Override
|
|
|
|
public void registerAdapters(GsonBuilder builder) {
|
|
|
|
super.registerAdapters(builder);
|
2022-01-11 22:15:01 +03:00
|
|
|
builder.registerTypeAdapterFactory(RecordTypeAdapterFactory.builder()
|
2022-11-18 10:47:03 +03:00
|
|
|
.allowMissingComponentValues()
|
|
|
|
.create());
|
2023-04-20 15:06:12 +03:00
|
|
|
builder.registerTypeAdapter(ClientProfile.Version.class, new ClientProfile.Version.GsonSerializer());
|
2019-04-20 01:58:59 +03:00
|
|
|
builder.registerTypeAdapter(TextureProvider.class, new UniversalJsonAdapter<>(TextureProvider.providers));
|
2021-05-16 16:07:44 +03:00
|
|
|
builder.registerTypeAdapter(AuthCoreProvider.class, new UniversalJsonAdapter<>(AuthCoreProvider.providers));
|
2021-05-19 22:18:01 +03:00
|
|
|
builder.registerTypeAdapter(PasswordVerifier.class, new UniversalJsonAdapter<>(PasswordVerifier.providers));
|
2019-04-20 01:58:59 +03:00
|
|
|
builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers));
|
|
|
|
builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers));
|
2020-06-22 07:20:42 +03:00
|
|
|
builder.registerTypeAdapter(WebSocketServerResponse.class, new UniversalJsonAdapter<>(WebSocketService.providers, UnknownResponse.class));
|
2019-07-01 13:46:49 +03:00
|
|
|
builder.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter());
|
2019-09-27 03:31:19 +03:00
|
|
|
builder.registerTypeAdapter(AuthRequest.AuthPasswordInterface.class, new UniversalJsonAdapter<>(AuthRequest.providers));
|
2021-04-14 13:22:07 +03:00
|
|
|
builder.registerTypeAdapter(GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails.class, new UniversalJsonAdapter<>(GetAvailabilityAuthRequest.providers));
|
2020-09-12 09:41:58 +03:00
|
|
|
builder.registerTypeAdapter(OptionalAction.class, new UniversalJsonAdapter<>(OptionalAction.providers));
|
2021-06-18 07:34:32 +03:00
|
|
|
builder.registerTypeAdapter(OptionalTrigger.class, new UniversalJsonAdapter<>(OptionalTrigger.providers));
|
2019-08-26 13:24:19 +03:00
|
|
|
modulesManager.invokeEvent(new PreGsonPhase(builder));
|
2019-07-03 10:23:26 +03:00
|
|
|
//ClientWebSocketService.appendTypeAdapters(builder);
|
2019-04-20 01:03:06 +03:00
|
|
|
}
|
|
|
|
}
|