Skip to content

Commit

Permalink
Fix type check in LocationAdapter deserialization
Browse files Browse the repository at this point in the history
Changed the deserialization method to correctly check for a JSON primitive instead of a JSON object before splitting the string. This ensures that the deserialization process handles input as expected and prevents potential runtime errors due to incorrect type handling.
  • Loading branch information
NonSwag committed Nov 24, 2024
1 parent 148a62f commit f87b235
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion adapters/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks.compileJava {
}

group = "net.thenextlvl.core"
version = "2.0.0"
version = "2.0.1"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static final class WorldLess implements PaperAdapter<Location> {

@Override
public @Nullable Location deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
if (!element.isJsonObject()) return null;
if (!element.isJsonPrimitive()) return null;
var split = element.getAsString().split(", ");
var x = Double.parseDouble(split[0]);
var y = Double.parseDouble(split[1]);
Expand Down

0 comments on commit f87b235

Please sign in to comment.