Skip to content

Commit ea45db1

Browse files
Merge pull request #88 from DazedNConfused-/develop
build: prepare for v0.3.3 release [macata #86]
2 parents e86e5c8 + 46f1ade commit ea45db1

File tree

16 files changed

+276
-234
lines changed

16 files changed

+276
-234
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/test/resources/** linguist-vendored

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
path: ~/.m2/repository
2121
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2222
restore-keys: |
23-
${{ runner.os }}-maven-
23+
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2424
- name: Build with Maven
2525
run: mvn package

.github/workflows/sonarcloud.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
path: ~/.m2/repository
2929
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
3030
restore-keys: |
31-
${{ runner.os }}-maven-
31+
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
3232
- name: Cache SonarCloud packages
3333
uses: actions/cache@v3
3434
with:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ While not mandatory, if commits are not properly formatted, they may get rejecte
5656
### Current
5757

5858
- [x] Launch game & launch from last played world
59+
- [x] Game process monitor
5960
- [x] Save management & backups
6061
- Custom save directory is located at `/<macata_launcher_folder>/saves`
6162
- Custom backups directory is located at `/<macata_launcher_folder>/backups`
@@ -65,12 +66,12 @@ While not mandatory, if commits are not properly formatted, they may get rejecte
6566
- [x] Soundpack management
6667
- [x] Launcher autoupdater
6768
- [x] Mod management
69+
- [x] Bright Nights support
6870

6971
### Planned
7072

7173
- [ ] Tileset support (soon)
7274
- [ ] Automatic CDDA binary updates & backups
73-
- [ ] Bright Nights support
7475

7576
### Maybes
7677

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.dazednconfused</groupId>
88
<artifactId>macatalauncher</artifactId>
9-
<version>0.3.2</version>
9+
<version>0.3.3</version>
1010

1111
<properties>
1212
<maven.compiler.source>11</maven.compiler.source>

src/main/java/com/dazednconfused/catalauncher/backup/SaveManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static Optional<Thread> backupCurrentSaves(Consumer<Integer> onPercentDon
3737
return Optional.empty();
3838
}
3939

40-
File savesFolder = new File(Paths.getCustomSavePath());
40+
File savesFolder = Paths.getCustomSavePath().toFile();
4141
return Optional.of(compressFolderAsJob(
4242
savesFolder,
4343
getSaveBackupFolder().getAbsolutePath() + "/" + generateNameBasedOnCurrentTimestamp() + ".zip",
@@ -51,20 +51,20 @@ public static Optional<Thread> backupCurrentSaves(Consumer<Integer> onPercentDon
5151
public static Optional<Thread> restoreBackup(File backup2beRestored, Consumer<Integer> onPercentDoneCallback) {
5252
LOGGER.info("Restoring backup [{}]...", backup2beRestored);
5353

54-
File trashedSaves = new File(Paths.getCustomTrashedSavePath());
54+
File trashedSaves = Paths.getCustomTrashedSavePath().toFile();
5555

5656
if (!trashedSaves.exists()) {
5757
LOGGER.debug("Trashed saves' folder [{}] doesn't exist. Generating...", trashedSaves);
5858
Try.of(trashedSaves::mkdirs).onFailure(t -> LOGGER.error("There was an error while creating trashed saves' folder [{}]", trashedSaves, t));
5959
}
6060

61-
File trashedSavePath = new File(Paths.getCustomTrashedSavePath(), generateNameBasedOnCurrentTimestamp());
61+
File trashedSavePath = Paths.getCustomTrashedSavePath().resolve(generateNameBasedOnCurrentTimestamp()).toFile();
6262

6363
if (!saveFilesExist()) {
6464
LOGGER.info("No current saves found. Nothing to move to trash folder.");
6565
} else {
6666
LOGGER.debug("Trashing existent saves into [{}]...", trashedSavePath);
67-
File currentSave = new File(Paths.getCustomSavePath());
67+
File currentSave = Paths.getCustomSavePath().toFile();
6868

6969
Try.of(() -> Files.move(
7070
currentSave.toPath(),
@@ -74,7 +74,7 @@ public static Optional<Thread> restoreBackup(File backup2beRestored, Consumer<In
7474

7575
return Optional.of(decompressFolderAsJob(
7676
backup2beRestored,
77-
Path.of(Paths.getCustomSavePath()).getParent().toString(), // we don't decompress into CUSTOM_SAVE_PATH because we end up with ./saves/saves/<actual world saves>
77+
Paths.getCustomSavePath().getParent().toString(), // we don't decompress into CUSTOM_SAVE_PATH because we end up with ./saves/saves/<actual world saves>
7878
onPercentDoneCallback
7979
));
8080
}
@@ -117,7 +117,7 @@ public static List<File> listAllBackups() {
117117
* if it has a {@code .sav} file in it.
118118
* */
119119
private static Optional<File> getLastModifiedValidSave() {
120-
File savesFolder = new File(Paths.getCustomSavePath());
120+
File savesFolder = Paths.getCustomSavePath().toFile();
121121
if (!saveFilesExist()) {
122122
return Optional.empty();
123123
}
@@ -139,7 +139,7 @@ private static Optional<File> getLastModifiedValidSave() {
139139
* Determines whether save files exist in {@link Paths#getCustomSavePath()}.
140140
* */
141141
public static boolean saveFilesExist() {
142-
File savesFolder = new File(Paths.getCustomSavePath());
142+
File savesFolder = Paths.getCustomSavePath().toFile();
143143
return savesFolder.exists() && Arrays.stream(Objects.requireNonNull(savesFolder.listFiles())).anyMatch(file -> !file.getName().equals(".DS_Store"));
144144
}
145145

@@ -160,7 +160,7 @@ public static Optional<File> getLatestSave() {
160160
* Retrieves the {@link Paths#getSaveBackupPath()} as a {@link File}.
161161
* */
162162
private static File getSaveBackupFolder() {
163-
File backupPath = new File(Paths.getSaveBackupPath());
163+
File backupPath = Paths.getSaveBackupPath().toFile();
164164
if (!backupPath.exists()) {
165165
LOGGER.debug("Save backup destination folder [{}] not found. Creating...", backupPath);
166166
Try.of(backupPath::mkdirs).onFailure(t -> LOGGER.error("Could not create backup destination folder [{}]", backupPath, t));

src/main/java/com/dazednconfused/catalauncher/database/h2/H2Database.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class H2Database implements DisposableDatabase {
2424

2525
private static final Logger LOGGER = LoggerFactory.getLogger(H2Database.class);
2626

27-
private static final String DATABASE_DIRECTORY = Paths.getDatabaseDirectory();
27+
private static final String DATABASE_DIRECTORY = Paths.getDatabaseDirectory().toString();
2828
private static final String JDBC_URL_TEMPLATE = "jdbc:h2:" + DATABASE_DIRECTORY + "/%s;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=TRUE";
2929

3030
private static final String USER = null;

src/main/java/com/dazednconfused/catalauncher/gui/ConsoleLogReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public ConsoleLogReader() throws IOException {
3232
this.textArea.setEditable(false);
3333

3434
// populate current console with existing logs ---
35-
File file = new File(Paths.getLogFilePath());
35+
File file = Paths.getLogFilePath().toFile();
3636
BufferedReader reader = new BufferedReader(new FileReader(file));
3737
String line;
3838
while ((line = reader.readLine()) != null) {

src/main/java/com/dazednconfused/catalauncher/gui/MainWindow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public class MainWindow {
6767

6868
private static final Logger LOGGER = LoggerFactory.getLogger(MainWindow.class);
6969

70-
private static final String[] CUSTOM_SAVE_DIR_ARGS = { "--savedir", Paths.getCustomSavePath() };
71-
private static final String[] CUSTOM_USER_DIR_ARGS = { "--userdir", Paths.getCustomUserDir() };
70+
private static final String[] CUSTOM_SAVE_DIR_ARGS = { "--savedir", Paths.getCustomSavePath() + "/" };
71+
private static final String[] CUSTOM_USER_DIR_ARGS = { "--userdir", Paths.getCustomUserDir() + "/" };
7272

7373
/**
7474
* The array of all {@link Runnable}s to be executed on invocation of {@link #refreshGuiElements()}.

src/main/java/com/dazednconfused/catalauncher/helper/Paths.java

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.dazednconfused.catalauncher.Application;
44

5+
import java.nio.file.Path;
6+
57
/**
68
* A set of common filesystem {@link Paths} used throughout the application.
79
* */
@@ -11,8 +13,8 @@ public class Paths {
1113
* Retrieves the {@link Application}'s root folder - that is, the filesystem path where the binary is currently executing.
1214
* Most defined {@link Paths} depend on this one.
1315
* */
14-
public static String getLauncherRootFolder() {
15-
return Application.getRootFolder();
16+
public static Path getLauncherRootFolder() {
17+
return Path.of(Application.getRootFolder());
1618
}
1719

1820
/**
@@ -22,8 +24,8 @@ public static String getLauncherRootFolder() {
2224
* getLauncherRootFolder() + "/.macatalauncher"
2325
* }</pre>
2426
* */
25-
public static String getLauncherFiles() {
26-
return getLauncherRootFolder() + "/.macatalauncher";
27+
public static Path getLauncherFiles() {
28+
return getLauncherRootFolder().resolve(".macatalauncher");
2729
}
2830

2931
/**
@@ -33,19 +35,19 @@ public static String getLauncherFiles() {
3335
* getLauncherRootFolder() + "/.macatalauncher/logs/main.log"
3436
* }</pre>
3537
* */
36-
public static String getLogFilePath() {
37-
return getLauncherFiles() + "/logs/main.log";
38+
public static Path getLogFilePath() {
39+
return getLauncherFiles().resolve("logs/main.log");
3840
}
3941

4042
/**
4143
* Retrieves the {@link Application}'s custom savefile path.
4244
*
4345
* <pre> {@code
44-
* getLauncherRootFolder() + "/saves/"
46+
* getLauncherRootFolder() + "/saves"
4547
* }</pre>
4648
* */
47-
public static String getCustomSavePath() {
48-
return getLauncherRootFolder() + "/saves/";
49+
public static Path getCustomSavePath() {
50+
return getLauncherRootFolder().resolve("saves");
4951
}
5052

5153
/**
@@ -55,19 +57,19 @@ public static String getCustomSavePath() {
5557
* getLauncherRootFolder() + "/trashed"
5658
* }</pre>
5759
* */
58-
public static String getCustomTrashedPath() {
59-
return getLauncherRootFolder() + "/trashed";
60+
public static Path getCustomTrashedPath() {
61+
return getLauncherRootFolder().resolve("trashed");
6062
}
6163

6264
/**
6365
* Retrieves the {@link Application}'s custom path for trashed savefiles.
6466
*
6567
* <pre> {@code
66-
* getLauncherRootFolder() + "/trashed/saves/"
68+
* getLauncherRootFolder() + "/trashed/saves"
6769
* }</pre>
6870
* */
69-
public static String getCustomTrashedSavePath() {
70-
return getCustomTrashedPath() + "/saves/";
71+
public static Path getCustomTrashedSavePath() {
72+
return getCustomTrashedPath().resolve("saves");
7173
}
7274

7375
/**
@@ -77,64 +79,63 @@ public static String getCustomTrashedSavePath() {
7779
* getLauncherRootFolder() + "/backups"
7880
* }</pre>
7981
* */
80-
public static String getSaveBackupPath() {
81-
return getLauncherRootFolder() + "/backups";
82+
public static Path getSaveBackupPath() {
83+
return getLauncherRootFolder().resolve("backups");
8284
}
8385

8486
/**
8587
* Retrieves the {@link Application}'s custom {@code userdir/} directory.
8688
*
8789
* <pre> {@code
88-
* getLauncherRootFolder() + "/userdir/"
90+
* getLauncherRootFolder() + "/userdir"
8991
* }</pre>
9092
* */
91-
public static String getCustomUserDir() {
92-
return getLauncherRootFolder() + "/userdir/";
93+
public static Path getCustomUserDir() {
94+
return getLauncherRootFolder().resolve("userdir");
9395
}
9496

9597
/**
9698
* Retrieves the {@link Application}'s custom {@code userdir/sound} directory.
9799
*
98100
* <pre> {@code
99-
* getLauncherRootFolder() + "/userdir/sound/"
101+
* getLauncherRootFolder() + "/userdir/sound"
100102
* }</pre>
101103
* */
102-
public static String getCustomSoundpacksDir() {
103-
return getCustomUserDir() + "sound/";
104+
public static Path getCustomSoundpacksDir() {
105+
return getCustomUserDir().resolve("sound");
104106
}
105107

106108
/**
107109
* Retrieves the {@link Application}'s custom {@code userdir/mods} directory.
108110
*
109111
* <pre> {@code
110-
* getLauncherRootFolder() + "/userdir/mods/"
112+
* getLauncherRootFolder() + "/userdir/mods"
111113
* }</pre>
112114
* */
113-
public static String getCustomModsDir() {
114-
return getCustomUserDir() + "mods/";
115+
public static Path getCustomModsDir() {
116+
return getCustomUserDir().resolve("mods");
115117
}
116118

117119
/**
118120
* Retrieves the {@link Application}'s custom path for trashed mods.
119121
*
120122
* <pre> {@code
121-
* getLauncherRootFolder() + "/trashed/saves/"
123+
* getLauncherRootFolder() + "/trashed/mods"
122124
* }</pre>
123125
* */
124-
public static String getCustomTrashedModsPath() {
125-
return getCustomTrashedPath() + "/mods/";
126+
public static Path getCustomTrashedModsPath() {
127+
return getCustomTrashedPath().resolve("mods");
126128
}
127129

128-
129130
/**
130131
* Retrieves the {@link Application}'s database(s) directory.
131132
*
132133
* <pre> {@code
133134
* getLauncherRootFolder() + "/.macatalauncher/db"
134135
* }</pre>
135136
* */
136-
public static String getDatabaseDirectory() {
137-
return getLauncherFiles() + "/db";
137+
public static Path getDatabaseDirectory() {
138+
return getLauncherFiles().resolve("db");
138139
}
139140

140141
// java resources

0 commit comments

Comments
 (0)