001/* 002 * PlotSquared, a land and world management plugin for Minecraft. 003 * Copyright (C) IntellectualSites <https://intellectualsites.com> 004 * Copyright (C) IntellectualSites team and contributors 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU 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 General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 018 */ 019package com.plotsquared.core.generator; 020 021import com.plotsquared.core.PlotSquared; 022import com.plotsquared.core.plot.PlotArea; 023import com.plotsquared.core.plot.PlotId; 024import com.plotsquared.core.queue.ScopedQueueCoordinator; 025import com.plotsquared.core.setup.PlotAreaBuilder; 026import org.checkerframework.checker.nullness.qual.NonNull; 027 028/** 029 * This class allows for implementation independent world generation. 030 * - Sponge/Bukkit API 031 * Use the specify method to get the generator for that platform. 032 */ 033public abstract class IndependentPlotGenerator { 034 035 /** 036 * Get the name of this generator. 037 * 038 * @return generator name 039 */ 040 public abstract String getName(); 041 042 /** 043 * Generate chunk block data 044 * 045 * @param result queue 046 * @param settings PlotArea (settings) 047 * @deprecated {@link ScopedQueueCoordinator} will be renamed in v7. 048 */ 049 @Deprecated(forRemoval = true, since = "6.9.0") 050 public abstract void generateChunk(ScopedQueueCoordinator result, PlotArea settings); 051 052 /** 053 * Populates the queue representing a chunk area with tile entities and entities 054 * 055 * @param result Queue to write to 056 * @param settings PlotArea (settings) 057 * @return True if any population occurred 058 * @deprecated {@link ScopedQueueCoordinator} will be renamed in v7. 059 */ 060 @Deprecated(forRemoval = true, since = "6.9.0") 061 public boolean populateChunk(ScopedQueueCoordinator result, PlotArea settings) { 062 return false; 063 } 064 065 /** 066 * Return a new PlotArea object. 067 * 068 * @param world world name 069 * @param id (May be null) Area name 070 * @param min Min plot id (may be null) 071 * @param max Max plot id (may be null) 072 * @return new plot area 073 */ 074 public abstract PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max); 075 076 /** 077 * If any additional setup options need to be changed before world creation. 078 * - e.g. If setup doesn't support some standard options 079 * 080 * @param builder the area builder to modify 081 */ 082 public void processAreaSetup(PlotAreaBuilder builder) { 083 } 084 085 /** 086 * It is preferred for the PlotArea object to do most of the initialization necessary. 087 * 088 * @param area area 089 */ 090 public abstract void initialize(PlotArea area); 091 092 /** 093 * Get the generator for your specific implementation (bukkit/sponge).<br> 094 * - e.g. YourIndependentGenerator.<ChunkGenerator>specify() - Would return a ChunkGenerator object<br> 095 * 096 * @param <T> world 097 * @param world ChunkGenerator Implementation 098 * @return Chunk generator 099 */ 100 @SuppressWarnings("unchecked") 101 public <T> GeneratorWrapper<T> specify(final @NonNull String world) { 102 return (GeneratorWrapper<T>) PlotSquared.platform().wrapPlotGenerator(world, this); 103 } 104 105 @Override 106 public String toString() { 107 return getName(); 108 } 109 110}