consumer) {
return Bukkit.createBlockData(this, consumer);
}
@@ -3059,7 +3064,8 @@ public enum Material implements Keyed {
* @return new data instance
* @throws IllegalArgumentException if the specified data is not valid
*/
- public BlockData createBlockData(String data) throws IllegalArgumentException {
+ @NotNull
+ public BlockData createBlockData(@Nullable String data) throws IllegalArgumentException {
return Bukkit.createBlockData(this, data);
}
@@ -3068,6 +3074,7 @@ public enum Material implements Keyed {
*
* @return MaterialData associated with this Material
*/
+ @NotNull
public Class extends MaterialData> getData() {
Validate.isTrue(legacy, "Cannot get data class of Modern Material");
return ctor.getDeclaringClass();
@@ -3082,6 +3089,7 @@ public enum Material implements Keyed {
* @deprecated Magic value
*/
@Deprecated
+ @NotNull
public MaterialData getNewData(final byte raw) {
Validate.isTrue(legacy, "Cannot get new data of Modern Material");
try {
@@ -3804,7 +3812,8 @@ public enum Material implements Keyed {
* @param name Name of the material to get
* @return Material if found, or null
*/
- public static Material getMaterial(final String name) {
+ @Nullable
+ public static Material getMaterial(@NotNull final String name) {
return getMaterial(name, false);
}
@@ -3818,7 +3827,8 @@ public enum Material implements Keyed {
* @param legacyName whether this is a legacy name
* @return Material if found, or null
*/
- public static Material getMaterial(String name, boolean legacyName) {
+ @Nullable
+ public static Material getMaterial(@NotNull String name, boolean legacyName) {
if (legacyName) {
if (!name.startsWith(LEGACY_PREFIX)) {
name = LEGACY_PREFIX + name;
@@ -3841,7 +3851,8 @@ public enum Material implements Keyed {
* @param name Name of the material to get
* @return Material if found, or null
*/
- public static Material matchMaterial(final String name) {
+ @Nullable
+ public static Material matchMaterial(@NotNull final String name) {
return matchMaterial(name, false);
}
@@ -3856,7 +3867,8 @@ public enum Material implements Keyed {
* @param legacyName whether this is a legacy name
* @return Material if found, or null
*/
- public static Material matchMaterial(final String name, boolean legacyName) {
+ @Nullable
+ public static Material matchMaterial(@NotNull final String name, boolean legacyName) {
Validate.notNull(name, "Name cannot be null");
String filtered = name;
diff --git a/paper-api/src/main/java/org/bukkit/Nameable.java b/paper-api/src/main/java/org/bukkit/Nameable.java
index 49cf519c6b..fee814e01a 100644
--- a/paper-api/src/main/java/org/bukkit/Nameable.java
+++ b/paper-api/src/main/java/org/bukkit/Nameable.java
@@ -1,5 +1,7 @@
package org.bukkit;
+import org.jetbrains.annotations.Nullable;
+
public interface Nameable {
/**
@@ -11,6 +13,7 @@ public interface Nameable {
*
* @return name of the mob/block or null
*/
+ @Nullable
public String getCustomName();
/**
@@ -24,5 +27,5 @@ public interface Nameable {
*
* @param name the name to set
*/
- public void setCustomName(String name);
+ public void setCustomName(@Nullable String name);
}
diff --git a/paper-api/src/main/java/org/bukkit/NamespacedKey.java b/paper-api/src/main/java/org/bukkit/NamespacedKey.java
index 43239f8443..ffebffd8bd 100644
--- a/paper-api/src/main/java/org/bukkit/NamespacedKey.java
+++ b/paper-api/src/main/java/org/bukkit/NamespacedKey.java
@@ -5,6 +5,7 @@ import java.util.Locale;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.plugin.Plugin;
+import org.jetbrains.annotations.NotNull;
/**
* Represents a String based key which consists of two components - a namespace
@@ -43,7 +44,7 @@ public final class NamespacedKey {
* @deprecated should never be used by plugins, for internal use only!!
*/
@Deprecated
- public NamespacedKey(String namespace, String key) {
+ public NamespacedKey(@NotNull String namespace, @NotNull String key) {
Preconditions.checkArgument(namespace != null && VALID_NAMESPACE.matcher(namespace).matches(), "Invalid namespace. Must be [a-z0-9._-]: %s", namespace);
Preconditions.checkArgument(key != null && VALID_KEY.matcher(key).matches(), "Invalid key. Must be [a-z0-9/._-]: %s", key);
@@ -66,7 +67,7 @@ public final class NamespacedKey {
* @param plugin the plugin to use for the namespace
* @param key the key to create
*/
- public NamespacedKey(Plugin plugin, String key) {
+ public NamespacedKey(@NotNull Plugin plugin, @NotNull String key) {
Preconditions.checkArgument(plugin != null, "Plugin cannot be null");
Preconditions.checkArgument(key != null, "Key cannot be null");
@@ -81,10 +82,12 @@ public final class NamespacedKey {
Preconditions.checkArgument(string.length() < 256, "NamespacedKey must be less than 256 characters (%s)", string);
}
+ @NotNull
public String getNamespace() {
return namespace;
}
+ @NotNull
public String getKey() {
return key;
}
@@ -121,6 +124,7 @@ public final class NamespacedKey {
* @deprecated should never be used by plugins, for internal use only!!
*/
@Deprecated
+ @NotNull
public static NamespacedKey randomKey() {
return new NamespacedKey(BUKKIT, UUID.randomUUID().toString());
}
@@ -131,7 +135,8 @@ public final class NamespacedKey {
* @param key the key to use
* @return new key in the Minecraft namespace
*/
- public static NamespacedKey minecraft(String key) {
+ @NotNull
+ public static NamespacedKey minecraft(@NotNull String key) {
return new NamespacedKey(MINECRAFT, key);
}
}
diff --git a/paper-api/src/main/java/org/bukkit/Note.java b/paper-api/src/main/java/org/bukkit/Note.java
index 417936fab8..6aa02542bf 100644
--- a/paper-api/src/main/java/org/bukkit/Note.java
+++ b/paper-api/src/main/java/org/bukkit/Note.java
@@ -5,6 +5,8 @@ import java.util.Map;
import org.apache.commons.lang.Validate;
import com.google.common.collect.Maps;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* A note class to store a specific note.
@@ -100,6 +102,7 @@ public class Note {
* @deprecated Magic value
*/
@Deprecated
+ @Nullable
public static Tone getById(byte id) {
return BY_DATA.get(id);
}
@@ -139,7 +142,7 @@ public class Note {
* to be F#.
* @param sharped Set if the tone is sharped (e.g. for F#).
*/
- public Note(int octave, Tone tone, boolean sharped) {
+ public Note(int octave, @NotNull Tone tone, boolean sharped) {
if (sharped && !tone.isSharpable()) {
tone = Tone.values()[tone.ordinal() + 1];
sharped = false;
@@ -158,7 +161,8 @@ public class Note {
* @param tone The tone within the octave.
* @return The new note.
*/
- public static Note flat(int octave, Tone tone) {
+ @NotNull
+ public static Note flat(int octave, @NotNull Tone tone) {
Validate.isTrue(octave != 2, "Octave cannot be 2 for flats");
tone = tone == Tone.G ? Tone.F : Tone.values()[tone.ordinal() - 1];
return new Note(octave, tone, tone.isSharpable());
@@ -172,7 +176,8 @@ public class Note {
* to be F#.
* @return The new note.
*/
- public static Note sharp(int octave, Tone tone) {
+ @NotNull
+ public static Note sharp(int octave, @NotNull Tone tone) {
return new Note(octave, tone, true);
}
@@ -183,7 +188,8 @@ public class Note {
* @param tone The tone within the octave.
* @return The new note.
*/
- public static Note natural(int octave, Tone tone) {
+ @NotNull
+ public static Note natural(int octave, @NotNull Tone tone) {
Validate.isTrue(octave != 2, "Octave cannot be 2 for naturals");
return new Note(octave, tone, false);
}
@@ -191,6 +197,7 @@ public class Note {
/**
* @return The note a semitone above this one.
*/
+ @NotNull
public Note sharped() {
Validate.isTrue(note < 24, "This note cannot be sharped because it is the highest known note!");
return new Note(note + 1);
@@ -199,6 +206,7 @@ public class Note {
/**
* @return The note a semitone below this one.
*/
+ @NotNull
public Note flattened() {
Validate.isTrue(note > 0, "This note cannot be flattened because it is the lowest known note!");
return new Note(note - 1);
@@ -233,6 +241,7 @@ public class Note {
*
* @return the tone of this note.
*/
+ @NotNull
public Tone getTone() {
return Tone.getById(getToneByte());
}
diff --git a/paper-api/src/main/java/org/bukkit/OfflinePlayer.java b/paper-api/src/main/java/org/bukkit/OfflinePlayer.java
index d827907173..cf8a2cb8a8 100644
--- a/paper-api/src/main/java/org/bukkit/OfflinePlayer.java
+++ b/paper-api/src/main/java/org/bukkit/OfflinePlayer.java
@@ -6,6 +6,8 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Player;
import org.bukkit.permissions.ServerOperator;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable {
@@ -24,6 +26,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Player name or null if we have not seen a name for this player yet
*/
+ @Nullable
public String getName();
/**
@@ -31,6 +34,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Player UUID
*/
+ @NotNull
public UUID getUniqueId();
/**
@@ -62,6 +66,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Online player
*/
+ @Nullable
public Player getPlayer();
/**
@@ -101,6 +106,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Bed Spawn Location if bed exists, otherwise null.
*/
+ @Nullable
public Location getBedSpawnLocation();
}
diff --git a/paper-api/src/main/java/org/bukkit/Particle.java b/paper-api/src/main/java/org/bukkit/Particle.java
index 4d0acaf5b7..a376e52f4d 100644
--- a/paper-api/src/main/java/org/bukkit/Particle.java
+++ b/paper-api/src/main/java/org/bukkit/Particle.java
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
+import org.jetbrains.annotations.NotNull;
public enum Particle {
EXPLOSION_NORMAL,
@@ -70,7 +71,7 @@ public enum Particle {
dataType = Void.class;
}
- Particle(Class> data) {
+ Particle(@NotNull Class> data) {
dataType = data;
}
@@ -78,6 +79,7 @@ public enum Particle {
* Returns the required data type for the particle
* @return the required data type
*/
+ @NotNull
public Class> getDataType() {
return dataType;
}
@@ -91,7 +93,7 @@ public enum Particle {
private final Color color;
private final float size;
- public DustOptions(Color color, float size) {
+ public DustOptions(@NotNull Color color, float size) {
Preconditions.checkArgument(color != null, "color");
this.color = color;
this.size = size;
@@ -102,6 +104,7 @@ public enum Particle {
*
* @return particle color
*/
+ @NotNull
public Color getColor() {
return color;
}
diff --git a/paper-api/src/main/java/org/bukkit/Rotation.java b/paper-api/src/main/java/org/bukkit/Rotation.java
index 8afd04698f..78708fe390 100644
--- a/paper-api/src/main/java/org/bukkit/Rotation.java
+++ b/paper-api/src/main/java/org/bukkit/Rotation.java
@@ -1,5 +1,7 @@
package org.bukkit;
+import org.jetbrains.annotations.NotNull;
+
/**
* An enum to specify a rotation based orientation, like that on a clock.
*
@@ -48,6 +50,7 @@ public enum Rotation {
*
* @return the relative rotation
*/
+ @NotNull
public Rotation rotateClockwise() {
return rotations[(this.ordinal() + 1) & 0x7];
}
@@ -57,6 +60,7 @@ public enum Rotation {
*
* @return the relative rotation
*/
+ @NotNull
public Rotation rotateCounterClockwise() {
return rotations[(this.ordinal() - 1) & 0x7];
}
diff --git a/paper-api/src/main/java/org/bukkit/SandstoneType.java b/paper-api/src/main/java/org/bukkit/SandstoneType.java
index a9ac16e7a3..3b3a4a7cc8 100644
--- a/paper-api/src/main/java/org/bukkit/SandstoneType.java
+++ b/paper-api/src/main/java/org/bukkit/SandstoneType.java
@@ -3,6 +3,7 @@ package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
+import org.jetbrains.annotations.Nullable;
/**
* Represents the three different types of Sandstone
@@ -39,6 +40,7 @@ public enum SandstoneType {
* @deprecated Magic value
*/
@Deprecated
+ @Nullable
public static SandstoneType getByData(final byte data) {
return BY_DATA.get(data);
}
diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java
index 22352f7aea..3f3a06a00a 100644
--- a/paper-api/src/main/java/org/bukkit/Server.java
+++ b/paper-api/src/main/java/org/bukkit/Server.java
@@ -51,6 +51,9 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Represents a server implementation.
@@ -78,6 +81,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return name of this server implementation
*/
+ @NotNull
public String getName();
/**
@@ -85,6 +89,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return version of this server implementation
*/
+ @NotNull
public String getVersion();
/**
@@ -92,6 +97,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return version of Bukkit
*/
+ @NotNull
public String getBukkitVersion();
/**
@@ -121,6 +127,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a view of currently online players.
*/
+ @NotNull
public Collection extends Player> getOnlinePlayers();
/**
@@ -151,6 +158,7 @@ public interface Server extends PluginMessageRecipient {
* @return the IP string that this server is bound to, otherwise empty
* string
*/
+ @NotNull
public String getIp();
/**
@@ -160,6 +168,7 @@ public interface Server extends PluginMessageRecipient {
* @deprecated not a standard server property
*/
@Deprecated
+ @NotNull
public String getServerName();
/**
@@ -170,6 +179,7 @@ public interface Server extends PluginMessageRecipient {
* @deprecated not a standard server property
*/
@Deprecated
+ @NotNull
public String getServerId();
/**
@@ -177,6 +187,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1)
*/
+ @NotNull
public String getWorldType();
/**
@@ -219,6 +230,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a set containing all whitelisted players
*/
+ @NotNull
public Set getWhitelistedPlayers();
/**
@@ -235,7 +247,7 @@ public interface Server extends PluginMessageRecipient {
* @param message the message
* @return the number of players
*/
- public int broadcastMessage(String message);
+ public int broadcastMessage(@NotNull String message);
/**
* Gets the name of the update folder. The update folder is used to safely
@@ -245,6 +257,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the name of the update folder
*/
+ @NotNull
public String getUpdateFolder();
/**
@@ -253,6 +266,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the update folder
*/
+ @NotNull
public File getUpdateFolderFile();
/**
@@ -315,7 +329,8 @@ public interface Server extends PluginMessageRecipient {
* @return a player if one was found, null otherwise
*/
@Deprecated
- public Player getPlayer(String name);
+ @Nullable
+ public Player getPlayer(@NotNull String name);
/**
* Gets the player with the exact given name, case insensitive.
@@ -326,7 +341,8 @@ public interface Server extends PluginMessageRecipient {
* @return a player object if one was found, null otherwise
*/
@Deprecated
- public Player getPlayerExact(String name);
+ @Nullable
+ public Player getPlayerExact(@NotNull String name);
/**
* Attempts to match any players with the given name, and returns a list
@@ -341,7 +357,8 @@ public interface Server extends PluginMessageRecipient {
* @return list of all possible players
*/
@Deprecated
- public List matchPlayer(String name);
+ @NotNull
+ public List matchPlayer(@NotNull String name);
/**
* Gets the player with the given UUID.
@@ -349,13 +366,15 @@ public interface Server extends PluginMessageRecipient {
* @param id UUID of the player to retrieve
* @return a player object if one was found, null otherwise
*/
- public Player getPlayer(UUID id);
+ @Nullable
+ public Player getPlayer(@NotNull UUID id);
/**
* Gets the plugin manager for interfacing with plugins.
*
* @return a plugin manager for this Server instance
*/
+ @NotNull
public PluginManager getPluginManager();
/**
@@ -363,6 +382,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a scheduling service for this server
*/
+ @NotNull
public BukkitScheduler getScheduler();
/**
@@ -370,6 +390,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return s services manager
*/
+ @NotNull
public ServicesManager getServicesManager();
/**
@@ -377,6 +398,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a list of worlds
*/
+ @NotNull
public List getWorlds();
/**
@@ -389,7 +411,8 @@ public interface Server extends PluginMessageRecipient {
* @param creator the options to use when creating the world
* @return newly created or loaded world
*/
- public World createWorld(WorldCreator creator);
+ @Nullable
+ public World createWorld(@NotNull WorldCreator creator);
/**
* Unloads a world with the given name.
@@ -398,7 +421,7 @@ public interface Server extends PluginMessageRecipient {
* @param save whether to save the chunks before unloading
* @return true if successful, false otherwise
*/
- public boolean unloadWorld(String name, boolean save);
+ public boolean unloadWorld(@NotNull String name, boolean save);
/**
* Unloads the given world.
@@ -407,7 +430,7 @@ public interface Server extends PluginMessageRecipient {
* @param save whether to save the chunks before unloading
* @return true if successful, false otherwise
*/
- public boolean unloadWorld(World world, boolean save);
+ public boolean unloadWorld(@NotNull World world, boolean save);
/**
* Gets the world with the given name.
@@ -415,7 +438,8 @@ public interface Server extends PluginMessageRecipient {
* @param name the name of the world to retrieve
* @return a world with the given name, or null if none exists
*/
- public World getWorld(String name);
+ @Nullable
+ public World getWorld(@NotNull String name);
/**
* Gets the world from the given Unique ID.
@@ -423,7 +447,8 @@ public interface Server extends PluginMessageRecipient {
* @param uid a unique-id of the world to retrieve
* @return a world with the given Unique ID, or null if none exists
*/
- public World getWorld(UUID uid);
+ @Nullable
+ public World getWorld(@NotNull UUID uid);
/**
* Gets the map from the given item ID.
@@ -433,6 +458,7 @@ public interface Server extends PluginMessageRecipient {
* @deprecated Magic value
*/
@Deprecated
+ @Nullable
public MapView getMap(int id);
/**
@@ -441,7 +467,8 @@ public interface Server extends PluginMessageRecipient {
* @param world the world the map will belong to
* @return a newly created map view
*/
- public MapView createMap(World world);
+ @NotNull
+ public MapView createMap(@NotNull World world);
/**
* Create a new explorer map targeting the closest nearby structure of a
@@ -458,7 +485,8 @@ public interface Server extends PluginMessageRecipient {
* @see World#locateNearestStructure(org.bukkit.Location,
* org.bukkit.StructureType, int, boolean)
*/
- public ItemStack createExplorerMap(World world, Location location, StructureType structureType);
+ @NotNull
+ public ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType);
/**
* Create a new explorer map targeting the closest nearby structure of a
@@ -478,7 +506,8 @@ public interface Server extends PluginMessageRecipient {
* @see World#locateNearestStructure(org.bukkit.Location,
* org.bukkit.StructureType, int, boolean)
*/
- public ItemStack createExplorerMap(World world, Location location, StructureType structureType, int radius, boolean findUnexplored);
+ @NotNull
+ public ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType, int radius, boolean findUnexplored);
/**
* Reloads the server, refreshing settings and plugin information.
@@ -496,6 +525,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return Logger associated with this server
*/
+ @NotNull
public Logger getLogger();
/**
@@ -504,7 +534,8 @@ public interface Server extends PluginMessageRecipient {
* @param name the name of the command to retrieve
* @return a plugin command if found, null otherwise
*/
- public PluginCommand getPluginCommand(String name);
+ @Nullable
+ public PluginCommand getPluginCommand(@NotNull String name);
/**
* Writes loaded players to disk.
@@ -521,7 +552,7 @@ public interface Server extends PluginMessageRecipient {
* @throws CommandException thrown when the executor for the given command
* fails with an unhandled exception
*/
- public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException;
+ public boolean dispatchCommand(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException;
/**
* Adds a recipe to the crafting manager.
@@ -530,7 +561,8 @@ public interface Server extends PluginMessageRecipient {
* @return true if the recipe was added, false if it wasn't for some
* reason
*/
- public boolean addRecipe(Recipe recipe);
+ @Contract("null -> false")
+ public boolean addRecipe(@Nullable Recipe recipe);
/**
* Get a list of all recipes for a given item. The stack size is ignored
@@ -539,13 +571,15 @@ public interface Server extends PluginMessageRecipient {
* @param result the item to match against recipe results
* @return a list of recipes with the given result
*/
- public List getRecipesFor(ItemStack result);
+ @NotNull
+ public List getRecipesFor(@NotNull ItemStack result);
/**
* Get an iterator through the list of crafting recipes.
*
* @return an iterator
*/
+ @NotNull
public Iterator recipeIterator();
/**
@@ -563,6 +597,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a map of aliases to command names
*/
+ @NotNull
public Map getCommandAliases();
/**
@@ -614,7 +649,7 @@ public interface Server extends PluginMessageRecipient {
* permissibles} must have to receive the broadcast
* @return number of message recipients
*/
- public int broadcast(String message, String permission);
+ public int broadcast(@NotNull String message, @NotNull String permission);
/**
* Gets the player by the given name, regardless if they are offline or
@@ -633,7 +668,8 @@ public interface Server extends PluginMessageRecipient {
* @see #getOfflinePlayer(java.util.UUID)
*/
@Deprecated
- public OfflinePlayer getOfflinePlayer(String name);
+ @NotNull
+ public OfflinePlayer getOfflinePlayer(@NotNull String name);
/**
* Gets the player by the given UUID, regardless if they are offline or
@@ -645,13 +681,15 @@ public interface Server extends PluginMessageRecipient {
* @param id the UUID of the player to retrieve
* @return an offline player
*/
- public OfflinePlayer getOfflinePlayer(UUID id);
+ @NotNull
+ public OfflinePlayer getOfflinePlayer(@NotNull UUID id);
/**
* Gets a set containing all current IPs that are banned.
*
* @return a set containing banned IP addresses
*/
+ @NotNull
public Set getIPBans();
/**
@@ -659,20 +697,21 @@ public interface Server extends PluginMessageRecipient {
*
* @param address the IP address to ban
*/
- public void banIP(String address);
+ public void banIP(@NotNull String address);
/**
* Unbans the specified address from the server.
*
* @param address the IP address to unban
*/
- public void unbanIP(String address);
+ public void unbanIP(@NotNull String address);
/**
* Gets a set containing all banned players.
*
* @return a set containing banned players
*/
+ @NotNull
public Set getBannedPlayers();
/**
@@ -684,13 +723,15 @@ public interface Server extends PluginMessageRecipient {
* @param type the type of list to fetch, cannot be null
* @return a ban list of the specified type
*/
- public BanList getBanList(BanList.Type type);
+ @NotNull
+ public BanList getBanList(@NotNull BanList.Type type);
/**
* Gets a set containing all player operators.
*
* @return a set containing player operators
*/
+ @NotNull
public Set getOperators();
/**
@@ -698,6 +739,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the default game mode
*/
+ @NotNull
public GameMode getDefaultGameMode();
/**
@@ -705,7 +747,7 @@ public interface Server extends PluginMessageRecipient {
*
* @param mode the new game mode
*/
- public void setDefaultGameMode(GameMode mode);
+ public void setDefaultGameMode(@NotNull GameMode mode);
/**
* Gets a {@link ConsoleCommandSender} that may be used as an input source
@@ -713,6 +755,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a console command sender
*/
+ @NotNull
public ConsoleCommandSender getConsoleSender();
/**
@@ -720,6 +763,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return folder that contains all worlds
*/
+ @NotNull
public File getWorldContainer();
/**
@@ -727,6 +771,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return an array containing all previous players
*/
+ @NotNull
public OfflinePlayer[] getOfflinePlayers();
/**
@@ -734,6 +779,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return messenger responsible for this server
*/
+ @NotNull
public Messenger getMessenger();
/**
@@ -741,6 +787,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a help map for this server
*/
+ @NotNull
public HelpMap getHelpMap();
/**
@@ -766,7 +813,8 @@ public interface Server extends PluginMessageRecipient {
*
* @see InventoryType#isCreatable()
*/
- Inventory createInventory(InventoryHolder owner, InventoryType type);
+ @NotNull
+ Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type);
/**
* Creates an empty inventory with the specified type and title. If the type
@@ -792,7 +840,8 @@ public interface Server extends PluginMessageRecipient {
*
* @see InventoryType#isCreatable()
*/
- Inventory createInventory(InventoryHolder owner, InventoryType type, String title);
+ @NotNull
+ Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title);
/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
@@ -803,7 +852,8 @@ public interface Server extends PluginMessageRecipient {
* @return a new inventory
* @throws IllegalArgumentException if the size is not a multiple of 9
*/
- Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException;
+ @NotNull
+ Inventory createInventory(@Nullable InventoryHolder owner, int size) throws IllegalArgumentException;
/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
@@ -816,7 +866,8 @@ public interface Server extends PluginMessageRecipient {
* @return a new inventory
* @throws IllegalArgumentException if the size is not a multiple of 9
*/
- Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException;
+ @NotNull
+ Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull String title) throws IllegalArgumentException;
/**
* Creates an empty merchant.
@@ -825,7 +876,8 @@ public interface Server extends PluginMessageRecipient {
* when the merchant inventory is viewed
* @return a new merchant
*/
- Merchant createMerchant(String title);
+ @NotNull
+ Merchant createMerchant(@Nullable String title);
/**
* Gets user-specified limit for number of monsters that can spawn in a
@@ -878,6 +930,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the servers MOTD
*/
+ @NotNull
String getMotd();
/**
@@ -885,6 +938,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the shutdown message
*/
+ @Nullable
String getShutdownMessage();
/**
@@ -892,6 +946,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the configured warning state
*/
+ @NotNull
public WarningState getWarningState();
/**
@@ -900,6 +955,7 @@ public interface Server extends PluginMessageRecipient {
* @return the item factory
* @see ItemFactory
*/
+ @NotNull
ItemFactory getItemFactory();
/**
@@ -909,6 +965,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the scoreboard manager or null if no worlds are loaded.
*/
+ @Nullable
ScoreboardManager getScoreboardManager();
/**
@@ -918,6 +975,7 @@ public interface Server extends PluginMessageRecipient {
* implementation to indicate no defined icon, but this behavior is
* not guaranteed
*/
+ @Nullable
CachedServerIcon getServerIcon();
/**
@@ -934,7 +992,8 @@ public interface Server extends PluginMessageRecipient {
* @return a cached server-icon that can be used for a {@link
* ServerListPingEvent#setServerIcon(CachedServerIcon)}
*/
- CachedServerIcon loadServerIcon(File file) throws IllegalArgumentException, Exception;
+ @NotNull
+ CachedServerIcon loadServerIcon(@NotNull File file) throws IllegalArgumentException, Exception;
/**
* Creates a cached server-icon for the specific image.
@@ -949,7 +1008,8 @@ public interface Server extends PluginMessageRecipient {
* @return a cached server-icon that can be used for a {@link
* ServerListPingEvent#setServerIcon(CachedServerIcon)}
*/
- CachedServerIcon loadServerIcon(BufferedImage image) throws IllegalArgumentException, Exception;
+ @NotNull
+ CachedServerIcon loadServerIcon(@NotNull BufferedImage image) throws IllegalArgumentException, Exception;
/**
* Set the idle kick timeout. Any players idle for the specified amount of
@@ -977,7 +1037,8 @@ public interface Server extends PluginMessageRecipient {
* @return a new ChunkData for the world
*
*/
- public ChunkGenerator.ChunkData createChunkData(World world);
+ @NotNull
+ public ChunkGenerator.ChunkData createChunkData(@NotNull World world);
/**
* Creates a boss bar instance to display to players. The progress
@@ -989,7 +1050,8 @@ public interface Server extends PluginMessageRecipient {
* @param flags an optional list of flags to set on the boss bar
* @return the created boss bar
*/
- BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags);
+ @NotNull
+ BossBar createBossBar(@Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags);
/**
* Creates a boss bar instance to display to players. The progress defaults
@@ -1005,7 +1067,8 @@ public interface Server extends PluginMessageRecipient {
* @param flags an optional list of flags to set on the boss bar
* @return the created boss bar
*/
- KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags);
+ @NotNull
+ KeyedBossBar createBossBar(@NotNull NamespacedKey key, @Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags);
/**
* Gets an unmodifiable iterator through all persistent bossbars.
@@ -1021,6 +1084,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return a bossbar iterator
*/
+ @NotNull
Iterator getBossBars();
/**
@@ -1038,7 +1102,8 @@ public interface Server extends PluginMessageRecipient {
* @param key unique bossbar key
* @return bossbar or null if not exists
*/
- KeyedBossBar getBossBar(NamespacedKey key);
+ @Nullable
+ KeyedBossBar getBossBar(@NotNull NamespacedKey key);
/**
* Removes a {@link KeyedBossBar} specified by this key.
@@ -1055,7 +1120,7 @@ public interface Server extends PluginMessageRecipient {
* @param key unique bossbar key
* @return true if removal succeeded or false
*/
- boolean removeBossBar(NamespacedKey key);
+ boolean removeBossBar(@NotNull NamespacedKey key);
/**
* Gets an entity on the server by its UUID
@@ -1063,7 +1128,8 @@ public interface Server extends PluginMessageRecipient {
* @param uuid the UUID of the entity
* @return the entity with the given UUID, or null if it isn't found
*/
- Entity getEntity(UUID uuid);
+ @Nullable
+ Entity getEntity(@NotNull UUID uuid);
/**
* Get the advancement specified by this key.
@@ -1071,7 +1137,8 @@ public interface Server extends PluginMessageRecipient {
* @param key unique advancement key
* @return advancement or null if not exists
*/
- Advancement getAdvancement(NamespacedKey key);
+ @Nullable
+ Advancement getAdvancement(@NotNull NamespacedKey key);
/**
* Get an iterator through all advancements. Advancements cannot be removed
@@ -1079,6 +1146,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return an advancement iterator
*/
+ @NotNull
Iterator advancementIterator();
/**
@@ -1088,7 +1156,8 @@ public interface Server extends PluginMessageRecipient {
* @param material the material
* @return new data instance
*/
- BlockData createBlockData(Material material);
+ @NotNull
+ BlockData createBlockData(@NotNull Material material);
/**
* Creates a new {@link BlockData} instance for the specified Material, with
@@ -1098,7 +1167,8 @@ public interface Server extends PluginMessageRecipient {
* @param consumer consumer to run on new instance before returning
* @return new data instance
*/
- public BlockData createBlockData(Material material, Consumer consumer);
+ @NotNull
+ public BlockData createBlockData(@NotNull Material material, @Nullable Consumer consumer);
/**
* Creates a new {@link BlockData} instance with material and properties
@@ -1108,7 +1178,8 @@ public interface Server extends PluginMessageRecipient {
* @return new data instance
* @throws IllegalArgumentException if the specified data is not valid
*/
- BlockData createBlockData(String data) throws IllegalArgumentException;
+ @NotNull
+ BlockData createBlockData(@NotNull String data) throws IllegalArgumentException;
/**
* Creates a new {@link BlockData} instance for the specified Material, with
@@ -1123,7 +1194,9 @@ public interface Server extends PluginMessageRecipient {
* @return new data instance
* @throws IllegalArgumentException if the specified data is not valid
*/
- BlockData createBlockData(Material material, String data) throws IllegalArgumentException;
+ @NotNull
+ @Contract("null, null -> fail")
+ BlockData createBlockData(@Nullable Material material, @Nullable String data) throws IllegalArgumentException;
/**
* Gets a tag which has already been defined within the server. Plugins are
@@ -1143,7 +1216,8 @@ public interface Server extends PluginMessageRecipient {
* @param clazz the class of the tag entries
* @return the tag or null
*/
- Tag getTag(String registry, NamespacedKey tag, Class clazz);
+ @Nullable
+ Tag getTag(@NotNull String registry, @NotNull NamespacedKey tag, @NotNull Class clazz);
/**
* Gets a all tags which have been defined within the server.
@@ -1158,7 +1232,8 @@ public interface Server extends PluginMessageRecipient {
* @param clazz the class of the tag entries
* @return all defined tags
*/
- Iterable> getTags(String registry, Class clazz);
+ @NotNull
+ Iterable> getTags(@NotNull String registry, @NotNull Class clazz);
/**
* Gets the specified {@link LootTable}.
@@ -1166,7 +1241,8 @@ public interface Server extends PluginMessageRecipient {
* @param key the name of the LootTable
* @return the LootTable, or null if no LootTable is found with that name
*/
- LootTable getLootTable(NamespacedKey key);
+ @Nullable
+ LootTable getLootTable(@NotNull NamespacedKey key);
/**
* Selects entities using the given Vanilla selector.
@@ -1190,12 +1266,14 @@ public interface Server extends PluginMessageRecipient {
* @deprecated draft API
*/
@Deprecated
- List selectEntities(CommandSender sender, String selector) throws IllegalArgumentException;
+ @NotNull
+ List selectEntities(@NotNull CommandSender sender, @NotNull String selector) throws IllegalArgumentException;
/**
* @see UnsafeValues
* @return the unsafe values instance
*/
@Deprecated
+ @NotNull
UnsafeValues getUnsafe();
}
diff --git a/paper-api/src/main/java/org/bukkit/Statistic.java b/paper-api/src/main/java/org/bukkit/Statistic.java
index 5a3248ca73..4f414e82e9 100644
--- a/paper-api/src/main/java/org/bukkit/Statistic.java
+++ b/paper-api/src/main/java/org/bukkit/Statistic.java
@@ -1,5 +1,7 @@
package org.bukkit;
+import org.jetbrains.annotations.NotNull;
+
/**
* Represents a countable statistic, which is tracked by the server.
*/
@@ -80,7 +82,7 @@ public enum Statistic {
this(Type.UNTYPED);
}
- private Statistic(Type type) {
+ private Statistic(@NotNull Type type) {
this.type = type;
}
@@ -89,6 +91,7 @@ public enum Statistic {
*
* @return the type of this statistic
*/
+ @NotNull
public Type getType() {
return type;
}
diff --git a/paper-api/src/main/java/org/bukkit/StructureType.java b/paper-api/src/main/java/org/bukkit/StructureType.java
index 5de51989c4..02d7954513 100644
--- a/paper-api/src/main/java/org/bukkit/StructureType.java
+++ b/paper-api/src/main/java/org/bukkit/StructureType.java
@@ -4,6 +4,8 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang.Validate;
import org.bukkit.map.MapCursor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -153,7 +155,7 @@ public class StructureType {
* when creating explorer maps. Use null to indicate this structure should
* not be compatible with explorer maps.
*/
- private StructureType(String name, MapCursor.Type mapIcon) {
+ private StructureType(@NotNull String name, @Nullable MapCursor.Type mapIcon) {
Validate.notEmpty(name, "Structure name cannot be empty");
this.name = name;
this.mapCursor = mapIcon;
@@ -165,6 +167,7 @@ public class StructureType {
*
* @return the name of this structure
*/
+ @NotNull
public String getName() {
return name;
}
@@ -175,6 +178,7 @@ public class StructureType {
*
* @return the {@link org.bukkit.map.MapCursor.Type} or null.
*/
+ @Nullable
public MapCursor.Type getMapIcon() {
return mapCursor;
}
@@ -204,7 +208,8 @@ public class StructureType {
return "StructureType{name=" + this.name + ", cursor=" + this.mapCursor + "}";
}
- private static T register(T type) {
+ @NotNull
+ private static T register(@NotNull T type) {
Preconditions.checkNotNull(type, "Cannot register null StructureType.");
Preconditions.checkArgument(!structureTypeMap.containsKey(type.getName()), "Cannot register same StructureType twice. %s", type.getName());
StructureType.structureTypeMap.put(type.getName(), type);
@@ -216,6 +221,7 @@ public class StructureType {
*
* @return an immutable copy of registered structure types.
*/
+ @NotNull
public static Map getStructureTypes() {
return ImmutableMap.copyOf(structureTypeMap);
}
diff --git a/paper-api/src/main/java/org/bukkit/Tag.java b/paper-api/src/main/java/org/bukkit/Tag.java
index 5656e4cf88..03d1f25835 100644
--- a/paper-api/src/main/java/org/bukkit/Tag.java
+++ b/paper-api/src/main/java/org/bukkit/Tag.java
@@ -1,5 +1,7 @@
package org.bukkit;
+import org.jetbrains.annotations.NotNull;
+
import java.util.Set;
/**
@@ -196,13 +198,14 @@ public interface Tag extends Keyed {
* @param item to check
* @return if it is tagged
*/
- boolean isTagged(T item);
+ boolean isTagged(@NotNull T item);
/**
* Gets an immutable set of all tagged items.
*
* @return set of tagged items
*/
+ @NotNull
Set getValues();
}
diff --git a/paper-api/src/main/java/org/bukkit/TravelAgent.java b/paper-api/src/main/java/org/bukkit/TravelAgent.java
index 2dfeffa83c..f1a89e7c86 100644
--- a/paper-api/src/main/java/org/bukkit/TravelAgent.java
+++ b/paper-api/src/main/java/org/bukkit/TravelAgent.java
@@ -1,5 +1,7 @@
package org.bukkit;
+import org.jetbrains.annotations.NotNull;
+
/**
* The Travel Agent handles the creation and the research of Nether and End
* portals when Entities try to use one.
@@ -17,6 +19,7 @@ public interface TravelAgent {
* location
* @return this travel agent
*/
+ @NotNull
public TravelAgent setSearchRadius(int radius);
/**
@@ -32,6 +35,7 @@ public interface TravelAgent {
* @param radius the radius in which to create a portal from the location
* @return this travel agent
*/
+ @NotNull
public TravelAgent setCreationRadius(int radius);
/**
@@ -68,7 +72,8 @@ public interface TravelAgent {
* location passed to the method if unsuccessful
* @see #createPortal(Location)
*/
- public Location findOrCreate(Location location);
+ @NotNull
+ public Location findOrCreate(@NotNull Location location);
/**
* Attempt to find a portal near the given location.
@@ -76,7 +81,8 @@ public interface TravelAgent {
* @param location the desired location of the portal
* @return the location of the nearest portal to the location
*/
- public Location findPortal(Location location);
+ @NotNull
+ public Location findPortal(@NotNull Location location);
/**
* Attempt to create a portal near the given location.
@@ -90,5 +96,5 @@ public interface TravelAgent {
* @param location the desired location of the portal
* @return true if a portal was successfully created
*/
- public boolean createPortal(Location location);
+ public boolean createPortal(@NotNull Location location);
}
diff --git a/paper-api/src/main/java/org/bukkit/TreeSpecies.java b/paper-api/src/main/java/org/bukkit/TreeSpecies.java
index f29062acc9..a18e23a4dc 100644
--- a/paper-api/src/main/java/org/bukkit/TreeSpecies.java
+++ b/paper-api/src/main/java/org/bukkit/TreeSpecies.java
@@ -3,6 +3,7 @@ package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
+import org.jetbrains.annotations.Nullable;
/**
* Represents the different species of trees regardless of size.
@@ -62,6 +63,7 @@ public enum TreeSpecies {
* @deprecated Magic value
*/
@Deprecated
+ @Nullable
public static TreeSpecies getByData(final byte data) {
return BY_DATA.get(data);
}
diff --git a/paper-api/src/main/java/org/bukkit/UndefinedNullability.java b/paper-api/src/main/java/org/bukkit/UndefinedNullability.java
new file mode 100644
index 0000000000..f465ea001c
--- /dev/null
+++ b/paper-api/src/main/java/org/bukkit/UndefinedNullability.java
@@ -0,0 +1,26 @@
+package org.bukkit;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Annotation for types, whose nullability is not well defined, so
+ * {@link org.jetbrains.annotations.NotNull} nor
+ * {@link org.jetbrains.annotations.Nullable} is applicable. For example when
+ * interface defines a method, whose nullability depends on the implementation.
+ *
+ * @deprecated This should generally not be used in any new API code as it
+ * suggests a bad API design.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Deprecated
+public @interface UndefinedNullability {
+
+ /**
+ * Human readable description of the circumstances, in which the type is
+ * nullable.
+ *
+ * @return description
+ */
+ String value() default "";
+}
diff --git a/paper-api/src/main/java/org/bukkit/Warning.java b/paper-api/src/main/java/org/bukkit/Warning.java
index 6a2a3b0d6c..f86f25a0da 100644
--- a/paper-api/src/main/java/org/bukkit/Warning.java
+++ b/paper-api/src/main/java/org/bukkit/Warning.java
@@ -7,6 +7,8 @@ import java.lang.annotation.Target;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* This designates the warning state for a specific item.
@@ -65,7 +67,7 @@ public @interface Warning {
* specifies false for {@link Warning#value()}, true otherwise.
*
*/
- public boolean printFor(Warning warning) {
+ public boolean printFor(@Nullable Warning warning) {
if (this == DEFAULT) {
return warning == null || warning.value();
}
@@ -80,7 +82,8 @@ public @interface Warning {
* @return {@link #DEFAULT} if not found, or the respective
* WarningState
*/
- public static WarningState value(final String value) {
+ @NotNull
+ public static WarningState value(@Nullable final String value) {
if (value == null) {
return DEFAULT;
}
diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java
index 4bd2ea8890..0c84737a4f 100644
--- a/paper-api/src/main/java/org/bukkit/World.java
+++ b/paper-api/src/main/java/org/bukkit/World.java
@@ -22,6 +22,9 @@ import org.bukkit.util.BoundingBox;
import org.bukkit.util.Consumer;
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 world, which may contain entities, chunks and blocks
@@ -36,6 +39,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the block
* @return Block at the given coordinates
*/
+ @NotNull
public Block getBlockAt(int x, int y, int z);
/**
@@ -44,7 +48,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Location of the block
* @return Block at the given location
*/
- public Block getBlockAt(Location location);
+ @NotNull
+ public Block getBlockAt(@NotNull Location location);
/**
* Gets the y coordinate of the lowest block at this position such that the
@@ -64,7 +69,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Location of the blocks
* @return Y-coordinate of the highest non-air block
*/
- public int getHighestBlockYAt(Location location);
+ public int getHighestBlockYAt(@NotNull Location location);
/**
* Gets the lowest block at the given coordinates such that the block and
@@ -74,6 +79,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the block
* @return Highest non-empty block
*/
+ @NotNull
public Block getHighestBlockAt(int x, int z);
/**
@@ -83,7 +89,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Coordinates to get the highest block
* @return Highest non-empty block
*/
- public Block getHighestBlockAt(Location location);
+ @NotNull
+ public Block getHighestBlockAt(@NotNull Location location);
/**
* Gets the {@link Chunk} at the given coordinates
@@ -92,6 +99,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return Chunk at the given coordinates
*/
+ @NotNull
public Chunk getChunkAt(int x, int z);
/**
@@ -100,7 +108,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Location of the chunk
* @return Chunk at the given location
*/
- public Chunk getChunkAt(Location location);
+ @NotNull
+ public Chunk getChunkAt(@NotNull Location location);
/**
* Gets the {@link Chunk} that contains the given {@link Block}
@@ -108,7 +117,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param block Block to get the containing chunk from
* @return The chunk that contains the given block
*/
- public Chunk getChunkAt(Block block);
+ @NotNull
+ public Chunk getChunkAt(@NotNull Block block);
/**
* Checks if the specified {@link Chunk} is loaded
@@ -116,13 +126,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param chunk The chunk to check
* @return true if the chunk is loaded, otherwise false
*/
- public boolean isChunkLoaded(Chunk chunk);
+ public boolean isChunkLoaded(@NotNull Chunk chunk);
/**
* Gets an array of all loaded {@link Chunk}s
*
* @return Chunk[] containing all loaded chunks
*/
+ @NotNull
public Chunk[] getLoadedChunks();
/**
@@ -130,7 +141,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @param chunk The chunk to load
*/
- public void loadChunk(Chunk chunk);
+ public void loadChunk(@NotNull Chunk chunk);
/**
* Checks if the {@link Chunk} at the specified coordinates is loaded
@@ -189,12 +200,12 @@ public interface World extends PluginMessageRecipient, Metadatable {
* Safely unloads and saves the {@link Chunk} at the specified coordinates
*
* This method is analogous to {@link #unloadChunk(int, int, boolean,
- * boolean)} where safe and saveis true
+ * boolean)} where safe and save is true
*
* @param chunk the chunk to unload
* @return true if the chunk has unloaded successfully, otherwise false
*/
- public boolean unloadChunk(Chunk chunk);
+ public boolean unloadChunk(@NotNull Chunk chunk);
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
@@ -319,6 +330,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return unmodifiable collection of force loaded chunks
*/
+ @NotNull
public Collection getForceLoadedChunks();
/**
@@ -328,7 +340,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
- public Item dropItem(Location location, ItemStack item);
+ @NotNull
+ public Item dropItem(@NotNull Location location, @NotNull ItemStack item);
/**
* Drops an item at the specified {@link Location} with a random offset
@@ -337,7 +350,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
- public Item dropItemNaturally(Location location, ItemStack item);
+ @NotNull
+ public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item);
/**
* Creates an {@link Arrow} entity at the given {@link Location}
@@ -348,7 +362,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param spread Spread of the arrow. A recommend spread is 12
* @return Arrow entity spawned as a result of this method
*/
- public Arrow spawnArrow(Location location, Vector direction, float speed, float spread);
+ @NotNull
+ public Arrow spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread);
/**
* Creates an arrow entity of the given class at the given {@link Location}
@@ -362,7 +377,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* {@link org.bukkit.entity.SpectralArrow},{@link org.bukkit.entity.Arrow},{@link org.bukkit.entity.TippedArrow}
* @return Arrow entity spawned as a result of this method
*/
- public T spawnArrow(Location location, Vector direction, float speed, float spread, Class clazz);
+ @NotNull
+ public T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class clazz);
/**
* Creates a tree at the given {@link Location}
@@ -371,7 +387,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param type Type of the tree to create
* @return true if the tree was created successfully, otherwise false
*/
- public boolean generateTree(Location location, TreeType type);
+ public boolean generateTree(@NotNull Location location, @NotNull TreeType type);
/**
* Creates a tree at the given {@link Location}
@@ -382,7 +398,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* this method
* @return true if the tree was created successfully, otherwise false
*/
- public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
+ public boolean generateTree(@NotNull Location loc, @NotNull TreeType type, @NotNull BlockChangeDelegate delegate);
/**
* Creates a entity at the given {@link Location}
@@ -391,7 +407,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param type The entity to spawn
* @return Resulting Entity of this method, or null if it was unsuccessful
*/
- public Entity spawnEntity(Location loc, EntityType type);
+ @NotNull
+ public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type);
/**
* Strikes lightning at the given {@link Location}
@@ -399,7 +416,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param loc The location to strike lightning
* @return The lightning entity.
*/
- public LightningStrike strikeLightning(Location loc);
+ @NotNull
+ public LightningStrike strikeLightning(@NotNull Location loc);
/**
* Strikes lightning at the given {@link Location} without doing damage
@@ -407,13 +425,15 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param loc The location to strike lightning
* @return The lightning entity.
*/
- public LightningStrike strikeLightningEffect(Location loc);
+ @NotNull
+ public LightningStrike strikeLightningEffect(@NotNull Location loc);
/**
* Get a list of all entities in this World
*
* @return A List of all Entities currently residing in this world
*/
+ @NotNull
public List getEntities();
/**
@@ -421,6 +441,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return A List of all LivingEntities currently residing in this world
*/
+ @NotNull
public List getLivingEntities();
/**
@@ -433,7 +454,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* match the given class/interface
*/
@Deprecated
- public Collection getEntitiesByClass(Class... classes);
+ @NotNull
+ public Collection getEntitiesByClass(@NotNull Class... classes);
/**
* Get a collection of all entities in this World matching the given
@@ -444,7 +466,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return A List of all Entities currently residing in this world that
* match the given class/interface
*/
- public Collection getEntitiesByClass(Class cls);
+ @NotNull
+ public Collection getEntitiesByClass(@NotNull Class cls);
/**
* Get a collection of all entities in this World matching any of the
@@ -454,13 +477,15 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return A List of all Entities currently residing in this world that
* match one or more of the given classes/interfaces
*/
- public Collection getEntitiesByClasses(Class>... classes);
+ @NotNull
+ public Collection getEntitiesByClasses(@NotNull Class>... classes);
/**
* Get a list of all players in this World
*
* @return A list of all Players currently residing in this world
*/
+ @NotNull
public List getPlayers();
/**
@@ -478,7 +503,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the collection of entities near location. This will always be a
* non-null collection.
*/
- public Collection getNearbyEntities(Location location, double x, double y, double z);
+ @NotNull
+ public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z);
/**
* Returns a list of entities within a bounding box centered around a
@@ -497,7 +523,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the collection of entities near location. This will always be a
* non-null collection.
*/
- public Collection getNearbyEntities(Location location, double x, double y, double z, Predicate filter);
+ @NotNull
+ public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate filter);
/**
* Returns a list of entities within the given bounding box.
@@ -510,7 +537,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the collection of entities within the bounding box, will always
* be a non-null collection
*/
- public Collection getNearbyEntities(BoundingBox boundingBox);
+ @NotNull
+ public Collection getNearbyEntities(@NotNull BoundingBox boundingBox);
/**
* Returns a list of entities within the given bounding box.
@@ -525,7 +553,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the collection of entities within the bounding box, will always
* be a non-null collection
*/
- public Collection getNearbyEntities(BoundingBox boundingBox, Predicate filter);
+ @NotNull
+ public Collection getNearbyEntities(@NotNull BoundingBox boundingBox, @Nullable Predicate filter);
/**
* Performs a ray trace that checks for entity collisions.
@@ -541,7 +570,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/
- public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance);
+ @Nullable
+ public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance);
/**
* Performs a ray trace that checks for entity collisions.
@@ -559,7 +589,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/
- public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize);
+ @Nullable
+ public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize);
/**
* Performs a ray trace that checks for entity collisions.
@@ -577,7 +608,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/
- public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate filter);
+ @Nullable
+ public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, @Nullable Predicate filter);
/**
* Performs a ray trace that checks for entity collisions.
@@ -596,7 +628,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the closest ray trace hit result, or null
if there
* is no hit
*/
- public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate filter);
+ @Nullable
+ public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate filter);
/**
* Performs a ray trace that checks for block collisions using the blocks'
@@ -614,7 +647,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the ray trace hit result, or null
if there is no hit
* @see #rayTraceBlocks(Location, Vector, double, FluidCollisionMode, boolean)
*/
- public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance);
+ @Nullable
+ public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance);
/**
* Performs a ray trace that checks for block collisions using the blocks'
@@ -632,7 +666,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the ray trace hit result, or null
if there is no hit
* @see #rayTraceBlocks(Location, Vector, double, FluidCollisionMode, boolean)
*/
- public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode);
+ @Nullable
+ public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode);
/**
* Performs a ray trace that checks for block collisions using the blocks'
@@ -656,7 +691,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* blocks (ex. tall grass, signs, fluids, ..)
* @return the ray trace hit result, or null
if there is no hit
*/
- public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks);
+ @Nullable
+ public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks);
/**
* Performs a ray trace that checks for both block and entity collisions.
@@ -688,13 +724,15 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the closest ray trace hit result with either a block or an
* entity, or null
if there is no hit
*/
- public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate filter);
+ @Nullable
+ public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate filter);
/**
* Gets the unique name of this world
*
* @return Name of this world
*/
+ @NotNull
public String getName();
/**
@@ -702,6 +740,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return Unique ID of this world.
*/
+ @NotNull
public UUID getUID();
/**
@@ -709,6 +748,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return The spawn location of this world
*/
+ @NotNull
public Location getSpawnLocation();
/**
@@ -719,7 +759,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location The {@link Location} to set the spawn for this world at.
* @return True if it was successfully set.
*/
- public boolean setSpawnLocation(Location location);
+ @NotNull
+ public boolean setSpawnLocation(@NotNull Location location);
/**
* Sets the spawn location of the world
@@ -877,7 +918,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
- public boolean createExplosion(Location loc, float power);
+ public boolean createExplosion(@NotNull Location loc, float power);
/**
* Creates explosion at given coordinates with given power and optionally
@@ -888,13 +929,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
- public boolean createExplosion(Location loc, float power, boolean setFire);
+ public boolean createExplosion(@NotNull Location loc, float power, boolean setFire);
/**
* Gets the {@link Environment} type of this world
*
* @return This worlds Environment type
*/
+ @NotNull
public Environment getEnvironment();
/**
@@ -923,6 +965,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return ChunkGenerator associated with this world
*/
+ @Nullable
public ChunkGenerator getGenerator();
/**
@@ -935,6 +978,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return List containing any or none BlockPopulators
*/
+ @NotNull
public List getPopulators();
/**
@@ -947,7 +991,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @throws IllegalArgumentException if either parameter is null or the
* {@link Entity} requested cannot be spawned
*/
- public T spawn(Location location, Class clazz) throws IllegalArgumentException;
+ @NotNull
+ public T spawn(@NotNull Location location, @NotNull Class clazz) throws IllegalArgumentException;
/**
* Spawn an entity of a specific class at the given {@link Location}, with
@@ -965,7 +1010,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @throws IllegalArgumentException if either parameter is null or the
* {@link Entity} requested cannot be spawned
*/
- public T spawn(Location location, Class clazz, Consumer function) throws IllegalArgumentException;
+ @NotNull
+ public T spawn(@NotNull Location location, @NotNull Class clazz, @Nullable Consumer function) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of
@@ -981,7 +1027,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @throws IllegalArgumentException if {@link Location} or {@link
* MaterialData} are null or {@link Material} of the {@link MaterialData} is not a block
*/
- public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException;
+ @NotNull
+ public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of
@@ -997,7 +1044,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @throws IllegalArgumentException if {@link Location} or {@link
* BlockData} are null
*/
- public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException;
+ @NotNull
+ public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of the
@@ -1016,7 +1064,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value
*/
@Deprecated
- public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException;
+ @NotNull
+ public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull Material material, byte data) throws IllegalArgumentException;
/**
* Plays an effect to all players within a default radius around a given
@@ -1027,7 +1076,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param effect the {@link Effect}
* @param data a data bit needed for some effects
*/
- public void playEffect(Location location, Effect effect, int data);
+ public void playEffect(@NotNull Location location, @NotNull Effect effect, int data);
/**
* Plays an effect to all players within a given radius around a location.
@@ -1038,7 +1087,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data a data bit needed for some effects
* @param radius the radius around the location
*/
- public void playEffect(Location location, Effect effect, int data, int radius);
+ public void playEffect(@NotNull Location location, @NotNull Effect effect, int data, int radius);
/**
* Plays an effect to all players within a default radius around a given
@@ -1050,7 +1099,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param effect the {@link Effect}
* @param data a data bit needed for some effects
*/
- public void playEffect(Location location, Effect effect, T data);
+ public void playEffect(@NotNull Location location, @NotNull Effect effect, @Nullable T data);
/**
* Plays an effect to all players within a given radius around a location.
@@ -1062,7 +1111,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data a data bit needed for some effects
* @param radius the radius around the location
*/
- public void playEffect(Location location, Effect effect, T data, int radius);
+ public void playEffect(@NotNull Location location, @NotNull Effect effect, @Nullable T data, int radius);
/**
* Get empty chunk snapshot (equivalent to all air blocks), optionally
@@ -1077,6 +1126,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* raw biome temperature
* @return The empty snapshot.
*/
+ @NotNull
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTemp);
/**
@@ -1110,6 +1160,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate of the block
* @return Biome of the requested block
*/
+ @NotNull
Biome getBiome(int x, int z);
/**
@@ -1119,7 +1170,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate of the block
* @param bio new Biome type for this block
*/
- void setBiome(int x, int z, Biome bio);
+ void setBiome(int x, int z, @NotNull Biome bio);
/**
* Gets the temperature for the given block coordinates.
@@ -1203,13 +1254,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @param difficulty the new difficulty you want to set the world to
*/
- public void setDifficulty(Difficulty difficulty);
+ public void setDifficulty(@NotNull Difficulty difficulty);
/**
* Gets the Difficulty of the world.
*
* @return The difficulty of the world.
*/
+ @NotNull
public Difficulty getDifficulty();
/**
@@ -1217,6 +1269,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return The folder of this world.
*/
+ @NotNull
public File getWorldFolder();
/**
@@ -1224,6 +1277,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return Type of this world.
*/
+ @Nullable
public WorldType getWorldType();
/**
@@ -1425,7 +1479,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param volume The volume of the sound
* @param pitch The pitch of the sound
*/
- void playSound(Location location, Sound sound, float volume, float pitch);
+ void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World.
@@ -1439,7 +1493,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param volume the volume of the sound
* @param pitch the pitch of the sound
*/
- void playSound(Location location, String sound, float volume, float pitch);
+ void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World.
@@ -1452,7 +1506,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param volume The volume of the sound
* @param pitch The pitch of the sound
*/
- void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch);
+ void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World.
@@ -1467,13 +1521,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param volume the volume of the sound
* @param pitch the pitch of the sound
*/
- void playSound(Location location, String sound, SoundCategory category, float volume, float pitch);
+ void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch);
/**
* Get an array containing the names of all the {@link GameRule}s.
*
* @return An array of {@link GameRule} names.
*/
+ @NotNull
public String[] getGameRules();
/**
@@ -1486,7 +1541,9 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated use {@link #getGameRuleValue(GameRule)} instead
*/
@Deprecated
- public String getGameRuleValue(String rule);
+ @Contract("null -> null; !null -> !null")
+ @Nullable
+ public String getGameRuleValue(@Nullable String rule);
/**
* Set the specified gamerule to specified value.
@@ -1502,7 +1559,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated use {@link #setGameRule(GameRule, Object)} instead.
*/
@Deprecated
- public boolean setGameRuleValue(String rule, String value);
+ public boolean setGameRuleValue(@NotNull String rule, @NotNull String value);
/**
* Checks if string is a valid game rule
@@ -1510,7 +1567,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param rule Rule to check
* @return True if rule exists
*/
- public boolean isGameRule(String rule);
+ public boolean isGameRule(@NotNull String rule);
/**
* Get the current value for a given {@link GameRule}.
@@ -1519,7 +1576,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param the GameRule's type
* @return the current value
*/
- public T getGameRuleValue(GameRule rule);
+ @Nullable
+ public T getGameRuleValue(@NotNull GameRule rule);
/**
* Get the default value for a given {@link GameRule}. This value is not
@@ -1529,7 +1587,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param the type of GameRule
* @return the default value
*/
- public T getGameRuleDefault(GameRule rule);
+ @Nullable
+ public T getGameRuleDefault(@NotNull GameRule rule);
/**
* Set the given {@link GameRule}'s new value.
@@ -1539,13 +1598,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param the value type of the GameRule
* @return true if the value was successfully set
*/
- public boolean setGameRule(GameRule rule, T newValue);
+ public boolean setGameRule(@NotNull GameRule rule, @NotNull T newValue);
/**
* Gets the world border for this world.
*
* @return The world border for this world.
*/
+ @NotNull
public WorldBorder getWorldBorder();
/**
@@ -1556,7 +1616,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location the location to spawn at
* @param count the number of particles
*/
- public void spawnParticle(Particle particle, Location location, int count);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count);
/**
* Spawns the particle (the number of times specified by count)
@@ -1568,7 +1628,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z the position on the z axis to spawn at
* @param count the number of particles
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count);
/**
* Spawns the particle (the number of times specified by count)
@@ -1580,7 +1640,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()}
*/
- public void spawnParticle(Particle particle, Location location, int count, T data);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, @Nullable T data);
/**
@@ -1595,7 +1655,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()}
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count, T data);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, @Nullable T data);
/**
* Spawns the particle (the number of times specified by count)
@@ -1610,7 +1670,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param offsetY the maximum random offset on the Y axis
* @param offsetZ the maximum random offset on the Z axis
*/
- public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ);
/**
* Spawns the particle (the number of times specified by count)
@@ -1627,7 +1687,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param offsetY the maximum random offset on the Y axis
* @param offsetZ the maximum random offset on the Z axis
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ);
/**
* Spawns the particle (the number of times specified by count)
@@ -1644,7 +1704,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()}
*/
- public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, @Nullable T data);
/**
* Spawns the particle (the number of times specified by count)
@@ -1663,7 +1723,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()}
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, @Nullable T data);
/**
* Spawns the particle (the number of times specified by count)
@@ -1680,7 +1740,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param extra the extra data for this particle, depends on the
* particle used (normally speed)
*/
- public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra);
/**
* Spawns the particle (the number of times specified by count)
@@ -1699,7 +1759,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param extra the extra data for this particle, depends on the
* particle used (normally speed)
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra);
/**
* Spawns the particle (the number of times specified by count)
@@ -1718,7 +1778,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()}
*/
- public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data);
/**
* Spawns the particle (the number of times specified by count)
@@ -1739,7 +1799,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()}
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data);
/**
* Spawns the particle (the number of times specified by count)
@@ -1761,7 +1821,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* range and encourage their client to render it regardless of
* settings
*/
- public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force);
+ public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force);
/**
* Spawns the particle (the number of times specified by count)
@@ -1785,7 +1845,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* range and encourage their client to render it regardless of
* settings
*/
- public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force);
+ public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force);
/**
* Find the closest nearby structure of a given {@link StructureType}.
@@ -1811,7 +1871,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return the closest {@link Location}, or null if no structure of the
* specified type exists.
*/
- public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored);
+ @Nullable
+ public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored);
/**
* Represents various map environment types that a world may be
@@ -1857,6 +1918,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value
*/
@Deprecated
+ @Nullable
public static Environment getEnvironment(int id) {
return lookup.get(id);
}
diff --git a/paper-api/src/main/java/org/bukkit/WorldBorder.java b/paper-api/src/main/java/org/bukkit/WorldBorder.java
index 4dc18edc72..7e8f5649ce 100644
--- a/paper-api/src/main/java/org/bukkit/WorldBorder.java
+++ b/paper-api/src/main/java/org/bukkit/WorldBorder.java
@@ -1,5 +1,7 @@
package org.bukkit;
+import org.jetbrains.annotations.NotNull;
+
public interface WorldBorder {
/**
@@ -34,6 +36,7 @@ public interface WorldBorder {
*
* @return The current border center.
*/
+ @NotNull
public Location getCenter();
/**
@@ -49,7 +52,7 @@ public interface WorldBorder {
*
* @param location The new location of the border center. (Only x/z used)
*/
- public void setCenter(Location location);
+ public void setCenter(@NotNull Location location);
/**
* Gets the current border damage buffer.
@@ -113,5 +116,5 @@ public interface WorldBorder {
* @param location the location to check
* @return if this location is inside the border or not
*/
- public boolean isInside(Location location);
+ public boolean isInside(@NotNull Location location);
}
diff --git a/paper-api/src/main/java/org/bukkit/WorldCreator.java b/paper-api/src/main/java/org/bukkit/WorldCreator.java
index 53980fdbc6..a9b29b6e2e 100644
--- a/paper-api/src/main/java/org/bukkit/WorldCreator.java
+++ b/paper-api/src/main/java/org/bukkit/WorldCreator.java
@@ -4,6 +4,8 @@ import java.util.Random;
import org.bukkit.command.CommandSender;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Represents various types of options that may be used to create a world.
@@ -22,7 +24,7 @@ public class WorldCreator {
*
* @param name Name of the world that will be created
*/
- public WorldCreator(String name) {
+ public WorldCreator(@NotNull String name) {
if (name == null) {
throw new IllegalArgumentException("World name cannot be null");
}
@@ -37,7 +39,8 @@ public class WorldCreator {
* @param world World to copy options from
* @return This object, for chaining
*/
- public WorldCreator copy(World world) {
+ @NotNull
+ public WorldCreator copy(@NotNull World world) {
if (world == null) {
throw new IllegalArgumentException("World cannot be null");
}
@@ -55,7 +58,8 @@ public class WorldCreator {
* @param creator World creator to copy options from
* @return This object, for chaining
*/
- public WorldCreator copy(WorldCreator creator) {
+ @NotNull
+ public WorldCreator copy(@NotNull WorldCreator creator) {
if (creator == null) {
throw new IllegalArgumentException("Creator cannot be null");
}
@@ -72,6 +76,7 @@ public class WorldCreator {
*
* @return World name
*/
+ @NotNull
public String name() {
return name;
}
@@ -91,6 +96,7 @@ public class WorldCreator {
* @param seed World seed
* @return This object, for chaining
*/
+ @NotNull
public WorldCreator seed(long seed) {
this.seed = seed;
@@ -102,6 +108,7 @@ public class WorldCreator {
*
* @return World environment
*/
+ @NotNull
public World.Environment environment() {
return environment;
}
@@ -112,7 +119,8 @@ public class WorldCreator {
* @param env World environment
* @return This object, for chaining
*/
- public WorldCreator environment(World.Environment env) {
+ @NotNull
+ public WorldCreator environment(@NotNull World.Environment env) {
this.environment = env;
return this;
@@ -123,6 +131,7 @@ public class WorldCreator {
*
* @return World type
*/
+ @NotNull
public WorldType type() {
return type;
}
@@ -133,7 +142,8 @@ public class WorldCreator {
* @param type World type
* @return This object, for chaining
*/
- public WorldCreator type(WorldType type) {
+ @NotNull
+ public WorldCreator type(@NotNull WorldType type) {
this.type = type;
return this;
@@ -147,6 +157,7 @@ public class WorldCreator {
*
* @return Chunk generator
*/
+ @Nullable
public ChunkGenerator generator() {
return generator;
}
@@ -160,7 +171,8 @@ public class WorldCreator {
* @param generator Chunk generator
* @return This object, for chaining
*/
- public WorldCreator generator(ChunkGenerator generator) {
+ @NotNull
+ public WorldCreator generator(@Nullable ChunkGenerator generator) {
this.generator = generator;
return this;
@@ -179,7 +191,8 @@ public class WorldCreator {
* @param generator Name of the generator to use, in "plugin:id" notation
* @return This object, for chaining
*/
- public WorldCreator generator(String generator) {
+ @NotNull
+ public WorldCreator generator(@Nullable String generator) {
this.generator = getGeneratorForName(name, generator, Bukkit.getConsoleSender());
return this;
@@ -200,7 +213,8 @@ public class WorldCreator {
* messages
* @return This object, for chaining
*/
- public WorldCreator generator(String generator, CommandSender output) {
+ @NotNull
+ public WorldCreator generator(@Nullable String generator, @Nullable CommandSender output) {
this.generator = getGeneratorForName(name, generator, output);
return this;
@@ -212,7 +226,8 @@ public class WorldCreator {
* @param generatorSettings The settings that should be used by the generator
* @return This object, for chaining
*/
- public WorldCreator generatorSettings(String generatorSettings) {
+ @NotNull
+ public WorldCreator generatorSettings(@NotNull String generatorSettings) {
this.generatorSettings = generatorSettings;
return this;
@@ -223,6 +238,7 @@ public class WorldCreator {
*
* @return The settings that should be used by the generator
*/
+ @NotNull
public String generatorSettings() {
return generatorSettings;
}
@@ -234,6 +250,7 @@ public class WorldCreator {
* @param generate Whether to generate structures
* @return This object, for chaining
*/
+ @NotNull
public WorldCreator generateStructures(boolean generate) {
this.generateStructures = generate;
@@ -257,6 +274,7 @@ public class WorldCreator {
*
* @return Newly created or loaded world
*/
+ @Nullable
public World createWorld() {
return Bukkit.createWorld(this);
}
@@ -267,7 +285,8 @@ public class WorldCreator {
* @param name Name of the world to load or create
* @return Resulting WorldCreator
*/
- public static WorldCreator name(String name) {
+ @NotNull
+ public static WorldCreator name(@NotNull String name) {
return new WorldCreator(name);
}
@@ -287,7 +306,8 @@ public class WorldCreator {
* @param output Where to output if errors are present
* @return Resulting generator, or null
*/
- public static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output) {
+ @Nullable
+ public static ChunkGenerator getGeneratorForName(@NotNull String world, @Nullable String name, @Nullable CommandSender output) {
ChunkGenerator result = null;
if (world == null) {
diff --git a/paper-api/src/main/java/org/bukkit/WorldType.java b/paper-api/src/main/java/org/bukkit/WorldType.java
index ba481fc1b4..d3be76363a 100644
--- a/paper-api/src/main/java/org/bukkit/WorldType.java
+++ b/paper-api/src/main/java/org/bukkit/WorldType.java
@@ -1,6 +1,9 @@
package org.bukkit;
import com.google.common.collect.Maps;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.util.Map;
/**
@@ -18,7 +21,7 @@ public enum WorldType {
private final static Map BY_NAME = Maps.newHashMap();
private final String name;
- private WorldType(String name) {
+ private WorldType(@NotNull String name) {
this.name = name;
}
@@ -27,17 +30,19 @@ public enum WorldType {
*
* @return Name of this type
*/
+ @NotNull
public String getName() {
return name;
}
/**
- * Gets a Worldtype by its name
+ * Gets a WorldType by its name
*
* @param name Name of the WorldType to get
* @return Requested WorldType, or null if not found
*/
- public static WorldType getByName(String name) {
+ @Nullable
+ public static WorldType getByName(@NotNull String name) {
return BY_NAME.get(name.toUpperCase(java.util.Locale.ENGLISH));
}
diff --git a/paper-api/src/main/java/org/bukkit/advancement/Advancement.java b/paper-api/src/main/java/org/bukkit/advancement/Advancement.java
index c2bf3d5b44..7c5009974a 100644
--- a/paper-api/src/main/java/org/bukkit/advancement/Advancement.java
+++ b/paper-api/src/main/java/org/bukkit/advancement/Advancement.java
@@ -2,6 +2,7 @@ package org.bukkit.advancement;
import java.util.Collection;
import org.bukkit.Keyed;
+import org.jetbrains.annotations.NotNull;
/**
* Represents an advancement that may be awarded to a player. This class is not
@@ -14,5 +15,6 @@ public interface Advancement extends Keyed {
*
* @return a unmodifiable copy of all criteria
*/
+ @NotNull
Collection getCriteria();
}
diff --git a/paper-api/src/main/java/org/bukkit/advancement/AdvancementProgress.java b/paper-api/src/main/java/org/bukkit/advancement/AdvancementProgress.java
index 46b6637d8e..00823dc9b8 100644
--- a/paper-api/src/main/java/org/bukkit/advancement/AdvancementProgress.java
+++ b/paper-api/src/main/java/org/bukkit/advancement/AdvancementProgress.java
@@ -1,5 +1,8 @@
package org.bukkit.advancement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.util.Collection;
import java.util.Date;
@@ -14,6 +17,7 @@ public interface AdvancementProgress {
*
* @return the relevant advancement
*/
+ @NotNull
Advancement getAdvancement();
/**
@@ -30,7 +34,7 @@ public interface AdvancementProgress {
* @return true if awarded, false if criteria does not exist or already
* awarded.
*/
- boolean awardCriteria(String criteria);
+ boolean awardCriteria(@NotNull String criteria);
/**
* Mark the specified criteria as uncompleted.
@@ -38,7 +42,7 @@ public interface AdvancementProgress {
* @param criteria the criteria to mark
* @return true if removed, false if criteria does not exist or not awarded
*/
- boolean revokeCriteria(String criteria);
+ boolean revokeCriteria(@NotNull String criteria);
/**
* Get the date the specified criteria was awarded.
@@ -46,13 +50,15 @@ public interface AdvancementProgress {
* @param criteria the criteria to check
* @return date awarded or null if unawarded or criteria does not exist
*/
- Date getDateAwarded(String criteria);
+ @Nullable
+ Date getDateAwarded(@NotNull String criteria);
/**
* Get the criteria which have not been awarded.
*
* @return unmodifiable copy of criteria remaining
*/
+ @NotNull
Collection getRemainingCriteria();
/**
@@ -60,5 +66,6 @@ public interface AdvancementProgress {
*
* @return unmodifiable copy of criteria awarded
*/
+ @NotNull
Collection getAwardedCriteria();
}
diff --git a/paper-api/src/main/java/org/bukkit/attribute/Attributable.java b/paper-api/src/main/java/org/bukkit/attribute/Attributable.java
index 155f13f160..0ed96b5af0 100644
--- a/paper-api/src/main/java/org/bukkit/attribute/Attributable.java
+++ b/paper-api/src/main/java/org/bukkit/attribute/Attributable.java
@@ -1,5 +1,8 @@
package org.bukkit.attribute;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
/**
* Represents an object which may contain attributes.
*/
@@ -12,5 +15,6 @@ public interface Attributable {
* @param attribute the attribute to get
* @return the attribute instance or null if not applicable to this object
*/
- AttributeInstance getAttribute(Attribute attribute);
+ @Nullable
+ AttributeInstance getAttribute(@NotNull Attribute attribute);
}
diff --git a/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java b/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java
index ca8b76a6f1..18bafb04e6 100644
--- a/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java
+++ b/paper-api/src/main/java/org/bukkit/attribute/AttributeInstance.java
@@ -1,5 +1,7 @@
package org.bukkit.attribute;
+import org.jetbrains.annotations.NotNull;
+
import java.util.Collection;
/**
@@ -13,6 +15,7 @@ public interface AttributeInstance {
*
* @return the attribute
*/
+ @NotNull
Attribute getAttribute();
/**
@@ -34,6 +37,7 @@ public interface AttributeInstance {
*
* @return a copied collection of all modifiers
*/
+ @NotNull
Collection getModifiers();
/**
@@ -41,14 +45,14 @@ public interface AttributeInstance {
*
* @param modifier to add
*/
- void addModifier(AttributeModifier modifier);
+ void addModifier(@NotNull AttributeModifier modifier);
/**
* Remove a modifier from this instance.
*
* @param modifier to remove
*/
- void removeModifier(AttributeModifier modifier);
+ void removeModifier(@NotNull AttributeModifier modifier);
/**
* Get the value of this instance after all associated modifiers have been
diff --git a/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java b/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java
index 2bc9878ff3..a976314745 100644
--- a/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java
+++ b/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java
@@ -8,6 +8,8 @@ import org.apache.commons.lang.Validate;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.NumberConversions;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Concrete implementation of an attribute modifier.
@@ -20,15 +22,15 @@ public class AttributeModifier implements ConfigurationSerializable {
private final Operation operation;
private final EquipmentSlot slot;
- public AttributeModifier(String name, double amount, Operation operation) {
+ public AttributeModifier(@NotNull String name, double amount, @NotNull Operation operation) {
this(UUID.randomUUID(), name, amount, operation);
}
- public AttributeModifier(UUID uuid, String name, double amount, Operation operation) {
+ public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation) {
this(uuid, name, amount, operation, null);
}
- public AttributeModifier(UUID uuid, String name, double amount, Operation operation, EquipmentSlot slot) {
+ public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @Nullable EquipmentSlot slot) {
Validate.notNull(uuid, "UUID cannot be null");
Validate.notEmpty(name, "Name cannot be empty");
Validate.notNull(operation, "Operation cannot be null");
@@ -44,6 +46,7 @@ public class AttributeModifier implements ConfigurationSerializable {
*
* @return unique id
*/
+ @NotNull
public UUID getUniqueId() {
return uuid;
}
@@ -53,6 +56,7 @@ public class AttributeModifier implements ConfigurationSerializable {
*
* @return name
*/
+ @NotNull
public String getName() {
return name;
}
@@ -71,6 +75,7 @@ public class AttributeModifier implements ConfigurationSerializable {
*
* @return operation
*/
+ @NotNull
public Operation getOperation() {
return operation;
}
@@ -81,10 +86,12 @@ public class AttributeModifier implements ConfigurationSerializable {
*
* @return the slot
*/
+ @Nullable
public EquipmentSlot getSlot() {
return slot;
}
+ @NotNull
@Override
public Map serialize() {
Map data = new HashMap();
@@ -130,7 +137,8 @@ public class AttributeModifier implements ConfigurationSerializable {
+ "}";
}
- public static AttributeModifier deserialize(Map args) {
+ @NotNull
+ public static AttributeModifier deserialize(@NotNull Map args) {
if (args.containsKey("slot")) {
return new AttributeModifier(UUID.fromString((String) args.get("uuid")), (String) args.get("name"), NumberConversions.toDouble(args.get("amount")), Operation.values()[NumberConversions.toInt(args.get("operation"))], EquipmentSlot.valueOf((args.get("slot").toString().toUpperCase())));
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Banner.java b/paper-api/src/main/java/org/bukkit/block/Banner.java
index 0ce851dd6b..befa9da6f7 100644
--- a/paper-api/src/main/java/org/bukkit/block/Banner.java
+++ b/paper-api/src/main/java/org/bukkit/block/Banner.java
@@ -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 getPatterns();
/**
@@ -38,7 +41,7 @@ public interface Banner extends BlockState {
*
* @param patterns the new list of patterns
*/
- void setPatterns(List patterns);
+ void setPatterns(@NotNull List 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
diff --git a/paper-api/src/main/java/org/bukkit/block/Beacon.java b/paper-api/src/main/java/org/bukkit/block/Beacon.java
index 97d3921319..e5332c0a73 100644
--- a/paper-api/src/main/java/org/bukkit/block/Beacon.java
+++ b/paper-api/src/main/java/org/bukkit/block/Beacon.java
@@ -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 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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Block.java b/paper-api/src/main/java/org/bukkit/block/Block.java
index 7664728a04..c88088c0fe 100644
--- a/paper-api/src/main/java/org/bukkit/block/Block.java
+++ b/paper-api/src/main/java/org/bukkit/block/Block.java
@@ -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 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 getDrops(ItemStack tool);
+ @NotNull
+ Collection 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 null
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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/BlockFace.java b/paper-api/src/main/java/org/bukkit/block/BlockFace.java
index 959ee3a657..2fed469b67 100644
--- a/paper-api/src/main/java/org/bukkit/block/BlockFace.java
+++ b/paper-api/src/main/java/org/bukkit/block/BlockFace.java
@@ -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:
diff --git a/paper-api/src/main/java/org/bukkit/block/BlockState.java b/paper-api/src/main/java/org/bukkit/block/BlockState.java
index e6526060a8..631cbf2be5 100644
--- a/paper-api/src/main/java/org/bukkit/block/BlockState.java
+++ b/paper-api/src/main/java/org/bukkit/block/BlockState.java
@@ -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
diff --git a/paper-api/src/main/java/org/bukkit/block/BrewingStand.java b/paper-api/src/main/java/org/bukkit/block/BrewingStand.java
index f276c304f8..7611a126c5 100644
--- a/paper-api/src/main/java/org/bukkit/block/BrewingStand.java
+++ b/paper-api/src/main/java/org/bukkit/block/BrewingStand.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Chest.java b/paper-api/src/main/java/org/bukkit/block/Chest.java
index 815d79a533..c553891e0e 100644
--- a/paper-api/src/main/java/org/bukkit/block/Chest.java
+++ b/paper-api/src/main/java/org/bukkit/block/Chest.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/CommandBlock.java b/paper-api/src/main/java/org/bukkit/block/CommandBlock.java
index f94856cfec..b7ee5bc940 100644
--- a/paper-api/src/main/java/org/bukkit/block/CommandBlock.java
+++ b/paper-api/src/main/java/org/bukkit/block/CommandBlock.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Container.java b/paper-api/src/main/java/org/bukkit/block/Container.java
index 9eee5cc0f3..96888ba891 100644
--- a/paper-api/src/main/java/org/bukkit/block/Container.java
+++ b/paper-api/src/main/java/org/bukkit/block/Container.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/CreatureSpawner.java b/paper-api/src/main/java/org/bukkit/block/CreatureSpawner.java
index 8afa7fc479..5773e99ee6 100644
--- a/paper-api/src/main/java/org/bukkit/block/CreatureSpawner.java
+++ b/paper-api/src/main/java/org/bukkit/block/CreatureSpawner.java
@@ -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();
/**
diff --git a/paper-api/src/main/java/org/bukkit/block/Dispenser.java b/paper-api/src/main/java/org/bukkit/block/Dispenser.java
index 2741625db6..74cd194c9a 100644
--- a/paper-api/src/main/java/org/bukkit/block/Dispenser.java
+++ b/paper-api/src/main/java/org/bukkit/block/Dispenser.java
@@ -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();
/**
diff --git a/paper-api/src/main/java/org/bukkit/block/DoubleChest.java b/paper-api/src/main/java/org/bukkit/block/DoubleChest.java
index 663fcbbd89..97153adfad 100644
--- a/paper-api/src/main/java/org/bukkit/block/DoubleChest.java
+++ b/paper-api/src/main/java/org/bukkit/block/DoubleChest.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/EndGateway.java b/paper-api/src/main/java/org/bukkit/block/EndGateway.java
index 4849436eca..e737f2db20 100644
--- a/paper-api/src/main/java/org/bukkit/block/EndGateway.java
+++ b/paper-api/src/main/java/org/bukkit/block/EndGateway.java
@@ -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
diff --git a/paper-api/src/main/java/org/bukkit/block/FlowerPot.java b/paper-api/src/main/java/org/bukkit/block/FlowerPot.java
index 84029183bc..1155edc3a0 100644
--- a/paper-api/src/main/java/org/bukkit/block/FlowerPot.java
+++ b/paper-api/src/main/java/org/bukkit/block/FlowerPot.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Furnace.java b/paper-api/src/main/java/org/bukkit/block/Furnace.java
index fb82104bae..db3d22fa9a 100644
--- a/paper-api/src/main/java/org/bukkit/block/Furnace.java
+++ b/paper-api/src/main/java/org/bukkit/block/Furnace.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Jukebox.java b/paper-api/src/main/java/org/bukkit/block/Jukebox.java
index fb600c2b87..1203182f34 100644
--- a/paper-api/src/main/java/org/bukkit/block/Jukebox.java
+++ b/paper-api/src/main/java/org/bukkit/block/Jukebox.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/Lockable.java b/paper-api/src/main/java/org/bukkit/block/Lockable.java
index 5e9f76146c..f307cb1701 100644
--- a/paper-api/src/main/java/org/bukkit/block/Lockable.java
+++ b/paper-api/src/main/java/org/bukkit/block/Lockable.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/PistonMoveReaction.java b/paper-api/src/main/java/org/bukkit/block/PistonMoveReaction.java
index 3df37d0dce..02df886824 100644
--- a/paper-api/src/main/java/org/bukkit/block/PistonMoveReaction.java
+++ b/paper-api/src/main/java/org/bukkit/block/PistonMoveReaction.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/ShulkerBox.java b/paper-api/src/main/java/org/bukkit/block/ShulkerBox.java
index 8e061e4a4c..5a6bed64aa 100644
--- a/paper-api/src/main/java/org/bukkit/block/ShulkerBox.java
+++ b/paper-api/src/main/java/org/bukkit/block/ShulkerBox.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Sign.java b/paper-api/src/main/java/org/bukkit/block/Sign.java
index 9e7717ca41..74db5efcb8 100644
--- a/paper-api/src/main/java/org/bukkit/block/Sign.java
+++ b/paper-api/src/main/java/org/bukkit/block/Sign.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/Skull.java b/paper-api/src/main/java/org/bukkit/block/Skull.java
index 499a153e65..6325f58380 100644
--- a/paper-api/src/main/java/org/bukkit/block/Skull.java
+++ b/paper-api/src/main/java/org/bukkit/block/Skull.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/Structure.java b/paper-api/src/main/java/org/bukkit/block/Structure.java
index eb7a5363da..d0f1d507ed 100644
--- a/paper-api/src/main/java/org/bukkit/block/Structure.java
+++ b/paper-api/src/main/java/org/bukkit/block/Structure.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/banner/Pattern.java b/paper-api/src/main/java/org/bukkit/block/banner/Pattern.java
index e57c1a6cf3..5c293ab0b7 100644
--- a/paper-api/src/main/java/org/bukkit/block/banner/Pattern.java
+++ b/paper-api/src/main/java/org/bukkit/block/banner/Pattern.java
@@ -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 map) {
+ public Pattern(@NotNull Map 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 serialize() {
return ImmutableMap.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;
}
diff --git a/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java b/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java
index 25543b0b16..5c3a902387 100644
--- a/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java
+++ b/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java
@@ -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);
}
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/Bisected.java b/paper-api/src/main/java/org/bukkit/block/data/Bisected.java
index ece44a44c3..7b7c0d2be7 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/Bisected.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/Bisected.java
@@ -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.
*
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/BlockData.java b/paper-api/src/main/java/org/bukkit/block/data/BlockData.java
index cf4edde485..22c5e84eb2 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/BlockData.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/BlockData.java
@@ -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();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/Directional.java b/paper-api/src/main/java/org/bukkit/block/data/Directional.java
index 4e873e85e9..825ff08ddd 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/Directional.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/Directional.java
@@ -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 getFaces();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/MultipleFacing.java b/paper-api/src/main/java/org/bukkit/block/data/MultipleFacing.java
index 76fda60dff..e790b7fdb0 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/MultipleFacing.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/MultipleFacing.java
@@ -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 getFaces();
/**
@@ -41,5 +44,6 @@ public interface MultipleFacing extends BlockData {
*
* @return all allowed faces
*/
+ @NotNull
Set getAllowedFaces();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/Orientable.java b/paper-api/src/main/java/org/bukkit/block/data/Orientable.java
index f9cf29837c..5b4561a165 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/Orientable.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/Orientable.java
@@ -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 getAxes();
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/Rail.java b/paper-api/src/main/java/org/bukkit/block/data/Rail.java
index 18df0c0995..e8300a7414 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/Rail.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/Rail.java
@@ -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 getShapes();
/**
diff --git a/paper-api/src/main/java/org/bukkit/block/data/Rotatable.java b/paper-api/src/main/java/org/bukkit/block/data/Rotatable.java
index 07b3f61555..3f60fbce43 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/Rotatable.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/Rotatable.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Bed.java b/paper-api/src/main/java/org/bukkit/block/data/type/Bed.java
index bc1c95b029..ed519bfebe 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Bed.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Bed.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/BrewingStand.java b/paper-api/src/main/java/org/bukkit/block/data/type/BrewingStand.java
index 7694570082..6a7687d524 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/BrewingStand.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/BrewingStand.java
@@ -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 getBottles();
/**
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Chest.java b/paper-api/src/main/java/org/bukkit/block/data/type/Chest.java
index 7260240901..d79c3d0007 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Chest.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Chest.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Comparator.java b/paper-api/src/main/java/org/bukkit/block/data/type/Comparator.java
index efc7982ddb..6cfd296604 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Comparator.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Comparator.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Door.java b/paper-api/src/main/java/org/bukkit/block/data/type/Door.java
index dfea0933cc..5b0bba5efe 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Door.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Door.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/NoteBlock.java b/paper-api/src/main/java/org/bukkit/block/data/type/NoteBlock.java
index fb3a6ce58e..ec48ca8ca5 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/NoteBlock.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/NoteBlock.java
@@ -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);
}
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/RedstoneWire.java b/paper-api/src/main/java/org/bukkit/block/data/type/RedstoneWire.java
index c5e8d1ec12..ba8a80ee3e 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/RedstoneWire.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/RedstoneWire.java
@@ -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 getAllowedFaces();
/**
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Slab.java b/paper-api/src/main/java/org/bukkit/block/data/type/Slab.java
index a69007440e..cb09c32686 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Slab.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Slab.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Stairs.java b/paper-api/src/main/java/org/bukkit/block/data/type/Stairs.java
index 7bdf8de87a..8bc5539566 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Stairs.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Stairs.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/StructureBlock.java b/paper-api/src/main/java/org/bukkit/block/data/type/StructureBlock.java
index db09bf05b8..3c13a9a561 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/StructureBlock.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/StructureBlock.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java b/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java
index f6a5f55ba8..1060cb55b6 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/TechnicalPiston.java b/paper-api/src/main/java/org/bukkit/block/data/type/TechnicalPiston.java
index 257446d786..4c8b6e9be9 100644
--- a/paper-api/src/main/java/org/bukkit/block/data/type/TechnicalPiston.java
+++ b/paper-api/src/main/java/org/bukkit/block/data/type/TechnicalPiston.java
@@ -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.
diff --git a/paper-api/src/main/java/org/bukkit/boss/BossBar.java b/paper-api/src/main/java/org/bukkit/boss/BossBar.java
index effc329511..acaf8ff0b0 100644
--- a/paper-api/src/main/java/org/bukkit/boss/BossBar.java
+++ b/paper-api/src/main/java/org/bukkit/boss/BossBar.java
@@ -1,6 +1,9 @@
package org.bukkit.boss;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -11,6 +14,7 @@ public interface BossBar {
*
* @return the title of the bar
*/
+ @NotNull
String getTitle();
/**
@@ -18,13 +22,14 @@ public interface BossBar {
*
* @param title the title of the bar
*/
- void setTitle(String title);
+ void setTitle(@Nullable String title);
/**
* Returns the color of this boss bar
*
* @return the color of the bar
*/
+ @NotNull
BarColor getColor();
/**
@@ -32,13 +37,14 @@ public interface BossBar {
*
* @param color the color of the bar
*/
- void setColor(BarColor color);
+ void setColor(@NotNull BarColor color);
/**
* Returns the style of this boss bar
*
* @return the style of the bar
*/
+ @NotNull
BarStyle getStyle();
/**
@@ -46,21 +52,21 @@ public interface BossBar {
*
* @param style the style of the bar
*/
- void setStyle(BarStyle style);
+ void setStyle(@NotNull BarStyle style);
/**
* Remove an existing flag on this boss bar
*
* @param flag the existing flag to remove
*/
- void removeFlag(BarFlag flag);
+ void removeFlag(@NotNull BarFlag flag);
/**
* Add an optional flag to this boss bar
*
* @param flag an optional flag to set on the boss bar
*/
- void addFlag(BarFlag flag);
+ void addFlag(@NotNull BarFlag flag);
/**
* Returns whether this boss bar as the passed flag set
@@ -68,7 +74,7 @@ public interface BossBar {
* @param flag the flag to check
* @return whether it has the flag
*/
- boolean hasFlag(BarFlag flag);
+ boolean hasFlag(@NotNull BarFlag flag);
/**
* Sets the progress of the bar. Values should be between 0.0 (empty) and
@@ -90,7 +96,7 @@ public interface BossBar {
*
* @param player the player to add
*/
- void addPlayer(Player player);
+ void addPlayer(@NotNull Player player);
/**
* Removes the player from this boss bar causing it to be removed from their
@@ -98,7 +104,7 @@ public interface BossBar {
*
* @param player the player to remove
*/
- void removePlayer(Player player);
+ void removePlayer(@NotNull Player player);
/**
* Removes all players from this boss bar
@@ -112,6 +118,7 @@ public interface BossBar {
*
* @return a immutable list of players
*/
+ @NotNull
List getPlayers();
/**
diff --git a/paper-api/src/main/java/org/bukkit/command/BlockCommandSender.java b/paper-api/src/main/java/org/bukkit/command/BlockCommandSender.java
index ce229d24dc..b8f2f7ebe4 100644
--- a/paper-api/src/main/java/org/bukkit/command/BlockCommandSender.java
+++ b/paper-api/src/main/java/org/bukkit/command/BlockCommandSender.java
@@ -1,6 +1,7 @@
package org.bukkit.command;
import org.bukkit.block.Block;
+import org.jetbrains.annotations.NotNull;
public interface BlockCommandSender extends CommandSender {
@@ -9,5 +10,6 @@ public interface BlockCommandSender extends CommandSender {
*
* @return Block for the command sender
*/
+ @NotNull
public Block getBlock();
}
diff --git a/paper-api/src/main/java/org/bukkit/command/Command.java b/paper-api/src/main/java/org/bukkit/command/Command.java
index 1ad768c715..f0bfaaf764 100644
--- a/paper-api/src/main/java/org/bukkit/command/Command.java
+++ b/paper-api/src/main/java/org/bukkit/command/Command.java
@@ -18,6 +18,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.util.StringUtil;
import com.google.common.collect.ImmutableList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Represents a Command, which executes various tasks upon user input
@@ -28,22 +30,22 @@ public abstract class Command {
private String label;
private List aliases;
private List activeAliases;
- private CommandMap commandMap = null;
- protected String description = "";
+ private CommandMap commandMap;
+ protected String description;
protected String usageMessage;
private String permission;
private String permissionMessage;
- protected Command(String name) {
+ protected Command(@NotNull String name) {
this(name, "", "/" + name, new ArrayList());
}
- protected Command(String name, String description, String usageMessage, List aliases) {
+ protected Command(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List aliases) {
this.name = name;
this.nextLabel = name;
this.label = name;
- this.description = description;
- this.usageMessage = usageMessage;
+ this.description = (description == null) ? "" : description;
+ this.usageMessage = (usageMessage == null) ? "/" + name : usageMessage;
this.aliases = aliases;
this.activeAliases = new ArrayList(aliases);
}
@@ -56,7 +58,7 @@ public abstract class Command {
* @param args All arguments passed to the command, split via ' '
* @return true if the command was successful, otherwise false
*/
- public abstract boolean execute(CommandSender sender, String commandLabel, String[] args);
+ public abstract boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args);
/**
* Executed on tab completion for this command, returning a list of
@@ -69,7 +71,8 @@ public abstract class Command {
* will never be null. List may be immutable.
* @throws IllegalArgumentException if sender, alias, or args is null
*/
- public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
+ @NotNull
+ public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
return tabComplete0(sender, alias, args, null);
}
@@ -85,11 +88,13 @@ public abstract class Command {
* will never be null. List may be immutable.
* @throws IllegalArgumentException if sender, alias, or args is null
*/
- public List tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+ @NotNull
+ public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
return tabComplete(sender, alias, args);
}
- private List tabComplete0(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+ @NotNull
+ private List tabComplete0(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
@@ -119,6 +124,7 @@ public abstract class Command {
*
* @return Name of this command
*/
+ @NotNull
public String getName() {
return name;
}
@@ -134,9 +140,9 @@ public abstract class Command {
* @return returns true if the name change happened instantly or false if
* the command was already registered
*/
- public boolean setName(String name) {
+ public boolean setName(@NotNull String name) {
if (!isRegistered()) {
- this.name = name;
+ this.name = (name == null) ? "" : name;
return true;
}
return false;
@@ -148,6 +154,7 @@ public abstract class Command {
*
* @return Permission name, or null if none
*/
+ @Nullable
public String getPermission() {
return permission;
}
@@ -158,7 +165,7 @@ public abstract class Command {
*
* @param permission Permission name or null
*/
- public void setPermission(String permission) {
+ public void setPermission(@Nullable String permission) {
this.permission = permission;
}
@@ -172,7 +179,7 @@ public abstract class Command {
* @param target User to test
* @return true if they can use it, otherwise false
*/
- public boolean testPermission(CommandSender target) {
+ public boolean testPermission(@NotNull CommandSender target) {
if (testPermissionSilent(target)) {
return true;
}
@@ -197,7 +204,7 @@ public abstract class Command {
* @param target User to test
* @return true if they can use it, otherwise false
*/
- public boolean testPermissionSilent(CommandSender target) {
+ public boolean testPermissionSilent(@NotNull CommandSender target) {
if ((permission == null) || (permission.length() == 0)) {
return true;
}
@@ -216,6 +223,7 @@ public abstract class Command {
*
* @return Label of this command
*/
+ @NotNull
public String getLabel() {
return label;
}
@@ -231,7 +239,10 @@ public abstract class Command {
* @return returns true if the name change happened instantly or false if
* the command was already registered
*/
- public boolean setLabel(String name) {
+ public boolean setLabel(@NotNull String name) {
+ if (name == null) {
+ name = "";
+ }
this.nextLabel = name;
if (!isRegistered()) {
this.label = name;
@@ -248,7 +259,7 @@ public abstract class Command {
* @return true if the registration was successful (the current registered
* CommandMap was the passed CommandMap or null) false otherwise
*/
- public boolean register(CommandMap commandMap) {
+ public boolean register(@NotNull CommandMap commandMap) {
if (allowChangesFrom(commandMap)) {
this.commandMap = commandMap;
return true;
@@ -266,7 +277,7 @@ public abstract class Command {
* registered CommandMap was the passed CommandMap or null) false
* otherwise
*/
- public boolean unregister(CommandMap commandMap) {
+ public boolean unregister(@NotNull CommandMap commandMap) {
if (allowChangesFrom(commandMap)) {
this.commandMap = null;
this.activeAliases = new ArrayList(this.aliases);
@@ -277,7 +288,7 @@ public abstract class Command {
return false;
}
- private boolean allowChangesFrom(CommandMap commandMap) {
+ private boolean allowChangesFrom(@NotNull CommandMap commandMap) {
return (null == this.commandMap || this.commandMap == commandMap);
}
@@ -295,6 +306,7 @@ public abstract class Command {
*
* @return List of aliases
*/
+ @NotNull
public List getAliases() {
return activeAliases;
}
@@ -305,6 +317,7 @@ public abstract class Command {
*
* @return Permission check failed message
*/
+ @Nullable
public String getPermissionMessage() {
return permissionMessage;
}
@@ -314,6 +327,7 @@ public abstract class Command {
*
* @return Description of this command
*/
+ @NotNull
public String getDescription() {
return description;
}
@@ -323,6 +337,7 @@ public abstract class Command {
*
* @return One or more example usages
*/
+ @NotNull
public String getUsage() {
return usageMessage;
}
@@ -336,7 +351,8 @@ public abstract class Command {
* @param aliases aliases to register to this command
* @return this command object, for chaining
*/
- public Command setAliases(List aliases) {
+ @NotNull
+ public Command setAliases(@NotNull List aliases) {
this.aliases = aliases;
if (!isRegistered()) {
this.activeAliases = new ArrayList(aliases);
@@ -352,8 +368,9 @@ public abstract class Command {
* @param description new command description
* @return this command object, for chaining
*/
- public Command setDescription(String description) {
- this.description = description;
+ @NotNull
+ public Command setDescription(@NotNull String description) {
+ this.description = description == null ? "" : "";
return this;
}
@@ -364,7 +381,8 @@ public abstract class Command {
* default message, or an empty string to indicate no message
* @return this command object, for chaining
*/
- public Command setPermissionMessage(String permissionMessage) {
+ @NotNull
+ public Command setPermissionMessage(@Nullable String permissionMessage) {
this.permissionMessage = permissionMessage;
return this;
}
@@ -375,16 +393,17 @@ public abstract class Command {
* @param usage new example usage
* @return this command object, for chaining
*/
- public Command setUsage(String usage) {
- this.usageMessage = usage;
+ @NotNull
+ public Command setUsage(@NotNull String usage) {
+ this.usageMessage = (usage == null) ? "" : usage;
return this;
}
- public static void broadcastCommandMessage(CommandSender source, String message) {
+ public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message) {
broadcastCommandMessage(source, message, true);
}
- public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) {
+ public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message, boolean sendToSource) {
String result = source.getName() + ": " + message;
if (source instanceof BlockCommandSender) {
diff --git a/paper-api/src/main/java/org/bukkit/command/CommandExecutor.java b/paper-api/src/main/java/org/bukkit/command/CommandExecutor.java
index ae31ff8a20..45cb8da120 100644
--- a/paper-api/src/main/java/org/bukkit/command/CommandExecutor.java
+++ b/paper-api/src/main/java/org/bukkit/command/CommandExecutor.java
@@ -1,5 +1,7 @@
package org.bukkit.command;
+import org.jetbrains.annotations.NotNull;
+
/**
* Represents a class which contains a single method for executing commands
*/
@@ -17,5 +19,5 @@ public interface CommandExecutor {
* @param args Passed command arguments
* @return true if a valid command, otherwise false
*/
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args);
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args);
}
diff --git a/paper-api/src/main/java/org/bukkit/command/CommandMap.java b/paper-api/src/main/java/org/bukkit/command/CommandMap.java
index 30d60247e7..bd2c7a6964 100644
--- a/paper-api/src/main/java/org/bukkit/command/CommandMap.java
+++ b/paper-api/src/main/java/org/bukkit/command/CommandMap.java
@@ -2,6 +2,8 @@ package org.bukkit.command;
import java.util.List;
import org.bukkit.Location;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public interface CommandMap {
@@ -20,7 +22,7 @@ public interface CommandMap {
* a ':' one or more times to make the command unique
* @param commands a list of commands to register
*/
- public void registerAll(String fallbackPrefix, List commands);
+ public void registerAll(@NotNull String fallbackPrefix, @NotNull List commands);
/**
* Registers a command. Returns true on success; false if name is already
@@ -42,7 +44,7 @@ public interface CommandMap {
* otherwise, which indicates the fallbackPrefix was used one or more
* times
*/
- public boolean register(String label, String fallbackPrefix, Command command);
+ public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command);
/**
* Registers a command. Returns true on success; false if name is already
@@ -64,7 +66,7 @@ public interface CommandMap {
* otherwise, which indicates the fallbackPrefix was used one or more
* times
*/
- public boolean register(String fallbackPrefix, Command command);
+ public boolean register(@NotNull String fallbackPrefix, @NotNull Command command);
/**
* Looks for the requested command and executes it if found.
@@ -75,7 +77,7 @@ public interface CommandMap {
* @throws CommandException Thrown when the executor for the given command
* fails with an unhandled exception
*/
- public boolean dispatch(CommandSender sender, String cmdLine) throws CommandException;
+ public boolean dispatch(@NotNull CommandSender sender, @NotNull String cmdLine) throws CommandException;
/**
* Clears all registered commands.
@@ -89,7 +91,8 @@ public interface CommandMap {
* @return Command with the specified name or null if a command with that
* label doesn't exist
*/
- public Command getCommand(String name);
+ @Nullable
+ public Command getCommand(@NotNull String name);
/**
* Looks for the requested command and executes an appropriate
@@ -105,7 +108,8 @@ public interface CommandMap {
* command fails with an unhandled exception
* @throws IllegalArgumentException if either sender or cmdLine are null
*/
- public List tabComplete(CommandSender sender, String cmdLine) throws IllegalArgumentException;
+ @Nullable
+ public List tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine) throws IllegalArgumentException;
/**
* Looks for the requested command and executes an appropriate
@@ -122,5 +126,6 @@ public interface CommandMap {
* command fails with an unhandled exception
* @throws IllegalArgumentException if either sender or cmdLine are null
*/
- public List tabComplete(CommandSender sender, String cmdLine, Location location) throws IllegalArgumentException;
+ @Nullable
+ public List tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine, @Nullable Location location) throws IllegalArgumentException;
}
diff --git a/paper-api/src/main/java/org/bukkit/command/CommandSender.java b/paper-api/src/main/java/org/bukkit/command/CommandSender.java
index 148756b9ca..d247b0d8e2 100644
--- a/paper-api/src/main/java/org/bukkit/command/CommandSender.java
+++ b/paper-api/src/main/java/org/bukkit/command/CommandSender.java
@@ -2,6 +2,7 @@ package org.bukkit.command;
import org.bukkit.Server;
import org.bukkit.permissions.Permissible;
+import org.jetbrains.annotations.NotNull;
public interface CommandSender extends Permissible {
@@ -10,20 +11,21 @@ public interface CommandSender extends Permissible {
*
* @param message Message to be displayed
*/
- public void sendMessage(String message);
+ public void sendMessage(@NotNull String message);
/**
* Sends this sender multiple messages
*
* @param messages An array of messages to be displayed
*/
- public void sendMessage(String[] messages);
+ public void sendMessage(@NotNull String[] messages);
/**
* Returns the server instance that this command is running on
*
* @return Server instance
*/
+ @NotNull
public Server getServer();
/**
@@ -31,5 +33,6 @@ public interface CommandSender extends Permissible {
*
* @return Name of the sender
*/
+ @NotNull
public String getName();
}
diff --git a/paper-api/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/paper-api/src/main/java/org/bukkit/command/FormattedCommandAlias.java
index 5025788376..2035880ee3 100644
--- a/paper-api/src/main/java/org/bukkit/command/FormattedCommandAlias.java
+++ b/paper-api/src/main/java/org/bukkit/command/FormattedCommandAlias.java
@@ -3,17 +3,18 @@ package org.bukkit.command;
import java.util.ArrayList;
import org.bukkit.Bukkit;
+import org.jetbrains.annotations.NotNull;
public class FormattedCommandAlias extends Command {
private final String[] formatStrings;
- public FormattedCommandAlias(String alias, String[] formatStrings) {
+ public FormattedCommandAlias(@NotNull String alias, @NotNull String[] formatStrings) {
super(alias);
this.formatStrings = formatStrings;
}
@Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
boolean result = false;
ArrayList commands = new ArrayList();
for (String formatString : formatStrings) {
@@ -36,7 +37,7 @@ public class FormattedCommandAlias extends Command {
return result;
}
- private String buildCommand(String formatString, String[] args) {
+ private String buildCommand(@NotNull String formatString, @NotNull String[] args) {
int index = formatString.indexOf('$');
while (index != -1) {
int start = index;
diff --git a/paper-api/src/main/java/org/bukkit/command/MultipleCommandAlias.java b/paper-api/src/main/java/org/bukkit/command/MultipleCommandAlias.java
index a0a41295ec..8487bfe332 100644
--- a/paper-api/src/main/java/org/bukkit/command/MultipleCommandAlias.java
+++ b/paper-api/src/main/java/org/bukkit/command/MultipleCommandAlias.java
@@ -1,12 +1,14 @@
package org.bukkit.command;
+import org.jetbrains.annotations.NotNull;
+
/**
* Represents a command that delegates to one or more other commands
*/
public class MultipleCommandAlias extends Command {
private Command[] commands;
- public MultipleCommandAlias(String name, Command[] commands) {
+ public MultipleCommandAlias(@NotNull String name, @NotNull Command[] commands) {
super(name);
this.commands = commands;
}
@@ -16,12 +18,13 @@ public class MultipleCommandAlias extends Command {
*
* @return commands associated with alias
*/
+ @NotNull
public Command[] getCommands() {
return commands;
}
@Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
boolean result = false;
for (Command command : commands) {
diff --git a/paper-api/src/main/java/org/bukkit/command/PluginCommand.java b/paper-api/src/main/java/org/bukkit/command/PluginCommand.java
index 2abe1208f2..92c23424e2 100644
--- a/paper-api/src/main/java/org/bukkit/command/PluginCommand.java
+++ b/paper-api/src/main/java/org/bukkit/command/PluginCommand.java
@@ -4,6 +4,8 @@ import java.util.List;
import org.apache.commons.lang.Validate;
import org.bukkit.plugin.Plugin;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Represents a {@link Command} belonging to a plugin
@@ -13,7 +15,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
private CommandExecutor executor;
private TabCompleter completer;
- protected PluginCommand(String name, Plugin owner) {
+ protected PluginCommand(@NotNull String name, @NotNull Plugin owner) {
super(name);
this.executor = owner;
this.owningPlugin = owner;
@@ -29,7 +31,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
* @return true if the command was successful, otherwise false
*/
@Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
boolean success = false;
if (!owningPlugin.isEnabled()) {
@@ -60,7 +62,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
*
* @param executor New executor to run
*/
- public void setExecutor(CommandExecutor executor) {
+ public void setExecutor(@Nullable CommandExecutor executor) {
this.executor = executor == null ? owningPlugin : executor;
}
@@ -69,6 +71,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
*
* @return CommandExecutor object linked to this command
*/
+ @NotNull
public CommandExecutor getExecutor() {
return executor;
}
@@ -81,7 +84,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
*
* @param completer New tab completer
*/
- public void setTabCompleter(TabCompleter completer) {
+ public void setTabCompleter(@Nullable TabCompleter completer) {
this.completer = completer;
}
@@ -90,6 +93,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
*
* @return TabCompleter object linked to this command
*/
+ @Nullable
public TabCompleter getTabCompleter() {
return completer;
}
@@ -99,6 +103,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
*
* @return Plugin that owns this command
*/
+ @NotNull
public Plugin getPlugin() {
return owningPlugin;
}
@@ -120,8 +125,9 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
* exception during the process of tab-completing.
* @throws IllegalArgumentException if sender, alias, or args is null
*/
+ @NotNull
@Override
- public java.util.List tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
+ public java.util.List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws CommandException, IllegalArgumentException {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
diff --git a/paper-api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java b/paper-api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
index 5854583e1a..92b3f79973 100644
--- a/paper-api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
+++ b/paper-api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
@@ -7,10 +7,12 @@ import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
+import org.jetbrains.annotations.NotNull;
public class PluginCommandYamlParser {
- public static List parse(Plugin plugin) {
+ @NotNull
+ public static List parse(@NotNull Plugin plugin) {
List pluginCmds = new ArrayList();
Map> map = plugin.getDescription().getCommands();
diff --git a/paper-api/src/main/java/org/bukkit/command/PluginIdentifiableCommand.java b/paper-api/src/main/java/org/bukkit/command/PluginIdentifiableCommand.java
index c5e0d2c4d3..d51e0fd604 100644
--- a/paper-api/src/main/java/org/bukkit/command/PluginIdentifiableCommand.java
+++ b/paper-api/src/main/java/org/bukkit/command/PluginIdentifiableCommand.java
@@ -1,6 +1,7 @@
package org.bukkit.command;
import org.bukkit.plugin.Plugin;
+import org.jetbrains.annotations.NotNull;
/**
* This interface is used by the help system to group commands into
@@ -15,5 +16,6 @@ public interface PluginIdentifiableCommand {
*
* @return Plugin that owns this PluginIdentifiableCommand.
*/
+ @NotNull
public Plugin getPlugin();
}
diff --git a/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java b/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java
index 24c4ebad53..fcc34b6402 100644
--- a/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java
+++ b/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java
@@ -1,6 +1,8 @@
package org.bukkit.command;
+import org.jetbrains.annotations.NotNull;
+
public interface ProxiedCommandSender extends CommandSender {
/**
@@ -8,6 +10,7 @@ public interface ProxiedCommandSender extends CommandSender {
*
* @return the caller which triggered the command
*/
+ @NotNull
CommandSender getCaller();
/**
@@ -15,6 +18,7 @@ public interface ProxiedCommandSender extends CommandSender {
*
* @return the caller which the command is being run as
*/
+ @NotNull
CommandSender getCallee();
}
diff --git a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 9eeafaf942..aa44e79eb3 100644
--- a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -15,12 +15,14 @@ import org.bukkit.Server;
import org.bukkit.command.defaults.*;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class SimpleCommandMap implements CommandMap {
protected final Map knownCommands = new HashMap();
private final Server server;
- public SimpleCommandMap(final Server server) {
+ public SimpleCommandMap(@NotNull final Server server) {
this.server = server;
setDefaultCommands();
}
@@ -39,7 +41,7 @@ public class SimpleCommandMap implements CommandMap {
/**
* {@inheritDoc}
*/
- public void registerAll(String fallbackPrefix, List