Skip to content

Commit 5cd9211

Browse files
Merge pull request #56 from DazedNConfused-/develop
build: prepare for v0.3.0 release [macata #2]
2 parents e9d1732 + f2c35cf commit 5cd9211

File tree

109 files changed

+6991
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+6991
-159
lines changed

.java-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.0.16
1+
11.0.24

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ While not mandatory, if commits are not properly formatted, they may get rejecte
6464
- This shared data directory is located at `/<macata_launcher_folder>/userdir`
6565
- [x] Soundpack management
6666
- [x] Launcher autoupdater
67+
- [x] Mod management
6768

6869
### Planned
6970

70-
- [ ] Mod support (soon)
7171
- [ ] Tileset support (soon)
7272
- [ ] Automatic CDDA binary updates & backups
73+
- [ ] Bright Nights support
7374

7475
### Maybes
7576

pom.xml

Lines changed: 53 additions & 2 deletions
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.2.2</version>
9+
<version>0.3.0</version>
1010

1111
<properties>
1212
<maven.compiler.source>11</maven.compiler.source>
@@ -25,6 +25,15 @@
2525
</activation>
2626

2727
<build>
28+
<testResources>
29+
<testResource>
30+
<directory>${project.basedir}/src/test/resources</directory>
31+
</testResource>
32+
<testResource>
33+
<directory>${project.basedir}/src/main/resources</directory>
34+
</testResource>
35+
</testResources>
36+
2837
<plugins>
2938

3039
<plugin>
@@ -36,7 +45,7 @@
3645
<excludes></excludes>
3746
<reportFormat>plain</reportFormat>
3847
<reuseForks>true</reuseForks>
39-
<forkCount>1C</forkCount>
48+
<forkCount>4C</forkCount>
4049
<forkedProcessExitTimeoutInSeconds>3000</forkedProcessExitTimeoutInSeconds>
4150
<forkedProcessTimeoutInSeconds>0</forkedProcessTimeoutInSeconds>
4251
<parallel>all</parallel>
@@ -71,6 +80,23 @@
7180
<configuration>
7281
<source>11</source>
7382
<target>11</target>
83+
<annotationProcessorPaths>
84+
<path>
85+
<groupId>org.projectlombok</groupId>
86+
<artifactId>lombok</artifactId>
87+
<version>1.18.34</version>
88+
</path>
89+
<path>
90+
<groupId>org.mapstruct</groupId>
91+
<artifactId>mapstruct-processor</artifactId>
92+
<version>1.5.5.Final</version>
93+
</path>
94+
<path>
95+
<groupId>org.projectlombok</groupId>
96+
<artifactId>lombok-mapstruct-binding</artifactId>
97+
<version>0.2.0</version>
98+
</path>
99+
</annotationProcessorPaths>
74100
</configuration>
75101
</plugin>
76102

@@ -257,6 +283,31 @@
257283
<version>2.14.2</version>
258284
</dependency>
259285

286+
<dependency>
287+
<groupId>com.h2database</groupId>
288+
<artifactId>h2</artifactId>
289+
<version>2.2.224</version>
290+
</dependency>
291+
292+
<dependency>
293+
<groupId>org.mapstruct</groupId>
294+
<artifactId>mapstruct</artifactId>
295+
<version>1.5.5.Final</version>
296+
</dependency>
297+
298+
<dependency>
299+
<groupId>org.projectlombok</groupId>
300+
<artifactId>lombok</artifactId>
301+
<version>1.18.34</version>
302+
<scope>provided</scope>
303+
</dependency>
304+
305+
<dependency>
306+
<groupId>org.projectlombok</groupId>
307+
<artifactId>lombok-mapstruct-binding</artifactId>
308+
<version>0.2.0</version>
309+
</dependency>
310+
260311
<dependency>
261312
<groupId>org.junit.jupiter</groupId>
262313
<artifactId>junit-jupiter-api</artifactId>

src/main/java/com/dazednconfused/catalauncher/Application.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ public static void main(final String[] args) {
88
MainWindow.main(args);
99
}
1010

11+
/**
12+
* Returns the folder where the current instance of the {@link Application} is running.
13+
* */
14+
public static String getRootFolder() {
15+
return System.getProperty("user.dir");
16+
}
1117
}

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

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.dazednconfused.catalauncher.backup;
22

3-
import static com.dazednconfused.catalauncher.helper.Constants.CUSTOM_SAVE_PATH;
4-
import static com.dazednconfused.catalauncher.helper.Constants.CUSTOM_TRASHED_SAVE_PATH;
5-
import static com.dazednconfused.catalauncher.helper.Constants.LAUNCHER_ROOT_FOLDER;
6-
import static com.dazednconfused.catalauncher.helper.Constants.SAVE_BACKUP_PATH;
7-
3+
import com.dazednconfused.catalauncher.helper.Paths;
4+
import com.dazednconfused.catalauncher.helper.Zipper;
85
import com.dazednconfused.catalauncher.helper.result.Result;
96

