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);
}
}
}
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);
}
}
}