mirror of
https://github.com/ceratic/project_vollidioten_mod.git
synced 2026-05-14 00:16:47 +02:00
40 lines
1.5 KiB
Java
40 lines
1.5 KiB
Java
package ceratic.projectvollidioten.config;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
import java.io.*;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
|
|
public class GithubResourcePackConfig {
|
|
public String githubOwner = "your-username";
|
|
public String githubRepo = "your-repo";
|
|
public String resourcePackFileName = "my-pack.zip";
|
|
public int checkIntervalMinutes = 60; // check every hour
|
|
|
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
|
private static final String CONFIG_NAME = "resourcepack.json";
|
|
|
|
public static GithubResourcePackConfig loadOrCreate(Path configDir) {
|
|
Path configFile = configDir.resolve(CONFIG_NAME);
|
|
try {
|
|
if (Files.exists(configFile)) {
|
|
try (Reader reader = Files.newBufferedReader(configFile)) {
|
|
return GSON.fromJson(reader, GithubResourcePackConfig.class);
|
|
}
|
|
} else {
|
|
// Create default config
|
|
GithubResourcePackConfig defaultConfig = new GithubResourcePackConfig();
|
|
Files.createDirectories(configDir);
|
|
try (Writer writer = Files.newBufferedWriter(configFile)) {
|
|
GSON.toJson(defaultConfig, writer);
|
|
}
|
|
return defaultConfig;
|
|
}
|
|
} catch (Exception e) {
|
|
System.err.println("[GithubRP] Failed to load config, using defaults: " + e.getMessage());
|
|
return new GithubResourcePackConfig();
|
|
}
|
|
}
|
|
} |