mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 01:15:52 +01:00
Fixed only the issue about "BOOLEAN" occurring when importing resources. (#2028)
* Only Fix 'Exception in thread 'main' com.google.gson.JsonSyntaxException: java.io.IOException: Invalid DynamicFloat definition - BOOLEAN' problem. * Update ResourceLoader.java * Modify code indentation and optimization. * Update JsonUtils.java * Update JsonUtils.java * Update DynamicFloat.java --------- Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,10 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.val;
|
||||
|
||||
import static com.google.gson.stream.JsonToken.BEGIN_ARRAY;
|
||||
import static com.google.gson.stream.JsonToken.BEGIN_OBJECT;
|
||||
import static emu.grasscutter.utils.JsonUtils.gson;
|
||||
|
||||
public class JsonAdapters {
|
||||
static class DynamicFloatAdapter extends TypeAdapter<DynamicFloat> {
|
||||
@Override
|
||||
@@ -28,6 +32,8 @@ public class JsonAdapters {
|
||||
return new DynamicFloat(reader.nextString());
|
||||
case NUMBER:
|
||||
return new DynamicFloat((float) reader.nextDouble());
|
||||
case BOOLEAN:
|
||||
return new DynamicFloat(reader.nextBoolean());
|
||||
case BEGIN_ARRAY:
|
||||
reader.beginArray();
|
||||
val opStack = new ArrayList<DynamicFloat.StackOp>();
|
||||
@@ -35,6 +41,7 @@ public class JsonAdapters {
|
||||
opStack.add(switch (reader.peek()) {
|
||||
case STRING -> new DynamicFloat.StackOp(reader.nextString());
|
||||
case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble());
|
||||
case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean());
|
||||
default -> throw new IOException("Invalid DynamicFloat definition - " + reader.peek().name());
|
||||
});
|
||||
}
|
||||
@@ -122,7 +129,7 @@ public class JsonAdapters {
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
Class<T> enumClass = (Class<T>) type.getRawType();
|
||||
if (!enumClass.isEnum()) return null;
|
||||
|
||||
|
||||
// Make mappings of (string) names to enum constants
|
||||
val map = new HashMap<String, T>();
|
||||
val enumConstants = enumClass.getEnumConstants();
|
||||
|
||||
Reference in New Issue
Block a user