Added option for persistent resources like configuration files

This commit is contained in:
2023-11-11 22:45:23 +01:00
parent c6ecbe7548
commit 541eb1e733
2 changed files with 9 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ import java.util.logging.Logger;
* Predefined resources which are extracted on Runtime
*/
public enum Resource {
CONFIG("config.yml"),
CONFIG("config.yml", true),
HUB_MAP("maps/hub"),
LOBBY_MAP("maps/lobby"),
@@ -20,18 +20,22 @@ public enum Resource {
private final Path path;
private final String name;
Resource(String name) {
Resource(String name, boolean keepOutdated) {
this.name = name;
this.path = Path.of("resources/" + name);
try {
Logger.getLogger("ressource").info("extracting resource " + name + " ... ");
ResourceUtils.extractResource(name);
ResourceUtils.extractResource(name, keepOutdated);
} catch (URISyntaxException | IOException e) {
throw new RuntimeException(e);
}
}
Resource(String name) {
this(name, false);
}
public Path getPath() {
return path;
}