SPIGOT-2540: Add nullability annotations to entire Bukkit API

By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
Bukkit/Spigot
2019-03-13 17:42:57 +11:00
parent e069a80fd8
commit 416c865476
565 changed files with 5372 additions and 2008 deletions

View File

@@ -3,6 +3,7 @@ package org.bukkit.generator;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
/**
* A block populator is responsible for generating a small area of blocks.
@@ -25,5 +26,5 @@ public abstract class BlockPopulator {
* @param random The random generator to use
* @param source The chunk to generate for
*/
public abstract void populate(World world, Random random, Chunk source);
public abstract void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source);
}

View File

@@ -11,6 +11,8 @@ import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A chunk generator is responsible for the initial shaping of an entire
@@ -35,6 +37,7 @@ public abstract class ChunkGenerator {
* @param z - 0-15
* @return Biome value
*/
@NotNull
Biome getBiome(int x, int z);
/**
@@ -44,7 +47,7 @@ public abstract class ChunkGenerator {
* @param z - 0-15
* @param bio - Biome value
*/
void setBiome(int x, int z, Biome bio);
void setBiome(int x, int z, @NotNull Biome bio);
}
/**
@@ -71,7 +74,8 @@ public abstract class ChunkGenerator {
* @return ChunkData containing the types for each block created by this
* generator
*/
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
@NotNull
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) {
throw new UnsupportedOperationException("Custom generator is missing required method generateChunkData");
}
@@ -80,7 +84,8 @@ public abstract class ChunkGenerator {
* @param world the world the ChunkData is for
* @return a new ChunkData for world
*/
protected final ChunkData createChunkData(World world) {
@NotNull
protected final ChunkData createChunkData(@NotNull World world) {
return Bukkit.getServer().createChunkData(world);
}
@@ -92,7 +97,7 @@ public abstract class ChunkGenerator {
* @param z Z-coordinate of the block to test
* @return true if the location is valid, otherwise false
*/
public boolean canSpawn(World world, int x, int z) {
public boolean canSpawn(@NotNull World world, int x, int z) {
Block highest = world.getBlockAt(x, world.getHighestBlockYAt(x, z), z);
switch (world.getEnvironment()) {
@@ -113,7 +118,8 @@ public abstract class ChunkGenerator {
* @param world World to apply to
* @return List containing any amount of BlockPopulators
*/
public List<BlockPopulator> getDefaultPopulators(World world) {
@NotNull
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
return new ArrayList<BlockPopulator>();
}
@@ -127,7 +133,8 @@ public abstract class ChunkGenerator {
* @param random Random generator to use in the calculation
* @return Location containing a new spawn point, otherwise null
*/
public Location getFixedSpawnLocation(World world, Random random) {
@Nullable
public Location getFixedSpawnLocation(@NotNull World world, @NotNull Random random) {
return null;
}
@@ -154,7 +161,7 @@ public abstract class ChunkGenerator {
* @param z the z location in the chunk from 0-15 inclusive
* @param material the type to set the block to
*/
public void setBlock(int x, int y, int z, Material material);
public void setBlock(int x, int y, int z, @NotNull Material material);
/**
* Set the block at x,y,z in the chunk data to material.
@@ -166,7 +173,7 @@ public abstract class ChunkGenerator {
* @param z the z location in the chunk from 0-15 inclusive
* @param material the type to set the block to
*/
public void setBlock(int x, int y, int z, MaterialData material);
public void setBlock(int x, int y, int z, @NotNull MaterialData material);
/**
* Set the block at x,y,z in the chunk data to material.
@@ -178,7 +185,7 @@ public abstract class ChunkGenerator {
* @param z the z location in the chunk from 0-15 inclusive
* @param blockData the type to set the block to
*/
public void setBlock(int x, int y, int z, BlockData blockData);
public void setBlock(int x, int y, int z, @NotNull BlockData blockData);
/**
* Set a region of this chunk from xMin, yMin, zMin (inclusive)
@@ -194,7 +201,7 @@ public abstract class ChunkGenerator {
* @param zMax maximum z location (exclusive) in the chunk to set
* @param material the type to set the blocks to
*/
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material);
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material);
/**
* Set a region of this chunk from xMin, yMin, zMin (inclusive)
@@ -210,7 +217,7 @@ public abstract class ChunkGenerator {
* @param zMax maximum z location (exclusive) in the chunk to set
* @param material the type to set the blocks to
*/
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material);
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material);
/**
* Set a region of this chunk from xMin, yMin, zMin (inclusive) to xMax,
@@ -226,7 +233,7 @@ public abstract class ChunkGenerator {
* @param zMax maximum z location (exclusive) in the chunk to set
* @param blockData the type to set the blocks to
*/
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData);
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData);
/**
* Get the type of the block at x, y, z.
@@ -238,10 +245,11 @@ public abstract class ChunkGenerator {
* @param z the z location in the chunk from 0-15 inclusive
* @return the type of the block or Material.AIR if x, y or z are outside the chunk's bounds
*/
@NotNull
public Material getType(int x, int y, int z);
/**
* Get the type and data of the block at x, y ,z.
* Get the type and data of the block at x, y, z.
*
* Getting blocks outside the chunk's bounds returns air.
*
@@ -250,18 +258,20 @@ public abstract class ChunkGenerator {
* @param z the z location in the chunk from 0-15 inclusive
* @return the type and data of the block or the MaterialData for air if x, y or z are outside the chunk's bounds
*/
@NotNull
public MaterialData getTypeAndData(int x, int y, int z);
/**
* Get the type and data of the block at x, y ,z.
* Get the type and data of the block at x, y, z.
*
* Getting blocks outside the chunk's bounds returns air.
*
* @param x the x location in the chunk from 0-15 inclusive
* @param y the y location in the chunk from 0 (inclusive) - maxHeight (exclusive)
* @param z the z location in the chunk from 0-15 inclusive
* @return the data of the block or the MaterialData for air if x, y or z are outside the chunk's bounds
* @return the data of the block or the BlockData for air if x, y or z are outside the chunk's bounds
*/
@NotNull
public BlockData getBlockData(int x, int y, int z);
/**