107
import io.vavr.control.Try;
@@ -29,8 +26,8 @@ public class SaveManager {
2926
private static final Logger LOGGER = LoggerFactory.getLogger(SaveManager.class);
3027

3128
/**
32-
* Returns the current {@link com.dazednconfused.catalauncher.helper.Constants#CUSTOM_SAVE_PATH} compression job, wrapped
33-
* inside a {@link Thread} and ready to be executed.
29+
* Returns the current {@link Paths#getCustomSavePath()} compression job, wrapped inside a {@link Thread} and ready to
30+
* be executed.
3431
* */
3532
public static Optional<Thread> backupCurrentSaves(Consumer<Integer> onPercentDoneCallback) {
3633
LOGGER.info("Backup-ing all saves...");
@@ -40,7 +37,7 @@ public static Optional<Thread> backupCurrentSaves(Consumer<Integer> onPercentDon
4037
return Optional.empty();
4138
}
4239

43-
File savesFolder = new File(CUSTOM_SAVE_PATH);
40+
File savesFolder = new File(Paths.getCustomSavePath());
4441
return Optional.of(compressFolderAsJob(
4542
savesFolder,
4643
getSaveBackupFolder().getAbsolutePath() + "/" + generateNameBasedOnCurrentTimestamp() + ".zip",
@@ -54,19 +51,19 @@ public static Optional<Thread> backupCurrentSaves(Consumer<Integer> onPercentDon
5451
public static Optional<Thread> restoreBackup(File backup2beRestored, Consumer<Integer> onPercentDoneCallback) {
5552
LOGGER.info("Restoring backup [{}]...", backup2beRestored);
5653

57-
File trashedSaves = new File(CUSTOM_TRASHED_SAVE_PATH);
54+
File trashedSaves = new File(Paths.getCustomTrashedSavePath());
5855

5956
if (!trashedSaves.exists()) {
6057
LOGGER.debug("Trashed saves' folder [{}] doesn't exist. Generating...", trashedSaves);
6158
Try.of(trashedSaves::mkdirs).onFailure(t -> LOGGER.error("There was an error while creating trashed saves' folder [{}]", trashedSaves, t));
6259
}
6360

64-
File trashedSavePath = new File(CUSTOM_TRASHED_SAVE_PATH + generateNameBasedOnCurrentTimestamp());
61+
File trashedSavePath = new File(Paths.getCustomTrashedSavePath() + generateNameBasedOnCurrentTimestamp());
6562

6663
if (!saveFilesExist()) {
6764
LOGGER.info("No current saves found. Nothing to move to trash folder.");
6865
} else {
69-
File currentSave = new File(CUSTOM_SAVE_PATH);
66+
File currentSave = new File(Paths.getCustomSavePath());
7067

7168
Try.of(() -> Files.move(
7269
currentSave.toPath(),
@@ -76,7 +73,7 @@ public static Optional<Thread> restoreBackup(File backup2beRestored, Consumer<In
7673

7774
return Optional.of(decompressFolderAsJob(
7875
backup2beRestored,
79-
LAUNCHER_ROOT_FOLDER, // we don't decompress into CUSTOM_SAVE_PATH because we end up with ./saves/saves/<actual world saves>
76+
Paths.getLauncherRootFolder(), // we don't decompress into CUSTOM_SAVE_PATH because we end up with ./saves/saves/<actual world saves>
8077
onPercentDoneCallback
8178
));
8279
}
@@ -105,7 +102,7 @@ public static Result<Throwable, File> renameBackup(File toBeRenamed, String newN
105102
}
106103

107104
/**
108-
* Returns all save backups currently found in {@link com.dazednconfused.catalauncher.helper.Constants#SAVE_BACKUP_PATH}.
105+
* Returns all save backups currently found in {@link Paths#getSaveBackupPath()}.
109106
* */
110107
public static List<File> listAllBackups() {
111108
LOGGER.debug("Listing all backups...");
@@ -115,11 +112,11 @@ public static List<File> listAllBackups() {
115112
}
116113

117114
/**
118-
* If save files exist in {@link com.dazednconfused.catalauncher.helper.Constants#CUSTOM_SAVE_PATH}, returns the last
119-
* modified valid save file. Save file is valid if it has a .sav file in it.
115+
* If save files exist in {@link Paths#getCustomSavePath()}, returns the last modified valid save file. Save file is valid
116+
* if it has a .sav file in it.
120117
* */
121118
public static Optional<File> getLastModifiedValidSave() {
122-
File savesFolder = new File(CUSTOM_SAVE_PATH);
119+
File savesFolder = new File(Paths.getCustomSavePath());
123120
if (!saveFilesExist()) {
124121
return Optional.empty();
125122
}
@@ -137,18 +134,17 @@ public static Optional<File> getLastModifiedValidSave() {
137134

138135
}
139136
/**
140-
* Determines whether save files exist in {@link com.dazednconfused.catalauncher.helper.Constants#CUSTOM_SAVE_PATH}.
137+
* Determines whether save files exist in {@link Paths#getCustomSavePath()}.
141138
* */
142139

143140
public static boolean saveFilesExist() {
144-
File savesFolder = new File(CUSTOM_SAVE_PATH);
141+
File savesFolder = new File(Paths.getCustomSavePath());
145142
return savesFolder.exists() && Arrays.stream(Objects.requireNonNull(savesFolder.listFiles())).anyMatch(file -> !file.getName().equals(".DS_Store"));
146143
}
147144

148145
/**
149-
* Gets the latest save {@link File} from {@link com.dazednconfused.catalauncher.helper.Constants#CUSTOM_SAVE_PATH}, wrapped
150-
* inside an {@link Optional}. {@link Optional#empty()} if given path doesn't exist or doesn't have any folders that could
151-
* be assumed to be individual save files.
146+
* Gets the latest save {@link File} from {@link Paths#getCustomSavePath()}, wrapped inside an {@link Optional}. {@link Optional#empty()}
147+
* if given path doesn't exist or doesn't have any folders that could be assumed to be individual save files.
152148
* */
153149
public static Optional<File> getLatestSave() {
154150

@@ -160,10 +156,10 @@ public static Optional<File> getLatestSave() {
160156
}
161157

162158
/**
163-
* Retrieves the {@link com.dazednconfused.catalauncher.helper.Constants#SAVE_BACKUP_PATH} as a {@link File}.
159+
* Retrieves the {@link Paths#getSaveBackupPath()} as a {@link File}.
164160
* */
165161
private static File getSaveBackupFolder() {
166-
File backupPath = new File(SAVE_BACKUP_PATH);
162+
File backupPath = new File(Paths.getSaveBackupPath());
167163
if (!backupPath.exists()) {
168164
LOGGER.debug("Save backup destination folder [{}] not found. Creating...", backupPath);
169165
Try.of(backupPath::mkdirs).onFailure(t -> LOGGER.error("Could not create backup destination folder [{}]", backupPath, t));
@@ -176,14 +172,14 @@ private static File getSaveBackupFolder() {
176172
* Returns the requested compression job wrapped inside a {@link Thread} and ready to be executed.
177173
* */
178174
private static Thread compressFolderAsJob(File sourceDir, String outputFile, Consumer<Integer> onPercentDoneCallback) {
179-
return new Thread(() -> Zipper.compressAndCallback(sourceDir, outputFile, onPercentDoneCallback, 100));
175+
return new Thread(() -> Zipper.compressAndCallback(sourceDir, Path.of(outputFile), onPercentDoneCallback, 100));
180176
}
181177

182178
/**
183179
* Returns the requested decompression job wrapped inside a {@link Thread} and ready to be executed.
184180
* */
185181
private static Thread decompressFolderAsJob(File sourceFile, String destinationPath, Consumer<Integer> onPercentDoneCallback) {
186-
return new Thread(() -> Zipper.decompressAndCallback(sourceFile, destinationPath, onPercentDoneCallback, 100));
182+
return new Thread(() -> Zipper.decompressAndCallback(sourceFile, Path.of(destinationPath), onPercentDoneCallback, 100));
187183
}
188184

189185
/**

src/main/java/com/dazednconfused/catalauncher/configuration/ConfigurationManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.dazednconfused.catalauncher.configuration;
22

3-
import static com.dazednconfused.catalauncher.helper.Constants.LAUNCHER_FILES;
4-
3+
import com.dazednconfused.catalauncher.helper.Paths;
54
import com.fasterxml.jackson.databind.ObjectMapper;
65

76
import io.vavr.control.Try;
@@ -20,7 +19,7 @@ public class ConfigurationManager {
2019

2120
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class);
2221

23-
private static final String CONFIG_FILEPATH = LAUNCHER_FILES + "/configuration.json";
22+
private static final String CONFIG_FILEPATH = Paths.getLauncherFiles() + "/configuration.json";
2423

2524
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
2625

0 commit comments

Comments
 (0)