XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEServerManager

【Java】我的世界XFE服务器管理器

公开
关注 0 Fork 0 Star 0
UTF-8
package com.xfestudio.xfeservermanager.core.rollback;

import com.xfestudio.xfeservermanager.api.world.WorldChangeRecord;
import com.xfestudio.xfeservermanager.api.world.WorldStatePayload;

/** All methods are expected to be invoked by a platform adapter on the Minecraft server thread. */
public interface WorldAccessPort {
    boolean isChunkLoaded(String dimensionId, int chunkX, int chunkZ);

    /** Null represents the absence of the object, such as air or a removed entity. */
    WorldStatePayload currentState(WorldChangeRecord change);

    Compatibility compatibility(WorldChangeRecord change, WorldStatePayload target);

    /** Returns false if a bounded temporary load cannot be acquired. */
    boolean acquireChunk(String dimensionId, int chunkX, int chunkZ);

    void releaseChunk(String dimensionId, int chunkX, int chunkZ);

    /**
     * Applies one state transition. Platform implementations must emit a new
     * ROLLBACK/REDO journal transaction before reporting success.
     */
    void apply(WorldChangeRecord change, WorldStatePayload target) throws WorldMutationException;

    record Compatibility(boolean compatible, String detail) {
        public Compatibility {
            detail = detail == null ? "" : detail;
        }

        public static Compatibility supported() {
            return new Compatibility(true, "");
        }

        public static Compatibility unsupported(String detail) {
            return new Compatibility(false, detail);
        }
    }
}