/* * This file is a part of the SteamWar software. * * Copyright (C) 2026 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ package de.steamwar.techhider; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.entity.Player; public interface AccessPrivilegeProvider { /** * Resolves everything that can change concurrently about this player once. * The result is used for all decisions of one outgoing packet (including all packets of a bundle). */ ForPlayer forPlayer(Player p); boolean isPlayerPrivilegedToPerformAction(Player p); /** * What a single player may access, valid for the processing of one outgoing packet. */ interface ForPlayer { Player getPlayer(); /** * @return true if nothing within this chunk is restricted for this player, so the chunk may be sent unmodified */ boolean canAccessAllDataWithinChunk(int chunkX, int chunkZ); boolean canAccessPosition(int blockX, int blockY, int blockZ); boolean canAccessBlock(int blockX, int blockY, int blockZ, Block block); boolean canAccessBlockState(int blockX, int blockY, int blockZ, BlockState blockState); boolean canAccessEntity(int entityId); /** * @return whether the player may see the entity spawning at this position */ default boolean canAccessEntitySpawn(int entityId, int blockX, int blockY, int blockZ) { return canAccessEntity(entityId) && canAccessPosition(blockX, blockY, blockZ); } boolean canAccessBlockEntity(int blockX, int blockY, int blockZ, BlockEntityType type); /** * @return the block state sent instead of a block this player may not access at this position */ BlockState getObfuscation(int blockX, int blockY, int blockZ); } }