## **Current API** The current world generation API is very old and limited when you want to make more complex world generation. Resulting in some hard to fix bugs such as that you cannot modify blocks outside the chunk in the BlockPopulator (which should and was per the docs possible), or strange behavior such as SPIGOT-5880. ## **New API** With the new API, the generation is more separate in multiple methods and is more in line with Vanilla chunk generation. The new API is designed to as future proof as possible. If for example a new generation step is added it can easily also be added as a step in API by simply creating the method for it. On the other side if a generation step gets removed, the method can easily be called after another, which is the case with surface and bedrock. The new API and changes are also fully backwards compatible with old chunk generators. ### **Changes in the new api** **Extra generation steps:** Noise, surface, bedrock and caves are added as steps. With those generation steps three extra methods for Vanilla generation are also added. Those new methods provide the ChunkData instead of returning one. The reason for this is, that the ChunkData is now backed by a ChunkAccess. With this, each step has the information of the step before and the Vanilla information (if chosen by setting a 'should' method to true). The old method is deprecated. **New class BiomeProvider** The BiomeProvider acts as Biome source and wrapper for the NMS class WorldChunkManager. With this the underlying Vanilla ChunkGeneration knows which Biome to use for the structure and decoration generation. (Fixes: SPIGOT-5880). Although the List of Biomes which is required in BiomeProvider, is currently not much in use in Vanilla, I decided to add it to future proof the API when it may be required in later versions of Minecraft. The BiomeProvider is also separated from the ChunkGenerator for plugins which only want to change the biome map, such as single Biome worlds or if some biomes should be more present than others. **Deprecated isParallelCapable** Mojang has and is pushing to a more multi threaded chunk generation. This should also be the case for custom chunk generators. This is why the new API only supports multi threaded generation. This does not affect the old API, which is still checking this. **Base height method added** This method was added to also bring the Minecraft generator and Bukkit generator more in line. With this it is possible to return the max height of a location (before decorations). This is useful to let most structures know were to place them. This fixes SPIGOT-5567. (This fixes not all structures placement, desert pyramids for example are still way up at y-level 64, This however is more a vanilla bug and should be fixed at Mojangs end). **WorldInfo Class** The World object was swapped for a WorldInfo object. This is because many methods of the World object won't work during world generation and would mostly likely result in a deadlock. It contains any information a plugin should need to identify the world. **BlockPopulator Changes** Instead of directly manipulating a chunk, changes are now made to a new class LimitedRegion, this class provides methods to populated the chunk and its surrounding area. The wrapping is done so that the population can be moved into the place where Minecraft generates decorations. Where there is no chunk to access yet. By moving it into this place the generation is now async and the surrounding area of the chunk can also be used. For common methods between the World and LimitedRegion a RegionAccessor was added. By: DerFrZocker <derrieple@gmail.com>
193 lines
5.5 KiB
Java
193 lines
5.5 KiB
Java
package org.bukkit.plugin;
|
|
|
|
import java.io.File;
|
|
import java.io.InputStream;
|
|
import java.util.logging.Logger;
|
|
import org.bukkit.Server;
|
|
import org.bukkit.command.TabExecutor;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.generator.BiomeProvider;
|
|
import org.bukkit.generator.ChunkGenerator;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
/**
|
|
* Represents a Plugin
|
|
* <p>
|
|
* The use of {@link PluginBase} is recommended for actual Implementation
|
|
*/
|
|
public interface Plugin extends TabExecutor {
|
|
/**
|
|
* Returns the folder that the plugin data's files are located in. The
|
|
* folder may not yet exist.
|
|
*
|
|
* @return The folder
|
|
*/
|
|
@NotNull
|
|
public File getDataFolder();
|
|
|
|
/**
|
|
* Returns the plugin.yaml file containing the details for this plugin
|
|
*
|
|
* @return Contents of the plugin.yaml file
|
|
*/
|
|
@NotNull
|
|
public PluginDescriptionFile getDescription();
|
|
|
|
/**
|
|
* Gets a {@link FileConfiguration} for this plugin, read through
|
|
* "config.yml"
|
|
* <p>
|
|
* If there is a default config.yml embedded in this plugin, it will be
|
|
* provided as a default for this Configuration.
|
|
*
|
|
* @return Plugin configuration
|
|
*/
|
|
@NotNull
|
|
public FileConfiguration getConfig();
|
|
|
|
/**
|
|
* Gets an embedded resource in this plugin
|
|
*
|
|
* @param filename Filename of the resource
|
|
* @return File if found, otherwise null
|
|
*/
|
|
@Nullable
|
|
public InputStream getResource(@NotNull String filename);
|
|
|
|
/**
|
|
* Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}.
|
|
*/
|
|
public void saveConfig();
|
|
|
|
/**
|
|
* Saves the raw contents of the default config.yml file to the location
|
|
* retrievable by {@link #getConfig()}.
|
|
* <p>
|
|
* This should fail silently if the config.yml already exists.
|
|
*/
|
|
public void saveDefaultConfig();
|
|
|
|
/**
|
|
* Saves the raw contents of any resource embedded with a plugin's .jar
|
|
* file assuming it can be found using {@link #getResource(String)}.
|
|
* <p>
|
|
* The resource is saved into the plugin's data folder using the same
|
|
* hierarchy as the .jar file (subdirectories are preserved).
|
|
*
|
|
* @param resourcePath the embedded resource path to look for within the
|
|
* plugin's .jar file. (No preceding slash).
|
|
* @param replace if true, the embedded resource will overwrite the
|
|
* contents of an existing file.
|
|
* @throws IllegalArgumentException if the resource path is null, empty,
|
|
* or points to a nonexistent resource.
|
|
*/
|
|
public void saveResource(@NotNull String resourcePath, boolean replace);
|
|
|
|
/**
|
|
* Discards any data in {@link #getConfig()} and reloads from disk.
|
|
*/
|
|
public void reloadConfig();
|
|
|
|
/**
|
|
* Gets the associated PluginLoader responsible for this plugin
|
|
*
|
|
* @return PluginLoader that controls this plugin
|
|
*/
|
|
@NotNull
|
|
public PluginLoader getPluginLoader();
|
|
|
|
/**
|
|
* Returns the Server instance currently running this plugin
|
|
*
|
|
* @return Server running this plugin
|
|
*/
|
|
@NotNull
|
|
public Server getServer();
|
|
|
|
/**
|
|
* Returns a value indicating whether or not this plugin is currently
|
|
* enabled
|
|
*
|
|
* @return true if this plugin is enabled, otherwise false
|
|
*/
|
|
public boolean isEnabled();
|
|
|
|
/**
|
|
* Called when this plugin is disabled
|
|
*/
|
|
public void onDisable();
|
|
|
|
/**
|
|
* Called after a plugin is loaded but before it has been enabled.
|
|
* <p>
|
|
* When multiple plugins are loaded, the onLoad() for all plugins is
|
|
* called before any onEnable() is called.
|
|
*/
|
|
public void onLoad();
|
|
|
|
/**
|
|
* Called when this plugin is enabled
|
|
*/
|
|
public void onEnable();
|
|
|
|
/**
|
|
* Simple boolean if we can still nag to the logs about things
|
|
*
|
|
* @return boolean whether we can nag
|
|
*/
|
|
public boolean isNaggable();
|
|
|
|
/**
|
|
* Set naggable state
|
|
*
|
|
* @param canNag is this plugin still naggable?
|
|
*/
|
|
public void setNaggable(boolean canNag);
|
|
|
|
/**
|
|
* Gets a {@link ChunkGenerator} for use in a default world, as specified
|
|
* in the server configuration
|
|
*
|
|
* @param worldName Name of the world that this will be applied to
|
|
* @param id Unique ID, if any, that was specified to indicate which
|
|
* generator was requested
|
|
* @return ChunkGenerator for use in the default world generation
|
|
*/
|
|
@Nullable
|
|
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id);
|
|
|
|
/**
|
|
* Gets a {@link BiomeProvider} for use in a default world, as specified
|
|
* in the server configuration
|
|
*
|
|
* @param worldName Name of the world that this will be applied to
|
|
* @param id Unique ID, if any, that was specified to indicate which
|
|
* biome provider was requested
|
|
* @return BiomeProvider for use in the default world generation
|
|
*/
|
|
@Nullable
|
|
public BiomeProvider getDefaultBiomeProvider(@NotNull String worldName, @Nullable String id);
|
|
|
|
/**
|
|
* Returns the plugin logger associated with this server's logger. The
|
|
* returned logger automatically tags all log messages with the plugin's
|
|
* name.
|
|
*
|
|
* @return Logger associated with this plugin
|
|
*/
|
|
@NotNull
|
|
public Logger getLogger();
|
|
|
|
/**
|
|
* Returns the name of the plugin.
|
|
* <p>
|
|
* This should return the bare name of the plugin and should be used for
|
|
* comparison.
|
|
*
|
|
* @return name of the plugin
|
|
*/
|
|
@NotNull
|
|
public String getName();
|
|
}
|