[FIX] Фиксы автозамены

This commit is contained in:
Gravit 2019-04-20 05:09:47 +07:00
parent b12c26047b
commit d266fe8b74
7 changed files with 5 additions and 70 deletions

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.HTTPRequest;

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver.command.dump;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.auth.handler.CachedAuthHandler;

View file

@ -1,6 +1,7 @@
package ru.gravit.launchserver.command.dump;
import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.socket.Client;

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver.command.hash;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launchserver.LaunchServer;

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver.command.service;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;

View file

@ -1,35 +0,0 @@
package ru.gravit.launchserver.config.adapter;
import com.google.gson.*;
import ru.gravit.launchserver.components.Component;
import ru.gravit.utils.helper.LogHelper;
import java.lang.reflect.Type;
public class ComponentAdapter implements JsonSerializer<Component>, JsonDeserializer<Component> {
private static final String PROP_NAME = "component";
@Override
public Component deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends Component> cls = Component.getComponentClass(typename);
if (cls == null) {
LogHelper.error("Component %s not found", typename);
return null;
}
return (Component) context.deserialize(json, cls);
}
@Override
public JsonElement serialize(Component src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject jo = context.serialize(src).getAsJsonObject();
@SuppressWarnings("unchecked")
String classPath = Component.getComponentName((Class<Component>) src.getClass());
jo.add(PROP_NAME, new JsonPrimitive(classPath));
return jo;
}
}

View file

@ -1,35 +0,0 @@
package ru.gravit.launchserver.config.adapter;
import com.google.gson.*;
import ru.gravit.launchserver.auth.protect.ProtectHandler;
import ru.gravit.utils.helper.LogHelper;
import java.lang.reflect.Type;
public class ProtectHandlerAdapter implements JsonSerializer<ProtectHandler>, JsonDeserializer<ProtectHandler> {
private static final String PROP_NAME = "type";
@Override
public ProtectHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends ProtectHandler> cls = ProtectHandler.getHandlerClass(typename);
if (cls == null) {
LogHelper.error("ProtectHandler %s not found", typename);
return null;
}
return (ProtectHandler) context.deserialize(json, cls);
}
@Override
public JsonElement serialize(ProtectHandler src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject jo = context.serialize(src).getAsJsonObject();
@SuppressWarnings("unchecked")
String classPath = ProtectHandler.getHandlerName((Class<ProtectHandler>) src.getClass());
jo.add(PROP_NAME, new JsonPrimitive(classPath));
return jo;
}
}