diff --git a/.github/workflows/wasm.yml b/.github/workflows/build.yml similarity index 53% rename from .github/workflows/wasm.yml rename to .github/workflows/build.yml index ac4c1fa..e736302 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,18 @@ -name: wasm +name: build on: push: branches: - master + pull_request: + branches: + - master jobs: - build: + rust: runs-on: ubuntu-latest + env: + RUSTFLAGS: -D warnings steps: - name: Checkout uses: actions/checkout@v2 @@ -17,6 +22,12 @@ jobs: toolchain: nightly-2021-04-25 override: true profile: minimal + - name: Test + run: | + cd rust/ddsaveedit + cargo check + cargo test + cargo test --release - name: Install Node uses: actions/setup-node@v1 with: @@ -31,9 +42,33 @@ jobs: npm run build cd ../../../ - name: Deploy + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: crazy-max/ghaction-github-pages@v2 with: target_branch: gh-pages build_dir: rust/ddsaveedit/wasm-ddsaveedit/dist # The folder the action should deploy. env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + java: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Java + uses: actions/setup-java@v1 + with: + java-version: '8' + java-package: jdk + - name: Test + run: | + ./gradlew test + - name: Build distribution zip + run: | + ./gradlew dist + - name: Upload distribution zip + uses: actions/upload-artifact@v1 + with: + name: DDSaveEditor + path: build/dist/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 42ffd28..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: test - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - test-rust: - runs-on: ubuntu-latest - env: - RUSTFLAGS: -D warnings - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly-2021-04-25 - override: true - profile: minimal - - name: Test - run: | - cd rust/ddsaveedit - cargo check - cargo test - cargo test --release - test-java: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install Java - uses: actions/setup-java@v1 - with: - java-version: '8' - java-package: jdk - - name: Test - run: | - ./gradlew test diff --git a/build.gradle b/build.gradle index 9ffc097..a64e176 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,11 @@ plugins { - id 'de.fuerstenau.buildconfig' version '1.1.8' + id 'java' + id 'application' + id 'com.github.gmazzo.buildconfig' version '3.0.0' } - -apply plugin: 'java' -apply plugin: 'application' -apply plugin: 'eclipse' - repositories { mavenCentral() - jcenter() } sourceCompatibility = 1.8 @@ -17,28 +13,25 @@ targetCompatibility = 1.8 dependencies { - testCompile 'org.testng:testng:6.8.8' - compile 'com.google.code.gson:gson:2.8.5' - compile 'com.google.api-client:google-api-client:1.23.0' - compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0' - compile 'com.google.apis:google-api-services-sheets:v4-rev516-1.23.0' - compile 'com.fifesoft:rsyntaxtextarea:3.0.3' - compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.6' + testImplementation 'org.testng:testng:7.4.0' + implementation 'com.google.code.gson:gson:2.8.6' + implementation 'com.google.api-client:google-api-client:1.31.2' + implementation 'com.google.oauth-client:google-oauth-client-jetty:1.31.2' + implementation 'com.google.apis:google-api-services-sheets:v4-rev612-1.25.0' + implementation 'com.fifesoft:rsyntaxtextarea:3.1.2' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.12.3' } buildConfig { - appName = project.name - version = project.version - - buildConfigField 'String', 'DISPLAY_NAME', "$displayname" - buildConfigField 'String', 'GITHUB_URL', "$githuburl" - buildConfigField 'String', 'UPDATE_URL', "$releasesurl" - buildConfigField 'String', 'JAR_NAME', "${jarname}.jar" - buildConfigField 'String', 'DATA_DIR', "$datadir" + packageName("de.robojumper.ddsavereader") + buildConfigField('String', 'NAME', "\"${project.name}\"") + buildConfigField('String', 'VERSION', "\"${project.version}\"") - clsName = 'BuildConfig' - packageName = project.group - charset = 'UTF-8' + buildConfigField('String', 'DISPLAY_NAME', "\"$displayname\"") + buildConfigField('String', 'GITHUB_URL', "\"$githuburl\"") + buildConfigField('String', 'UPDATE_URL', "\"$releasesurl\"") + buildConfigField('String', 'JAR_NAME', "\"${jarname}.jar\"") + buildConfigField('String', 'DATA_DIR', "\"$datadir\"") } test { @@ -61,9 +54,10 @@ task fatJar(type: Jar) { 'Implementation-Version': project.version, 'Main-Class': mainClassName } + setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) archiveBaseName = "$jarname" archiveFileName = "${jarname}.jar" - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar } @@ -84,6 +78,7 @@ task dist(type: Zip, dependsOn: fatJar) { include "**/*" into "docs" } - destinationDir = file("${buildDir}/dist") - baseName = "${jarname}" + + destinationDirectory = file("${buildDir}/dist") + archiveBaseName = "${jarname}" } diff --git a/gradle.properties b/gradle.properties index 469debf..bcf5b53 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ displayname=Darkest Dungeon Save Editor -version=v0.0.69 +version=v0.0.70 githuburl=https://github.com/robojumper/DarkestDungeonSaveEditor releasesurl=https://api.github.com/repos/robojumper/DarkestDungeonSaveEditor/releases/latest jarname=DDSaveEditor diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2b..f371643 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/rust/ddsaveedit/ddsavelib/src/file/mod.rs b/rust/ddsaveedit/ddsavelib/src/file/mod.rs index 20f82cc..e6bd262 100644 --- a/rust/ddsaveedit/ddsavelib/src/file/mod.rs +++ b/rust/ddsaveedit/ddsavelib/src/file/mod.rs @@ -421,6 +421,7 @@ fn hardcoded_type(parents: &'_ [impl AsRef], name: impl AsRef) -> Opti [IntVector, "result_event_history"], [IntVector, "dead_hero_entries"], [IntVector, "additional_mash_disabled_infestation_monster_class_ids"], + [IntVector, "mash", "valid_additional_mash_entry_indexes"], [IntVector, "party", "heroes"], [IntVector, "skill_cooldown_keys"], [IntVector, "skill_cooldown_values"], diff --git a/src/main/java/de/robojumper/ddsavereader/Dson2Json.java b/src/main/java/de/robojumper/ddsavereader/Dson2Json.java index 39c490e..dc7de55 100644 --- a/src/main/java/de/robojumper/ddsavereader/Dson2Json.java +++ b/src/main/java/de/robojumper/ddsavereader/Dson2Json.java @@ -8,7 +8,7 @@ import java.nio.file.Files; import java.nio.file.Paths; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.file.DsonFile; import de.robojumper.ddsavereader.file.DsonTypes; import de.robojumper.ddsavereader.file.DsonFile.UnhashBehavior; diff --git a/src/main/java/de/robojumper/ddsavereader/Json2Dson.java b/src/main/java/de/robojumper/ddsavereader/Json2Dson.java index fc25755..2dcdfef 100644 --- a/src/main/java/de/robojumper/ddsavereader/Json2Dson.java +++ b/src/main/java/de/robojumper/ddsavereader/Json2Dson.java @@ -5,7 +5,7 @@ import java.nio.file.Paths; import java.text.ParseException; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.file.DsonWriter; public class Json2Dson { diff --git a/src/main/java/de/robojumper/ddsavereader/Main.java b/src/main/java/de/robojumper/ddsavereader/Main.java index 5e1de13..681510b 100644 --- a/src/main/java/de/robojumper/ddsavereader/Main.java +++ b/src/main/java/de/robojumper/ddsavereader/Main.java @@ -1,6 +1,6 @@ package de.robojumper.ddsavereader; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.spreadsheets.SpreadsheetsService; import de.robojumper.ddsavereader.ui.MainWindow; import de.robojumper.ddsavereader.util.ReadNames; diff --git a/src/main/java/de/robojumper/ddsavereader/file/DsonFile.java b/src/main/java/de/robojumper/ddsavereader/file/DsonFile.java index f4b5642..f5547d3 100644 --- a/src/main/java/de/robojumper/ddsavereader/file/DsonFile.java +++ b/src/main/java/de/robojumper/ddsavereader/file/DsonFile.java @@ -99,7 +99,7 @@ public DsonFile(byte[] File, UnhashBehavior behavior) throws ParseException { Stack parentIdxStack = new Stack(); // base_root starts at -1 int runningObjIdx = -1; - parentIdxStack.push(new Integer(runningObjIdx)); + parentIdxStack.push(Integer.valueOf(runningObjIdx)); rootFields = new ArrayList(); // Is this the correct way to do it? // WARNING: Apparently, META2 is not necessarily ordered the same way as DATA @@ -180,7 +180,7 @@ public DsonFile(byte[] File, UnhashBehavior behavior) throws ParseException { // If we have an object, push it to the stack if (field.type == FieldType.TYPE_OBJECT) { fieldStack.push(field); - parentIdxStack.push(new Integer(runningObjIdx)); + parentIdxStack.push(Integer.valueOf(runningObjIdx)); } // Then check if the object on top of the stack has all its children. If so, pop diff --git a/src/main/java/de/robojumper/ddsavereader/file/DsonTypes.java b/src/main/java/de/robojumper/ddsavereader/file/DsonTypes.java index 6e7495f..6ee512a 100644 --- a/src/main/java/de/robojumper/ddsavereader/file/DsonTypes.java +++ b/src/main/java/de/robojumper/ddsavereader/file/DsonTypes.java @@ -37,6 +37,7 @@ public enum FieldType { { "result_event_history" }, // town_event.json { "dead_hero_entries" }, // town_event.json { "additional_mash_disabled_infestation_monster_class_ids" }, // campaign_mash.json + { "mash", "valid_additional_mash_entry_indexes" }, // raid.json { "party", "heroes" }, // raid.json { "skill_cooldown_keys" }, // raid.json { "skill_cooldown_values" }, diff --git a/src/main/java/de/robojumper/ddsavereader/model/CampaignLog.java b/src/main/java/de/robojumper/ddsavereader/model/CampaignLog.java index 9cd31c6..da8ec49 100644 --- a/src/main/java/de/robojumper/ddsavereader/model/CampaignLog.java +++ b/src/main/java/de/robojumper/ddsavereader/model/CampaignLog.java @@ -32,8 +32,7 @@ public void write(JsonWriter out, Chapter value) throws IOException { @Override public Chapter read(JsonReader in) throws IOException { - JsonParser p = new JsonParser(); - JsonObject chapterRoot = p.parse(in).getAsJsonObject(); + JsonObject chapterRoot = JsonParser.parseReader(in).getAsJsonObject(); Chapter c = new Chapter(); c.chapterIndex = chapterRoot.getAsJsonPrimitive("chapterIndex").getAsInt(); Gson g = SaveState.makeGson(); @@ -189,8 +188,7 @@ public List getCells() { @Override public void update(String json) { - JsonParser parser = new JsonParser(); - JsonObject o = parser.parse(json).getAsJsonObject(); + JsonObject o = JsonParser.parseString(json).getAsJsonObject(); o = o.getAsJsonObject("base_root"); Gson g = SaveState.makeGson(); diff --git a/src/main/java/de/robojumper/ddsavereader/model/Estate.java b/src/main/java/de/robojumper/ddsavereader/model/Estate.java index 636563c..d2297b8 100644 --- a/src/main/java/de/robojumper/ddsavereader/model/Estate.java +++ b/src/main/java/de/robojumper/ddsavereader/model/Estate.java @@ -61,8 +61,7 @@ class ItemEntry { @Override public void update(String json) { - JsonParser parser = new JsonParser(); - JsonObject o = parser.parse(json).getAsJsonObject(); + JsonObject o = JsonParser.parseString(json).getAsJsonObject(); o = o.getAsJsonObject("base_root"); Gson g = SaveState.makeGson(); diff --git a/src/main/java/de/robojumper/ddsavereader/model/Roster.java b/src/main/java/de/robojumper/ddsavereader/model/Roster.java index 38674c8..01001e7 100644 --- a/src/main/java/de/robojumper/ddsavereader/model/Roster.java +++ b/src/main/java/de/robojumper/ddsavereader/model/Roster.java @@ -30,7 +30,7 @@ public Map read(JsonReader in) throws IOException { Map map = new HashMap<>(); in.beginObject(); while (in.peek() != JsonToken.END_OBJECT) { - int id = new Integer(in.nextName()); + int id = Integer.valueOf(in.nextName()); in.beginObject(); if (!Objects.equals(in.nextName(), "hero_file_data")) @@ -94,8 +94,7 @@ class RosterData { @Override public void update(String json) { - JsonParser parser = new JsonParser(); - JsonObject o = parser.parse(json).getAsJsonObject(); + JsonObject o = JsonParser.parseString(json).getAsJsonObject(); o = o.getAsJsonObject("base_root"); Gson g = SaveState.makeGson(); diff --git a/src/main/java/de/robojumper/ddsavereader/model/Town.java b/src/main/java/de/robojumper/ddsavereader/model/Town.java index 7cf8018..bceca4e 100644 --- a/src/main/java/de/robojumper/ddsavereader/model/Town.java +++ b/src/main/java/de/robojumper/ddsavereader/model/Town.java @@ -24,8 +24,7 @@ public static class BuildingActivitiesTypeAdapter extends TypeAdapter read(JsonReader in) throws IOException { Map map = new LinkedTreeMap<>(); - JsonParser p = new JsonParser(); - JsonObject o = p.parse(in).getAsJsonObject(); + JsonObject o = JsonParser.parseReader(in).getAsJsonObject(); for (Entry e : o.entrySet()) { String activityName = e.getKey(); for (Entry slot : e.getValue().getAsJsonObject().entrySet()) { @@ -78,8 +77,7 @@ class District { @Override public void update(String json) { - JsonParser parser = new JsonParser(); - JsonObject o = parser.parse(json).getAsJsonObject(); + JsonObject o = JsonParser.parseString(json).getAsJsonObject(); o = o.getAsJsonObject("base_root"); Gson g = SaveState.makeGson(); diff --git a/src/main/java/de/robojumper/ddsavereader/spreadsheets/SpreadsheetsService.java b/src/main/java/de/robojumper/ddsavereader/spreadsheets/SpreadsheetsService.java index 179b311..338109e 100644 --- a/src/main/java/de/robojumper/ddsavereader/spreadsheets/SpreadsheetsService.java +++ b/src/main/java/de/robojumper/ddsavereader/spreadsheets/SpreadsheetsService.java @@ -31,7 +31,7 @@ import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.util.store.FileDataStoreFactory; import com.google.api.services.sheets.v4.Sheets; import com.google.api.services.sheets.v4.SheetsScopes; @@ -40,7 +40,7 @@ import de.robojumper.ddsavereader.model.CampaignLog.BaseRTTI; import de.robojumper.ddsavereader.model.CampaignLog.Chapter; import de.robojumper.ddsavereader.util.Helpers; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.file.DsonTypes; import de.robojumper.ddsavereader.model.Hero; import de.robojumper.ddsavereader.model.SaveState; @@ -49,7 +49,7 @@ public class SpreadsheetsService { private static final String APPLICATION_NAME = "robojumper-" + BuildConfig.NAME + "/" + BuildConfig.VERSION; - private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance(); private static final List SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS); private static final String CLIENT_SECRET_DIR = "/client_secret.json"; diff --git a/src/main/java/de/robojumper/ddsavereader/ui/DataPathsDialog.java b/src/main/java/de/robojumper/ddsavereader/ui/DataPathsDialog.java index e4d379a..a59bad8 100644 --- a/src/main/java/de/robojumper/ddsavereader/ui/DataPathsDialog.java +++ b/src/main/java/de/robojumper/ddsavereader/ui/DataPathsDialog.java @@ -102,7 +102,7 @@ public void changedUpdate(DocumentEvent e) { JButton chooseGamePathButton = new JButton("Browse..."); chooseGamePathButton.addActionListener(e -> { - MainWindow.directoryChooser("", s -> this.gameDir = s); + MainWindow.directoryChooser(state.getGameDir(), s -> this.gameDir = s); gameDataPathBox.setText(this.gameDir); }); gameDataPathPanel.add(chooseGamePathButton); @@ -122,7 +122,7 @@ public void changedUpdate(DocumentEvent e) { JButton chooseWorkshopPathButton = new JButton("Browse..."); chooseWorkshopPathButton.addActionListener(e -> { - MainWindow.directoryChooser("", s -> this.modsDir = s); + MainWindow.directoryChooser(state.getModsDir(), s -> this.modsDir = s); workshopPathBox.setText(this.modsDir); }); workshopPathPanel.add(chooseWorkshopPathButton); diff --git a/src/main/java/de/robojumper/ddsavereader/ui/MainWindow.java b/src/main/java/de/robojumper/ddsavereader/ui/MainWindow.java index 7fcc08e..74ad27f 100644 --- a/src/main/java/de/robojumper/ddsavereader/ui/MainWindow.java +++ b/src/main/java/de/robojumper/ddsavereader/ui/MainWindow.java @@ -51,7 +51,7 @@ import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.spreadsheets.SpreadsheetsService; import de.robojumper.ddsavereader.spreadsheets.SpreadsheetsService.SheetUpdater; import de.robojumper.ddsavereader.ui.State.SaveFile; @@ -181,7 +181,7 @@ public void windowClosing(WindowEvent e) { mntmSpreadsheets = new JMenuItem("Spreadsheets"); mntmSpreadsheets.setEnabled(false); mntmSpreadsheets.addActionListener(e -> { - if (state.getSaveStatus() == Status.OK) { + if (state.getSaveStatus() != Status.ERROR) { SheetUpdater sheetUpdater; try { final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); @@ -323,7 +323,7 @@ public void run() { JButton chooseSavePathButton = new JButton("Browse..."); chooseSavePathButton.addActionListener(e -> { if (confirmLoseChanges()) { - directoryChooser("", s -> state.setSaveDir(s)); + directoryChooser(state.getSaveDir(), s -> state.setSaveDir(s)); updateSaveDir(); updateFiles(); } @@ -332,7 +332,7 @@ public void run() { makeBackupButton = new JButton("Make Backup..."); makeBackupButton.setEnabled(false); makeBackupButton.addActionListener(e -> { - if (state.getSaveStatus() == Status.OK) { + if (state.getSaveStatus() != Status.ERROR) { String result = JOptionPane.showInputDialog(frame, "Choose backup name", new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date())); if (result == null) { @@ -359,7 +359,7 @@ public void run() { restoreBackupButton = new JButton("Load Backup..."); restoreBackupButton.addActionListener(e -> { - if (state.getSaveStatus() == Status.OK && state.hasAnyBackups() && confirmLoseChanges()) { + if (state.getSaveStatus() != Status.ERROR && state.hasAnyBackups() && confirmLoseChanges()) { String[] backups = state.getBackupNames().toArray(new String[0]); Object result = JOptionPane.showInputDialog(frame, "Choose backup", "Restore", JOptionPane.OK_CANCEL_OPTION, null, backups, backups[0]); @@ -438,6 +438,7 @@ public void run() { protected static final void directoryChooser(String def, Consumer onSuccess) { JFileChooser chooser = new JFileChooser(); + chooser.setCurrentDirectory(new File(def)); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.putClientProperty("JFileChooser.appBundleIsTraversable", "always"); int result = chooser.showOpenDialog(null); @@ -449,13 +450,13 @@ protected static final void directoryChooser(String def, Consumer onSucc private void updateSaveDir() { savePathBox.setText(state.getSaveDir()); saveFileStatus.setIcon(state.getSaveStatus().icon); - reloadButton.setEnabled(state.getSaveStatus() == Status.OK); - mntmSpreadsheets.setEnabled(state.getSaveStatus() == Status.OK); + reloadButton.setEnabled(state.getSaveStatus() != Status.ERROR); + mntmSpreadsheets.setEnabled(state.getSaveStatus() != Status.ERROR); updateBackupButtons(); } private void updateBackupButtons() { - makeBackupButton.setEnabled(state.getSaveStatus() == Status.OK); + makeBackupButton.setEnabled(state.getSaveStatus() != Status.ERROR); restoreBackupButton.setEnabled(state.hasAnyBackups()); } diff --git a/src/main/java/de/robojumper/ddsavereader/ui/State.java b/src/main/java/de/robojumper/ddsavereader/ui/State.java index a7c65c6..ee6d921 100644 --- a/src/main/java/de/robojumper/ddsavereader/ui/State.java +++ b/src/main/java/de/robojumper/ddsavereader/ui/State.java @@ -32,7 +32,7 @@ import javax.swing.Icon; import javax.swing.SwingWorker; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.file.DsonFile; import de.robojumper.ddsavereader.file.DsonFile.UnhashBehavior; import de.robojumper.ddsavereader.file.DsonWriter; @@ -158,10 +158,10 @@ public String getLastSheetID() { public void setSaveDir(String dir) { if (!Objects.equals(dir, saveDir)) { this.saveDir = dir; - if (new File(saveDir).exists() && saveDir.matches(".*profile_[0-9]*/?")) { + if (new File(saveDir).exists()) { profileString = Paths.get(saveDir).toFile().getName(); new File(BACKUP_DIR, profileString).mkdirs(); - saveStatus = Status.OK; + saveStatus = saveDir.matches(".*profile_[0-9]*/?") ? Status.OK : Status.WARNING; loadFiles(); } else { saveStatus = Status.ERROR; diff --git a/src/main/java/de/robojumper/ddsavereader/updatechecker/UpdateChecker.java b/src/main/java/de/robojumper/ddsavereader/updatechecker/UpdateChecker.java index b59211f..3fc6d81 100644 --- a/src/main/java/de/robojumper/ddsavereader/updatechecker/UpdateChecker.java +++ b/src/main/java/de/robojumper/ddsavereader/updatechecker/UpdateChecker.java @@ -13,7 +13,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import de.robojumper.ddsavereader.util.Helpers; public class UpdateChecker { @@ -48,8 +48,7 @@ public static Release getLatestRelease() throws IOException { Files.write(CACHED_LAST_RELEASE.toPath(), content.getBytes(StandardCharsets.UTF_8)); } - JsonParser parser = new JsonParser(); - JsonElement rootObject = parser.parse(content); + JsonElement rootObject = JsonParser.parseString(content); return new Release(rootObject.getAsJsonObject().get("tag_name").getAsString(), rootObject.getAsJsonObject().get("html_url").getAsString()); diff --git a/src/main/java/de/robojumper/ddsavereader/util/Helpers.java b/src/main/java/de/robojumper/ddsavereader/util/Helpers.java index 773c259..5599d4a 100644 --- a/src/main/java/de/robojumper/ddsavereader/util/Helpers.java +++ b/src/main/java/de/robojumper/ddsavereader/util/Helpers.java @@ -1,6 +1,6 @@ package de.robojumper.ddsavereader.util; -import de.fuerstenau.buildconfig.BuildConfig; +import de.robojumper.ddsavereader.BuildConfig; import java.io.File; import java.io.IOException; import java.nio.file.Files; diff --git a/src/main/java/de/robojumper/ddsavereader/util/ReadNames.java b/src/main/java/de/robojumper/ddsavereader/util/ReadNames.java index be8d7f4..90f579e 100644 --- a/src/main/java/de/robojumper/ddsavereader/util/ReadNames.java +++ b/src/main/java/de/robojumper/ddsavereader/util/ReadNames.java @@ -68,8 +68,7 @@ public void parseFile(Path filePath, byte[] file, Set names) { @Override public void parseFile(Path filePath, byte[] file, Set names) { String JsonString = new String(file); - JsonParser parser = new JsonParser(); - JsonObject rootObject = parser.parse(JsonString).getAsJsonObject(); + JsonObject rootObject = JsonParser.parseString(JsonString).getAsJsonObject(); JsonArray arrArray = rootObject.getAsJsonArray("skills"); if (arrArray != null) { for (int i = 0; i < arrArray.size(); i++) { @@ -116,9 +115,8 @@ public void parseFile(Path filePath, byte[] file, Set names) { @Override public void parseFile(Path filePath, byte[] file, Set names) { addBaseName(filePath, names); - String JsonString = new String(file); - JsonParser parser = new JsonParser(); - JsonObject rootObject = parser.parse(JsonString).getAsJsonObject(); + String jsonString = new String(file); + JsonObject rootObject = JsonParser.parseString(jsonString).getAsJsonObject(); JsonObject dataObject = rootObject.getAsJsonObject("data"); if (dataObject != null) { JsonArray activitiesArray = dataObject.getAsJsonArray("activities"); @@ -312,9 +310,8 @@ static void addBaseName(Path filePath, Set Set) { // assuming a JSON file where the root object has an array of objects each with a string variable // add that ID string static void addSimpleJSONArrayEntryIDs(byte[] data, String arrayName, String idString, Set Set) { - String JsonString = new String(data); - JsonParser parser = new JsonParser(); - JsonObject rootObject = parser.parse(JsonString).getAsJsonObject(); + String jsonString = new String(data); + JsonObject rootObject = JsonParser.parseString(jsonString).getAsJsonObject(); JsonArray arrArray = rootObject.getAsJsonArray(arrayName); if (arrArray != null) { for (int i = 0; i < arrArray.size(); i++) { diff --git a/src/test/java/de/robojumper/ddsavereader/file/ConverterTests.java b/src/test/java/de/robojumper/ddsavereader/file/ConverterTests.java index 40a5007..27bf6ee 100644 --- a/src/test/java/de/robojumper/ddsavereader/file/ConverterTests.java +++ b/src/test/java/de/robojumper/ddsavereader/file/ConverterTests.java @@ -126,6 +126,7 @@ public void testOtherFiles() throws ParseException, IOException { testCorrectConversion("quirk_monster_class_ids"); testCorrectConversion("dead_hero_entries"); testCorrectConversion("networkFiles"); + testCorrectConversion("valid_additional_mash_entry_indexes"); } private List getResourceFiles(String path) throws IOException { diff --git a/src/test/resources/valid_additional_mash_entry_indexes/persist.raid.json b/src/test/resources/valid_additional_mash_entry_indexes/persist.raid.json new file mode 100644 index 0000000..fd9351d Binary files /dev/null and b/src/test/resources/valid_additional_mash_entry_indexes/persist.raid.json differ