94 lines
5.2 KiB
Diff
94 lines
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
Date: Fri, 16 Jan 2026 02:34:43 +0800
|
|
Subject: [PATCH] Add config to enable save-all command
|
|
|
|
|
|
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
|
index dbd713226f45b8b9992aa349ddbbc1c69ed47c04..cbfb4bdde0f32ec3996e5baa7e7ed5749e2d12a0 100644
|
|
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
|
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
|
@@ -364,6 +364,8 @@ public final class RegionizedServer {
|
|
// tick player ping sample
|
|
this.tickPlayerSample();
|
|
|
|
+ fun.bm.lophine.utils.SaveAllUtil.checkTimeout(); // Lophine - save-all fix
|
|
+
|
|
// tick worlds
|
|
for (final ServerLevel world : this.worlds) {
|
|
this.globalTick(world, tickCount);
|
|
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
|
|
index b03d47746879e57ad106bc1b736358d9a5ea1a9d..25951b9858a8d141e2cde7c442ac830e6921e716 100644
|
|
--- a/io/papermc/paper/threadedregions/TickRegions.java
|
|
+++ b/io/papermc/paper/threadedregions/TickRegions.java
|
|
@@ -190,6 +190,8 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
|
public final ThreadedRegionizer.ThreadedRegion<TickRegionData, TickRegionSectionData> region;
|
|
public final ServerLevel world;
|
|
|
|
+ public long lastSavedTime = 0; // Lophine - save-all fix
|
|
+
|
|
// generic regionised data
|
|
private final Reference2ReferenceOpenHashMap<RegionizedData<?>, Object> regionizedData = new Reference2ReferenceOpenHashMap<>();
|
|
|
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
|
index 9800ae1d3c49800b0c7342d43d696109b5b72cf4..f9a8c79640ed6ca381e4482eaeab6b23db59419f 100644
|
|
--- a/net/minecraft/commands/Commands.java
|
|
+++ b/net/minecraft/commands/Commands.java
|
|
@@ -299,7 +299,11 @@ public class Commands {
|
|
PardonCommand.register(this.dispatcher);
|
|
PardonIpCommand.register(this.dispatcher);
|
|
//PerfCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
|
- //SaveAllCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
|
+ // Lophine start - Add a config to enable save all command
|
|
+ if (fun.bm.lophine.config.modules.experiment.CommandConfig.saveAll) {
|
|
+ SaveAllCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
|
+ }
|
|
+ // Lophine end - Add a config to enable save all command
|
|
SaveOffCommand.register(this.dispatcher);
|
|
SaveOnCommand.register(this.dispatcher);
|
|
SetPlayerIdleTimeoutCommand.register(this.dispatcher);
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 56bd710443b794320f97f6e775247df9b09c4c0e..c27779b5ca53aad8c87830b2e2647dbfcdcb762b 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1649,6 +1649,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// Folia start - region threading
|
|
public void tickServer(final long startTime, final long scheduledEnd, final long targetBuffer,
|
|
final io.papermc.paper.threadedregions.TickRegions.TickRegionData region) {
|
|
+ // Lophine start - save-all fix
|
|
+ if (fun.bm.lophine.utils.SaveAllUtil.isSaving()) {
|
|
+ fun.bm.lophine.utils.SaveAllUtil.postRegionSave(region);
|
|
+ }
|
|
+ // Lophine end - save-all fix
|
|
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
|
|
// Folia end - region threading
|
|
org.spigotmc.WatchdogThread.tick(); // Spigot
|
|
diff --git a/net/minecraft/server/commands/SaveAllCommand.java b/net/minecraft/server/commands/SaveAllCommand.java
|
|
index 299991905c24a7018f8ac60d0c16e56fa43cd710..39c1b67e457c26a7e8d87be21658bbe6e802440c 100644
|
|
--- a/net/minecraft/server/commands/SaveAllCommand.java
|
|
+++ b/net/minecraft/server/commands/SaveAllCommand.java
|
|
@@ -22,14 +22,21 @@ public class SaveAllCommand {
|
|
}
|
|
|
|
private static int saveAll(final CommandSourceStack source, final boolean flush) throws CommandSyntaxException {
|
|
- source.sendSuccess(() -> Component.translatable("commands.save.saving"), false);
|
|
+ // Lophine start - save all
|
|
+ fun.bm.lophine.utils.SaveAllUtil.preSaveAll(source, flush);
|
|
+/* source.sendSuccess(() -> Component.translatable("commands.save.saving"), false);
|
|
MinecraftServer server = source.getServer();
|
|
boolean success = server.saveEverything(true, flush, true);
|
|
if (!success) {
|
|
throw ERROR_FAILED.create();
|
|
}
|
|
|
|
- source.sendSuccess(() -> Component.translatable("commands.save.success"), true);
|
|
+ source.sendSuccess(() -> Component.translatable("commands.save.success"), true);*/
|
|
return Command.SINGLE_SUCCESS;
|
|
}
|
|
+
|
|
+ public static SimpleCommandExceptionType getErrorFailed() {
|
|
+ return ERROR_FAILED;
|
|
+ }
|
|
+ // Lophine end - save all
|
|
}
|