Compare commits

...

3 commits

Author SHA1 Message Date
Gravita
5c374462ef [FIX] Ping error handle 2023-02-25 19:54:05 +07:00
Gravita
ef5695f679 [ANY] Update modules 2023-02-25 18:43:34 +07:00
Gravita
b4331819cb [FEATURE] Update OptionalView 2023-02-25 18:42:26 +07:00
6 changed files with 41 additions and 8 deletions

View file

@ -1,5 +1,6 @@
package pro.gravit.launcher.client;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import pro.gravit.launcher.profiles.ClientProfile;
@ -162,9 +163,13 @@ private Result modernPing(HInput input, HOutput output) throws IOException {
}
// Parse JSON response
JsonObject object = JsonParser.parseString(response).getAsJsonObject();
JsonElement element = JsonParser.parseString(response);
if(element.isJsonPrimitive()) {
throw new IOException(element.getAsString());
}
JsonObject object = element.getAsJsonObject();
if (object.has("error")) {
throw new IOException(object.get("error").getAsString());
throw new IOException(object.get("error").getAsString()); // May be not needed?
}
JsonObject playersObject = object.get("players").getAsJsonObject();
int online = playersObject.get("online").getAsInt();

View file

@ -27,6 +27,21 @@ public OptionalView(OptionalView view) {
this.all = view.all;
}
public OptionalView(ClientProfile profile, OptionalView old) {
this(profile);
for(OptionalFile oldFile : old.all) {
OptionalFile newFile = findByName(oldFile.name);
if(newFile == null) {
continue;
}
if(old.isEnabled(oldFile)) {
enable(newFile, old.installInfo.get(oldFile).isManual, (file, status) -> {});
} else {
disable(newFile, (file, status) -> {});
}
}
}
@SuppressWarnings("unchecked")
public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) {
Set<T> results = new HashSet<>();
@ -42,6 +57,19 @@ public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) {
return results;
}
public OptionalFile findByName(String name) {
for(OptionalFile file : all) {
if(name.equals(file.name)) {
return file;
}
}
return null;
}
public boolean isEnabled(OptionalFile file) {
return enabled.contains(file);
}
public Set<OptionalAction> getEnabledActions() {
Set<OptionalAction> results = new HashSet<>();
for (OptionalFile e : enabled) {

View file

@ -6,9 +6,9 @@ public final class Version implements Comparable<Version> {
public static final int MAJOR = 5;
public static final int MINOR = 3;
public static final int PATCH = 5;
public static final int PATCH = 6;
public static final int BUILD = 1;
public static final Version.Type RELEASE = Type.STABLE;
public static final Version.Type RELEASE = Type.DEV;
public final int major;
public final int minor;
public final int patch;

View file

@ -64,7 +64,7 @@ pack project(':LauncherAPI')
shadowJar {
duplicatesStrategy = 'EXCLUDE'
classifier = null
archiveClassifier = null
relocate 'io.netty', 'pro.gravit.repackage.io.netty'
configurations = [project.configurations.pack]
exclude 'module-info.class'

View file

@ -1,11 +1,11 @@
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'maven-publish'
id 'signing'
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
}
group = 'pro.gravit.launcher'
version = '5.3.5'
version = '5.3.6-SNAPSHOT'
apply from: 'props.gradle'

@ -1 +1 @@
Subproject commit c0d181172391f9540f1477407daab7499974fa2a
Subproject commit 0fbbc50f875b477078d61de2135b8d3600851ebe