Skip to content

Commit 690a500

Browse files
authored
Merge pull request #11 from anweisen/development
Release v1.3.8
2 parents 473a799 + 61767ce commit 690a500

File tree

11 files changed

+52
-14
lines changed

11 files changed

+52
-14
lines changed

.idea/encodings.xml

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bukkit-utils/bukkit-utils.iml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>SPIGOT</platformType>
8+
</autoDetectTypes>
9+
</configuration>
10+
</facet>
11+
</component>
12+
</module>

bukkit-utils/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>net.anweisen.utilities</groupId>
99
<artifactId>root</artifactId>
10-
<version>1.3.7</version>
10+
<version>1.3.8</version>
1111
</parent>
1212

1313
<artifactId>bukkit-utils</artifactId>

common-utils/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>net.anweisen.utilities</groupId>
99
<artifactId>root</artifactId>
10-
<version>1.3.7</version>
10+
<version>1.3.8</version>
1111
</parent>
1212

1313
<artifactId>common-utils</artifactId>

common-utils/src/main/java/net/anweisen/utilities/common/config/document/GsonDocument.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package net.anweisen.utilities.common.config.document;
22

33
import com.google.gson.*;
4+
import com.google.gson.internal.LazilyParsedNumber;
45
import com.google.gson.internal.bind.TypeAdapters;
6+
import com.google.gson.stream.JsonReader;
7+
import com.google.gson.stream.JsonToken;
8+
import com.google.gson.stream.JsonWriter;
59
import net.anweisen.utilities.common.collection.pair.Pair;
610
import net.anweisen.utilities.common.config.Document;
711
import net.anweisen.utilities.common.config.document.gson.*;
@@ -40,6 +44,28 @@ public class GsonDocument extends AbstractDocument {
4044
GSON_PRETTY_PRINT = builder.setPrettyPrinting().create();
4145
}
4246

47+
// Not implemented in some versions of gson
48+
TypeAdapter<Number> NUMBER = new TypeAdapter<Number>() {
49+
@Override
50+
public void write(JsonWriter jsonWriter, Number number) throws IOException {
51+
TypeAdapters.STRING.write(jsonWriter, String.valueOf(number));
52+
}
53+
public Number read(JsonReader in) throws IOException {
54+
JsonToken jsonToken = in.peek();
55+
switch (jsonToken) {
56+
case NUMBER:
57+
case STRING:
58+
return new LazilyParsedNumber(in.nextString());
59+
case BOOLEAN:
60+
default:
61+
throw new JsonSyntaxException("Expecting number, got: " + jsonToken);
62+
case NULL:
63+
in.nextNull();
64+
return null;
65+
}
66+
}
67+
};
68+
4369
public static final Gson GSON, GSON_PRETTY_PRINT;
4470

4571
private static boolean cleanupEmptyObjects = false;
@@ -395,7 +421,7 @@ private void setElement(@Nonnull String path, @Nullable Object value) {
395421
JsonElement jsonValue =
396422
value instanceof JsonElement ? (JsonElement) value
397423
: value == null ? JsonNull.INSTANCE
398-
: value instanceof Number ? TypeAdapters.NUMBER.toJsonTree((Number) value)
424+
: value instanceof Number ? NUMBER.toJsonTree((Number) value)
399425
: value instanceof Boolean ? TypeAdapters.BOOLEAN.toJsonTree((boolean) value)
400426
: value instanceof Character ? TypeAdapters.CHARACTER.toJsonTree((char) value)
401427
: GSON.toJsonTree(value);

database-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>net.anweisen.utilities</groupId>
99
<artifactId>root</artifactId>
10-
<version>1.3.7</version>
10+
<version>1.3.8</version>
1111
</parent>
1212

1313
<artifactId>database-api</artifactId>

database-mongodb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>net.anweisen.utilities</groupId>
99
<artifactId>root</artifactId>
10-
<version>1.3.7</version>
10+
<version>1.3.8</version>
1111
</parent>
1212

1313
<artifactId>database-mongodb</artifactId>

database-sql/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>net.anweisen.utilities</groupId>
99
<artifactId>root</artifactId>
10-
<version>1.3.7</version>
10+
<version>1.3.8</version>
1111
</parent>
1212

1313
<artifactId>database-sql</artifactId>

jda-manager/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>net.anweisen.utilities</groupId>
99
<artifactId>root</artifactId>
10-
<version>1.3.7</version>
10+
<version>1.3.8</version>
1111
</parent>
1212

1313
<artifactId>jda-manager</artifactId>

0 commit comments

Comments
 (0)