Fill out a lot more JavaDoc.

I've left DB stuff alone
This commit is contained in:
dordsor21 2020-08-16 13:22:49 +01:00
parent a4c9ed90b7
commit 665a72a08f
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
41 changed files with 468 additions and 156 deletions

View File

@ -85,11 +85,13 @@ public interface PlotPlatform<P> extends LocaleHolder {
/**
* Gets the version of Minecraft that is running.
* @return server version as array of numbers
*/
int[] getServerVersion();
/**
* Gets the server implementation name and version
* @return server implementationa and version as string
*/
String getServerImplementation();

View File

@ -1313,6 +1313,8 @@ public class PlotSquared {
* Setup all configuration files<br>
* - Config: settings.yml<br>
* - Storage: storage.yml<br>
*
* @return success or not
*/
public boolean setupConfigs() {
File folder = new File(this.platform.getDirectory(), "config");

View File

@ -126,10 +126,10 @@ public class Auto extends SubCommand {
/**
* Teleport the player home, or claim a new plot
*
* @param player
* @param area
* @param start
* @param schematic
* @param player player
* @param area plot area
* @param start start id
* @param schematic schematic
*/
public static void homeOrAuto(final PlotPlayer player, final PlotArea area, PlotId start,
final String schematic) {
@ -145,10 +145,10 @@ public class Auto extends SubCommand {
/**
* Claim a new plot for a player
*
* @param player
* @param area
* @param start
* @param schematic
* @param player player
* @param area plot area
* @param start start id
* @param schematic schematic
*/
public static void autoClaimSafe(final PlotPlayer<?> player, final PlotArea area, PlotId start,
final String schematic) {

View File

@ -280,9 +280,10 @@ public abstract class Command {
}
/**
* @param player Caller
* @param args Arguments
* @param confirm Instance, Success, Failure
* @param player Caller
* @param args Arguments
* @param confirm Instance, Success, Failure
* @param whenDone task to run when done
* @return CompletableFuture true if the command executed fully, false in
* any other case
*/

View File

@ -48,6 +48,7 @@ public interface CommandCaller {
* Check the player's permissions. <i>Will be cached if permission caching is enabled.</i>
*
* @param permission the name of the permission
* @return if permission is had
*/
boolean hasPermission(@Nonnull String permission);

View File

@ -172,6 +172,7 @@ public class Like extends SubCommand {
/**
* Get the likes to dislike ratio of a plot as a percentage (in decimal form)
*
* @param plot plot
* @return likes to dislike ratio, returns zero if the plot has no likes
*/
public static double getLikesPercentage(final Plot plot) {

View File

@ -86,7 +86,7 @@ public class Trim extends SubCommand {
*
* @param world The world
* @param result (viable = .mcr to trim, nonViable = .mcr keep)
* @return
* @return success or not
*/
public static boolean getTrimRegions(String world,
final RunnableVal2<Set<BlockVector2>, Set<BlockVector2>> result) {

View File

@ -128,6 +128,7 @@ public class ComponentPresetManager {
* if the player is in a compatible plot, and sends appropriate
* error messages if not
*
* @param player player
* @return Build inventory, if it could be created
*/
@Nullable public PlotInventory buildInventory(final PlotPlayer<?> player) {

View File

@ -53,10 +53,10 @@ public class Config {
* Get the value for a node<br>
* Probably throws some error if you try to get a non existent key
*
* @param key
* @param root
* @param <T>
* @return
* @param key configuration key
* @param root configuration class
* @param <T> value type
* @return value
*/
public static <T> T get(String key, Class<?> root) {
String[] split = key.split("\\.");
@ -80,7 +80,7 @@ public class Config {
*
* @param key config node
* @param value value
* @param root
* @param root configuration class
*/
public static void set(String key, Object value, Class<? extends Config> root) {
String[] split = key.split("\\.");
@ -124,8 +124,8 @@ public class Config {
/**
* Set all values in the file (load first to avoid overwriting)
*
* @param file
* @param root
* @param file file
* @param root configuration file class
*/
public static void save(File file, Class<? extends Config> root) {
try {
@ -145,8 +145,8 @@ public class Config {
/**
* Get the static fields in a section.
*
* @param clazz
* @return
* @param clazz config section
* @return map or string against object of static fields
*/
public static Map<String, Object> getFields(Class<Enabled_Components> clazz) {
HashMap<String, Object> map = new HashMap<>();

View File

@ -33,11 +33,9 @@ import java.util.Map;
public interface Configuration extends ConfigurationSection {
/**
* Sets the default value of the given path as provided.
* <p>
* <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default value.</p>
* <p>
* <p>If value is null, the value will be removed from the default
* Configuration source.</p>
*
@ -49,7 +47,6 @@ public interface Configuration extends ConfigurationSection {
/**
* Sets the default values of the given paths as provided.
* <p>
* <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default values.</p>
@ -61,11 +58,9 @@ public interface Configuration extends ConfigurationSection {
/**
* Sets the default values of the given paths as provided.
* <p>
* <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default value.</p>
* <p>
* <p>This method will not hold a reference to the specified Configuration,
* nor will it automatically update if that Configuration ever changes. If
* you check this, you should set the default source with {@link
@ -78,9 +73,8 @@ public interface Configuration extends ConfigurationSection {
/**
* Gets the source {@link Configuration} for this configuration.
* <p>
* <p>
* If no configuration source was set, but default values were added, then
*
* <p>If no configuration source was set, but default values were added, then
* a {@link MemoryConfiguration} will be returned. If no source was set
* and no defaults were set, then this method will return null.</p>
*
@ -90,9 +84,8 @@ public interface Configuration extends ConfigurationSection {
/**
* Sets the source of all default values for this {@link Configuration}.
* <p>
* <p>
* If a previous source was set, or previous default values were defined,
*
* <p>If a previous source was set, or previous default values were defined,
* then they will not be copied to the new source.</p>
*
* @param defaults New source of default values for this configuration.
@ -102,7 +95,6 @@ public interface Configuration extends ConfigurationSection {
/**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
* <p>
* <p>All setters through this method are chainable.</p>
*
* @return Options for this configuration

View File

@ -53,11 +53,9 @@ public class ConfigurationSerialization {
/**
* Attempts to deserialize the given arguments into a new instance of the
* given class.
* <p>
* <p>The class must implement {@link ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p>
* <p>
* <p>If a new instance could not be made, an example being the class not
* fully implementing the interface, null will be returned.</p>
*
@ -72,15 +70,12 @@ public class ConfigurationSerialization {
/**
* Attempts to deserialize the given arguments into a new instance of the
* <p>
* given class.
* <p>
* The class must implement {@link ConfigurationSerializable}, including
*
* <p>The class must implement {@link ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p>
* <p>
* <p>
* If a new instance could not be made, an example being the class not
* <p>If a new instance could not be made, an example being the class not
* fully implementing the interface, null will be returned.</p>
*
* @param args Arguments for deserialization

View File

@ -60,10 +60,8 @@ public class ClassicPlotManager extends SquarePlotManager {
this.regionManager = regionManager;
}
@Override public boolean setComponent(@Nonnull PlotId plotId,
@Nonnull String component,
@Nonnull Pattern blocks,
@Nullable QueueCoordinator queue) {
@Override
public boolean setComponent(@Nonnull PlotId plotId, @Nonnull String component, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
final Optional<ClassicPlotManagerComponent> componentOptional = ClassicPlotManagerComponent.fromString(component);
if (componentOptional.isPresent()) {
switch (componentOptional.get()) {
@ -101,8 +99,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Set the plot floor
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set floor of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setFloor(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
Plot plot = classicPlotWorld.getPlotAbs(plotId);
@ -116,8 +117,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Sets the plot main, floor and air areas.
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set all of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setAll(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
Plot plot = classicPlotWorld.getPlotAbs(plotId);
@ -130,8 +134,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Sets the plot air region.
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set air of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setAir(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
Plot plot = classicPlotWorld.getPlotAbs(plotId);
@ -145,8 +152,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Sets the plot main blocks.
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set main of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setMain(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
Plot plot = classicPlotWorld.getPlotAbs(plotId);
@ -159,8 +169,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Set the middle plot block to a Pattern
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set middle block of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setMiddle(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
Plot plot = classicPlotWorld.getPlotAbs(plotId);
@ -184,8 +197,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Set a plot's outline
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set outline of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setOutline(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
if (classicPlotWorld.ROAD_WIDTH == 0) {
@ -257,8 +273,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Set the wall filling for a plot
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set wall filling of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setWallFilling(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
if (classicPlotWorld.ROAD_WIDTH == 0) {
@ -321,8 +340,11 @@ public class ClassicPlotManager extends SquarePlotManager {
/**
* Set a plot's wall top block only
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotId id of plot to set wall top block of
* @param blocks pattern to set
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public boolean setWall(@Nonnull PlotId plotId, @Nonnull Pattern blocks, @Nullable QueueCoordinator queue) {
if (classicPlotWorld.ROAD_WIDTH == 0) {

View File

@ -73,7 +73,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
/**
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP.
* <p>
*
* <p>Set the last boolean to false if you do not check a specific config node to be set while using the setup
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
* world generation</p>

View File

@ -41,6 +41,8 @@ public abstract class IndependentPlotGenerator {
/**
* Get the name of this generator.
*
* @return generator name
*/
public abstract String getName();
@ -49,8 +51,8 @@ public abstract class IndependentPlotGenerator {
* The PlotArea settings is the same one this was initialized with.
* The PseudoRandom random is a fast random object.
*
* @param result
* @param settings
* @param result queue
* @param settings PlotArea (settings)
*/
public abstract void generateChunk(ScopedQueueCoordinator result, PlotArea settings);
@ -65,7 +67,7 @@ public abstract class IndependentPlotGenerator {
* @param id (May be null) Area name
* @param min Min plot id (may be null)
* @param max Max plot id (may be null)
* @return
* @return new plot area
*/
public abstract PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max);
@ -73,7 +75,7 @@ public abstract class IndependentPlotGenerator {
* If any additional setup options need to be changed before world creation.
* - e.g. If setup doesn't support some standard options
*
* @param setup
* @param setup setup object
*/
@Deprecated public void processSetup(SetupObject setup) {
}
@ -90,7 +92,7 @@ public abstract class IndependentPlotGenerator {
/**
* It is preferred for the PlotArea object to do most of the initialization necessary.
*
* @param area
* @param area area
*/
public abstract void initialize(PlotArea area);
@ -98,9 +100,9 @@ public abstract class IndependentPlotGenerator {
* Get the generator for your specific implementation (bukkit/sponge).<br>
* - e.g. YourIndependentGenerator.&lt;ChunkGenerator&gt;specify() - Would return a ChunkGenerator object<br>
*
* @param <T>
* @param <T>
* @return
* @param <T> world
* @param world ChunkGenerator Implementation
* @return Chunk generator
*/
public <T> GeneratorWrapper<T> specify(String world) {
return (GeneratorWrapper<T>) PlotSquared.platform().wrapPlotGenerator(world, this);

View File

@ -51,6 +51,7 @@ public interface World<T> {
/**
* Get a {@link NullWorld} implementation
*
* @param <T> implementation-specific world object type e.g. a bukkit World
* @return NullWorld instance
*/
static <T> NullWorld<T> nullWorld() {

View File

@ -58,6 +58,7 @@ public final class MetaDataKey<T> {
* Get a new named lock key
*
* @param key Key name
* @param type type
* @param <T> Type
* @return MetaData key instance
*/

View File

@ -317,7 +317,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
* Get the number of plots this player owns in the world.
*
* @param world the name of the plotworld to check.
* @return
* @return plot count
*/
public int getPlotCount(String world) {
UUID uuid = getUUID();
@ -393,6 +393,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
/**
* Get this player's full location (including yaw/pitch)
* @return location
*/
public abstract Location getLocationFull();
@ -460,7 +461,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
* - Please note that this is not intended to store large values
* - For session only data use meta
*
* @param key
* @param key metadata key
*/
public void setAttribute(String key) {
setPersistentMeta("attrib_" + key, new byte[] {(byte) 1});
@ -469,7 +470,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
/**
* Retrieves the attribute of this player.
*
* @param key
* @param key metadata key
* @return the attribute will be either true or false
*/
public boolean getAttribute(String key) {
@ -482,7 +483,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
/**
* Remove an attribute from a player.
*
* @param key
* @param key metadata key
*/
public void removeAttribute(String key) {
removePersistentMeta("attrib_" + key);
@ -605,8 +606,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
/**
* Get the amount of clusters this player owns in the specific world.
*
* @param world
* @return
* @param world world
* @return number of clusters owned
*/
public int getPlayerClusterCount(String world) {
return PlotSquared.get().getClusters(world).stream()
@ -914,6 +915,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
/**
* The amount of money this Player has.
*
* @return amount of money owned by the player
*/
public double getMoney() {
return this.econHandler == null ?

View File

@ -269,8 +269,15 @@ public class Plot {
* @param id the plot id
* @param owner the plot owner
* @param trusted the plot trusted players
* @param members the plot added players
* @param denied the plot denied players
* @param alias the plot's alias
* @param position plot home position
* @param flags the plot's flags
* @param area the plot's PlotArea
* @param merged an array giving merged plots
* @param timestamp when the plot was created
* @param temp value representing whatever DBManager needs to to. Do not touch tbh.
* @see Plot#getPlot(Location) for existing plots
*/
public Plot(@Nonnull PlotId id,
@ -563,6 +570,8 @@ public class Plot {
* Direct access is discouraged: use getOwners()
*
* @see #getOwnerAbs() getOwnerAbs() to get the owner as stored in the database
*
* @return Server if ServerPlot flag set, else {@link #getOwnerAbs()}
*/
public UUID getOwner() {
if (this.getFlag(ServerPlotFlag.class)) {
@ -750,6 +759,8 @@ public class Plot {
* - If the plot is not merged it will return itself.<br>
* - The result is cached locally
*
* @param recalculate whether to recalculate the merged plots to find the origin
*
* @return base Plot
*/
public Plot getBasePlot(boolean recalculate) {
@ -1210,6 +1221,8 @@ public class Plot {
/**
* This will return null if the plot hasn't been analyzed
*
* @param settings The set of settings to obtain the analysis of
*
* @return analysis of plot
*/
public PlotAnalysis getComplexity(Settings.Auto_Clear settings) {
@ -1233,6 +1246,7 @@ public class Plot {
* Sets a flag for the plot and stores it in the database.
*
* @param flag Flag to set
* @param <V> flag value type
* @return A boolean indicating whether or not the operation succeeded
*/
public <V> boolean setFlag(PlotFlag<V, ?> flag) {
@ -1343,6 +1357,10 @@ public class Plot {
*
* @see PlotSquared#removePlot(Plot, boolean)
* @see #clear(boolean, boolean, Runnable) to simply clear a plot
*
* @param whenDone task to run when plot has been deleted. Nullable
*
* @return success status
*/
public boolean deletePlot(final Runnable whenDone) {
if (!this.hasOwner()) {
@ -1490,6 +1508,8 @@ public class Plot {
/**
* @deprecated May cause synchronous chunk loads
*
* @return Location of center
*/
@Deprecated public Location getCenterSynchronous() {
Location[] corners = getCorners();
@ -1509,6 +1529,8 @@ public class Plot {
/**
* @deprecated May cause synchronous chunk loads
*
* @return side where players should teleport to
*/
@Deprecated public Location getSideSynchronous() {
CuboidRegion largest = getLargestRegion();
@ -1546,6 +1568,8 @@ public class Plot {
/**
* @deprecated May cause synchronous chunk loading
*
* @return the plot home location
*/
@Deprecated public Location getHomeSynchronous() {
BlockLoc home = this.getPosition();
@ -1569,6 +1593,8 @@ public class Plot {
/**
* Return the home location for the plot
*
* @param result consumer to pass location to when found
*/
public void getHome(final Consumer<Location> result) {
BlockLoc home = this.getPosition();
@ -1615,6 +1641,8 @@ public class Plot {
/**
* Gets the default home location for a plot<br>
* - Ignores any home location set for that specific plot
*
* @param result consumer to pass location to when found
*/
public void getDefaultHome(Consumer<Location> result) {
getDefaultHome(false, result);
@ -1622,6 +1650,10 @@ public class Plot {
/**
* @deprecated May cause synchronous chunk loads
*
* @param member if to get the home for plot members
*
* @return location of home for members or visitors
*/
@Deprecated public Location getDefaultHomeSynchronous(final boolean member) {
Plot plot = this.getBasePlot(false);
@ -1927,6 +1959,13 @@ public class Plot {
/**
* Sets components such as border, wall, floor.
* (components are generator specific)
*
* @param component component to set
* @param blocks string of block(s) to set component to
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
*
* @return success or not
*/
@Deprecated public boolean setComponent(String component, String blocks, QueueCoordinator queue) {
BlockBucket parsed = ConfigurationUtil.BLOCK_BUCKET.parseString(blocks);
@ -1940,6 +1979,8 @@ public class Plot {
/**
* Retrieve the biome of the plot.
*
* @param result consumer to pass biome to when found
*/
public void getBiome(Consumer<BiomeType> result) {
this.getCenter(location -> this.worldUtil.getBiome(location.getWorldName(), location.getX(), location.getZ(), result));
@ -1949,6 +1990,8 @@ public class Plot {
/**
* @deprecated May cause synchronous chunk loads
*
* @return biome at center of plot
*/
@Deprecated public BiomeType getBiomeSynchronous() {
final Location location = this.getCenterSynchronous();
@ -1957,6 +2000,8 @@ public class Plot {
/**
* Returns the top location for the plot.
*
* @return location of Absolute Top
*/
public Location getTopAbs() {
return this.getManager().getPlotTopLocAbs(this.id).withWorld(this.getWorldName());
@ -1964,6 +2009,8 @@ public class Plot {
/**
* Returns the bottom location for the plot.
*
* @return location of absolute bottom of plot
*/
public Location getBottomAbs() {
return this.getManager().getPlotBottomLocAbs(this.id).withWorld(this.getWorldName());
@ -2003,8 +2050,8 @@ public class Plot {
* Moves the settings for a plot.
*
* @param plot the plot to move
* @param whenDone
* @return
* @param whenDone task to run when settings have been moved
* @return success or not
*/
public boolean moveData(Plot plot, Runnable whenDone) {
if (!this.hasOwner()) {
@ -2100,8 +2147,8 @@ public class Plot {
}
/**
* @return
* @deprecated in favor of getCorners()[0];<br>
* @return bottom corner location
*/
// Won't remove as suggestion also points to deprecated method
@Deprecated public Location getBottom() {
@ -2109,8 +2156,8 @@ public class Plot {
}
/**
* @return the top corner of the plot
* @deprecated in favor of getCorners()[1];
* @return the top corner of the plot
*/
// Won't remove as suggestion also points to deprecated method
@Deprecated public Location getTop() {
@ -2158,7 +2205,9 @@ public class Plot {
* Remove a denied player (use DBFunc as well)<br>
* Using the * uuid will remove all users
*
* @param uuid
* @param uuid uuid of player to remove from denied list
*
* @return success or not
*/
public boolean removeDenied(UUID uuid) {
if (uuid == DBFunc.EVERYONE && !denied.contains(uuid)) {
@ -2186,7 +2235,9 @@ public class Plot {
* Remove a helper (use DBFunc as well)<br>
* Using the * uuid will remove all users
*
* @param uuid
* @param uuid uuid of trusted player to remove
*
* @return success or not
*/
public boolean removeTrusted(UUID uuid) {
if (uuid == DBFunc.EVERYONE && !trusted.contains(uuid)) {
@ -2214,7 +2265,9 @@ public class Plot {
* Remove a trusted user (use DBFunc as well)<br>
* Using the * uuid will remove all users
*
* @param uuid
* @param uuid uuid of player to remove
*
* @return success or not
*/
public boolean removeMember(UUID uuid) {
if (this.members == null) {
@ -2243,6 +2296,8 @@ public class Plot {
/**
* Export the plot as a schematic to the configured output directory.
*
* @param whenDone task to run when the export has finished
*/
public void export(final RunnableVal<Boolean> whenDone) {
this.schematicHandler.getCompoundTag(this, new RunnableVal<CompoundTag>() {
@ -2284,7 +2339,7 @@ public class Plot {
* - The mca files are each 512x512, so depending on the plot size it may also download adjacent plots<br>
* - Works best when (plot width + road width) % 512 == 0<br>
*
* @param whenDone
* @param whenDone task to run when plot is uploaded
* @see WorldUtil
*/
public void uploadWorld(RunnableVal<URL> whenDone) {
@ -2354,8 +2409,8 @@ public class Plot {
* - Updates DB<br>
* - Does not modify terrain<br>
*
* @param direction
* @param value
* @param direction direction to merge the plot in
* @param value if the plot is merged or not
*/
public void setMerged(Direction direction, boolean value) {
if (this.getSettings().setMerged(direction, value)) {
@ -2404,7 +2459,7 @@ public class Plot {
* ----------<br>
* Note: Diagonal merging (4-7) must be done by merging the corresponding plots.
*
* @param merged
* @param merged set the plot's merged plots
*/
public void setMerged(boolean[] merged) {
this.getSettings().setMerged(merged);
@ -2424,6 +2479,8 @@ public class Plot {
/**
* Gets the set home location or 0,0,0 if no location is set<br>
* - Does not take the default home location into account
*
* @return home location
*/
public BlockLoc getPosition() {
return this.getSettings().getPosition();
@ -2433,6 +2490,8 @@ public class Plot {
* Check if a plot can be claimed by the provided player.
*
* @param player the claiming player
*
* @return if the given player can claim the plot
*/
public boolean canClaim(@Nonnull PlotPlayer player) {
PlotCluster cluster = this.getCluster();
@ -2574,7 +2633,7 @@ public class Plot {
* Merge the plot settings<br>
* - Used when a plot is merged<br>
*
* @param plot
* @param plot plot to merge the data from
*/
public void mergeData(Plot plot) {
final FlagContainer flagContainer1 = this.getFlagContainer();
@ -2640,8 +2699,8 @@ public class Plot {
* Gets the plot in a relative location<br>
* Note: May be null if the partial plot area does not include the relative location
*
* @param x
* @param y
* @param x relative id X
* @param y relative id Y
* @return Plot
*/
public Plot getRelative(int x, int y) {
@ -2793,7 +2852,7 @@ public class Plot {
* - This result is cached globally<br>
* - Useful for handling non rectangular shapes
*
* @return
* @return all regions within the plot
*/
@Nonnull public Set<CuboidRegion> getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
@ -2922,7 +2981,7 @@ public class Plot {
/**
* Attempt to find the largest rectangular region in a plot (as plots can form non rectangular shapes)
*
* @return
* @return the plot's largest CuboidRegion
*/
public CuboidRegion getLargestRegion() {
Set<CuboidRegion> regions = this.getRegions();
@ -3085,6 +3144,8 @@ public class Plot {
*
* @param component Component to set
* @param blocks Pattern to use the generation
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return True if the component was set successfully
*/
public boolean setComponent(String component, Pattern blocks, @Nullable QueueCoordinator queue) {
@ -3117,6 +3178,8 @@ public class Plot {
/**
* Merges two plots. <br>- Assumes plots are directly next to each other <br> - saves to DB
*
* @param lesserPlot the plot to merge into this plot instance
* @param removeRoads if roads should be removed during the merge
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
*/
@ -3297,9 +3360,9 @@ public class Plot {
/**
* Copy a plot to a location, both physically and the settings
*
* @param destination
* @param whenDone
* @return
* @param destination destination plot
* @param whenDone task to run when copy is complete
* @return success or not
*/
public boolean copy(final Plot destination, final Runnable whenDone) {
PlotId offset = PlotId.of(destination.getId().getX() - this.getId().getX(), destination.getId().getY() - this.getId().getY());
@ -3419,6 +3482,7 @@ public class Plot {
* and at last, it will look at the default values stored in {@link GlobalFlagContainer}.
*
* @param flagClass The flag type (Class)
* @param <T> the flag value type
* @return The flag value
*/
public <T> T getFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
@ -3431,6 +3495,8 @@ public class Plot {
* and at last, it will look at the default values stored in {@link GlobalFlagContainer}.
*
* @param flag The flag type (Any instance of the flag)
* @param <V> the flag type (Any instance of the flag)
* @param <T> the flag's value type
* @return The flag value
*/
public <T, V extends PlotFlag<T, ?>> T getFlag(final V flag) {

View File

@ -659,6 +659,9 @@ public abstract class PlotArea {
* Retrieves the plots for the player in this PlotArea.
*
* @deprecated Use {@link #getPlots(UUID)}
*
* @param player player to get plots of
* @return set of player's plots
*/
@Deprecated public Set<Plot> getPlots(@Nonnull final PlotPlayer player) {
return getPlots(player.getUUID());
@ -737,6 +740,9 @@ public abstract class PlotArea {
* Session only plot metadata (session is until the server stops).
* <br>
* For persistent metadata use the flag system
*
* @param key metadata key
* @param value metadata value
*/
public void setMeta(@Nonnull final String key, @Nullable final Object value) {
if (this.meta == null) {
@ -754,6 +760,8 @@ public abstract class PlotArea {
* Get the metadata for a key<br>
* <br>
* For persistent metadata use the flag system
* @param key metadata key to get value for
* @return metadata value
*/
@Nullable public Object getMeta(@Nonnull final String key) {
if (this.meta != null) {
@ -782,17 +790,12 @@ public abstract class PlotArea {
}
}
/**
* Returns an ImmutableMap of PlotId's and Plots in this PlotArea.
*/
public Map<PlotId, Plot> getPlotsMap() {
return ImmutableMap.copyOf(plots);
}
/**
* Returns an ImmutableMap of PlotId's and Plots in this PlotArea.
*
* @deprecated Use {@link #getPlotsMap()}
* @deprecated Poorly implemented. May be removed in future.
*
* @return map of PlotId against Plot for all plots in this area
*/
//todo eventually remove
@Deprecated @Nonnull public Map<PlotId, Plot> getPlotsRaw() {
@ -1159,6 +1162,7 @@ public abstract class PlotArea {
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flagClass The flag type (Class)
* @param <T> The flag value type
* @return The flag value
*/
public <T> T getFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
@ -1170,6 +1174,8 @@ public abstract class PlotArea {
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flag The flag type (Any instance of the flag)
* @param <V> The flag type (Any instance of the flag)
* @param <T> flag valye type
* @return The flag value
*/
public <T, V extends PlotFlag<T, ?>> T getFlag(final V flag) {
@ -1183,6 +1189,7 @@ public abstract class PlotArea {
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flagClass The flag type (Class)
* @param <T> the flag value type
* @return The flag value
*/
public <T> T getRoadFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
@ -1194,6 +1201,8 @@ public abstract class PlotArea {
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flag The flag type (Any instance of the flag)
* @param <V> The flag type (Any instance of the flag)
* @param <T> flag valye type
* @return The flag value
*/
public <T, V extends PlotFlag<T, ?>> T getRoadFlag(final V flag) {

View File

@ -117,6 +117,8 @@ public class PlotCluster {
/**
* Get the area (in plots).
*
* @return area of plots
*/
public int getArea() {
return (1 + this.pos2.getX() - this.pos1.getX()) * (1 + this.pos2.getY() - this.pos1.getY());

View File

@ -58,6 +58,7 @@ public final class PlotId {
*
* @param x The plot x coordinate
* @param y The plot y coordinate
* @return a new PlotId at x,y
*/
@Nonnull public static PlotId of(final int x, final int y) {
return new PlotId(x, y);
@ -275,7 +276,7 @@ public final class PlotId {
@Override public PlotId next() {
if (!hasNext()) {
throw new IndexOutOfBoundsException("The iterator has no more entries");
throw new IndexOutOfBoundsException("The iterator has no more entries");
}
if (this.y == this.end.getY()) {
this.x++;

View File

@ -68,8 +68,11 @@ public abstract class PlotManager {
/**
* Completes block changes associated with plot unclaim.
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plot plot to unclaim
* @param whenDone task to run when plot is unclaimed
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean unClaimPlot(@Nonnull Plot plot, @Nullable Runnable whenDone, @Nullable QueueCoordinator queue);
@ -81,18 +84,23 @@ public abstract class PlotManager {
*/
public abstract Location getSignLoc(@Nonnull Plot plot);
/*
* Plot set functions (return false if you do not support the specific set
* method).
/**
* Get an array of the plot's component values as string
*
* @param plotId plotId to get components of
* @return array of plot's component values
*/
public abstract String[] getPlotComponents(@Nonnull PlotId plotId);
/**
* Set the specified components to the specified Pattern on the specified plot.
*
* @param plotId id of plot to set component to
* @param component FLOOR, WALL, AIR, MAIN, MIDDLE, OUTLINE, BORDER, ALL (floor, air and main).
* @param blocks Pattern to set component to
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean setComponent(@Nonnull PlotId plotId,
@Nonnull String component,
@ -102,48 +110,60 @@ public abstract class PlotManager {
/**
* Create the road east of the plot (not schematic-based)
*
* @param plot plot to create the road for
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean createRoadEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue);
/**
* Create the road south of the plot (not schematic-based)
*
* @param plot plot to create the road for
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean createRoadSouth(@Nonnull Plot plot, @Nullable QueueCoordinator queue);
/**
* Create the south-east corner of the road (intersection, not schematic-based)
*
* @param plot plot to create the road for
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean createRoadSouthEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue);
/**
* Replace the road to the east of the plot with standard plot blocks (for when merging plots)
*
* @param plot plot to remove east road from
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean removeRoadEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue);
/**
* Replace the road to the south of the plot with standard plot blocks (for when merging plots)
*
* @param plot plot to remove south road from
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean removeRoadSouth(@Nonnull Plot plot, @Nullable QueueCoordinator queue);
/**
* Replace the road to the south east of the plot (intersection) with standard plot blocks (for when merging plots)
*
* @param plot plot to remove south east road intersection from
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean removeRoadSouthEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue);
@ -154,8 +174,9 @@ public abstract class PlotManager {
/**
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED).
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotIds list of PlotIds to finish the merge for
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return false if part if the merge failed, otherwise true if successful.
*/
public abstract boolean finishPlotMerge(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue);
@ -163,8 +184,10 @@ public abstract class PlotManager {
/**
* Finished off an unlink by resetting the top wall block for unlinked plots
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param plotIds list of PlotIds to reset the top wall block of
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return success or not
*/
public abstract boolean finishPlotUnlink(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue);

View File

@ -67,9 +67,9 @@ public abstract class CommentInbox {
* The `whenDone` parameter should be executed when it's done fetching the comments.
* The value should be set to List of comments
*
* @param plot
* @param whenDone
* @return
* @param plot plot
* @param whenDone task to run when comments are obtained
* @return success or not
*/
public abstract boolean getComments(Plot plot, RunnableVal<List<PlotComment>> whenDone);

View File

@ -119,7 +119,7 @@ public class ExpireManager {
/**
* Gets the account last joined - first joined (or Long.MAX_VALUE)
*
* @param uuid
* @param uuid player uuid
* @return result
*/
public long getAccountAge(UUID uuid) {

View File

@ -92,8 +92,8 @@ public class PlotAnalysis {
* This will set the optimal modifiers for the plot analysis based on the current plot ratings<br>
* - Will be used to calibrate the threshold for plot clearing
*
* @param whenDone
* @param threshold
* @param whenDone task to run when done
* @param threshold threshold
*/
public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
if (running) {
@ -495,7 +495,9 @@ public class PlotAnalysis {
/**
* Get correlation coefficient.
*
* @return
* @param n n
* @param sum sum
* @return result
*/
public static double getCC(int n, int sum) {
return 1 - 6 * (double) sum / (n * (n * n - 1));
@ -503,6 +505,9 @@ public class PlotAnalysis {
/**
* Calls {@code Arrays.stream(array).sum()}
*
* @param array array
* @return sum
*/
public static int sum(int[] array) {
return Arrays.stream(array).sum();
@ -512,8 +517,8 @@ public class PlotAnalysis {
* A simple array squaring algorithm.
* - Used for calculating the variance
*
* @param array
* @return
* @param array array
* @return result
*/
public static int[] square(int[] array) {
array = array.clone();
@ -526,8 +531,8 @@ public class PlotAnalysis {
/**
* An optimized lossy standard deviation algorithm.
*
* @param ranks
* @return
* @param ranks ranks
* @return result
*/
public static int[] getSD(int[]... ranks) {
if (ranks.length == 0) {
@ -555,9 +560,8 @@ public class PlotAnalysis {
* - Input is an array of int with a max size of 102400<br>
* - A reduced sample space allows for sorting (and ranking in this case) in linear time
*
* @param input
* @param input
* @return
* @param input input
* @return result
*/
public static int[] rank(int[] input) {
return rank(input, 102400);
@ -566,8 +570,9 @@ public class PlotAnalysis {
/**
* An optimized algorithm for ranking a very specific set of inputs
*
* @param input
* @return
* @param input input
* @param size size
* @return result
*/
public static int[] rank(int[] input, int size) {
int[] cache = new int[size];

View File

@ -128,6 +128,8 @@ public class FlagContainer {
* Add a flag to the container
*
* @param flag Flag to add
* @param <T> flag type
* @param <V> flag value type
* @see #addAll(Collection) to add multiple flags
*/
public <V, T extends PlotFlag<V, ?>> void addFlag(final T flag) {
@ -158,6 +160,9 @@ public class FlagContainer {
* Remove a flag from the container
*
* @param flag Flag to remove
* @param <T> flag type
* @param <V> flag value type
* @return value of flag removed
*/
public <V, T extends PlotFlag<V, ?>> V removeFlag(final T flag) {
final Object value = this.flagMap.remove(flag.getClass());
@ -224,6 +229,7 @@ public class FlagContainer {
* with wildcard generic types.
*
* @param flagClass The {@link PlotFlag} class.
* @return the plot flag
*/
public PlotFlag<?, ?> getFlagErased(Class<?> flagClass) {
final PlotFlag<?, ?> flag = this.flagMap.get(flagClass);

View File

@ -62,10 +62,10 @@ public abstract class NumberFlag<N extends Number & Comparable<N>, F extends Plo
/**
* Parse the raw string input to the number type.
* Throw a {@link FlagParseException} if the number couldn't be parsed.
*
* @param input the string to parse the number from.
* @return the parsed number.
* @throws FlagParseException if the number couldn't be parsed.
*/
@Nonnull protected abstract N parseNumber(String input) throws FlagParseException;
}

View File

@ -50,6 +50,8 @@ public class AreaBoundDelegateQueueCoordinator extends DelegateQueueCoordinator
/**
* Gets the plot area block settings is limited to
*
* @return PlotArea
*/
public PlotArea getArea() {
return this.area;

View File

@ -201,6 +201,8 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
/**
* Gets the int[x,z] chunk coordinates where regeneration should start from
*
* @return int[x, z] of regen start
*/
public int[] getRegenStart() {
return regenStart;
@ -208,6 +210,8 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
/**
* Gets the int[x,z] chunk coordinates where regeneration should finish
*
* @return int[x, z] of regen end
*/
public int[] getRegenEnd() {
return regenEnd;
@ -215,6 +219,8 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
/**
* Whether the queue has a start/end to chunk regeneration
*
* @return if is regenerating queue with int[x,z] start and end
*/
public boolean isRegen() {
return regen;
@ -222,6 +228,8 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
/**
* Gets the map of ChunkCoordinates in {@link BlockVector2} form against the {@link LocalChunk} of cached chunks to be written
*
* @return ConcurrentHashMap of chunks to be accessed
*/
@Nonnull public ConcurrentHashMap<BlockVector2, LocalChunk> getBlockChunks() {
return this.blockChunks;
@ -229,6 +237,8 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
/**
* Forces an {@link LocalChunk} into the list of chunks to be written. Overwrites existing chunks in the map
*
* @param chunk add a LocalChunk to be written to by the queue
*/
public final void setChunk(@Nonnull LocalChunk chunk) {
this.blockChunks.put(BlockVector2.at(chunk.getX(), chunk.getZ()), chunk);

View File

@ -62,6 +62,9 @@ public class ChunkCoordinatorBuilder {
/**
* Set the world
*
* @param world world
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder inWorld(@Nonnull final World world) {
this.world = Preconditions.checkNotNull(world, "World may not be null");
@ -70,6 +73,9 @@ public class ChunkCoordinatorBuilder {
/**
* Add a chunk to be accessed
*
* @param chunkLocation BlockVector2 of chunk to add
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withChunk(@Nonnull final BlockVector2 chunkLocation) {
this.requestedChunks.add(Preconditions.checkNotNull(chunkLocation, "Chunk location may not be null"));
@ -78,6 +84,9 @@ public class ChunkCoordinatorBuilder {
/**
* Add a Collection of chunks to be accessed
*
* @param chunkLocations Collection of BlockVector2 to add
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withChunks(@Nonnull final Collection<BlockVector2> chunkLocations) {
chunkLocations.forEach(this::withChunk);
@ -86,6 +95,10 @@ public class ChunkCoordinatorBuilder {
/**
* Add chunks within a region to be accessed
*
* @param pos1 minimum region location
* @param pos2 maximum region location
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withRegion(@Nonnull Location pos1, @Nonnull Location pos2) {
final int p1x = pos1.getX();
@ -110,6 +123,9 @@ public class ChunkCoordinatorBuilder {
/**
* Set the consumer to be used when a chunk is loaded
*
* @param chunkConsumer Consumer to be used by the ChunkCoordinator
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withConsumer(@Nonnull final Consumer<BlockVector2> chunkConsumer) {
this.chunkConsumer = Preconditions.checkNotNull(chunkConsumer, "Chunk consumer may not be null");
@ -118,6 +134,9 @@ public class ChunkCoordinatorBuilder {
/**
* Set the Runnable to run when all chunks have been accessed
*
* @param whenDone task to run when all chunks are accessed
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withFinalAction(@Nullable final Runnable whenDone) {
if (whenDone == null) {
@ -129,6 +148,9 @@ public class ChunkCoordinatorBuilder {
/**
* Set the max time taken while iterating over and accessing loaded chunks
*
* @param maxIterationTime max iteration time
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withMaxIterationTime(final long maxIterationTime) {
Preconditions.checkArgument(maxIterationTime > 0, "Max iteration time must be positive");
@ -138,6 +160,9 @@ public class ChunkCoordinatorBuilder {
/**
* Set the initial batch size to be used for loading chunks
*
* @param initialBatchSize initial batch size
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withInitialBatchSize(final int initialBatchSize) {
Preconditions.checkArgument(initialBatchSize > 0, "Initial batch size must be positive");
@ -147,6 +172,9 @@ public class ChunkCoordinatorBuilder {
/**
* Set the consumer to be used to handle {@link Throwable}s
*
* @param throwableConsumer consumer to hanble throwables
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder withThrowableConsumer(@Nonnull final Consumer<Throwable> throwableConsumer) {
this.throwableConsumer = Preconditions.checkNotNull(throwableConsumer, "Throwable consumer may not be null");
@ -155,7 +183,10 @@ public class ChunkCoordinatorBuilder {
/**
* Set whether the chunks should be allow to unload after being accessed. This should only be used where the chunks are read from
* and then written to from a separate queue where they're consequently unloaded.
* and then written to from a separate queue where they're consequently unloaded.
*
* @param unloadAfter if to unload chuns afterwards
* @return this ChunkCoordinatorBuilder instance
*/
@Nonnull public ChunkCoordinatorBuilder unloadAfter(final boolean unloadAfter) {
this.unloadAfter = unloadAfter;
@ -164,6 +195,8 @@ public class ChunkCoordinatorBuilder {
/**
* Create a new {@link ChunkCoordinator} instance based on the values in the Builder instance.
*
* @return a new ChunkCoordinator
*/
@Nonnull public ChunkCoordinator build() {
Preconditions.checkNotNull(this.world, "No world was supplied");

View File

@ -45,6 +45,9 @@ public class GlobalBlockQueue {
/**
* Get a new {@link QueueCoordinator} for the given world.
*
* @param world world to get new queue for
* @return new QueueCoordinator for world
*/
@Nonnull public QueueCoordinator getNewQueue(@Nonnull World world) {
QueueCoordinator queue = provider.getNewQueue(world);

View File

@ -54,6 +54,8 @@ public abstract class QueueCoordinator {
/**
* Default constructor requires world to indicate any extents given to {@link QueueCoordinator} also need this constructor.
*
* @param world world as all queues should have this constructor
*/
public QueueCoordinator(@Nullable World world) {
PlotSquared.platform().getInjector().injectMembers(this);
@ -61,6 +63,10 @@ public abstract class QueueCoordinator {
/**
* Get a {@link ScopedQueueCoordinator} limited to the chunk at the specific chunk Coordinates
*
* @param x chunk x coordinate
* @param z chunk z coordinate
* @return a new {@link ScopedQueueCoordinator}
*/
public ScopedQueueCoordinator getForChunk(int x, int z) {
int bx = x << 4;
@ -71,16 +77,22 @@ public abstract class QueueCoordinator {
/**
* Get the size of the queue in chunks
*
* @return size
*/
public abstract int size();
/**
* Set when the queue was last modified
*
* @param modified long of system millis
*/
public abstract void setModified(long modified);
/**
* Returns true if the queue should be forced to be synchronous when enqueued.
*
* @return is force sync
*/
public boolean isForceSync() {
return forceSync;
@ -88,6 +100,8 @@ public abstract class QueueCoordinator {
/**
* Set whether the queue should be forced to be synchronous
*
* @param forceSync force sync or not
*/
public void setForceSync(boolean forceSync) {
this.forceSync = forceSync;
@ -95,6 +109,8 @@ public abstract class QueueCoordinator {
/**
* Get the Chunk Object set to the queue
*
* @return chunk object. Usually the implementation-specific chunk (e.g. bukkit Chunk)
*/
@Nullable public Object getChunkObject() {
return chunkObject;
@ -102,6 +118,8 @@ public abstract class QueueCoordinator {
/**
* Set a chunk object (e.g. the Bukkit Chunk object) to the queue
*
* @param chunkObject chunk object. Usually the implementation-specific chunk (e.g. bukkit Chunk)
*/
public void setChunkObject(@Nonnull Object chunkObject) {
this.chunkObject = chunkObject;
@ -114,6 +132,7 @@ public abstract class QueueCoordinator {
* @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive)
* @param z the z coordinate from 0 to 15 inclusive
* @param id the BlockState to set the block to
* @return success or not
*/
public abstract boolean setBlock(final int x, final int y, final int z, @Nonnull final BlockState id);
@ -124,6 +143,7 @@ public abstract class QueueCoordinator {
* @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive)
* @param z the z coordinate from 0 to 15 inclusive
* @param id the BaseBlock to set the block to
* @return success or not
*/
public abstract boolean setBlock(final int x, final int y, final int z, @Nonnull final BaseBlock id);
@ -134,6 +154,7 @@ public abstract class QueueCoordinator {
* @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive)
* @param z the z coordinate from 0 to 15 inclusive
* @param pattern the pattern to set the block to
* @return success or not
*/
public boolean setBlock(final int x, final int y, final int z, @Nonnull final Pattern pattern) {
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
@ -146,36 +167,59 @@ public abstract class QueueCoordinator {
* @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive)
* @param z the z coordinate from 0 to 15 inclusive
* @param tag the CompoundTag to set the tile to
* @return success or not
*/
public abstract boolean setTile(int x, int y, int z, @Nonnull CompoundTag tag);
/**
* Whether the queue has any tiles being set
*
* @return if setting tiles
*/
public abstract boolean isSettingTiles();
/**
* Get a block at the given coordinates.
*
* @param x block x
* @param y block y
* @param z block z
* @return WorldEdit BlockState
*/
@Nullable public abstract BlockState getBlock(int x, int y, int z);
/**
* Set a biome in XZ. This will likely set to the whole column
*
* @param x x coordinate
* @param z z coordinate
* @param biome biome
* @return success or not
*/
@Deprecated public abstract boolean setBiome(int x, int z, @Nonnull BiomeType biome);
/**
* Set a biome in XYZ
*
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param biome biome
* @return success or not
*/
public abstract boolean setBiome(int x, int y, int z, @Nonnull BiomeType biome);
/**
* Whether the queue has any biomes to be set
*
* @return if setting biomes
*/
public abstract boolean isSettingBiomes();
/**
* Add entities to be created
*
* @param entities list of entities to add to queue
*/
public void addEntities(@Nonnull List<? extends Entity> entities) {
for (Entity e : entities) {
@ -185,51 +229,73 @@ public abstract class QueueCoordinator {
/**
* Add an entity to be created
*
* @param entity entity to add to queue
* @return success or not
*/
public abstract boolean setEntity(@Nonnull Entity entity);
/**
* Get the list of chunks that are added manually. This usually indicated the queue is "read only".
*
* @return list of BlockVector2 of chunks that are to be "read"
*/
@Nonnull public abstract List<BlockVector2> getReadChunks();
/**
* Add a set of {@link BlockVector2} Chunk coordinates to the Read Chunks list
*
* @param readChunks set of BlockVector2 to add to "read" chunks
*/
public abstract void addReadChunks(@Nonnull Set<BlockVector2> readChunks);
/**
* Add a {@link BlockVector2} Chunk coordinate to the Read Chunks list
*
* @param chunk BlockVector2 to add to "read" chunks
*/
public abstract void addReadChunk(@Nonnull BlockVector2 chunk);
/**
* Whether chunks should be unloaded after being accessed
*
* @return if is unloading chunks after accessing them
*/
public abstract boolean isUnloadAfter();
/**
* Set whether chunks should be unloaded after being accessed
*
* @param unloadAfter if to unload chunks after being accessed
*/
public abstract void setUnloadAfter(boolean unloadAfter);
/**
* Get the {@link CuboidRegion} designated for direct regeneration
*
* @return CuboidRegion to regenerate
*/
@Nullable public abstract CuboidRegion getRegenRegion();
/**
* Set the {@link CuboidRegion} designated for direct regeneration
*
* @param regenRegion CuboidRegion to regenerate
*/
public abstract void setRegenRegion(@Nonnull CuboidRegion regenRegion);
/**
* Set a specific chunk at the chunk coordinates XZ to be regenerated.
*
* @param x chunk x
* @param z chunk z
*/
public abstract void regenChunk(int x, int z);
/**
* Get the world the queue is writing to
*
* @return world of the queue
*/
@Nullable public abstract World getWorld();
@ -242,6 +308,8 @@ public abstract class QueueCoordinator {
/**
* Enqueue the queue with the {@link GlobalBlockQueue}
*
* @return success or not
*/
public boolean enqueue() {
return blockQueue.enqueue(this);
@ -259,26 +327,38 @@ public abstract class QueueCoordinator {
/**
* Get the task to be run when all chunks have been accessed
*
* @return task to be run when queue is complete
*/
public abstract Runnable getCompleteTask();
/**
* Set the task to be run when all chunks have been accessed
*
* @param whenDone task to be run when queue is complete
*/
public abstract void setCompleteTask(@Nullable Runnable whenDone);
/**
* Return the chunk consumer set to the queue or null if one is not set
*
* @return Consumer to be executed on each chunk in queue
*/
@Nullable public abstract Consumer<BlockVector2> getChunkConsumer();
/**
* Set the Consumer that will
* Set the Consumer that will be executed on each chunk in queue
*
* @param consumer Consumer to be executed on each chunk in queue
*/
public abstract void setChunkConsumer(@Nonnull Consumer<BlockVector2> consumer);
/**
* Fill a cuboid between two positions with a BlockState
*
* @param pos1 1st cuboid position
* @param pos2 2nd cuboid position
* @param block block to fill
*/
public void setCuboid(@Nonnull Location pos1, @Nonnull Location pos2, @Nonnull BlockState block) {
int yMin = Math.min(pos1.getY(), pos2.getY());
@ -298,6 +378,10 @@ public abstract class QueueCoordinator {
/**
* Fill a cuboid between two positions with a Pattern
*
* @param pos1 1st cuboid position
* @param pos2 2nd cuboid position
* @param blocks pattern to fill
*/
public void setCuboid(@Nonnull Location pos1, @Nonnull Location pos2, @Nonnull Pattern blocks) {
int yMin = Math.min(pos1.getY(), pos2.getY());
@ -317,6 +401,10 @@ public abstract class QueueCoordinator {
/**
* Fill a cuboid between two positions with a BiomeType
*
* @param pos1 1st cuboid position
* @param pos2 2nd cuboid position
* @param biome biome to fill
*/
public void setBiomeCuboid(@Nonnull Location pos1, @Nonnull Location pos2, @Nonnull BiomeType biome) {
int yMin = Math.min(pos1.getY(), pos2.getY());

View File

@ -57,6 +57,9 @@ public abstract class QueueProvider {
/**
* Get a queue for the given world
*
* @param world world
* @return new QueueCoordinator
*/
public abstract QueueCoordinator getNewQueue(@Nonnull World world);
}

View File

@ -207,11 +207,11 @@ public class MathMan {
}
/**
* Returns [x, y, z]
* get the x,y,z unit vector from pitch and yaw specified
*
* @param yaw
* @param pitch
* @return
* @param yaw yaw
* @param pitch pitch
* @return x,y,z unit vector
*/
public static float[] getDirection(float yaw, float pitch) {
double pitch_sin = Math.sin(pitch);
@ -234,10 +234,10 @@ public class MathMan {
/**
* Returns [ pitch, yaw ]
*
* @param x
* @param y
* @param z
* @return
* @param x x
* @param y y
* @param z z
* @return pitch and yaw of x,y,z from 0,0,0
*/
public static float[] getPitchAndYaw(float x, float y, float z) {
float distance = sqrtApprox((z * z) + (x * x));

View File

@ -48,6 +48,7 @@ public class Permissions {
/**
* Check if the owner of the profile has a given (global) permission
*
* @param caller permission holder
* @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false}
*/
@ -58,6 +59,7 @@ public class Permissions {
/**
* Check if the owner of the profile has a given (global) permission
*
* @param caller permission holder
* @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false}
*/
@ -68,10 +70,10 @@ public class Permissions {
/**
* Checks if a PlotPlayer has a permission, and optionally send the no permission message if applicable.
*
* @param player
* @param permission
* @param notify
* @return
* @param player permission holder
* @param permission permission
* @param notify if to notify the permission holder
* @return if permission is had
*/
public static boolean hasPermission(PlotPlayer<?> player, String permission, boolean notify) {
if (!hasPermission(player, permission)) {

View File

@ -60,6 +60,8 @@ public class PremiumVerification {
/**
* Returns true if this plugin is premium
*
* @return if is premium
*/
public static Boolean isPremium() {
return usingPremium == null ? (usingPremium = isPremium(getUserID())) : usingPremium;

View File

@ -130,7 +130,7 @@ public class ReflectionUtils {
* @param name name
* @param types method parameters. can be Class or RefClass
* @return RefMethod object
* @throws RuntimeException if method not found
* @throws NoSuchMethodException if method not found
*/
public RefMethod getMethod(String name, Object... types) throws NoSuchMethodException {
Class[] classes = new Class[types.length];
@ -156,7 +156,7 @@ public class ReflectionUtils {
*
* @param name field name
* @return RefField
* @throws RuntimeException if field not found
* @throws NoSuchFieldException if field not found
*/
public RefField getField(String name) throws NoSuchFieldException {
try {
@ -242,8 +242,8 @@ public class ReflectionUtils {
*
* @param params parameters for constructor
* @return new object
* @throws ReflectiveOperationException
* @throws IllegalArgumentException
* @throws ReflectiveOperationException reflective operation exception
* @throws IllegalArgumentException illegal argument exception
*/
public Object create(Object... params)
throws ReflectiveOperationException, IllegalArgumentException {

View File

@ -78,6 +78,9 @@ public abstract class RegionManager {
* 3 = Mob
* 4 = Boat
* 5 = Misc
*
* @param plot plot
* @return array of counts of entity types
*/
public abstract int[] countEntities(Plot plot);
@ -98,8 +101,13 @@ public abstract class RegionManager {
/**
* Set a number of cuboids to a certain block between two y values.
*
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @param area plot area
* @param regions cuboid regions
* @param blocks pattern
* @param minY y to set from
* @param maxY y to set to
* @param queue Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
* otherwise writes to the queue but does not enqueue.
* @return true if not enqueued, otherwise whether the created queue enqueued.
*/
public boolean setCuboids(final PlotArea area,
@ -124,6 +132,7 @@ public abstract class RegionManager {
/**
* Notify any plugins that may want to modify clear behaviour that a clear is occuring
*
* @param manager plot manager
* @return true if the notified will accept the clear task
*/
public boolean notifyClear(PlotManager manager) {
@ -133,12 +142,21 @@ public abstract class RegionManager {
/**
* Only called when {@link RegionManager#notifyClear(PlotManager)} returns true in specific PlotManagers
*
* @param plot plot
* @param whenDone task to run when complete
* @param manager plot manager
* @return true if the clear worked. False if someone went wrong so P2 can then handle the clear
*/
public abstract boolean handleClear(Plot plot, final Runnable whenDone, PlotManager manager);
/**
* Copy a region to a new location (in the same world)
*
* @param pos1 position 1
* @param pos2 position 2
* @param newPos position to move pos1 to
* @param whenDone task to run when complete
* @return success or not
*/
public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) {
final int relX = newPos.getX() - pos1.getX();
@ -152,14 +170,19 @@ public abstract class RegionManager {
copyFrom
.addReadChunks(new CuboidRegion(BlockVector3.at(pos1.getX(), 0, pos1.getZ()), BlockVector3.at(pos2.getX(), 0, pos2.getZ())).getChunks());
copyTo.setCompleteTask(whenDone);
copyFrom.enqueue();
return true;
return copyFrom.enqueue();
}
/**
* Assumptions:<br>
* - pos1 and pos2 are in the same plot<br>
* It can be harmful to the world if parameters outside this scope are provided
*
* @param pos1 position 1
* @param pos2 position 2
* @param ignoreAugment if to bypass synchronisation ish thing
* @param whenDone task to run when regeneration completed
* @return success or not
*/
public abstract boolean regenerateRegion(Location pos1, Location pos2, boolean ignoreAugment, Runnable whenDone);

View File

@ -251,10 +251,13 @@ public abstract class SchematicHandler {
/**
* Paste a schematic.
*
* @param schematic the schematic object to paste
* @param plot plot to paste in
* @param xOffset offset x to paste it from plot origin
* @param zOffset offset z to paste it from plot origin
* @param schematic the schematic object to paste
* @param plot plot to paste in
* @param xOffset offset x to paste it from plot origin
* @param yOffset offset y to paste it from plot origin
* @param zOffset offset z to paste it from plot origin
* @param autoHeight if to automatically choose height to paste from
* @param whenDone task to run when schematic is pasted
*/
public void paste(final Schematic schematic,
final Plot plot,
@ -357,6 +360,7 @@ public abstract class SchematicHandler {
*
* @param name to check
* @return schematic if found, else null
* @throws UnsupportedFormatException thrown if schematic format is unsupported
*/
public Schematic getSchematic(String name) throws UnsupportedFormatException {
File parent = FileUtils.getFile(PlotSquared.platform().getDirectory(), Settings.Paths.SCHEMATICS);
@ -400,6 +404,7 @@ public abstract class SchematicHandler {
*
* @param file to check
* @return schematic if found, else null
* @throws UnsupportedFormatException thrown if schematic format is unsupported
*/
public Schematic getSchematic(File file) throws UnsupportedFormatException {
if (!file.exists()) {

View File

@ -150,6 +150,8 @@ public final class PlotQuery implements Iterable<Plot> {
/**
* Query for plots based on a search term
*
* @param searchTerm search term to use (uuid, plotID, username)
*
* @return The query instance
*/
@Nonnull public PlotQuery plotsBySearch(@Nonnull final String searchTerm) {
@ -161,6 +163,8 @@ public final class PlotQuery implements Iterable<Plot> {
/**
* Query with a pre-defined result
*
* @param plot to return when Query is searched
*
* @return The query instance
*/
@Nonnull public PlotQuery withPlot(@Nonnull final Plot plot) {

View File

@ -69,6 +69,7 @@ public abstract class TaskManager {
*
* @param string String to remove
* return {@code true} if the value was stored in the map, or {@code false}
* @return if string was actually removed
*/
public static boolean removeFromTeleportQueue(@Nonnull final String string) {
return teleportQueue.remove(string);