Skip to content

Commit

Permalink
add config to allow backups when nobody is online
Browse files Browse the repository at this point in the history
closes #27
  • Loading branch information
MelanX committed May 23, 2024
1 parent 036d5c3 commit d5d4666
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/de/melanx/simplebackups/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onServerTick(TickEvent.LevelTickEvent event) {
//noinspection ConstantConditions
if (event.phase == TickEvent.Phase.END && !event.level.isClientSide
&& event.level.getGameTime() % 20 == 0 && event.level == event.level.getServer().overworld()) {
if (!event.level.getServer().getPlayerList().getPlayers().isEmpty() || this.doBackup) {
if (!event.level.getServer().getPlayerList().getPlayers().isEmpty() || this.doBackup || CommonConfig.doNoPlayerBackups()) {
this.doBackup = false;

boolean done = BackupThread.tryCreateBackup(event.level.getServer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CommonConfig {
private static ForgeConfigSpec.BooleanValue sendMessages;
private static ForgeConfigSpec.ConfigValue<String> maxDiskSize;
private static ForgeConfigSpec.ConfigValue<String> outputPath;
private static ForgeConfigSpec.BooleanValue noPlayerBackups;

private static ForgeConfigSpec.BooleanValue mc2discord;

Expand All @@ -51,6 +52,8 @@ public static void init(ForgeConfigSpec.Builder builder) {
.define("maxDiskSize", "25 GB");
outputPath = builder.comment("Used to define the output path.")
.define("outputPath", "simplebackups");
noPlayerBackups = builder.comment("Create backups, even if nobody is online")
.define("noPlayerBackups", false);

builder.push("mod_compat");
mc2discord = builder.comment("Should backup notifications be sent to Discord by using mc2discord? (needs to be installed)")
Expand Down Expand Up @@ -97,6 +100,10 @@ public static Path getOutputPath() {
}
}

public static boolean doNoPlayerBackups() {
return noPlayerBackups.get();
}

public static BackupType backupType() {
return backupType.get();
}
Expand Down

0 comments on commit d5d4666

Please sign in to comment.