Run the chunk deleter in Fabric (#1641)

This commit is contained in:
Octavia Togami 2021-01-09 14:38:07 -08:00 committed by GitHub
parent 86bf3a3419
commit 3a3bf3de2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.fabric.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory;
@ -69,6 +70,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.fabric.FabricAdapter.adaptPlayer;
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
/**
* The Fabric implementation of WorldEdit.
@ -113,6 +115,7 @@ public void onInitialize() {
ServerTickEvents.END_SERVER_TICK.register(ThreadSafeCache.getInstance());
CommandRegistrationCallback.EVENT.register(this::registerCommands);
ServerLifecycleEvents.SERVER_STARTING.register(this::onStartingServer);
ServerLifecycleEvents.SERVER_STARTED.register(this::onStartServer);
ServerLifecycleEvents.SERVER_STOPPING.register(this::onStopServer);
AttackBlockCallback.EVENT.register(this::onLeftClickBlock);
@ -196,6 +199,13 @@ private void setupRegistries(MinecraftServer server) {
}
}
private void onStartingServer(MinecraftServer minecraftServer) {
final Path delChunks = workingDir.resolve(DELCHUNKS_FILE_NAME);
if (Files.exists(delChunks)) {
ChunkDeleter.runFromFile(delChunks, true);
}
}
private void onStartServer(MinecraftServer minecraftServer) {
FabricAdapter.setServer(minecraftServer);
setupPlatform(minecraftServer);