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 java.time.Instant;
import java.util.Objects;
import java.util.Set;
import com.xfestudio.xfeservermanager.api.world.WorldChangeKind;

/** Neutral lookup filters. Empty sets/strings mean unrestricted. */
public record RollbackQuery(
        Instant fromInclusive,
        Instant toExclusive,
        Set<String> actorIds,
        Set<String> dimensionIds,
        Set<String> resourceIds,
        Set<WorldChangeKind> kinds,
        Integer centerX,
        Integer centerZ,
        Integer radiusBlocks
) {
    public RollbackQuery {
        Objects.requireNonNull(fromInclusive, "fromInclusive");
        Objects.requireNonNull(toExclusive, "toExclusive");
        if (!fromInclusive.isBefore(toExclusive)) throw new IllegalArgumentException("invalid time range");
        actorIds = Set.copyOf(actorIds);
        dimensionIds = Set.copyOf(dimensionIds);
        resourceIds = Set.copyOf(resourceIds);
        kinds = Set.copyOf(kinds);
        boolean anySpatial = centerX != null || centerZ != null || radiusBlocks != null;
        boolean allSpatial = centerX != null && centerZ != null && radiusBlocks != null;
        if (anySpatial != allSpatial || (radiusBlocks != null && radiusBlocks < 0)) {
            throw new IllegalArgumentException("center and non-negative radius must be supplied together");
        }
    }

    /** Source-compatible constructor retained for integrations compiled against the first v2 core draft. */
    public RollbackQuery(Instant fromInclusive, Instant toExclusive, Set<String> actorIds,
                         Set<String> dimensionIds, Set<String> resourceIds,
                         Integer centerX, Integer centerZ, Integer radiusBlocks) {
        this(fromInclusive, toExclusive, actorIds, dimensionIds, resourceIds, Set.of(),
                centerX, centerZ, radiusBlocks);
    }
}