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

XFEServerManager

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

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

import com.xfestudio.xfeservermanager.api.util.ApiChecks;
import com.xfestudio.xfeservermanager.api.command.CommandNames;
import java.util.Set;

public record CommandConstraints(
        SelectorConstraint selector,
        ItemConstraint item,
        Set<String> allowedFunctionIds,
        boolean denyUnlistedFunctions
) {
    public CommandConstraints {
        if (selector == null) {
            throw new NullPointerException("selector");
        }
        if (item == null) {
            throw new NullPointerException("item");
        }
        allowedFunctionIds = ApiChecks.immutableLowercaseSet(allowedFunctionIds, "allowedFunctionIds").stream()
                .map(CommandNames::canonicalize)
                .collect(java.util.stream.Collectors.toUnmodifiableSet());
    }

    public static CommandConstraints unrestricted() {
        return new CommandConstraints(
                SelectorConstraint.unrestricted(), ItemConstraint.unrestricted(), Set.of(), false);
    }
}