Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public StoryPackMetadata readMetadata(InputStream inputStream) throws IOExceptio
if (!entry.isDirectory() && entry.getName().equalsIgnoreCase("story.json")) {
hasStoryJsonEntry = true;

JsonParser parser = new JsonParser();
JsonObject root = parser.parse(new InputStreamReader(zis)).getAsJsonObject();
JsonObject root = JsonParser.parseReader(new InputStreamReader(zis)).getAsJsonObject();

// Read metadata
metadata.setVersion(root.get("version").getAsShort());
Expand Down Expand Up @@ -104,8 +103,7 @@ public StoryPack read(InputStream inputStream) throws IOException {
while((entry = zis.getNextEntry()) != null) {
// Story descriptor file: story.json
if (!entry.isDirectory() && entry.getName().equalsIgnoreCase("story.json")) {
JsonParser parser = new JsonParser();
JsonObject root = parser.parse(new InputStreamReader(zis)).getAsJsonObject();
JsonObject root = JsonParser.parseReader(new InputStreamReader(zis)).getAsJsonObject();

// Read metadata
version = root.get("version").getAsShort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public DatabaseMetadataService(boolean isAgent) {
String databasePath = System.getProperty(OFFICIAL_DB_PROP, System.getProperty("user.home") + OFFICIAL_DB_JSON_PATH);
JsonObject officialRoot;
try (FileReader databaseReader = new FileReader(databasePath)) {
officialRoot = new JsonParser().parse(databaseReader).getAsJsonObject(); // throws IllegalStateException
officialRoot = JsonParser.parseReader(databaseReader).getAsJsonObject(); // throws IllegalStateException
}
// Support newer file format which has an additional wrapper: { "code": "0.0", "response": { ...
final JsonObject packsRoot = (officialRoot.keySet().contains("response")) ? officialRoot.getAsJsonObject("response") : officialRoot;
Expand Down Expand Up @@ -124,7 +124,7 @@ public synchronized Optional<DatabasePackMetadata> getUnofficialMetadata(String
String databasePath = System.getProperty(UNOFFICIAL_DB_PROP, System.getProperty("user.home") + UNOFFICIAL_DB_JSON_PATH);
JsonObject unofficialRoot;
try (FileReader databaseReader = new FileReader(databasePath)) {
unofficialRoot = new JsonParser().parse(databaseReader).getAsJsonObject();
unofficialRoot = JsonParser.parseReader(databaseReader).getAsJsonObject();
}
if (unofficialRoot.has(uuid)) {
JsonObject packMetadata = unofficialRoot.getAsJsonObject(uuid);
Expand Down Expand Up @@ -178,11 +178,10 @@ private void fetchOfficialDatabase() {
if (tokenStatusCode == 200) {
// OK, read response body
InputStream inputStream = tokenConnection.getInputStream();
JsonParser parser = new JsonParser();
String token;
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
// Extract token from response body
JsonObject tokenJson = parser.parse(new JsonReader(bufferedReader)).getAsJsonObject();
JsonObject tokenJson = JsonParser.parseReader(new JsonReader(bufferedReader)).getAsJsonObject();
token = tokenJson.getAsJsonObject("response").getAsJsonObject("token").get("server").getAsString();
}
LOGGER.fine("Guest token: " + token);
Expand All @@ -202,7 +201,7 @@ private void fetchOfficialDatabase() {
JsonObject response;
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
// Extract metadata database from response body
JsonObject json = parser.parse(new JsonReader(bufferedReader)).getAsJsonObject();
JsonObject json = JsonParser.parseReader(new JsonReader(bufferedReader)).getAsJsonObject();
response = json.get("response").getAsJsonObject();
}

Expand Down Expand Up @@ -231,7 +230,7 @@ public void refreshUnofficialMetadata(DatabasePackMetadata meta) {
String databasePath = System.getProperty(UNOFFICIAL_DB_PROP, System.getProperty("user.home") + UNOFFICIAL_DB_JSON_PATH);
JsonObject unofficialRoot;
try (FileReader databaseReader = new FileReader(databasePath)) {
unofficialRoot = new JsonParser().parse(databaseReader).getAsJsonObject();
unofficialRoot = JsonParser.parseReader(databaseReader).getAsJsonObject();
}

// Replace or add pack metadata
Expand Down Expand Up @@ -264,7 +263,7 @@ public void cleanUnofficialDatabase() {
String databasePath = System.getProperty(UNOFFICIAL_DB_PROP, System.getProperty("user.home") + UNOFFICIAL_DB_JSON_PATH);
JsonObject unofficialRoot;
try (FileReader databaseReader = new FileReader(databasePath)) {
unofficialRoot = new JsonParser().parse(databaseReader).getAsJsonObject();
unofficialRoot = JsonParser.parseReader(databaseReader).getAsJsonObject();
}
List<String> toClean = new ArrayList<>();
for (String uuid : unofficialRoot.keySet()) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
Loading