2020-04-16 04:52:39 +02:00
|
|
|
/*
|
2022-06-15 20:17:17 +02:00
|
|
|
* PlotSquared, a land and world management plugin for Minecraft.
|
|
|
|
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
|
|
|
* Copyright (C) IntellectualSites team and contributors
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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.
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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.
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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-16 04:52:39 +02:00
|
|
|
*/
|
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;
|
2022-06-16 16:41:03 +02:00
|
|
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
2020-06-05 14:13:03 +02:00
|
|
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
2022-06-22 14:57:39 +02:00
|
|
|
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
|
|
|
|
2016-03-12 17:57:24 +01:00
|
|
|
/**
|
2016-04-05 18:37:11 +02:00
|
|
|
* This class allows for implementation independent world generation.
|
2018-08-10 17:01:10 +02:00
|
|
|
* - Sponge/Bukkit API
|
2016-03-12 17:57:24 +01:00
|
|
|
* 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.
|
2020-08-16 14:22:49 +02:00
|
|
|
*
|
|
|
|
* @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
|
|
|
/**
|
2022-06-12 10:47:25 +02:00
|
|
|
* Generate chunk block data
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2022-06-22 14:57:39 +02:00
|
|
|
* @param result Queue to write to
|
2020-08-16 14:22:49 +02:00
|
|
|
* @param settings PlotArea (settings)
|
2022-06-22 14:57:39 +02:00
|
|
|
* @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
|
|
|
*/
|
2022-06-22 14:57:39 +02:00
|
|
|
public abstract void generateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea settings, boolean biomes);
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2022-06-22 14:57:39 +02: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
|
2022-06-22 14:57:39 +02:00
|
|
|
*/
|
2023-03-06 11:38:30 +01:00
|
|
|
public void populateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea setting) {
|
|
|
|
}
|
2016-03-31 19:23:26 +02:00
|
|
|
|
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)
|
2020-08-16 14:22:49 +02:00
|
|
|
* @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
|
|
|
/**
|
2020-05-31 23:55:59 +02: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
|
2020-05-31 23:55:59 +02:00
|
|
|
*/
|
2020-07-17 16:41:06 +02:00
|
|
|
public void processAreaSetup(PlotAreaBuilder builder) {
|
|
|
|
}
|
2020-05-31 23:55:59 +02:00
|
|
|
|
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
|
|
|
*
|
2020-08-16 14:22:49 +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.<ChunkGenerator>specify() - Would return a ChunkGenerator object<br>
|
|
|
|
*
|
2020-08-16 14:22:49 +02:00
|
|
|
* @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) {
|
2020-07-07 12:56:43 +02:00
|
|
|
return (GeneratorWrapper<T>) PlotSquared.platform().wrapPlotGenerator(world, this);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2022-06-22 14:57:39 +02:00
|
|
|
/**
|
|
|
|
* Get the biome to be generated at a specific point
|
|
|
|
*
|
|
|
|
* @param settings PlotArea settings to provide biome
|
2023-03-06 11:38:30 +01:00
|
|
|
* @param x World x position
|
|
|
|
* @param y World y position
|
|
|
|
* @param z World z position
|
2022-06-22 14:57:39 +02:00
|
|
|
* @return Biome type to be generated
|
2023-06-15 17:24:21 +02:00
|
|
|
* @since 7.0.0
|
2022-06-22 14:57:39 +02:00
|
|
|
*/
|
|
|
|
public abstract BiomeType getBiome(PlotArea settings, int x, int y, int z);
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2016-02-10 19:59:51 +01:00
|
|
|
return getName();
|
|
|
|
}
|
2021-01-09 22:28:41 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|