Skip to content

Commit

Permalink
auto generate dirs and config.
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana committed Jan 23, 2025
1 parent 14704cb commit cb2fed0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/com/vulpeus/kyoyu/Kyoyu.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,32 @@ public static boolean isServer() {
}

public static void loadConfig() {
File kyoyuDir;
if (isClient()) {
File schematicsDir = Paths.get("schematics").toFile();
if (schematicsDir.mkdir()) {
LOGGER.info("File not found. generated: {}", schematicsDir);
}
kyoyuDir = Paths.get("schematics/kyoyu").toFile();
} else {
kyoyuDir = Paths.get("kyoyu").toFile();
}
if (kyoyuDir.mkdir()) {
LOGGER.info("File not found. generated: {}", kyoyuDir);
}

File configDir = Paths.get("config").toFile();
if (configDir.mkdir()) {
LOGGER.info("File not found. generated: {}", configDir);
}

try {
Path configFile = Paths.get("config/kyoyu.json");
if (!configFile.toFile().exists()) {
InputStream istream = Kyoyu.class.getResourceAsStream("/assets/kyoyu/kyoyu.json");
if (istream == null) return;
FileUtils.copyInputStreamToFile(istream, configFile.toFile());
LOGGER.info("File not found. generated: {}", configFile);
}
String json = new String(Files.readAllBytes(configFile), StandardCharsets.UTF_8);
CONFIG = KyoyuConfig.fromJson(json);
Expand Down

0 comments on commit cb2fed0

Please sign in to comment.