feat: split timeout options to config file

This commit is contained in:
Helvetica Volubi
2026-03-19 18:39:37 +08:00
parent 3c3a2a6ff4
commit faa3529943
2 changed files with 5 additions and 2 deletions
@@ -39,4 +39,8 @@ public class CommandConfig implements IConfigModule {
"""
Log all process of save-all command to console""")
public static boolean logAllProcess = false;
@ConfigInfo(name = "save_all_command_timeout", directory = {"save_all_command"}, comments = """
Maximum seconds to save before the chunk report it is timeout.""")
public static long saveAllTimeout = 30;
}
@@ -13,7 +13,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public class SaveAllUtil {
private static final long TIMEOUT = 1000 * 30; // 30 seconds
public static final Object lock = new Object();
public static volatile long lastSaveAllTime = 0;
private static volatile Pair<CommandSourceStack, Boolean> currentSaveAll = null;
@@ -76,7 +75,7 @@ public class SaveAllUtil {
public static void checkTimeout() {
Pair<CommandSourceStack, Boolean> currentSaveAll = SaveAllUtil.currentSaveAll;
if (!isSaving()) return;
if (System.currentTimeMillis() - lastSaveAllTime > TIMEOUT) {
if (System.currentTimeMillis() - lastSaveAllTime > CommandConfig.saveAllTimeout) {
currentSaveAll.getFirst().sendFailure(Component.literal("At least one region save data timeout!"));
currentSaveAll.getFirst().sendFailure(Component.literal("Regions need to save expect is " + regionCount + ", but only " + savedRegionCount.get() + " saved!"));
SaveAllUtil.currentSaveAll = null;