Skip to content

Commit

Permalink
Add config option to start with deletion paused
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikoo committed Feb 11, 2024
1 parent 8f44591 commit 1fe07fe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/github/jikoo/regionerator/Regionerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void onEnable() {

getServer().getPluginManager().registerEvents(new WorldListener(this), this);

if (config.startPaused()) {
this.setPaused(true);
}

// Don't load features if there are no worlds configured
if (config.enabledWorlds().isEmpty()) {
getLogger().severe("No worlds are enabled. There's nothing to do!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,8 @@ public int getCacheMaxSize() {
return cacheMaxSize;
}

public boolean startPaused() {
return getBoolean("deletion.start-paused");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@

package com.github.jikoo.regionerator.util.yaml;

import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;

import java.util.List;

final class ConfigUpdater {

private static final int CURRENT_CONFIG_VERSION = 1;
private static final int CURRENT_CONFIG_VERSION = 2;

static void doUpdates(@NotNull Config config) {
switch (config.raw().getInt("config-version", 0)) {
case 0:
updateConfig0To1(config);
case 1:
updateConfig1To2(config);
case CURRENT_CONFIG_VERSION:
return;
default:
Expand All @@ -32,7 +35,12 @@ static void doUpdates(@NotNull Config config) {
}
}

static void updateConfig0To1(@NotNull Config config) {
private static void updateConfig1To2(Config config) {
config.set("deletion.start-paused", false);
config.set("config-version", 2);
}

private static void updateConfig0To1(@NotNull Config config) {
// Flagging section
config.set("flagging.seconds-per-flag", config.getInt("seconds-per-flag"));
config.set("seconds-per-flag", null);
Expand Down

0 comments on commit 1fe07fe

Please sign in to comment.