mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-21 04:49:51 +08:00
Run the chunk deleter in Fabric (#1641)
This commit is contained in:
parent
86bf3a3419
commit
3a3bf3de2c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user