Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev

This commit is contained in:
Gravit 2020-04-04 17:30:26 +07:00
commit e226cb397d
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
6 changed files with 7 additions and 11 deletions

1
.gitignore vendored
View file

@ -109,3 +109,4 @@ cmd.bat
cmd.sh cmd.sh
## PVS Studio ## PVS Studio
.PVS-Studio/ .PVS-Studio/
project/target

View file

@ -43,8 +43,8 @@ public synchronized Connection getConnection() throws SQLException {
PGSimpleDataSource postgresqlSource = new PGSimpleDataSource(); PGSimpleDataSource postgresqlSource = new PGSimpleDataSource();
// Set credentials // Set credentials
postgresqlSource.setServerName(address); postgresqlSource.setServerNames(new String[] {address}); //TODO support multinode PostgreSQL DB
postgresqlSource.setPortNumber(port); postgresqlSource.setPortNumbers(new int[] {port});
postgresqlSource.setUser(username); postgresqlSource.setUser(username);
postgresqlSource.setPassword(password); postgresqlSource.setPassword(password);
postgresqlSource.setDatabaseName(database); postgresqlSource.setDatabaseName(database);

View file

@ -16,8 +16,6 @@
import java.util.Map; import java.util.Map;
public final class UnindexAssetCommand extends Command { public final class UnindexAssetCommand extends Command {
private static final JsonParser parser = new JsonParser();
public UnindexAssetCommand(LaunchServer server) { public UnindexAssetCommand(LaunchServer server) {
super(server); super(server);
} }
@ -51,7 +49,7 @@ public void invoke(String... args) throws Exception {
JsonObject objects; JsonObject objects;
LogHelper.subInfo("Reading asset index file: '%s'", indexFileName); LogHelper.subInfo("Reading asset index file: '%s'", indexFileName);
try (BufferedReader reader = IOHelper.newReader(IndexAssetCommand.resolveIndexFile(inputAssetDir, indexFileName))) { try (BufferedReader reader = IOHelper.newReader(IndexAssetCommand.resolveIndexFile(inputAssetDir, indexFileName))) {
objects = parser.parse(reader).getAsJsonObject().get("objects").getAsJsonObject(); objects = JsonParser.parseReader(reader).getAsJsonObject().get("objects").getAsJsonObject();
} }
// Restore objects // Restore objects

View file

@ -20,7 +20,6 @@
import java.util.regex.Pattern; import java.util.regex.Pattern;
public final class ServerPinger { public final class ServerPinger {
private final JsonParser parser = new JsonParser();
public static final class Result { public static final class Result {
@ -184,7 +183,7 @@ private Result modernPing(HInput input, HOutput output) throws IOException {
} }
// Parse JSON response // Parse JSON response
JsonObject object = parser.parse(response).getAsJsonObject(); JsonObject object = JsonParser.parseString(response).getAsJsonObject();
JsonObject playersObject = object.get("players").getAsJsonObject(); JsonObject playersObject = object.get("players").getAsJsonObject();
int online = playersObject.get("online").getAsInt(); int online = playersObject.get("online").getAsInt();
int max = playersObject.get("max").getAsInt(); int max = playersObject.get("max").getAsInt();

View file

@ -28,7 +28,6 @@
import java.util.UUID; import java.util.UUID;
public class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService { public class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService {
public static final JsonParser JSON_PARSER = new JsonParser();
public static final boolean NO_TEXTURES = Boolean.parseBoolean("launcher.com.mojang.authlib.noTextures"); public static final boolean NO_TEXTURES = Boolean.parseBoolean("launcher.com.mojang.authlib.noTextures");
public static void fillTextureProperties(GameProfile profile, PlayerProfile pp) { public static void fillTextureProperties(GameProfile profile, PlayerProfile pp) {
@ -62,7 +61,7 @@ private static void getTexturesMojang(Map<MinecraftProfileTexture.Type, Minecraf
JsonObject texturesJSON; JsonObject texturesJSON;
try { try {
byte[] decoded = Base64.getDecoder().decode(texturesBase64); byte[] decoded = Base64.getDecoder().decode(texturesBase64);
texturesJSON = JSON_PARSER.parse(new String(decoded, IOHelper.UNICODE_CHARSET)).getAsJsonObject().getAsJsonObject("textures"); texturesJSON = JsonParser.parseString(new String(decoded, IOHelper.UNICODE_CHARSET)).getAsJsonObject().getAsJsonObject("textures");
} catch (Exception ignored) { } catch (Exception ignored) {
LogHelper.error("Could not decode textures payload, Username: '%s', UUID: '%s'", profile.getName(), profile.getUUID()); LogHelper.error("Could not decode textures payload, Username: '%s', UUID: '%s'", profile.getName(), profile.getUUID());
return; return;

View file

@ -13,7 +13,6 @@
public final class HTTPRequest { public final class HTTPRequest {
private static final int TIMEOUT = 10000; private static final int TIMEOUT = 10000;
private static final JsonParser parser = new JsonParser();
public static JsonElement jsonRequest(JsonElement request, URL url) throws IOException { public static JsonElement jsonRequest(JsonElement request, URL url) throws IOException {
return jsonRequest(request, "POST", url); return jsonRequest(request, "POST", url);
@ -42,7 +41,7 @@ public static JsonElement jsonRequest(JsonElement request, String method, URL ur
else else
reader = new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8); reader = new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8);
try { try {
return parser.parse(reader); return JsonParser.parseReader(reader);
} catch (Exception e) { } catch (Exception e) {
if (200 > statusCode || statusCode > 300) { if (200 > statusCode || statusCode > 300) {
LogHelper.error("JsonRequest failed. Server response code %d", statusCode); LogHelper.error("JsonRequest failed. Server response code %d", statusCode);