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

@@ -2,6 +2,7 @@ package org.bukkit.block;
import org.bukkit.DyeColor;
import org.bukkit.block.banner.Pattern;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -15,6 +16,7 @@ public interface Banner extends BlockState {
*
* @return the base color
*/
@NotNull
DyeColor getBaseColor();
/**
@@ -24,13 +26,14 @@ public interface Banner extends BlockState {
*
* @param color the base color
*/
void setBaseColor(DyeColor color);
void setBaseColor(@NotNull DyeColor color);
/**
* Returns a list of patterns on this banner
*
* @return the patterns
*/
@NotNull
List<Pattern> getPatterns();
/**
@@ -38,7 +41,7 @@ public interface Banner extends BlockState {
*
* @param patterns the new list of patterns
*/
void setPatterns(List<Pattern> patterns);
void setPatterns(@NotNull List<Pattern> patterns);
/**
* Adds a new pattern on top of the existing
@@ -46,7 +49,7 @@ public interface Banner extends BlockState {
*
* @param pattern the new pattern to add
*/
void addPattern(Pattern pattern);
void addPattern(@NotNull Pattern pattern);
/**
* Returns the pattern at the specified index
@@ -54,6 +57,7 @@ public interface Banner extends BlockState {
* @param i the index
* @return the pattern
*/
@NotNull
Pattern getPattern(int i);
/**
@@ -62,6 +66,7 @@ public interface Banner extends BlockState {
* @param i the index
* @return the removed pattern
*/
@NotNull
Pattern removePattern(int i);
/**
@@ -70,7 +75,7 @@ public interface Banner extends BlockState {
* @param i the index
* @param pattern the new pattern
*/
void setPattern(int i, Pattern pattern);
void setPattern(int i, @NotNull Pattern pattern);
/**
* Returns the number of patterns on this

View File

@@ -6,15 +6,19 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.BeaconInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a beacon.
*/
public interface Beacon extends Container, Nameable {
@NotNull
@Override
BeaconInventory getInventory();
@NotNull
@Override
BeaconInventory getSnapshotInventory();
@@ -27,6 +31,7 @@ public interface Beacon extends Container, Nameable {
* @return the players in range
* @throws IllegalStateException if this block state is not placed
*/
@NotNull
Collection<LivingEntity> getEntitiesInRange();
/**
@@ -43,6 +48,7 @@ public interface Beacon extends Container, Nameable {
*
* @return the primary effect or null if not set
*/
@Nullable
PotionEffect getPrimaryEffect();
/**
@@ -50,13 +56,14 @@ public interface Beacon extends Container, Nameable {
*
* @param effect new primary effect
*/
void setPrimaryEffect(PotionEffectType effect);
void setPrimaryEffect(@Nullable PotionEffectType effect);
/**
* Returns the secondary effect set on the beacon.
*
* @return the secondary effect or null if no secondary effect
*/
@Nullable
PotionEffect getSecondaryEffect();
/**
@@ -65,5 +72,5 @@ public interface Beacon extends Container, Nameable {
*
* @param effect desired secondary effect
*/
void setSecondaryEffect(PotionEffectType effect);
void setSecondaryEffect(@Nullable PotionEffectType effect);
}

View File

@@ -4,9 +4,9 @@ import java.util.Collection;
import org.bukkit.Chunk;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.Location;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
@@ -14,6 +14,9 @@ import org.bukkit.metadata.Metadatable;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a block. This is a live object, and only one Block may exist for
@@ -42,6 +45,7 @@ public interface Block extends Metadatable {
*
* @return block specific data
*/
@NotNull
BlockData getBlockData();
/**
@@ -52,6 +56,7 @@ public interface Block extends Metadatable {
* @param modZ Z-coordinate offset
* @return Block at the given offsets
*/
@NotNull
Block getRelative(int modX, int modY, int modZ);
/**
@@ -63,7 +68,8 @@ public interface Block extends Metadatable {
* @return Block at the given face
* @see #getRelative(BlockFace, int)
*/
Block getRelative(BlockFace face);
@NotNull
Block getRelative(@NotNull BlockFace face);
/**
* Gets the block at the given distance of the given face
@@ -81,13 +87,15 @@ public interface Block extends Metadatable {
* @param distance Distance to get the block at
* @return Block at the given face
*/
Block getRelative(BlockFace face, int distance);
@NotNull
Block getRelative(@NotNull BlockFace face, int distance);
/**
* Gets the type of this block
*
* @return block type
*/
@NotNull
Material getType();
/**
@@ -121,6 +129,7 @@ public interface Block extends Metadatable {
*
* @return World containing this block
*/
@NotNull
World getWorld();
/**
@@ -149,6 +158,7 @@ public interface Block extends Metadatable {
*
* @return Location of block
*/
@NotNull
Location getLocation();
/**
@@ -160,13 +170,16 @@ public interface Block extends Metadatable {
* @param loc the location to copy into
* @return The Location object provided or null
*/
Location getLocation(Location loc);
@Contract("null -> null; !null -> !null")
@Nullable
Location getLocation(@Nullable Location loc);
/**
* Gets the chunk which contains this block
*
* @return Containing Chunk
*/
@NotNull
Chunk getChunk();
/**
@@ -174,7 +187,7 @@ public interface Block extends Metadatable {
*
* @param data new block specific data
*/
void setBlockData(BlockData data);
void setBlockData(@NotNull BlockData data);
/**
* Sets the complete data for this block
@@ -195,14 +208,14 @@ public interface Block extends Metadatable {
* @param data new block specific data
* @param applyPhysics false to cancel physics from the changed block
*/
void setBlockData(BlockData data, boolean applyPhysics);
void setBlockData(@NotNull BlockData data, boolean applyPhysics);
/**
* Sets the type of this block
*
* @param type Material to change this block to
*/
void setType(Material type);
void setType(@NotNull Material type);
/**
* Sets the type of this block
@@ -223,7 +236,7 @@ public interface Block extends Metadatable {
* @param type Material to change this block to
* @param applyPhysics False to cancel physics on the changed block.
*/
void setType(Material type, boolean applyPhysics);
void setType(@NotNull Material type, boolean applyPhysics);
/**
* Gets the face relation of this block compared to the given block.
@@ -241,7 +254,8 @@ public interface Block extends Metadatable {
* @param block Block to compare against this block
* @return BlockFace of this block which has the requested block, or null
*/
BlockFace getFace(Block block);
@Nullable
BlockFace getFace(@NotNull Block block);
/**
* Captures the current state of this block. You may then cast that state
@@ -252,6 +266,7 @@ public interface Block extends Metadatable {
*
* @return BlockState with the current state of this block.
*/
@NotNull
BlockState getState();
/**
@@ -259,6 +274,7 @@ public interface Block extends Metadatable {
*
* @return Biome type containing this block
*/
@NotNull
Biome getBiome();
/**
@@ -266,7 +282,7 @@ public interface Block extends Metadatable {
*
* @param bio new Biome type for this block
*/
void setBiome(Biome bio);
void setBiome(@NotNull Biome bio);
/**
* Returns true if the block is being powered by Redstone.
@@ -288,7 +304,7 @@ public interface Block extends Metadatable {
* @param face The block face
* @return True if the block face is powered.
*/
boolean isBlockFacePowered(BlockFace face);
boolean isBlockFacePowered(@NotNull BlockFace face);
/**
* Returns true if the block face is being indirectly powered by Redstone.
@@ -296,7 +312,7 @@ public interface Block extends Metadatable {
* @param face The block face
* @return True if the block face is indirectly powered.
*/
boolean isBlockFaceIndirectlyPowered(BlockFace face);
boolean isBlockFaceIndirectlyPowered(@NotNull BlockFace face);
/**
* Returns the redstone power being provided to this block face
@@ -305,7 +321,7 @@ public interface Block extends Metadatable {
* block itself
* @return The power level.
*/
int getBlockPower(BlockFace face);
int getBlockPower(@NotNull BlockFace face);
/**
* Returns the redstone power being provided to this block
@@ -356,6 +372,7 @@ public interface Block extends Metadatable {
*
* @return reaction
*/
@NotNull
PistonMoveReaction getPistonMoveReaction();
/**
@@ -372,13 +389,14 @@ public interface Block extends Metadatable {
* @param tool The tool or item in hand used for digging
* @return true if the block was destroyed
*/
boolean breakNaturally(ItemStack tool);
boolean breakNaturally(@NotNull ItemStack tool);
/**
* Returns a list of items which would drop by destroying this block
*
* @return a list of dropped items for this type of block
*/
@NotNull
Collection<ItemStack> getDrops();
/**
@@ -388,7 +406,8 @@ public interface Block extends Metadatable {
* @param tool The tool or item in hand used for digging
* @return a list of dropped items for this type of block
*/
Collection<ItemStack> getDrops(ItemStack tool);
@NotNull
Collection<ItemStack> getDrops(@NotNull ItemStack tool);
/**
* Checks if this block is passable.
@@ -414,7 +433,8 @@ public interface Block extends Metadatable {
* @param fluidCollisionMode the fluid collision mode
* @return the ray trace hit result, or <code>null</code> if there is no hit
*/
RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode);
@Nullable
RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode);
/**
* Gets the approximate bounding box for this block.
@@ -430,5 +450,6 @@ public interface Block extends Metadatable {
*
* @return the approximate bounding box of the block
*/
@NotNull
BoundingBox getBoundingBox();
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.block;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Represents the face of a block
@@ -74,6 +75,7 @@ public enum BlockFace {
*
* @return the normal vector
*/
@NotNull
public Vector getDirection() {
Vector direction = new Vector(modX, modY, modZ);
if (modX != 0 || modY != 0 || modZ != 0) {
@@ -82,6 +84,7 @@ public enum BlockFace {
return direction;
}
@NotNull
public BlockFace getOppositeFace() {
switch (this) {
case NORTH:

View File

@@ -7,6 +7,9 @@ import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.Metadatable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a block, which will not change
@@ -25,6 +28,7 @@ public interface BlockState extends Metadatable {
* @return the block represented by this block state
* @throws IllegalStateException if this block state is not placed
*/
@NotNull
Block getBlock();
/**
@@ -32,6 +36,7 @@ public interface BlockState extends Metadatable {
*
* @return block specific metadata
*/
@NotNull
MaterialData getData();
/**
@@ -39,6 +44,7 @@ public interface BlockState extends Metadatable {
*
* @return block specific data
*/
@NotNull
BlockData getBlockData();
/**
@@ -46,6 +52,7 @@ public interface BlockState extends Metadatable {
*
* @return block type
*/
@NotNull
Material getType();
/**
@@ -62,6 +69,7 @@ public interface BlockState extends Metadatable {
* @return the world containing the block represented by this block state
* @throws IllegalStateException if this block state is not placed
*/
@NotNull
World getWorld();
/**
@@ -92,6 +100,7 @@ public interface BlockState extends Metadatable {
*
* @return the location
*/
@NotNull
Location getLocation();
/**
@@ -105,7 +114,9 @@ public interface BlockState extends Metadatable {
* @param loc the location to copy into
* @return The Location object provided or null
*/
Location getLocation(Location loc);
@Contract("null -> null; !null -> !null")
@Nullable
Location getLocation(@Nullable Location loc);
/**
* Gets the chunk which contains the block represented by this block state.
@@ -113,6 +124,7 @@ public interface BlockState extends Metadatable {
* @return the containing Chunk
* @throws IllegalStateException if this block state is not placed
*/
@NotNull
Chunk getChunk();
/**
@@ -120,21 +132,21 @@ public interface BlockState extends Metadatable {
*
* @param data New block specific metadata
*/
void setData(MaterialData data);
void setData(@NotNull MaterialData data);
/**
* Sets the data for this block state.
*
* @param data New block specific data
*/
void setBlockData(BlockData data);
void setBlockData(@NotNull BlockData data);
/**
* Sets the type of this block state.
*
* @param type Material to change this block state to
*/
void setType(Material type);
void setType(@NotNull Material type);
/**
* Attempts to update the block represented by this state, setting it to

View File

@@ -2,6 +2,7 @@ package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.BrewerInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a brewing stand.
@@ -36,9 +37,11 @@ public interface BrewingStand extends Container, Nameable {
*/
void setFuelLevel(int level);
@NotNull
@Override
BrewerInventory getInventory();
@NotNull
@Override
BrewerInventory getSnapshotInventory();
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.Inventory;
import org.bukkit.loot.Lootable;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a chest.
@@ -23,5 +24,6 @@ public interface Chest extends Container, Nameable, Lootable {
*
* @return the inventory
*/
@NotNull
Inventory getBlockInventory();
}

View File

@@ -1,5 +1,8 @@
package org.bukkit.block;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a command block.
*/
@@ -12,6 +15,7 @@ public interface CommandBlock extends BlockState {
*
* @return Command that this CommandBlock will run when powered.
*/
@NotNull
public String getCommand();
/**
@@ -21,7 +25,7 @@ public interface CommandBlock extends BlockState {
*
* @param command Command that this CommandBlock will run when powered.
*/
public void setCommand(String command);
public void setCommand(@Nullable String command);
/**
* Gets the name of this CommandBlock. The name is used with commands
@@ -30,6 +34,7 @@ public interface CommandBlock extends BlockState {
*
* @return Name of this CommandBlock.
*/
@NotNull
public String getName();
/**
@@ -39,5 +44,5 @@ public interface CommandBlock extends BlockState {
*
* @param name New name for this CommandBlock.
*/
public void setName(String name);
public void setName(@Nullable String name);
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.block;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a container block.
@@ -19,6 +20,7 @@ public interface Container extends BlockState, InventoryHolder, Lockable {
*
* @return the inventory
*/
@NotNull
@Override
Inventory getInventory();
@@ -32,5 +34,6 @@ public interface Container extends BlockState, InventoryHolder, Lockable {
*
* @return the captured inventory snapshot
*/
@NotNull
Inventory getSnapshotInventory();
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.block;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a creature spawner.
@@ -12,6 +13,7 @@ public interface CreatureSpawner extends BlockState {
*
* @return The creature type.
*/
@NotNull
public EntityType getSpawnedType();
/**
@@ -19,7 +21,7 @@ public interface CreatureSpawner extends BlockState {
*
* @param creatureType The creature type.
*/
public void setSpawnedType(EntityType creatureType);
public void setSpawnedType(@NotNull EntityType creatureType);
/**
* Set the spawner mob type.
@@ -29,7 +31,7 @@ public interface CreatureSpawner extends BlockState {
* {@link #setSpawnedType(org.bukkit.entity.EntityType)}.
*/
@Deprecated
public void setCreatureTypeByName(String creatureType);
public void setCreatureTypeByName(@NotNull String creatureType);
/**
* Get the spawner's creature type.
@@ -38,6 +40,7 @@ public interface CreatureSpawner extends BlockState {
* @deprecated magic value, use {@link #getSpawnedType()}.
*/
@Deprecated
@NotNull
public String getCreatureTypeName();
/**

View File

@@ -3,6 +3,7 @@ package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.loot.Lootable;
import org.bukkit.projectiles.BlockProjectileSource;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a dispenser.
@@ -18,6 +19,7 @@ public interface Dispenser extends Container, Nameable, Lootable {
* @return a BlockProjectileSource if valid, otherwise null
* @throws IllegalStateException if this block state is not placed
*/
@Nullable
public BlockProjectileSource getBlockProjectileSource();
/**

View File

@@ -5,6 +5,8 @@ import org.bukkit.World;
import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a double chest.
@@ -12,26 +14,31 @@ import org.bukkit.inventory.InventoryHolder;
public class DoubleChest implements InventoryHolder {
private DoubleChestInventory inventory;
public DoubleChest(DoubleChestInventory chest) {
public DoubleChest(@NotNull DoubleChestInventory chest) {
inventory = chest;
}
@NotNull
public Inventory getInventory() {
return inventory;
}
@Nullable
public InventoryHolder getLeftSide() {
return inventory.getLeftSide().getHolder();
}
@Nullable
public InventoryHolder getRightSide() {
return inventory.getRightSide().getHolder();
}
@NotNull
public Location getLocation() {
return getInventory().getLocation();
}
@Nullable
public World getWorld() {
return getLocation().getWorld();
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.block;
import org.bukkit.Location;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of an end gateway.
@@ -15,6 +16,7 @@ public interface EndGateway extends BlockState {
*
* @return the gateway exit location
*/
@Nullable
Location getExitLocation();
/**
@@ -26,7 +28,7 @@ public interface EndGateway extends BlockState {
* @param location the new exit location
* @throws IllegalArgumentException for differing worlds
*/
void setExitLocation(Location location);
void setExitLocation(@Nullable Location location);
/**
* Gets whether this gateway will teleport entities directly to

View File

@@ -1,6 +1,7 @@
package org.bukkit.block;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a flower pot.
@@ -14,6 +15,7 @@ public interface FlowerPot extends BlockState {
*
* @return item present, or null for empty.
*/
@Nullable
MaterialData getContents();
/**
@@ -24,5 +26,5 @@ public interface FlowerPot extends BlockState {
*
* @param item new item, or null for empty.
*/
void setContents(MaterialData item);
void setContents(@Nullable MaterialData item);
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.FurnaceInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a furnace.
@@ -61,9 +62,11 @@ public interface Furnace extends Container, Nameable {
*/
public void setCookTimeTotal(int cookTimeTotal);
@NotNull
@Override
public FurnaceInventory getInventory();
@NotNull
@Override
public FurnaceInventory getSnapshotInventory();
}

View File

@@ -2,6 +2,8 @@ package org.bukkit.block;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a jukebox.
@@ -13,6 +15,7 @@ public interface Jukebox extends BlockState {
*
* @return The record Material, or AIR if none is inserted
*/
@NotNull
public Material getPlaying();
/**
@@ -20,13 +23,14 @@ public interface Jukebox extends BlockState {
*
* @param record The record Material, or null/AIR to stop playing
*/
public void setPlaying(Material record);
public void setPlaying(@Nullable Material record);
/**
* Gets the record item inserted into the jukebox.
*
* @return a copy of the inserted record, or an air stack if none
*/
@NotNull
public ItemStack getRecord();
/**
@@ -34,7 +38,7 @@ public interface Jukebox extends BlockState {
*
* @param record the record to insert or null/AIR to empty
*/
public void setRecord(ItemStack record);
public void setRecord(@Nullable ItemStack record);
/**
* Checks if the jukebox is playing a record.

View File

@@ -1,5 +1,8 @@
package org.bukkit.block;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a block (usually a container) that may be locked. When a lock is
* active an item with a name corresponding to the key will be required to open
@@ -19,6 +22,7 @@ public interface Lockable {
*
* @return the key needed.
*/
@NotNull
String getLock();
/**
@@ -27,5 +31,5 @@ public interface Lockable {
*
* @param key the key required to access the container.
*/
void setLock(String key);
void setLock(@Nullable String key);
}

View File

@@ -1,5 +1,7 @@
package org.bukkit.block;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -60,6 +62,7 @@ public enum PistonMoveReaction {
* @deprecated Magic value
*/
@Deprecated
@Nullable
public static PistonMoveReaction getById(int id) {
return byId.get(id);
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.block;
import org.bukkit.DyeColor;
import org.bukkit.Nameable;
import org.bukkit.loot.Lootable;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a ShulkerBox.
@@ -14,5 +15,6 @@ public interface ShulkerBox extends Container, Nameable, Lootable {
*
* @return the {@link DyeColor} of this ShulkerBox
*/
@NotNull
public DyeColor getColor();
}

View File

@@ -1,5 +1,7 @@
package org.bukkit.block;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of either a SignPost or a WallSign.
*/
@@ -10,6 +12,7 @@ public interface Sign extends BlockState {
*
* @return Array of Strings containing each line of text
*/
@NotNull
public String[] getLines();
/**
@@ -21,6 +24,7 @@ public interface Sign extends BlockState {
* @throws IndexOutOfBoundsException Thrown when the line does not exist
* @return Text on the given line
*/
@NotNull
public String getLine(int index) throws IndexOutOfBoundsException;
/**
@@ -33,7 +37,7 @@ public interface Sign extends BlockState {
* @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3
*/
public void setLine(int index, String line) throws IndexOutOfBoundsException;
public void setLine(int index, @NotNull String line) throws IndexOutOfBoundsException;
/**
* Marks whether this sign can be edited by players.

View File

@@ -4,6 +4,9 @@ import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.SkullType;
import org.bukkit.block.data.BlockData;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a skull block.
@@ -24,6 +27,7 @@ public interface Skull extends BlockState {
* @deprecated See {@link #getOwningPlayer()}.
*/
@Deprecated
@Nullable
public String getOwner();
/**
@@ -37,7 +41,8 @@ public interface Skull extends BlockState {
* @deprecated see {@link #setOwningPlayer(org.bukkit.OfflinePlayer)}.
*/
@Deprecated
public boolean setOwner(String name);
@Contract("null -> false")
public boolean setOwner(@Nullable String name);
/**
* Get the player which owns the skull. This player may appear as the
@@ -45,6 +50,7 @@ public interface Skull extends BlockState {
*
* @return owning player
*/
@Nullable
public OfflinePlayer getOwningPlayer();
/**
@@ -53,7 +59,7 @@ public interface Skull extends BlockState {
*
* @param player the owning player
*/
public void setOwningPlayer(OfflinePlayer player);
public void setOwningPlayer(@NotNull OfflinePlayer player);
/**
* Gets the rotation of the skull in the world (or facing direction if this
@@ -63,6 +69,7 @@ public interface Skull extends BlockState {
* @deprecated use {@link BlockData}
*/
@Deprecated
@NotNull
public BlockFace getRotation();
/**
@@ -73,7 +80,7 @@ public interface Skull extends BlockState {
* @deprecated use {@link BlockData}
*/
@Deprecated
public void setRotation(BlockFace rotation);
public void setRotation(@NotNull BlockFace rotation);
/**
* Gets the type of skull
@@ -82,6 +89,7 @@ public interface Skull extends BlockState {
* @deprecated check {@link Material} instead
*/
@Deprecated
@NotNull
public SkullType getSkullType();
/**
@@ -91,5 +99,6 @@ public interface Skull extends BlockState {
* @deprecated check {@link Material} instead
*/
@Deprecated
@Contract("_ -> fail")
public void setSkullType(SkullType skullType);
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.block.structure.StructureRotation;
import org.bukkit.block.structure.UsageMode;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.BlockVector;
import org.jetbrains.annotations.NotNull;
/**
* Represents a structure block that can save and load blocks from a file. They
@@ -17,6 +18,7 @@ public interface Structure extends BlockState {
*
* @return structure name
*/
@NotNull
String getStructureName();
/**
@@ -27,21 +29,22 @@ public interface Structure extends BlockState {
*
* @param name the case-sensitive name of this structure
*/
void setStructureName(String name);
void setStructureName(@NotNull String name);
/**
* Get the name of who created this structure.
*
* @return the name of whoever created this structure.
*/
@NotNull
String getAuthor();
/**
* Set the name of whoever created this structure.
*
* @param author whoever created this structure
* @param author whoever created this structure (not empty)
*/
void setAuthor(String author);
void setAuthor(@NotNull String author);
/**
* Set the name of whoever created this structure using a
@@ -49,7 +52,7 @@ public interface Structure extends BlockState {
*
* @param livingEntity the entity who created this structure
*/
void setAuthor(LivingEntity livingEntity);
void setAuthor(@NotNull LivingEntity livingEntity);
/**
* The relative position of the structure outline based on the position of
@@ -59,6 +62,7 @@ public interface Structure extends BlockState {
* @return a Location which contains the relative distance this structure is
* from the structure block.
*/
@NotNull
BlockVector getRelativePosition();
/**
@@ -68,7 +72,7 @@ public interface Structure extends BlockState {
* @param vector the {@link BlockVector} containing the relative origin
* coordinates of this structure.
*/
void setRelativePosition(BlockVector vector);
void setRelativePosition(@NotNull BlockVector vector);
/**
* The distance to the opposite corner of this structure. The maximum
@@ -79,6 +83,7 @@ public interface Structure extends BlockState {
* @return a {@link BlockVector} which contains the total size of the
* structure.
*/
@NotNull
BlockVector getStructureSize();
/**
@@ -88,20 +93,21 @@ public interface Structure extends BlockState {
* @param vector the {@link BlockVector} containing the size of this
* structure, based off of the origin coordinates.
*/
void setStructureSize(BlockVector vector);
void setStructureSize(@NotNull BlockVector vector);
/**
* Sets the mirroring of the structure.
*
* @param mirror the new mirroring method
*/
void setMirror(Mirror mirror);
void setMirror(@NotNull Mirror mirror);
/**
* How this structure is mirrored.
*
* @return the current mirroring method
*/
@NotNull
Mirror getMirror();
/**
@@ -109,13 +115,14 @@ public interface Structure extends BlockState {
*
* @param rotation the new rotation
*/
void setRotation(StructureRotation rotation);
void setRotation(@NotNull StructureRotation rotation);
/**
* Get how this structure is rotated.
*
* @return the new rotation
*/
@NotNull
StructureRotation getRotation();
/**
@@ -123,13 +130,14 @@ public interface Structure extends BlockState {
*
* @param mode the new mode to set.
*/
void setUsageMode(UsageMode mode);
void setUsageMode(@NotNull UsageMode mode);
/**
* Get the {@link UsageMode} of this structure block.
*
* @return the mode this block is currently in.
*/
@NotNull
UsageMode getUsageMode();
/**
@@ -220,7 +228,7 @@ public interface Structure extends BlockState {
*
* @param metadata the function to perform on the selected location
*/
void setMetadata(String metadata);
void setMetadata(@NotNull String metadata);
/**
* Get the metadata function this structure block will perform when
@@ -230,5 +238,6 @@ public interface Structure extends BlockState {
*
* @return the function that will be performed when this block is activated
*/
@NotNull
String getMetadata();
}

View File

@@ -6,6 +6,7 @@ import java.util.NoSuchElementException;
import org.bukkit.DyeColor;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.NotNull;
@SerializableAs("Pattern")
public class Pattern implements ConfigurationSerializable {
@@ -23,7 +24,7 @@ public class Pattern implements ConfigurationSerializable {
* @param color the pattern color
* @param pattern the pattern type
*/
public Pattern(DyeColor color, PatternType pattern) {
public Pattern(@NotNull DyeColor color, @NotNull PatternType pattern) {
this.color = color;
this.pattern = pattern;
}
@@ -33,12 +34,12 @@ public class Pattern implements ConfigurationSerializable {
*
* @param map the map to deserialize from
*/
public Pattern(Map<String, Object> map) {
public Pattern(@NotNull Map<String, Object> map) {
color = DyeColor.legacyValueOf(getString(map, COLOR));
pattern = PatternType.getByIdentifier(getString(map, PATTERN));
}
private static String getString(Map<?, ?> map, Object key) {
private static String getString(@NotNull Map<?, ?> map, @NotNull Object key) {
Object str = map.get(key);
if (str instanceof String) {
return (String) str;
@@ -46,6 +47,7 @@ public class Pattern implements ConfigurationSerializable {
throw new NoSuchElementException(map + " does not contain " + key);
}
@NotNull
@Override
public Map<String, Object> serialize() {
return ImmutableMap.<String, Object>of(
@@ -59,6 +61,7 @@ public class Pattern implements ConfigurationSerializable {
*
* @return the color of the pattern
*/
@NotNull
public DyeColor getColor() {
return color;
}
@@ -68,6 +71,7 @@ public class Pattern implements ConfigurationSerializable {
*
* @return the pattern type
*/
@NotNull
public PatternType getPattern() {
return pattern;
}

View File

@@ -1,5 +1,9 @@
package org.bukkit.block.banner;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -53,7 +57,7 @@ public enum PatternType {
}
}
private PatternType(String key) {
private PatternType(@NotNull String key) {
this.identifier = key;
}
@@ -63,6 +67,7 @@ public enum PatternType {
*
* @return the pattern's identifier
*/
@NotNull
public String getIdentifier() {
return identifier;
}
@@ -74,7 +79,9 @@ public enum PatternType {
* @param identifier the identifier
* @return the matched pattern type or null
*/
public static PatternType getByIdentifier(String identifier) {
@Contract("null -> null")
@Nullable
public static PatternType getByIdentifier(@Nullable String identifier) {
return byString.get(identifier);
}
}

View File

@@ -1,5 +1,7 @@
package org.bukkit.block.data;
import org.jetbrains.annotations.NotNull;
/**
* 'half' denotes which half of a two block tall material this block is.
* <br>
@@ -12,6 +14,7 @@ public interface Bisected extends BlockData {
*
* @return the 'half' value
*/
@NotNull
Half getHalf();
/**
@@ -19,7 +22,7 @@ public interface Bisected extends BlockData {
*
* @param half the new 'half' value
*/
void setHalf(Half half);
void setHalf(@NotNull Half half);
/**
* The half of a vertically bisected block.

View File

@@ -2,6 +2,8 @@ package org.bukkit.block.data;
import org.bukkit.Material;
import org.bukkit.Server;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface BlockData extends Cloneable {
@@ -10,6 +12,7 @@ public interface BlockData extends Cloneable {
*
* @return the material
*/
@NotNull
Material getMaterial();
/**
@@ -19,6 +22,7 @@ public interface BlockData extends Cloneable {
*
* @return serialized data string for this block
*/
@NotNull
String getAsString();
/**
@@ -47,6 +51,7 @@ public interface BlockData extends Cloneable {
*
* @return serialized data string for this block
*/
@NotNull
String getAsString(boolean hideUnspecified);
/**
@@ -61,7 +66,8 @@ public interface BlockData extends Cloneable {
* @param data the data to merge from
* @return a new instance of this blockdata with the merged data
*/
BlockData merge(BlockData data);
@NotNull
BlockData merge(@NotNull BlockData data);
/**
* Checks if the specified BlockData matches this block data.
@@ -78,12 +84,13 @@ public interface BlockData extends Cloneable {
* @param data the data to match against (normally a parsed constant)
* @return if there is a match
*/
boolean matches(BlockData data);
boolean matches(@Nullable BlockData data);
/**
* Returns a copy of this BlockData.
*
* @return a copy of the block data
*/
@NotNull
BlockData clone();
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data;
import java.util.Set;
import org.bukkit.block.BlockFace;
import org.jetbrains.annotations.NotNull;
/**
* 'facing' represents the face towards which the block is pointing.
@@ -16,6 +17,7 @@ public interface Directional extends BlockData {
*
* @return the 'facing' value
*/
@NotNull
BlockFace getFacing();
/**
@@ -23,12 +25,13 @@ public interface Directional extends BlockData {
*
* @param facing the new 'facing' value
*/
void setFacing(BlockFace facing);
void setFacing(@NotNull BlockFace facing);
/**
* Gets the faces which are applicable to this block.
*
* @return the allowed 'facing' values
*/
@NotNull
Set<BlockFace> getFaces();
}

View File

@@ -2,6 +2,8 @@ package org.bukkit.block.data;
import java.util.Set;
import org.bukkit.block.BlockFace;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This class encompasses the 'north', 'east', 'south', 'west', 'up', 'down'
@@ -19,7 +21,7 @@ public interface MultipleFacing extends BlockData {
* @param face to check
* @return if face is enabled
*/
boolean hasFace(BlockFace face);
boolean hasFace(@NotNull BlockFace face);
/**
* Set whether this block has the specified face enabled.
@@ -27,13 +29,14 @@ public interface MultipleFacing extends BlockData {
* @param face to set
* @param has the face
*/
void setFace(BlockFace face, boolean has);
void setFace(@Nullable BlockFace face, boolean has);
/**
* Get all of the faces which are enabled on this block.
*
* @return all faces enabled
*/
@NotNull
Set<BlockFace> getFaces();
/**
@@ -41,5 +44,6 @@ public interface MultipleFacing extends BlockData {
*
* @return all allowed faces
*/
@NotNull
Set<BlockFace> getAllowedFaces();
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data;
import java.util.Set;
import org.bukkit.Axis;
import org.jetbrains.annotations.NotNull;
/**
* 'axis' represents the axis along whilst this block is oriented.
@@ -17,6 +18,7 @@ public interface Orientable extends BlockData {
*
* @return the 'axis' value
*/
@NotNull
Axis getAxis();
/**
@@ -24,12 +26,13 @@ public interface Orientable extends BlockData {
*
* @param axis the new 'axis' value
*/
void setAxis(Axis axis);
void setAxis(@NotNull Axis axis);
/**
* Gets the axes which are applicable to this block.
*
* @return the allowed 'axis' values
*/
@NotNull
Set<Axis> getAxes();
}

View File

@@ -1,5 +1,7 @@
package org.bukkit.block.data;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
@@ -15,6 +17,7 @@ public interface Rail extends BlockData {
*
* @return the 'shape' value
*/
@NotNull
Shape getShape();
/**
@@ -22,13 +25,14 @@ public interface Rail extends BlockData {
*
* @param shape the new 'shape' value
*/
void setShape(Shape shape);
void setShape(@NotNull Shape shape);
/**
* Gets the shapes which are applicable to this block.
*
* @return the allowed 'shape' values
*/
@NotNull
Set<Shape> getShapes();
/**

View File

@@ -1,6 +1,7 @@
package org.bukkit.block.data;
import org.bukkit.block.BlockFace;
import org.jetbrains.annotations.NotNull;
/**
* 'rotation' represents the current rotation of this block.
@@ -12,6 +13,7 @@ public interface Rotatable extends BlockData {
*
* @return the 'rotation' value
*/
@NotNull
BlockFace getRotation();
/**
@@ -19,5 +21,5 @@ public interface Rotatable extends BlockData {
*
* @param rotation the new 'rotation' value
*/
void setRotation(BlockFace rotation);
void setRotation(@NotNull BlockFace rotation);
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data.type;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Directional;
import org.jetbrains.annotations.NotNull;
/**
* Similar to {@link Bisected}, 'part' denotes which half of the bed this block
@@ -17,6 +18,7 @@ public interface Bed extends Directional {
*
* @return the 'part' value
*/
@NotNull
Part getPart();
/**
@@ -24,7 +26,7 @@ public interface Bed extends Directional {
*
* @param part the new 'part' value
*/
void setPart(Part part);
void setPart(@NotNull Part part);
/**
* Gets the value of the 'occupied' property.

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data.type;
import java.util.Set;
import org.bukkit.block.data.BlockData;
import org.jetbrains.annotations.NotNull;
/**
* Interface to the 'has_bottle_0', 'has_bottle_1', 'has_bottle_2' flags on a
@@ -32,6 +33,7 @@ public interface BrewingStand extends BlockData {
*
* @return set of all bottles
*/
@NotNull
Set<Integer> getBottles();
/**

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Waterlogged;
import org.jetbrains.annotations.NotNull;
/**
* 'type' represents which part of a double chest this block is, or if it is a
@@ -14,6 +15,7 @@ public interface Chest extends Directional, Waterlogged {
*
* @return the 'type' value
*/
@NotNull
Type getType();
/**
@@ -21,7 +23,7 @@ public interface Chest extends Directional, Waterlogged {
*
* @param type the new 'type' value
*/
void setType(Type type);
void setType(@NotNull Type type);
/**
* Type of this chest block.

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.NotNull;
/**
* 'mode' indicates what mode this comparator will operate in.
@@ -13,6 +14,7 @@ public interface Comparator extends Directional, Powerable {
*
* @return the 'mode' value
*/
@NotNull
Mode getMode();
/**
@@ -20,7 +22,7 @@ public interface Comparator extends Directional, Powerable {
*
* @param mode the new 'mode' value
*/
void setMode(Mode mode);
void setMode(@NotNull Mode mode);
/**
* The mode in which a comparator will operate in.

View File

@@ -4,6 +4,7 @@ import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.NotNull;
/**
* 'hinge' indicates which hinge this door is attached to and will rotate around
@@ -16,6 +17,7 @@ public interface Door extends Bisected, Directional, Openable, Powerable {
*
* @return the 'hinge' value
*/
@NotNull
Hinge getHinge();
/**
@@ -23,7 +25,7 @@ public interface Door extends Bisected, Directional, Openable, Powerable {
*
* @param hinge the new 'hinge' value
*/
void setHinge(Hinge hinge);
void setHinge(@NotNull Hinge hinge);
/**
* The hinge of a door.

View File

@@ -3,6 +3,7 @@ package org.bukkit.block.data.type;
import org.bukkit.Instrument;
import org.bukkit.Note;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.NotNull;
/**
* 'instrument' is the type of sound made when this note block is activated.
@@ -16,6 +17,7 @@ public interface NoteBlock extends Powerable {
*
* @return the 'instrument' value
*/
@NotNull
Instrument getInstrument();
/**
@@ -23,13 +25,14 @@ public interface NoteBlock extends Powerable {
*
* @param instrument the new 'instrument' value
*/
void setInstrument(Instrument instrument);
void setInstrument(@NotNull Instrument instrument);
/**
* Gets the value of the 'note' property.
*
* @return the 'note' value
*/
@NotNull
Note getNote();
/**
@@ -37,5 +40,5 @@ public interface NoteBlock extends Powerable {
*
* @param note the new 'note' value
*/
void setNote(Note note);
void setNote(@NotNull Note note);
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.block.data.type;
import java.util.Set;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.AnaloguePowerable;
import org.jetbrains.annotations.NotNull;
/**
* 'north', 'east', 'south', 'west' represent the types of connections this
@@ -16,7 +17,8 @@ public interface RedstoneWire extends AnaloguePowerable {
* @param face to check
* @return connection type
*/
Connection getFace(BlockFace face);
@NotNull
Connection getFace(@NotNull BlockFace face);
/**
* Sets the type of connection on the specified face.
@@ -24,13 +26,14 @@ public interface RedstoneWire extends AnaloguePowerable {
* @param face to set
* @param connection the connection type
*/
void setFace(BlockFace face, Connection connection);
void setFace(@NotNull BlockFace face, @NotNull Connection connection);
/**
* Gets all of this faces which may be set on this block.
*
* @return all allowed faces
*/
@NotNull
Set<BlockFace> getAllowedFaces();
/**

View File

@@ -1,6 +1,7 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Waterlogged;
import org.jetbrains.annotations.NotNull;
/**
* 'type' represents what state the slab is in - either top, bottom, or a double
@@ -13,6 +14,7 @@ public interface Slab extends Waterlogged {
*
* @return the 'type' value
*/
@NotNull
Type getType();
/**
@@ -20,7 +22,7 @@ public interface Slab extends Waterlogged {
*
* @param type the new 'type' value
*/
void setType(Type type);
void setType(@NotNull Type type);
/**
* The type of the slab.

View File

@@ -3,6 +3,7 @@ package org.bukkit.block.data.type;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Waterlogged;
import org.jetbrains.annotations.NotNull;
/**
* 'shape' represents the texture and bounding box shape of these stairs.
@@ -14,6 +15,7 @@ public interface Stairs extends Bisected, Directional, Waterlogged {
*
* @return the 'shape' value
*/
@NotNull
Shape getShape();
/**
@@ -21,7 +23,7 @@ public interface Stairs extends Bisected, Directional, Waterlogged {
*
* @param shape the new 'shape' value
*/
void setShape(Shape shape);
void setShape(@NotNull Shape shape);
/**
* The shape of a stair block - used for constructing corners.

View File

@@ -1,6 +1,7 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.BlockData;
import org.jetbrains.annotations.NotNull;
/**
* 'mode' represents the different modes in which this structure block may
@@ -13,6 +14,7 @@ public interface StructureBlock extends BlockData {
*
* @return the 'mode' value
*/
@NotNull
Mode getMode();
/**
@@ -20,7 +22,7 @@ public interface StructureBlock extends BlockData {
*
* @param mode the new 'mode' value
*/
void setMode(Mode mode);
void setMode(@NotNull Mode mode);
/**
* Operating mode of a structure block.

View File

@@ -2,6 +2,7 @@ package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.NotNull;
/**
* 'face' represents the face to which a lever or button is stuck.
@@ -16,6 +17,7 @@ public interface Switch extends Directional, Powerable {
*
* @return the 'face' value
*/
@NotNull
Face getFace();
/**
@@ -23,7 +25,7 @@ public interface Switch extends Directional, Powerable {
*
* @param face the new 'face' value
*/
void setFace(Face face);
void setFace(@NotNull Face face);
/**
* The face to which a switch type block is stuck.

View File

@@ -1,6 +1,7 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.jetbrains.annotations.NotNull;
/**
* 'type' represents the type of piston which this (technical) block corresponds
@@ -13,6 +14,7 @@ public interface TechnicalPiston extends Directional {
*
* @return the 'type' value
*/
@NotNull
Type getType();
/**
@@ -20,7 +22,7 @@ public interface TechnicalPiston extends Directional {
*
* @param type the new 'type' value
*/
void setType(Type type);
void setType(@NotNull Type type);
/**
* Different piston variants.