001package net.tnemc.plugincore.core.compatibility;
002/*
003 * The New Plugin Core
004 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU Affero General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU Affero General Public License for more details.
015 *
016 * You should have received a copy of the GNU Affero General Public License
017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018 */
019
020import org.jetbrains.annotations.NotNull;
021
022import java.util.List;
023
024/**
025 * ChunkProvider
026 *
027 * @author creatorfromhell
028 * @since 1.1.0.1
029 */
030public interface ChunkProvider {
031
032  /**
033   * This method is used to get the chunk's x coordinate.
034   *
035   * @return The chunk's x coordinate.
036   */
037  int x();
038
039  /**
040   * This method is used to get the chunk's y coordinate.
041   *
042   * @return The chunk's y coordinate.
043   */
044  default int y() {
045    return 0;
046  }
047
048  /**
049   * This method is responsible for returning a value of type int. The specific logic and calculations
050   * performed to determine this value are not documented.
051   *
052   * @return The integer value calculated by the method.
053   */
054  int z();
055
056  /**
057   * Checks if the ChunkProvider represents a slime chunk.
058   *
059   * @return True if the ChunkProvider is a slime chunk, false otherwise.
060   */
061  boolean isSlime();
062
063  /**
064   * Checks if the specified biome is contained within the chunk provider.
065   *
066   * @param biome The biome to check for.
067   * @return True if the specified biome is contained, false otherwise.
068   */
069  boolean containsBiome(final @NotNull String biome);
070
071  /**
072   * Checks if the provided list of biomes contains any of the specified biomes.
073   *
074   * @param biomes The list of biomes to check for.
075   * @return True if any of the specified biomes are contained in the list, false otherwise.
076   */
077  default boolean containsBiomes(final @NotNull List<String> biomes) {
078
079    for(final String biome : biomes) {
080      if(!containsBiome(biome)) {
081        return false;
082      }
083    }
084    return true;
085  }
086
087  /**
088   * Checks if the provided structure is contained.
089   *
090   * @param structure The structure to check if contained.
091   * @return True if the structure is contained, false otherwise.
092   */
093  boolean containsStructure(final @NotNull String structure);
094
095  /**
096   * Checks if the provided list of structures contains any structures.
097   *
098   * @param structures The list of structures to check for.
099   * @return True if any of the structures are contained in the list, false otherwise.
100   */
101  default boolean containsStructures(final @NotNull List<String> structures) {
102
103    for(final String structure : structures) {
104      if(!containsStructure(structure)) {
105        return false;
106      }
107    }
108    return true;
109  }
110}