From 515371053e9cfa66f42bd99a737a39f5e644ea8a Mon Sep 17 00:00:00 2001 From: lkno0705 Date: Tue, 18 May 2021 08:45:42 +0200 Subject: [PATCH 1/2] Fix ressource loading in JsonReader --- src/main/java/config/LootConfig.java | 2 +- src/main/java/utilities/JsonReader.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/config/LootConfig.java b/src/main/java/config/LootConfig.java index fd7b8ee..350a351 100644 --- a/src/main/java/config/LootConfig.java +++ b/src/main/java/config/LootConfig.java @@ -9,5 +9,5 @@ public class LootConfig { public static final int dropCommon = 60; public static final int dropRare = 35; public static final int dropLegendary = 5; - public static final JSONObject itemList = readJson(LootConfig.class.getResource("/items.JSON").getPath()); + public static final JSONObject itemList = readJson("/items.JSON"); } diff --git a/src/main/java/utilities/JsonReader.java b/src/main/java/utilities/JsonReader.java index 65e8731..d9f1a32 100644 --- a/src/main/java/utilities/JsonReader.java +++ b/src/main/java/utilities/JsonReader.java @@ -3,15 +3,20 @@ import org.json.JSONObject; import java.io.*; +import java.nio.charset.StandardCharsets; public class JsonReader { public static JSONObject readJson(String fileName) { + InputStream inputStream = JsonReader.class.getResourceAsStream(fileName); StringBuilder sJson = new StringBuilder(); - try (BufferedReader br = new BufferedReader(new FileReader(new File(fileName)))) { - String str; - while ((str = br.readLine()) != null) { - sJson.append(str).append("\n"); + try { + assert inputStream != null; + try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + String str; + while ((str = br.readLine()) != null) { + sJson.append(str).append("\n"); + } } } catch (IOException e) { e.printStackTrace(); From e1bf09c1e9b01ebf5952dd02de1ac8d2e3e14217 Mon Sep 17 00:00:00 2001 From: Leon Knorr <43034754+lkno0705@users.noreply.github.com> Date: Tue, 18 May 2021 09:49:43 +0200 Subject: [PATCH 2/2] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 96b681d..8b31c32 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,7 +24,7 @@ jobs: id: bump_version uses: christian-draeger/increment-semantic-version@1.0.2 with: - current-version: '2.0.0-alpha1' + current-version: '2.0.1-alpha1' version-fragment: 'bug' - name: Upload Artifacts run: mkdir builds && cp target/*.jar builds/calculationEngine-${{ steps.bump_version.outputs.next-version }}.jar