PlotSquared/Core/src/main/java/com/plotsquared/core/generator/IndependentPlotGenerator.java

121 lines
4.0 KiB
Java
Raw Normal View History

/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-04-15 21:26:54 +02:00
package com.plotsquared.core.generator;
2016-02-10 19:59:51 +01:00
2020-04-15 21:26:54 +02:00
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
2020-06-05 14:13:03 +02:00
import com.plotsquared.core.setup.PlotAreaBuilder;
import com.sk89q.worldedit.world.biome.BiomeType;
2021-01-10 00:01:48 +01:00
import org.checkerframework.checker.nullness.qual.NonNull;
2016-02-10 19:59:51 +01:00
/**
* This class allows for implementation independent world generation.
2018-08-10 17:01:10 +02:00
* - Sponge/Bukkit API
* Use the specify method to get the generator for that platform.
*/
2016-02-10 19:59:51 +01:00
public abstract class IndependentPlotGenerator {
2016-03-23 02:41:37 +01:00
2016-02-10 19:59:51 +01:00
/**
2016-03-23 02:41:37 +01:00
* Get the name of this generator.
*
* @return generator name
2016-02-10 19:59:51 +01:00
*/
public abstract String getName();
2016-03-23 02:41:37 +01:00
2016-02-10 19:59:51 +01:00
/**
* Generate chunk block data
2018-08-10 17:01:10 +02:00
*
* @param result Queue to write to
* @param settings PlotArea (settings)
* @param biomes If biomes should be generated
2023-06-15 17:24:21 +02:00
* @since 7.0.0
2016-02-10 19:59:51 +01:00
*/
public abstract void generateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea settings, boolean biomes);
2016-03-23 02:41:37 +01:00
/**
* Populate a chunk-queue with tile entities, entities, etc.
*
* @param result Queue to write to
* @param setting PlotArea (settings)
2023-06-15 17:24:21 +02:00
* @since 7.0.0
*/
public void populateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea setting) {
}
2016-02-10 19:59:51 +01:00
/**
2016-03-23 02:41:37 +01:00
* Return a new PlotArea object.
2018-08-10 17:01:10 +02:00
*
2016-02-10 19:59:51 +01:00
* @param world world name
2018-08-10 17:01:10 +02:00
* @param id (May be null) Area name
* @param min Min plot id (may be null)
* @param max Max plot id (may be null)
* @return new plot area
2016-02-10 19:59:51 +01:00
*/
public abstract PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max);
2016-03-23 02:41:37 +01:00
2016-02-10 19:59:51 +01:00
/**
* If any additional setup options need to be changed before world creation.
* - e.g. If setup doesn't support some standard options
*
2020-06-05 14:13:03 +02:00
* @param builder the area builder to modify
*/
public void processAreaSetup(PlotAreaBuilder builder) {
}
2016-02-10 19:59:51 +01:00
/**
2016-03-23 02:41:37 +01:00
* It is preferred for the PlotArea object to do most of the initialization necessary.
2018-08-10 17:01:10 +02:00
*
* @param area area
2016-02-10 19:59:51 +01:00
*/
public abstract void initialize(PlotArea area);
2016-03-23 02:41:37 +01:00
2016-02-10 19:59:51 +01:00
/**
* Get the generator for your specific implementation (bukkit/sponge).<br>
2018-08-10 17:01:10 +02:00
* - e.g. YourIndependentGenerator.&lt;ChunkGenerator&gt;specify() - Would return a ChunkGenerator object<br>
*
* @param <T> world
* @param world ChunkGenerator Implementation
* @return Chunk generator
2016-02-10 19:59:51 +01:00
*/
2022-01-20 21:01:38 +01:00
@SuppressWarnings("unchecked")
2021-01-10 00:01:48 +01:00
public <T> GeneratorWrapper<T> specify(final @NonNull String world) {
return (GeneratorWrapper<T>) PlotSquared.platform().wrapPlotGenerator(world, this);
2016-02-10 19:59:51 +01:00
}
2016-03-23 02:41:37 +01:00
/**
* Get the biome to be generated at a specific point
*
* @param settings PlotArea settings to provide biome
* @param x World x position
* @param y World y position
* @param z World z position
* @return Biome type to be generated
2023-06-15 17:24:21 +02:00
* @since 7.0.0
*/
public abstract BiomeType getBiome(PlotArea settings, int x, int y, int z);
@Override
public String toString() {
2016-02-10 19:59:51 +01:00
return getName();
}
2016-02-10 19:59:51 +01:00
}