/*
 *   This file is a part of the SteamWar software.
 *
 *   Copyright (C) 2024  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 <https://www.gnu.org/licenses/>.
 */

package de.steamwar.bausystem.region;

import com.sk89q.worldedit.EditSession;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Location;

import javax.annotation.Nullable;
import java.io.File;
import java.util.Optional;
import java.util.UUID;
import java.util.function.BiConsumer;

public interface Region {

    static Region getRegion(Location location) {
        return RegionSystem.INSTANCE.get(location);
    }

    UUID getID();

    RegionType getType();

    FlagStorage getFlags();

    Area getArea();

    Optional<Area> getBuildArea();

    Optional<Area> getTestblockArea();

    Optional<File> getGameModeConfig();

    RegionHistory getHistory();

    interface Area {

        Point getMinPoint(boolean extension);

        Point getMaxPoint(boolean extension);

        Point getCopyPoint();

        boolean inRegion(Location location, boolean extension);

        EditSession copy(boolean extension);

        void reset(@Nullable SchematicNode schematicNode, boolean extension);

        void forEachChunk(BiConsumer<Integer, Integer> executor);

        boolean isChunkOutside(int chunkX, int chunkZ);
    }
}
