fix GsonRequest serialize fail
This commit is contained in:
@ -3,7 +3,7 @@ package cn.forevermc.launcher.service;
|
|||||||
import cn.forevermc.launcher.bean.APISetting;
|
import cn.forevermc.launcher.bean.APISetting;
|
||||||
import cn.forevermc.launcher.util.Resources;
|
import cn.forevermc.launcher.util.Resources;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.imyeyu.fx.task.RunAsync;
|
import com.imyeyu.fx.task.RunAsync;
|
||||||
import com.imyeyu.inject.annotation.Inject;
|
import com.imyeyu.inject.annotation.Inject;
|
||||||
import com.imyeyu.inject.annotation.InvokeForInjected;
|
import com.imyeyu.inject.annotation.InvokeForInjected;
|
||||||
@ -49,7 +49,7 @@ public class APISettingService {
|
|||||||
for (APISetting.Key key : APISetting.Key.values()) {
|
for (APISetting.Key key : APISetting.Key.values()) {
|
||||||
reqArgs.put(key, null);
|
reqArgs.put(key, null);
|
||||||
}
|
}
|
||||||
Map<APISetting.Key, String> data = TimiRequest.<Map<APISetting.Key, String>>wrap(Request.post(API).bodyString(gson.toJson(reqArgs), ContentType.APPLICATION_JSON)).result();
|
Map<APISetting.Key, String> data = TimiRequest.wrap(Request.post(API).bodyString(gson.toJson(reqArgs), ContentType.APPLICATION_JSON)).resultAs(new TypeToken<>() {});
|
||||||
setting.setBg(gson.fromJson(data.get(APISetting.Key.FMC_BG), APISetting.DynamicList.class));
|
setting.setBg(gson.fromJson(data.get(APISetting.Key.FMC_BG), APISetting.DynamicList.class));
|
||||||
setting.setBgm(gson.fromJson(data.get(APISetting.Key.FMC_BGM), APISetting.DynamicList.class));
|
setting.setBgm(gson.fromJson(data.get(APISetting.Key.FMC_BGM), APISetting.DynamicList.class));
|
||||||
setting.setSplashes(gson.fromJson(data.get(APISetting.Key.FMC_SPLASHES), APISetting.DynamicList.class));
|
setting.setSplashes(gson.fromJson(data.get(APISetting.Key.FMC_SPLASHES), APISetting.DynamicList.class));
|
||||||
|
|||||||
@ -137,11 +137,11 @@ public class FMCLoginService implements OS.FileSystem {
|
|||||||
@Override
|
@Override
|
||||||
protected Void call() throws Exception {
|
protected Void call() throws Exception {
|
||||||
{
|
{
|
||||||
String data = TimiRequest.<String>get(SETTING_API + "/FMC_LOGIN_FABRIC").result();
|
String data = TimiRequest.get(SETTING_API + "/FMC_LOGIN_FABRIC").resultAs(String.class);
|
||||||
loginModMapTemp = gson.fromJson(data, new TypeToken<Map<String, String>>() {}.getType());
|
loginModMapTemp = gson.fromJson(data, new TypeToken<Map<String, String>>() {}.getType());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
List<FabricAPI> data = TimiRequest.<List<FabricAPI>>get(MIRROR_API + "/FabricAPI").result();
|
List<FabricAPI> data = TimiRequest.get(MIRROR_API + "/FabricAPI").resultAs(new TypeToken<>() {});
|
||||||
fabricAPIMapTemp = data.stream().collect(Collectors.toMap(FabricAPI::getMinecraftVer, item -> item));
|
fabricAPIMapTemp = data.stream().collect(Collectors.toMap(FabricAPI::getMinecraftVer, item -> item));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -214,19 +214,17 @@ public class FMCLoginService implements OS.FileSystem {
|
|||||||
TokenRequest request = new TokenRequest();
|
TokenRequest request = new TokenRequest();
|
||||||
request.setUser(user);
|
request.setUser(user);
|
||||||
request.setPassword(password);
|
request.setPassword(password);
|
||||||
return TimiRequest.<TokenResponse>wrap(Request.post(LOGIN_TOKEN_API).bodyString(gson.toJson(request), ContentType.APPLICATION_JSON)).result();
|
return TimiRequest.wrap(Request.post(LOGIN_TOKEN_API).bodyString(gson.toJson(request), ContentType.APPLICATION_JSON)).resultAs(TokenResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MinecraftPlayer> listBoundPlayer(String token) throws Exception {
|
public List<MinecraftPlayer> listBoundPlayer(String token) throws Exception {
|
||||||
return TimiRequest.<List<MinecraftPlayer>>wrap(Request.get(LIST_PLAYER_API).addHeader("Token", token)).result();
|
return TimiRequest.wrap(Request.get(LIST_PLAYER_API).addHeader("Token", token)).resultAs(new TypeToken<>() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
public TokenResponse doLogin(MinecraftPlayer player, String token) throws Exception {
|
public TokenResponse doLogin(MinecraftPlayer player, String token) throws Exception {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("playerId", player.id);
|
map.put("playerId", player.id);
|
||||||
return TimiRequest.<TokenResponse>wrap(Request.get(LIST_PLAYER_API)
|
return TimiRequest.wrap(Request.get(LIST_PLAYER_API).addHeader("Token", token).bodyString(gson.toJson(map), ContentType.APPLICATION_JSON)).resultAs(TokenResponse.class);
|
||||||
.addHeader("Token", token)
|
|
||||||
.bodyString(gson.toJson(map), ContentType.APPLICATION_JSON)).result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasMod(Game game, String name) {
|
private boolean hasMod(Game game, String name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user