/* * 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 . */ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.sql.SchematicNode; import lombok.NonNull; import org.bukkit.Location; import javax.annotation.Nullable; import java.io.File; import java.util.Optional; public interface Region { static Region getRegion(Location location) { return RegionSystem.INSTANCE.get(location); } RegionType getType(); & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); & Flag.Value> boolean setFlag(@NonNull Flag flag, T value); & Flag.Value> Optional getFlag(@NonNull Flag flag); default & Flag.Value> boolean isFlag(@NonNull Flag flag, T value) { if (hasFlag(flag).isReadable()) { Optional optional = getFlag(flag); return optional.isPresent() && optional.get() == value; } return false; } Point getMinPoint(); Point getMaxPoint(); boolean inRegion(Location location); Inner getBuildArea(); Inner getTestblockArea(); // TODO: Add forEachChunk and getChunkOutsidePredicate Optional getGameModeConfig(); boolean backup(boolean automatic); Optional copy(); void reset(); void remember(EditSession editSession); boolean undo(); boolean redo(); interface Inner { Inner EMPTY = new Inner() { private static final Point ZERO = new Point(0, 0, 0); @Override public Point getMinPoint(boolean extension) { return ZERO; } @Override public Point getMaxPoint(boolean extension) { return ZERO; } @Override public boolean inRegion(Location location, boolean extension) { return false; } @Override public Optional copy(boolean extension) { return Optional.empty(); } @Override public void reset(@Nullable SchematicNode schematicNode, boolean extension) { } }; default boolean isEmpty() { return this == EMPTY; } default boolean isPresent() { return this != EMPTY; } Point getMinPoint(boolean extension); Point getMaxPoint(boolean extension); boolean inRegion(Location location, boolean extension); Optional copy(boolean extension); void reset(@Nullable SchematicNode schematicNode, boolean extension); } }