diff --git a/paper-api/README.md b/paper-api/README.md index e1a8871bf5..39687f9913 100644 --- a/paper-api/README.md +++ b/paper-api/README.md @@ -19,7 +19,7 @@ Bukkit is a Java program which uses [Maven 3](http://maven.apache.org/) for comp * Install Maven and Git using your preferred installation methods. * `git clone https://hub.spigotmc.org/stash/scm/spigot/bukkit.git`. -* `mvn clean install`. +* `mvn -P development clean install`. Some IDEs such as [NetBeans](https://netbeans.org/) can perform these steps for you. Any Maven capable Java IDE can be used to develop with Bukkit, however the current team's personal preference is to use NetBeans. @@ -68,6 +68,7 @@ Code Requirements * All major additions should have documentation(e.g. javadocs). * Try to follow test driven development where available. * All code should be free of magic values. If this is not possible, it should be marked with a TODO comment indicating it should be addressed in the future. +* All non-private methods and constructors must have specified nullability through [annotations](https://github.com/JetBrains/java-annotations) Bukkit/CraftBukkit employs [JUnit 4](http://www.vogella.com/articles/JUnit/article.html) for testing. Pull Requests(PR) should attempt to integrate within that framework as appropriate. Bukkit is a large project and what seems simple to a PR author at the time of writing may easily be overlooked by other authors and updates. Including unit tests with your PR diff --git a/paper-api/pom.xml b/paper-api/pom.xml index 294c34280a..09c297b057 100644 --- a/paper-api/pom.xml +++ b/paper-api/pom.xml @@ -83,6 +83,13 @@ 1.23 compile + + + org.jetbrains + annotations-java5 + 17.0.0 + provided + junit @@ -96,6 +103,12 @@ 1.3 test + + org.ow2.asm + asm-tree + 7.1 + test + diff --git a/paper-api/src/main/java/org/bukkit/Achievement.java b/paper-api/src/main/java/org/bukkit/Achievement.java index 2a3d766740..5c5a72c070 100644 --- a/paper-api/src/main/java/org/bukkit/Achievement.java +++ b/paper-api/src/main/java/org/bukkit/Achievement.java @@ -1,5 +1,7 @@ package org.bukkit; +import org.jetbrains.annotations.Nullable; + /** * Represents an achievement, which may be given to players. * @deprecated future versions of Minecraft do not have achievements @@ -48,7 +50,7 @@ public enum Achievement { parent = null; } - private Achievement(Achievement parent) { + private Achievement(@Nullable Achievement parent) { this.parent = parent; } @@ -66,6 +68,7 @@ public enum Achievement { * * @return the parent achievement or null */ + @Nullable public Achievement getParent() { return parent; } diff --git a/paper-api/src/main/java/org/bukkit/Art.java b/paper-api/src/main/java/org/bukkit/Art.java index 9ad05cf45c..cfbcaf72d1 100644 --- a/paper-api/src/main/java/org/bukkit/Art.java +++ b/paper-api/src/main/java/org/bukkit/Art.java @@ -5,6 +5,8 @@ import java.util.HashMap; import org.apache.commons.lang.Validate; import com.google.common.collect.Maps; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents the art on a painting @@ -84,6 +86,7 @@ public enum Art { * @deprecated Magic value */ @Deprecated + @Nullable public static Art getById(int id) { return BY_ID.get(id); } @@ -96,7 +99,8 @@ public enum Art { * @param name The name * @return The painting */ - public static Art getByName(String name) { + @Nullable + public static Art getByName(@NotNull String name) { Validate.notNull(name, "Name cannot be null"); return BY_NAME.get(name.toLowerCase(java.util.Locale.ENGLISH)); diff --git a/paper-api/src/main/java/org/bukkit/BanEntry.java b/paper-api/src/main/java/org/bukkit/BanEntry.java index b2437c6dd5..30c8b0a0c6 100644 --- a/paper-api/src/main/java/org/bukkit/BanEntry.java +++ b/paper-api/src/main/java/org/bukkit/BanEntry.java @@ -1,5 +1,8 @@ package org.bukkit; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Date; /** @@ -47,6 +50,7 @@ public interface BanEntry { * * @return the target name or IP address */ + @NotNull public String getTarget(); /** @@ -54,6 +58,7 @@ public interface BanEntry { * * @return the creation date */ + @NotNull public Date getCreated(); /** @@ -62,7 +67,7 @@ public interface BanEntry { * @param created the new created date, cannot be null * @see #save() saving changes */ - public void setCreated(Date created); + public void setCreated(@NotNull Date created); /** * Gets the source of this ban. @@ -72,6 +77,7 @@ public interface BanEntry { * * @return the source of the ban */ + @NotNull public String getSource(); /** @@ -83,13 +89,14 @@ public interface BanEntry { * @param source the new source where null values become empty strings * @see #save() saving changes */ - public void setSource(String source); + public void setSource(@NotNull String source); /** * Gets the date this ban expires on, or null for no defined end date. * * @return the expiration date */ + @Nullable public Date getExpiration(); /** @@ -100,13 +107,14 @@ public interface BanEntry { * eternity * @see #save() saving changes */ - public void setExpiration(Date expiration); + public void setExpiration(@Nullable Date expiration); /** * Gets the reason for this ban. * * @return the ban reason, or null if not set */ + @Nullable public String getReason(); /** @@ -116,7 +124,7 @@ public interface BanEntry { * default * @see #save() saving changes */ - public void setReason(String reason); + public void setReason(@Nullable String reason); /** * Saves the ban entry, overwriting any previous data in the ban list. diff --git a/paper-api/src/main/java/org/bukkit/BanList.java b/paper-api/src/main/java/org/bukkit/BanList.java index c21b858e30..f506b644ad 100644 --- a/paper-api/src/main/java/org/bukkit/BanList.java +++ b/paper-api/src/main/java/org/bukkit/BanList.java @@ -1,5 +1,8 @@ package org.bukkit; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Date; import java.util.Set; @@ -29,7 +32,8 @@ public interface BanList { * @param target entry parameter to search for * @return the corresponding entry, or null if none found */ - public BanEntry getBanEntry(String target); + @Nullable + public BanEntry getBanEntry(@NotNull String target); /** * Adds a ban to the this list. If a previous ban exists, this will @@ -43,13 +47,15 @@ public interface BanList { * @return the entry for the newly created ban, or the entry for the * (updated) previous ban */ - public BanEntry addBan(String target, String reason, Date expires, String source); + @Nullable + public BanEntry addBan(@NotNull String target, @Nullable String reason, @Nullable Date expires, @Nullable String source); /** * Gets a set containing every {@link BanEntry} in this list. * * @return an immutable set containing every entry tracked by this list */ + @NotNull public Set getBanEntries(); /** @@ -60,7 +66,7 @@ public interface BanList { * @return true if a {@link BanEntry} exists for the name, indicating an * active ban status, false otherwise */ - public boolean isBanned(String target); + public boolean isBanned(@NotNull String target); /** * Removes the specified target from this list, therefore indicating a @@ -68,5 +74,5 @@ public interface BanList { * * @param target the target to remove from this list */ - public void pardon(String target); + public void pardon(@NotNull String target); } diff --git a/paper-api/src/main/java/org/bukkit/BlockChangeDelegate.java b/paper-api/src/main/java/org/bukkit/BlockChangeDelegate.java index 8bdaafadee..41eff1a31a 100644 --- a/paper-api/src/main/java/org/bukkit/BlockChangeDelegate.java +++ b/paper-api/src/main/java/org/bukkit/BlockChangeDelegate.java @@ -1,6 +1,7 @@ package org.bukkit; import org.bukkit.block.data.BlockData; +import org.jetbrains.annotations.NotNull; /** * A delegate for handling block changes. This serves as a direct interface @@ -18,7 +19,7 @@ public interface BlockChangeDelegate { * @param blockData Block data * @return true if the block was set successfully */ - public boolean setBlockData(int x, int y, int z, BlockData blockData); + public boolean setBlockData(int x, int y, int z, @NotNull BlockData blockData); /** * Get the block data at the location. @@ -28,6 +29,7 @@ public interface BlockChangeDelegate { * @param z Z coordinate * @return The block data */ + @NotNull public BlockData getBlockData(int x, int y, int z); /** diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 055c323d1a..515da1e3f3 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -50,6 +50,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 the Bukkit core, for version and Server singleton handling @@ -67,6 +70,7 @@ public final class Bukkit { * * @return Server instance being ran */ + @NotNull public static Server getServer() { return server; } @@ -78,7 +82,7 @@ public final class Bukkit { * * @param server Server instance */ - public static void setServer(Server server) { + public static void setServer(@NotNull Server server) { if (Bukkit.server != null) { throw new UnsupportedOperationException("Cannot redefine singleton Server"); } @@ -92,6 +96,7 @@ public final class Bukkit { * * @return name of this server implementation */ + @NotNull public static String getName() { return server.getName(); } @@ -101,6 +106,7 @@ public final class Bukkit { * * @return version of this server implementation */ + @NotNull public static String getVersion() { return server.getVersion(); } @@ -110,6 +116,7 @@ public final class Bukkit { * * @return version of Bukkit */ + @NotNull public static String getBukkitVersion() { return server.getBukkitVersion(); } @@ -141,6 +148,7 @@ public final class Bukkit { * * @return a view of currently online players. */ + @NotNull public static Collection getOnlinePlayers() { return server.getOnlinePlayers(); } @@ -179,6 +187,7 @@ public final class Bukkit { * @return the IP string that this server is bound to, otherwise empty * string */ + @NotNull public static String getIp() { return server.getIp(); } @@ -190,6 +199,7 @@ public final class Bukkit { * @deprecated not a standard server property */ @Deprecated + @NotNull public static String getServerName() { return server.getServerName(); } @@ -202,6 +212,7 @@ public final class Bukkit { * @deprecated not a standard server property */ @Deprecated + @NotNull public static String getServerId() { return server.getServerId(); } @@ -211,6 +222,7 @@ public final class Bukkit { * * @return the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1) */ + @NotNull public static String getWorldType() { return server.getWorldType(); } @@ -265,6 +277,7 @@ public final class Bukkit { * * @return a set containing all whitelisted players */ + @NotNull public static Set getWhitelistedPlayers() { return server.getWhitelistedPlayers(); } @@ -285,7 +298,7 @@ public final class Bukkit { * @param message the message * @return the number of players */ - public static int broadcastMessage(String message) { + public static int broadcastMessage(@NotNull String message) { return server.broadcastMessage(message); } @@ -297,6 +310,7 @@ public final class Bukkit { * * @return the name of the update folder */ + @NotNull public static String getUpdateFolder() { return server.getUpdateFolder(); } @@ -307,6 +321,7 @@ public final class Bukkit { * * @return the update folder */ + @NotNull public static File getUpdateFolderFile() { return server.getUpdateFolderFile(); } @@ -377,7 +392,8 @@ public final class Bukkit { * @return a player if one was found, null otherwise */ @Deprecated - public static Player getPlayer(String name) { + @Nullable + public static Player getPlayer(@NotNull String name) { return server.getPlayer(name); } @@ -390,7 +406,8 @@ public final class Bukkit { * @return a player object if one was found, null otherwise */ @Deprecated - public static Player getPlayerExact(String name) { + @Nullable + public static Player getPlayerExact(@NotNull String name) { return server.getPlayerExact(name); } @@ -407,7 +424,8 @@ public final class Bukkit { * @return list of all possible players */ @Deprecated - public static List matchPlayer(String name) { + @NotNull + public static List matchPlayer(@NotNull String name) { return server.matchPlayer(name); } @@ -417,7 +435,8 @@ public final class Bukkit { * @param id UUID of the player to retrieve * @return a player object if one was found, null otherwise */ - public static Player getPlayer(UUID id) { + @Nullable + public static Player getPlayer(@NotNull UUID id) { return server.getPlayer(id); } @@ -426,6 +445,7 @@ public final class Bukkit { * * @return a plugin manager for this Server instance */ + @NotNull public static PluginManager getPluginManager() { return server.getPluginManager(); } @@ -435,6 +455,7 @@ public final class Bukkit { * * @return a scheduling service for this server */ + @NotNull public static BukkitScheduler getScheduler() { return server.getScheduler(); } @@ -444,6 +465,7 @@ public final class Bukkit { * * @return s services manager */ + @NotNull public static ServicesManager getServicesManager() { return server.getServicesManager(); } @@ -453,6 +475,7 @@ public final class Bukkit { * * @return a list of worlds */ + @NotNull public static List getWorlds() { return server.getWorlds(); } @@ -467,7 +490,8 @@ public final class Bukkit { * @param creator the options to use when creating the world * @return newly created or loaded world */ - public static World createWorld(WorldCreator creator) { + @Nullable + public static World createWorld(@NotNull WorldCreator creator) { return server.createWorld(creator); } @@ -478,7 +502,7 @@ public final class Bukkit { * @param save whether to save the chunks before unloading * @return true if successful, false otherwise */ - public static boolean unloadWorld(String name, boolean save) { + public static boolean unloadWorld(@NotNull String name, boolean save) { return server.unloadWorld(name, save); } @@ -489,7 +513,7 @@ public final class Bukkit { * @param save whether to save the chunks before unloading * @return true if successful, false otherwise */ - public static boolean unloadWorld(World world, boolean save) { + public static boolean unloadWorld(@NotNull World world, boolean save) { return server.unloadWorld(world, save); } @@ -499,7 +523,8 @@ public final class Bukkit { * @param name the name of the world to retrieve * @return a world with the given name, or null if none exists */ - public static World getWorld(String name) { + @Nullable + public static World getWorld(@NotNull String name) { return server.getWorld(name); } @@ -509,7 +534,8 @@ public final class Bukkit { * @param uid a unique-id of the world to retrieve * @return a world with the given Unique ID, or null if none exists */ - public static World getWorld(UUID uid) { + @Nullable + public static World getWorld(@NotNull UUID uid) { return server.getWorld(uid); } @@ -521,6 +547,7 @@ public final class Bukkit { * @deprecated Magic value */ @Deprecated + @Nullable public static MapView getMap(int id) { return server.getMap(id); } @@ -531,7 +558,8 @@ public final class Bukkit { * @param world the world the map will belong to * @return a newly created map view */ - public static MapView createMap(World world) { + @NotNull + public static MapView createMap(@NotNull World world) { return server.createMap(world); } @@ -550,7 +578,8 @@ public final class Bukkit { * @see World#locateNearestStructure(org.bukkit.Location, * org.bukkit.StructureType, int, boolean) */ - public static ItemStack createExplorerMap(World world, Location location, StructureType structureType) { + @NotNull + public static ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType) { return server.createExplorerMap(world, location, structureType); } @@ -572,7 +601,8 @@ public final class Bukkit { * @see World#locateNearestStructure(org.bukkit.Location, * org.bukkit.StructureType, int, boolean) */ - public static ItemStack createExplorerMap(World world, Location location, StructureType structureType, int radius, boolean findUnexplored) { + @NotNull + public static ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType, int radius, boolean findUnexplored) { return server.createExplorerMap(world, location, structureType, radius, findUnexplored); } @@ -596,6 +626,7 @@ public final class Bukkit { * * @return Logger associated with this server */ + @NotNull public static Logger getLogger() { return server.getLogger(); } @@ -606,7 +637,8 @@ public final class Bukkit { * @param name the name of the command to retrieve * @return a plugin command if found, null otherwise */ - public static PluginCommand getPluginCommand(String name) { + @Nullable + public static PluginCommand getPluginCommand(@NotNull String name) { return server.getPluginCommand(name); } @@ -627,7 +659,7 @@ public final class Bukkit { * @throws CommandException thrown when the executor for the given command * fails with an unhandled exception */ - public static boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException { + public static boolean dispatchCommand(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException { return server.dispatchCommand(sender, commandLine); } @@ -638,7 +670,8 @@ public final class Bukkit { * @return true if the recipe was added, false if it wasn't for some * reason */ - public static boolean addRecipe(Recipe recipe) { + @Contract("null -> false") + public static boolean addRecipe(@Nullable Recipe recipe) { return server.addRecipe(recipe); } @@ -649,7 +682,8 @@ public final class Bukkit { * @param result the item to match against recipe results * @return a list of recipes with the given result */ - public static List getRecipesFor(ItemStack result) { + @NotNull + public static List getRecipesFor(@NotNull ItemStack result) { return server.getRecipesFor(result); } @@ -658,6 +692,7 @@ public final class Bukkit { * * @return an iterator */ + @NotNull public static Iterator recipeIterator() { return server.recipeIterator(); } @@ -681,6 +716,7 @@ public final class Bukkit { * * @return a map of aliases to command names */ + @NotNull public static Map getCommandAliases() { return server.getCommandAliases(); } @@ -746,7 +782,7 @@ public final class Bukkit { * permissibles} must have to receive the broadcast * @return number of message recipients */ - public static int broadcast(String message, String permission) { + public static int broadcast(@NotNull String message, @NotNull String permission) { return server.broadcast(message, permission); } @@ -767,7 +803,8 @@ public final class Bukkit { * @see #getOfflinePlayer(java.util.UUID) */ @Deprecated - public static OfflinePlayer getOfflinePlayer(String name) { + @NotNull + public static OfflinePlayer getOfflinePlayer(@NotNull String name) { return server.getOfflinePlayer(name); } @@ -781,7 +818,8 @@ public final class Bukkit { * @param id the UUID of the player to retrieve * @return an offline player */ - public static OfflinePlayer getOfflinePlayer(UUID id) { + @NotNull + public static OfflinePlayer getOfflinePlayer(@NotNull UUID id) { return server.getOfflinePlayer(id); } @@ -790,6 +828,7 @@ public final class Bukkit { * * @return a set containing banned IP addresses */ + @NotNull public static Set getIPBans() { return server.getIPBans(); } @@ -799,7 +838,7 @@ public final class Bukkit { * * @param address the IP address to ban */ - public static void banIP(String address) { + public static void banIP(@NotNull String address) { server.banIP(address); } @@ -808,7 +847,7 @@ public final class Bukkit { * * @param address the IP address to unban */ - public static void unbanIP(String address) { + public static void unbanIP(@NotNull String address) { server.unbanIP(address); } @@ -817,6 +856,7 @@ public final class Bukkit { * * @return a set containing banned players */ + @NotNull public static Set getBannedPlayers() { return server.getBannedPlayers(); } @@ -830,7 +870,8 @@ public final class Bukkit { * @param type the type of list to fetch, cannot be null * @return a ban list of the specified type */ - public static BanList getBanList(BanList.Type type) { + @NotNull + public static BanList getBanList(@NotNull BanList.Type type) { return server.getBanList(type); } @@ -839,6 +880,7 @@ public final class Bukkit { * * @return a set containing player operators */ + @NotNull public static Set getOperators() { return server.getOperators(); } @@ -848,6 +890,7 @@ public final class Bukkit { * * @return the default game mode */ + @NotNull public static GameMode getDefaultGameMode() { return server.getDefaultGameMode(); } @@ -857,7 +900,7 @@ public final class Bukkit { * * @param mode the new game mode */ - public static void setDefaultGameMode(GameMode mode) { + public static void setDefaultGameMode(@NotNull GameMode mode) { server.setDefaultGameMode(mode); } @@ -867,6 +910,7 @@ public final class Bukkit { * * @return a console command sender */ + @NotNull public static ConsoleCommandSender getConsoleSender() { return server.getConsoleSender(); } @@ -876,6 +920,7 @@ public final class Bukkit { * * @return folder that contains all worlds */ + @NotNull public static File getWorldContainer() { return server.getWorldContainer(); } @@ -885,6 +930,7 @@ public final class Bukkit { * * @return an array containing all previous players */ + @NotNull public static OfflinePlayer[] getOfflinePlayers() { return server.getOfflinePlayers(); } @@ -894,6 +940,7 @@ public final class Bukkit { * * @return messenger responsible for this server */ + @NotNull public static Messenger getMessenger() { return server.getMessenger(); } @@ -903,6 +950,7 @@ public final class Bukkit { * * @return a help map for this server */ + @NotNull public static HelpMap getHelpMap() { return server.getHelpMap(); } @@ -930,7 +978,8 @@ public final class Bukkit { * * @see InventoryType#isCreatable() */ - public static Inventory createInventory(InventoryHolder owner, InventoryType type) { + @NotNull + public static Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type) { return server.createInventory(owner, type); } @@ -958,7 +1007,8 @@ public final class Bukkit { * * @see InventoryType#isCreatable() */ - public static Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { + @NotNull + public static Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title) { return server.createInventory(owner, type, title); } @@ -971,7 +1021,8 @@ public final class Bukkit { * @return a new inventory * @throws IllegalArgumentException if the size is not a multiple of 9 */ - public static Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException { + @NotNull + public static Inventory createInventory(@Nullable InventoryHolder owner, int size) throws IllegalArgumentException { return server.createInventory(owner, size); } @@ -986,7 +1037,8 @@ public final class Bukkit { * @return a new inventory * @throws IllegalArgumentException if the size is not a multiple of 9 */ - public static Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException { + @NotNull + public static Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull String title) throws IllegalArgumentException { return server.createInventory(owner, size, title); } @@ -997,7 +1049,8 @@ public final class Bukkit { * when the merchant inventory is viewed * @return a new merchant */ - public static Merchant createMerchant(String title) { + @NotNull + public static Merchant createMerchant(@Nullable String title) { return server.createMerchant(title); } @@ -1062,6 +1115,7 @@ public final class Bukkit { * * @return the servers MOTD */ + @NotNull public static String getMotd() { return server.getMotd(); } @@ -1071,6 +1125,7 @@ public final class Bukkit { * * @return the shutdown message */ + @Nullable public static String getShutdownMessage() { return server.getShutdownMessage(); } @@ -1080,6 +1135,7 @@ public final class Bukkit { * * @return the configured warning state */ + @NotNull public static WarningState getWarningState() { return server.getWarningState(); } @@ -1090,6 +1146,7 @@ public final class Bukkit { * @return the item factory * @see ItemFactory */ + @NotNull public static ItemFactory getItemFactory() { return server.getItemFactory(); } @@ -1101,6 +1158,7 @@ public final class Bukkit { * * @return the scoreboard manager or null if no worlds are loaded. */ + @Nullable public static ScoreboardManager getScoreboardManager() { return server.getScoreboardManager(); } @@ -1112,6 +1170,7 @@ public final class Bukkit { * implementation to indicate no defined icon, but this behavior is * not guaranteed */ + @Nullable public static CachedServerIcon getServerIcon() { return server.getServerIcon(); } @@ -1130,7 +1189,8 @@ public final class Bukkit { * @return a cached server-icon that can be used for a {@link * ServerListPingEvent#setServerIcon(CachedServerIcon)} */ - public static CachedServerIcon loadServerIcon(File file) throws IllegalArgumentException, Exception { + @NotNull + public static CachedServerIcon loadServerIcon(@NotNull File file) throws IllegalArgumentException, Exception { return server.loadServerIcon(file); } @@ -1147,7 +1207,8 @@ public final class Bukkit { * @return a cached server-icon that can be used for a {@link * ServerListPingEvent#setServerIcon(CachedServerIcon)} */ - public static CachedServerIcon loadServerIcon(BufferedImage image) throws IllegalArgumentException, Exception { + @NotNull + public static CachedServerIcon loadServerIcon(@NotNull BufferedImage image) throws IllegalArgumentException, Exception { return server.loadServerIcon(image); } @@ -1181,7 +1242,8 @@ public final class Bukkit { * @return a new ChunkData for the world * */ - public static ChunkGenerator.ChunkData createChunkData(World world) { + @NotNull + public static ChunkGenerator.ChunkData createChunkData(@NotNull World world) { return server.createChunkData(world); } @@ -1195,7 +1257,8 @@ public final class Bukkit { * @param flags an optional list of flags to set on the boss bar * @return the created boss bar */ - public static BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) { + @NotNull + public static BossBar createBossBar(@Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags) { return server.createBossBar(title, color, style, flags); } @@ -1213,7 +1276,8 @@ public final class Bukkit { * @param flags an optional list of flags to set on the boss bar * @return the created boss bar */ - public static KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags) { + @NotNull + public static KeyedBossBar createBossBar(@NotNull NamespacedKey key, @Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags) { return server.createBossBar(key, title, color, style, flags); } @@ -1231,6 +1295,7 @@ public final class Bukkit { * * @return a bossbar iterator */ + @NotNull public static Iterator getBossBars() { return server.getBossBars(); } @@ -1250,7 +1315,8 @@ public final class Bukkit { * @param key unique bossbar key * @return bossbar or null if not exists */ - public static KeyedBossBar getBossBar(NamespacedKey key) { + @Nullable + public static KeyedBossBar getBossBar(@NotNull NamespacedKey key) { return server.getBossBar(key); } @@ -1269,7 +1335,7 @@ public final class Bukkit { * @param key unique bossbar key * @return true if removal succeeded or false */ - public static boolean removeBossBar(NamespacedKey key) { + public static boolean removeBossBar(@NotNull NamespacedKey key) { return server.removeBossBar(key); } @@ -1279,7 +1345,8 @@ public final class Bukkit { * @param uuid the UUID of the entity * @return the entity with the given UUID, or null if it isn't found */ - public static Entity getEntity(UUID uuid) { + @Nullable + public static Entity getEntity(@NotNull UUID uuid) { return server.getEntity(uuid); } @@ -1289,7 +1356,8 @@ public final class Bukkit { * @param key unique advancement key * @return advancement or null if not exists */ - public static Advancement getAdvancement(NamespacedKey key) { + @Nullable + public static Advancement getAdvancement(@NotNull NamespacedKey key) { return server.getAdvancement(key); } @@ -1299,6 +1367,7 @@ public final class Bukkit { * * @return an advancement iterator */ + @NotNull public static Iterator advancementIterator() { return server.advancementIterator(); } @@ -1310,7 +1379,8 @@ public final class Bukkit { * @param material the material * @return new data instance */ - public static BlockData createBlockData(Material material) { + @NotNull + public static BlockData createBlockData(@NotNull Material material) { return server.createBlockData(material); } @@ -1322,7 +1392,8 @@ public final class Bukkit { * @param consumer consumer to run on new instance before returning * @return new data instance */ - public static BlockData createBlockData(Material material, Consumer consumer) { + @NotNull + public static BlockData createBlockData(@NotNull Material material, @Nullable Consumer consumer) { return server.createBlockData(material, consumer); } @@ -1334,7 +1405,8 @@ public final class Bukkit { * @return new data instance * @throws IllegalArgumentException if the specified data is not valid */ - public static BlockData createBlockData(String data) throws IllegalArgumentException { + @NotNull + public static BlockData createBlockData(@NotNull String data) throws IllegalArgumentException { return server.createBlockData(data); } @@ -1348,7 +1420,9 @@ public final class Bukkit { * @return new data instance * @throws IllegalArgumentException if the specified data is not valid */ - public static BlockData createBlockData(Material material, String data) throws IllegalArgumentException { + @NotNull + @Contract("null, null -> fail") + public static BlockData createBlockData(@Nullable Material material, @Nullable String data) throws IllegalArgumentException { return server.createBlockData(material, data); } @@ -1370,7 +1444,8 @@ public final class Bukkit { * @param clazz the class of the tag entries * @return the tag or null */ - public static Tag getTag(String registry, NamespacedKey tag, Class clazz) { + @Nullable + public static Tag getTag(@NotNull String registry, @NotNull NamespacedKey tag, @NotNull Class clazz) { return server.getTag(registry, tag, clazz); } @@ -1387,7 +1462,8 @@ public final class Bukkit { * @param clazz the class of the tag entries * @return all defined tags */ - public static Iterable> getTags(String registry, Class clazz) { + @NotNull + public static Iterable> getTags(@NotNull String registry, @NotNull Class clazz) { return server.getTags(registry, clazz); } @@ -1397,7 +1473,8 @@ public final class Bukkit { * @param key the name of the LootTable * @return the LootTable, or null if no LootTable is found with that name */ - public static LootTable getLootTable(NamespacedKey key) { + @Nullable + public static LootTable getLootTable(@NotNull NamespacedKey key) { return server.getLootTable(key); } @@ -1423,7 +1500,8 @@ public final class Bukkit { * @deprecated draft API */ @Deprecated - public static List selectEntities(CommandSender sender, String selector) throws IllegalArgumentException { + @NotNull + public static List selectEntities(@NotNull CommandSender sender, @NotNull String selector) throws IllegalArgumentException { return server.selectEntities(sender, selector); } @@ -1432,6 +1510,7 @@ public final class Bukkit { * @return the unsafe values instance */ @Deprecated + @NotNull public static UnsafeValues getUnsafe() { return server.getUnsafe(); } diff --git a/paper-api/src/main/java/org/bukkit/ChatColor.java b/paper-api/src/main/java/org/bukkit/ChatColor.java index b8872b4113..de1c60a2f3 100644 --- a/paper-api/src/main/java/org/bukkit/ChatColor.java +++ b/paper-api/src/main/java/org/bukkit/ChatColor.java @@ -6,6 +6,9 @@ import java.util.regex.Pattern; import org.apache.commons.lang.Validate; import com.google.common.collect.Maps; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * All supported color values for chat @@ -134,6 +137,7 @@ public enum ChatColor { return code; } + @NotNull @Override public String toString() { return toString; @@ -164,6 +168,7 @@ public enum ChatColor { * @return Associative {@link org.bukkit.ChatColor} with the given code, * or null if it doesn't exist */ + @Nullable public static ChatColor getByChar(char code) { return BY_CHAR.get(code); } @@ -175,7 +180,8 @@ public enum ChatColor { * @return Associative {@link org.bukkit.ChatColor} with the given code, * or null if it doesn't exist */ - public static ChatColor getByChar(String code) { + @Nullable + public static ChatColor getByChar(@NotNull String code) { Validate.notNull(code, "Code cannot be null"); Validate.isTrue(code.length() > 0, "Code must have at least one char"); @@ -188,7 +194,9 @@ public enum ChatColor { * @param input String to strip of color * @return A copy of the input string, without any coloring */ - public static String stripColor(final String input) { + @Contract("!null -> !null; null -> null") + @Nullable + public static String stripColor(@Nullable final String input) { if (input == null) { return null; } @@ -206,7 +214,8 @@ public enum ChatColor { * @param textToTranslate Text containing the alternate color code character. * @return Text containing the ChatColor.COLOR_CODE color code character. */ - public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) { + @NotNull + public static String translateAlternateColorCodes(char altColorChar, @NotNull String textToTranslate) { char[] b = textToTranslate.toCharArray(); for (int i = 0; i < b.length - 1; i++) { if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) { @@ -223,7 +232,8 @@ public enum ChatColor { * @param input Input string to retrieve the colors from. * @return Any remaining ChatColors to pass onto the next line. */ - public static String getLastColors(String input) { + @NotNull + public static String getLastColors(@NotNull String input) { String result = ""; int length = input.length(); diff --git a/paper-api/src/main/java/org/bukkit/Chunk.java b/paper-api/src/main/java/org/bukkit/Chunk.java index 441ed7ad22..661ebd1fa7 100644 --- a/paper-api/src/main/java/org/bukkit/Chunk.java +++ b/paper-api/src/main/java/org/bukkit/Chunk.java @@ -3,6 +3,7 @@ package org.bukkit; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; /** * Represents a chunk of blocks @@ -28,6 +29,7 @@ public interface Chunk { * * @return Parent World */ + @NotNull World getWorld(); /** @@ -38,6 +40,7 @@ public interface Chunk { * @param z 0-15 * @return the Block */ + @NotNull Block getBlock(int x, int y, int z); /** @@ -45,6 +48,7 @@ public interface Chunk { * * @return ChunkSnapshot */ + @NotNull ChunkSnapshot getChunkSnapshot(); /** @@ -58,6 +62,7 @@ public interface Chunk { * raw biome temperature and rainfall * @return ChunkSnapshot */ + @NotNull ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain); /** @@ -65,6 +70,7 @@ public interface Chunk { * * @return The entities. */ + @NotNull Entity[] getEntities(); /** @@ -72,6 +78,7 @@ public interface Chunk { * * @return The tile entities. */ + @NotNull BlockState[] getTileEntities(); /** diff --git a/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java b/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java index 506137522b..153d72b0e5 100644 --- a/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java +++ b/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java @@ -2,6 +2,7 @@ package org.bukkit; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; +import org.jetbrains.annotations.NotNull; /** * Represents a static, thread-safe snapshot of chunk of blocks. @@ -30,6 +31,7 @@ public interface ChunkSnapshot { * * @return Parent World Name */ + @NotNull String getWorldName(); /** @@ -40,6 +42,7 @@ public interface ChunkSnapshot { * @param z 0-15 * @return block material type */ + @NotNull Material getBlockType(int x, int y, int z); /** @@ -50,6 +53,7 @@ public interface ChunkSnapshot { * @param z 0-15 * @return block material type */ + @NotNull BlockData getBlockData(int x, int y, int z); /** @@ -101,6 +105,7 @@ public interface ChunkSnapshot { * @param z Z-coordinate (0-15) * @return Biome at given coordinate */ + @NotNull Biome getBiome(int x, int z); /** diff --git a/paper-api/src/main/java/org/bukkit/CoalType.java b/paper-api/src/main/java/org/bukkit/CoalType.java index 4fcccd21f9..9e59a7ba18 100644 --- a/paper-api/src/main/java/org/bukkit/CoalType.java +++ b/paper-api/src/main/java/org/bukkit/CoalType.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 two types of coal @@ -38,6 +39,7 @@ public enum CoalType { * @deprecated Magic value */ @Deprecated + @Nullable public static CoalType getByData(final byte data) { return BY_DATA.get(data); } diff --git a/paper-api/src/main/java/org/bukkit/Color.java b/paper-api/src/main/java/org/bukkit/Color.java index 83927ddec6..fbad459059 100644 --- a/paper-api/src/main/java/org/bukkit/Color.java +++ b/paper-api/src/main/java/org/bukkit/Color.java @@ -7,6 +7,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.NotNull; /** * A container for a color palette. This class is immutable; the set methods @@ -115,6 +116,7 @@ public final class Color implements ConfigurationSerializable { * @return a new Color object for the red, green, blue * @throws IllegalArgumentException if any value is strictly {@literal >255 or <0} */ + @NotNull public static Color fromRGB(int red, int green, int blue) throws IllegalArgumentException { return new Color(red, green, blue); } @@ -128,6 +130,7 @@ public final class Color implements ConfigurationSerializable { * @return a new Color object for the red, green, blue * @throws IllegalArgumentException if any value is strictly {@literal >255 or <0} */ + @NotNull public static Color fromBGR(int blue, int green, int red) throws IllegalArgumentException { return new Color(red, green, blue); } @@ -141,6 +144,7 @@ public final class Color implements ConfigurationSerializable { * @throws IllegalArgumentException if any data is in the highest order 8 * bits */ + @NotNull public static Color fromRGB(int rgb) throws IllegalArgumentException { Validate.isTrue((rgb >> 24) == 0, "Extrenuous data in: ", rgb); return fromRGB(rgb >> 16 & BIT_MASK, rgb >> 8 & BIT_MASK, rgb >> 0 & BIT_MASK); @@ -155,6 +159,7 @@ public final class Color implements ConfigurationSerializable { * @throws IllegalArgumentException if any data is in the highest order 8 * bits */ + @NotNull public static Color fromBGR(int bgr) throws IllegalArgumentException { Validate.isTrue((bgr >> 24) == 0, "Extrenuous data in: ", bgr); return fromBGR(bgr >> 16 & BIT_MASK, bgr >> 8 & BIT_MASK, bgr >> 0 & BIT_MASK); @@ -185,6 +190,7 @@ public final class Color implements ConfigurationSerializable { * @param red the red component, from 0 to 255 * @return a new color object with the red component */ + @NotNull public Color setRed(int red) { return fromRGB(red, getGreen(), getBlue()); } @@ -204,6 +210,7 @@ public final class Color implements ConfigurationSerializable { * @param green the red component, from 0 to 255 * @return a new color object with the red component */ + @NotNull public Color setGreen(int green) { return fromRGB(getRed(), green, getBlue()); } @@ -223,6 +230,7 @@ public final class Color implements ConfigurationSerializable { * @param blue the red component, from 0 to 255 * @return a new color object with the red component */ + @NotNull public Color setBlue(int blue) { return fromRGB(getRed(), getGreen(), blue); } @@ -251,7 +259,8 @@ public final class Color implements ConfigurationSerializable { * @return A new color with the changed rgb components */ // TODO: Javadoc what this method does, not what it mimics. API != Implementation - public Color mixDyes(DyeColor... colors) { + @NotNull + public Color mixDyes(@NotNull DyeColor... colors) { Validate.noNullElements(colors, "Colors cannot be null"); Color[] toPass = new Color[colors.length]; @@ -270,7 +279,8 @@ public final class Color implements ConfigurationSerializable { * @return A new color with the changed rgb components */ // TODO: Javadoc what this method does, not what it mimics. API != Implementation - public Color mixColors(Color... colors) { + @NotNull + public Color mixColors(@NotNull Color... colors) { Validate.noNullElements(colors, "Colors cannot be null"); int totalRed = this.getRed(); @@ -309,6 +319,7 @@ public final class Color implements ConfigurationSerializable { return asRGB() ^ Color.class.hashCode(); } + @NotNull public Map serialize() { return ImmutableMap.of( "RED", getRed(), @@ -318,7 +329,8 @@ public final class Color implements ConfigurationSerializable { } @SuppressWarnings("javadoc") - public static Color deserialize(Map map) { + @NotNull + public static Color deserialize(@NotNull Map map) { return fromRGB( asInt("RED", map), asInt("GREEN", map), @@ -326,7 +338,7 @@ public final class Color implements ConfigurationSerializable { ); } - private static int asInt(String string, Map map) { + private static int asInt(@NotNull String string, @NotNull Map map) { Object value = map.get(string); if (value == null) { throw new IllegalArgumentException(string + " not in map " + map); diff --git a/paper-api/src/main/java/org/bukkit/CropState.java b/paper-api/src/main/java/org/bukkit/CropState.java index ef0faf93eb..9a3990dff7 100644 --- a/paper-api/src/main/java/org/bukkit/CropState.java +++ b/paper-api/src/main/java/org/bukkit/CropState.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 growth states of crops @@ -69,6 +70,7 @@ public enum CropState { * @deprecated Magic value */ @Deprecated + @Nullable public static CropState getByData(final byte data) { return BY_DATA.get(data); } diff --git a/paper-api/src/main/java/org/bukkit/Difficulty.java b/paper-api/src/main/java/org/bukkit/Difficulty.java index a8a5a78588..19367a7001 100644 --- a/paper-api/src/main/java/org/bukkit/Difficulty.java +++ b/paper-api/src/main/java/org/bukkit/Difficulty.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 various difficulty levels that are available. @@ -60,6 +61,7 @@ public enum Difficulty { * @deprecated Magic value */ @Deprecated + @Nullable public static Difficulty getByValue(final int value) { return BY_ID.get(value); } diff --git a/paper-api/src/main/java/org/bukkit/DyeColor.java b/paper-api/src/main/java/org/bukkit/DyeColor.java index a5beda449f..6f23582285 100644 --- a/paper-api/src/main/java/org/bukkit/DyeColor.java +++ b/paper-api/src/main/java/org/bukkit/DyeColor.java @@ -3,6 +3,8 @@ package org.bukkit; import java.util.Map; import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * All supported color values for dyes and cloth @@ -83,7 +85,7 @@ public enum DyeColor { private final static Map BY_COLOR; private final static Map BY_FIREWORK; - private DyeColor(final int woolData, final int dyeData, Color color, Color firework) { + private DyeColor(final int woolData, final int dyeData, @NotNull Color color, @NotNull Color firework) { this.woolData = (byte) woolData; this.dyeData = (byte) dyeData; this.color = color; @@ -119,6 +121,7 @@ public enum DyeColor { * * @return The {@link Color} that this dye represents */ + @NotNull public Color getColor() { return color; } @@ -128,6 +131,7 @@ public enum DyeColor { * * @return The {@link Color} that this dye represents */ + @NotNull public Color getFireworkColor() { return firework; } @@ -142,6 +146,7 @@ public enum DyeColor { * @deprecated Magic value */ @Deprecated + @Nullable public static DyeColor getByWoolData(final byte data) { int i = 0xff & data; if (i >= BY_WOOL_DATA.length) { @@ -160,6 +165,7 @@ public enum DyeColor { * @deprecated Magic value */ @Deprecated + @Nullable public static DyeColor getByDyeData(final byte data) { int i = 0xff & data; if (i >= BY_DYE_DATA.length) { @@ -175,7 +181,8 @@ public enum DyeColor { * @return The {@link DyeColor} representing the given value, or null if * it doesn't exist */ - public static DyeColor getByColor(final Color color) { + @Nullable + public static DyeColor getByColor(@NotNull final Color color) { return BY_COLOR.get(color); } @@ -186,7 +193,8 @@ public enum DyeColor { * @return The {@link DyeColor} representing the given value, or null if * it doesn't exist */ - public static DyeColor getByFireworkColor(final Color color) { + @Nullable + public static DyeColor getByFireworkColor(@NotNull final Color color) { return BY_FIREWORK.get(color); } @@ -198,7 +206,8 @@ public enum DyeColor { * @deprecated legacy use only */ @Deprecated - public static DyeColor legacyValueOf(String name) { + @NotNull + public static DyeColor legacyValueOf(@Nullable String name) { return "SILVER".equals(name) ? DyeColor.LIGHT_GRAY : DyeColor.valueOf(name); } diff --git a/paper-api/src/main/java/org/bukkit/Effect.java b/paper-api/src/main/java/org/bukkit/Effect.java index 21f7db586d..dd17003dc7 100644 --- a/paper-api/src/main/java/org/bukkit/Effect.java +++ b/paper-api/src/main/java/org/bukkit/Effect.java @@ -6,6 +6,8 @@ import com.google.common.collect.Maps; import org.bukkit.block.BlockFace; import org.bukkit.potion.Potion; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A list of effects that the server is able to send to players. @@ -203,11 +205,11 @@ public enum Effect { private final Class data; private static final Map BY_ID = Maps.newHashMap(); - Effect(int id, Type type) { + Effect(int id, @NotNull Type type) { this(id, type, null); } - Effect(int id, Type type, Class data) { + Effect(int id, @NotNull Type type, @Nullable Class data) { this.id = id; this.type = type; this.data = data; @@ -227,6 +229,7 @@ public enum Effect { /** * @return The type of the effect. */ + @NotNull public Type getType() { return this.type; } @@ -235,6 +238,7 @@ public enum Effect { * @return The class which represents data for this effect, or null if * none */ + @Nullable public Class getData() { return this.data; } @@ -247,6 +251,7 @@ public enum Effect { * @deprecated Magic value */ @Deprecated + @Nullable public static Effect getById(int id) { return BY_ID.get(id); } diff --git a/paper-api/src/main/java/org/bukkit/EntityEffect.java b/paper-api/src/main/java/org/bukkit/EntityEffect.java index 5d234350b0..6b43d5abb2 100644 --- a/paper-api/src/main/java/org/bukkit/EntityEffect.java +++ b/paper-api/src/main/java/org/bukkit/EntityEffect.java @@ -18,6 +18,8 @@ import org.bukkit.entity.Villager; import org.bukkit.entity.Witch; import org.bukkit.entity.Wolf; import org.bukkit.entity.ZombieVillager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A list of all Effects that can happen to entities. @@ -153,7 +155,7 @@ public enum EntityEffect { private final Class applicable; private final static Map BY_DATA = Maps.newHashMap(); - EntityEffect(final int data, Class clazz) { + EntityEffect(final int data, @NotNull Class clazz) { this.data = (byte) data; this.applicable = clazz; } @@ -174,6 +176,7 @@ public enum EntityEffect { * * @return applicable class */ + @NotNull public Class getApplicable() { return applicable; } @@ -187,6 +190,7 @@ public enum EntityEffect { * @deprecated Magic value */ @Deprecated + @Nullable public static EntityEffect getByData(final byte data) { return BY_DATA.get(data); } diff --git a/paper-api/src/main/java/org/bukkit/FireworkEffect.java b/paper-api/src/main/java/org/bukkit/FireworkEffect.java index f1fec892d4..524dc99894 100644 --- a/paper-api/src/main/java/org/bukkit/FireworkEffect.java +++ b/paper-api/src/main/java/org/bukkit/FireworkEffect.java @@ -9,6 +9,7 @@ import org.bukkit.configuration.serialization.SerializableAs; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.NotNull; /** * Represents a single firework effect. @@ -48,6 +49,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return A utility object for building a firework effect */ + @NotNull public static Builder builder() { return new Builder(); } @@ -73,7 +75,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @return This object, for chaining * @throws IllegalArgumentException If type is null */ - public Builder with(Type type) throws IllegalArgumentException { + @NotNull + public Builder with(@NotNull Type type) throws IllegalArgumentException { Validate.notNull(type, "Cannot have null type"); this.type = type; return this; @@ -84,6 +87,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return This object, for chaining */ + @NotNull public Builder withFlicker() { flicker = true; return this; @@ -95,6 +99,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * @param flicker true if it should flicker, false if not * @return This object, for chaining */ + @NotNull public Builder flicker(boolean flicker) { this.flicker = flicker; return this; @@ -105,6 +110,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return This object, for chaining */ + @NotNull public Builder withTrail() { trail = true; return this; @@ -116,6 +122,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * @param trail true if it should have a trail, false for no trail * @return This object, for chaining */ + @NotNull public Builder trail(boolean trail) { this.trail = trail; return this; @@ -128,7 +135,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @return This object, for chaining * @throws IllegalArgumentException If color is null */ - public Builder withColor(Color color) throws IllegalArgumentException { + @NotNull + public Builder withColor(@NotNull Color color) throws IllegalArgumentException { Validate.notNull(color, "Cannot have null color"); colors.add(color); @@ -145,7 +153,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @throws IllegalArgumentException If any color is null (may be * thrown after changes have occurred) */ - public Builder withColor(Color... colors) throws IllegalArgumentException { + @NotNull + public Builder withColor(@NotNull Color... colors) throws IllegalArgumentException { Validate.notNull(colors, "Cannot have null colors"); if (colors.length == 0) { return this; @@ -170,7 +179,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @throws IllegalArgumentException If any color is null (may be * thrown after changes have occurred) */ - public Builder withColor(Iterable colors) throws IllegalArgumentException { + @NotNull + public Builder withColor(@NotNull Iterable colors) throws IllegalArgumentException { Validate.notNull(colors, "Cannot have null colors"); ImmutableList.Builder list = this.colors; @@ -193,7 +203,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @throws IllegalArgumentException If any color is null (may be * thrown after changes have occurred) */ - public Builder withFade(Color color) throws IllegalArgumentException { + @NotNull + public Builder withFade(@NotNull Color color) throws IllegalArgumentException { Validate.notNull(color, "Cannot have null color"); if (fadeColors == null) { @@ -214,7 +225,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @throws IllegalArgumentException If any color is null (may be * thrown after changes have occurred) */ - public Builder withFade(Color... colors) throws IllegalArgumentException { + @NotNull + public Builder withFade(@NotNull Color... colors) throws IllegalArgumentException { Validate.notNull(colors, "Cannot have null colors"); if (colors.length == 0) { return this; @@ -243,7 +255,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @throws IllegalArgumentException If any color is null (may be * thrown after changes have occurred) */ - public Builder withFade(Iterable colors) throws IllegalArgumentException { + @NotNull + public Builder withFade(@NotNull Iterable colors) throws IllegalArgumentException { Validate.notNull(colors, "Cannot have null colors"); ImmutableList.Builder list = this.fadeColors; @@ -269,6 +282,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return The representative firework effect */ + @NotNull public FireworkEffect build() { return new FireworkEffect( flicker, @@ -293,7 +307,7 @@ public final class FireworkEffect implements ConfigurationSerializable { private final Type type; private String string = null; - FireworkEffect(boolean flicker, boolean trail, ImmutableList colors, ImmutableList fadeColors, Type type) { + FireworkEffect(boolean flicker, boolean trail, @NotNull ImmutableList colors, @NotNull ImmutableList fadeColors, @NotNull Type type) { if (colors.isEmpty()) { throw new IllegalStateException("Cannot make FireworkEffect without any color"); } @@ -327,6 +341,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return An immutable list of the primary colors */ + @NotNull public List getColors() { return colors; } @@ -336,6 +351,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return An immutable list of the fade colors */ + @NotNull public List getFadeColors() { return fadeColors; } @@ -345,6 +361,7 @@ public final class FireworkEffect implements ConfigurationSerializable { * * @return The effect type */ + @NotNull public Type getType() { return type; } @@ -354,7 +371,8 @@ public final class FireworkEffect implements ConfigurationSerializable { * @param map the map to deserialize * @return the resulting serializable */ - public static ConfigurationSerializable deserialize(Map map) { + @NotNull + public static ConfigurationSerializable deserialize(@NotNull Map map) { Type type = Type.valueOf((String) map.get(TYPE)); return builder() @@ -366,6 +384,7 @@ public final class FireworkEffect implements ConfigurationSerializable { .build(); } + @NotNull @Override public Map serialize() { return ImmutableMap.of( diff --git a/paper-api/src/main/java/org/bukkit/GameMode.java b/paper-api/src/main/java/org/bukkit/GameMode.java index 803944eaef..4cfc7762e4 100644 --- a/paper-api/src/main/java/org/bukkit/GameMode.java +++ b/paper-api/src/main/java/org/bukkit/GameMode.java @@ -5,6 +5,7 @@ import java.util.Map; import org.bukkit.entity.HumanEntity; import com.google.common.collect.Maps; +import org.jetbrains.annotations.Nullable; /** * Represents the various type of game modes that {@link HumanEntity}s may @@ -61,6 +62,7 @@ public enum GameMode { * @deprecated Magic value */ @Deprecated + @Nullable public static GameMode getByValue(final int value) { return BY_ID.get(value); } diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index 958fe3eaf1..da49c26c51 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -1,6 +1,9 @@ package org.bukkit; import com.google.common.base.Preconditions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.HashMap; import java.util.Map; @@ -150,7 +153,7 @@ public final class GameRule { private final String name; private final Class type; - private GameRule(String name, Class clazz) { + private GameRule(@NotNull String name, @NotNull Class clazz) { Preconditions.checkNotNull(name, "GameRule name cannot be null"); Preconditions.checkNotNull(clazz, "GameRule type cannot be null"); Preconditions.checkArgument(clazz == Boolean.class || clazz == Integer.class, "Must be of type Boolean or Integer. Found %s ", clazz.getName()); @@ -164,6 +167,7 @@ public final class GameRule { * * @return the name of this GameRule */ + @NotNull public String getName() { return name; } @@ -173,6 +177,7 @@ public final class GameRule { * * @return the rule type; Integer or Boolean */ + @NotNull public Class getType() { return type; } @@ -201,7 +206,8 @@ public final class GameRule { * @return the {@link GameRule} or null if no GameRule matches the given * name */ - public static GameRule getByName(String rule) { + @Nullable + public static GameRule getByName(@NotNull String rule) { Preconditions.checkNotNull(rule, "Rule cannot be null"); return gameRules.get(rule); } @@ -211,6 +217,7 @@ public final class GameRule { * * @return an immutable collection containing all registered GameRules. */ + @NotNull public static GameRule[] values() { return gameRules.values().toArray(new GameRule[gameRules.size()]); } diff --git a/paper-api/src/main/java/org/bukkit/GrassSpecies.java b/paper-api/src/main/java/org/bukkit/GrassSpecies.java index 111151573d..5943eddd31 100644 --- a/paper-api/src/main/java/org/bukkit/GrassSpecies.java +++ b/paper-api/src/main/java/org/bukkit/GrassSpecies.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 types of grass. @@ -49,6 +50,7 @@ public enum GrassSpecies { * @deprecated Magic value */ @Deprecated + @Nullable public static GrassSpecies getByData(final byte data) { return BY_DATA.get(data); } diff --git a/paper-api/src/main/java/org/bukkit/Instrument.java b/paper-api/src/main/java/org/bukkit/Instrument.java index 14cfaca0db..f21497fff8 100644 --- a/paper-api/src/main/java/org/bukkit/Instrument.java +++ b/paper-api/src/main/java/org/bukkit/Instrument.java @@ -3,6 +3,7 @@ package org.bukkit; import java.util.Map; import com.google.common.collect.Maps; +import org.jetbrains.annotations.Nullable; public enum Instrument { @@ -76,6 +77,7 @@ public enum Instrument { * @deprecated Magic value */ @Deprecated + @Nullable public static Instrument getByType(final byte type) { return BY_DATA.get(type); } diff --git a/paper-api/src/main/java/org/bukkit/Keyed.java b/paper-api/src/main/java/org/bukkit/Keyed.java index f1a7913b9b..32c92621c2 100644 --- a/paper-api/src/main/java/org/bukkit/Keyed.java +++ b/paper-api/src/main/java/org/bukkit/Keyed.java @@ -1,5 +1,7 @@ package org.bukkit; +import org.jetbrains.annotations.NotNull; + /** * Represents an object which has a {@link NamespacedKey} attached to it. */ @@ -10,5 +12,6 @@ public interface Keyed { * * @return this object's key */ + @NotNull NamespacedKey getKey(); } diff --git a/paper-api/src/main/java/org/bukkit/Location.java b/paper-api/src/main/java/org/bukkit/Location.java index 5c3d42cc40..6cffda15f7 100644 --- a/paper-api/src/main/java/org/bukkit/Location.java +++ b/paper-api/src/main/java/org/bukkit/Location.java @@ -7,6 +7,8 @@ import org.bukkit.block.Block; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.util.NumberConversions; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a 3-dimensional position in a world. @@ -32,7 +34,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param y The y-coordinate of this new location * @param z The z-coordinate of this new location */ - public Location(final World world, final double x, final double y, final double z) { + public Location(@Nullable final World world, final double x, final double y, final double z) { this(world, x, y, z, 0, 0); } @@ -46,7 +48,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param yaw The absolute rotation on the x-plane, in degrees * @param pitch The absolute rotation on the y-plane, in degrees */ - public Location(final World world, final double x, final double y, final double z, final float yaw, final float pitch) { + public Location(@Nullable final World world, final double x, final double y, final double z, final float yaw, final float pitch) { this.world = world; this.x = x; this.y = y; @@ -60,7 +62,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * * @param world New world that this location resides in */ - public void setWorld(World world) { + public void setWorld(@Nullable World world) { this.world = world; } @@ -69,6 +71,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * * @return World that contains this location */ + @Nullable public World getWorld() { return world; } @@ -78,6 +81,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * * @return Chunk at the represented location */ + @NotNull public Chunk getChunk() { return world.getChunkAt(this); } @@ -87,6 +91,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * * @return Block at the represented location */ + @NotNull public Block getBlock() { return world.getBlockAt(this); } @@ -250,6 +255,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return a vector pointing the direction of this location's {@link * #getPitch() pitch} and {@link #getYaw() yaw} */ + @NotNull public Vector getDirection() { Vector vector = new Vector(); @@ -273,7 +279,8 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param vector the direction vector * @return the same location */ - public Location setDirection(Vector vector) { + @NotNull + public Location setDirection(@NotNull Vector vector) { /* * Sin = Opp / Hyp * Cos = Adj / Hyp @@ -310,7 +317,8 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return the same location * @throws IllegalArgumentException for differing worlds */ - public Location add(Location vec) { + @NotNull + public Location add(@NotNull Location vec) { if (vec == null || vec.getWorld() != getWorld()) { throw new IllegalArgumentException("Cannot add Locations of differing worlds"); } @@ -328,7 +336,8 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param vec Vector to use * @return the same location */ - public Location add(Vector vec) { + @NotNull + public Location add(@NotNull Vector vec) { this.x += vec.getX(); this.y += vec.getY(); this.z += vec.getZ(); @@ -344,6 +353,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param z Z coordinate * @return the same location */ + @NotNull public Location add(double x, double y, double z) { this.x += x; this.y += y; @@ -359,7 +369,8 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return the same location * @throws IllegalArgumentException for differing worlds */ - public Location subtract(Location vec) { + @NotNull + public Location subtract(@NotNull Location vec) { if (vec == null || vec.getWorld() != getWorld()) { throw new IllegalArgumentException("Cannot add Locations of differing worlds"); } @@ -377,7 +388,8 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param vec The vector to use * @return the same location */ - public Location subtract(Vector vec) { + @NotNull + public Location subtract(@NotNull Vector vec) { this.x -= vec.getX(); this.y -= vec.getY(); this.z -= vec.getZ(); @@ -394,6 +406,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param z Z coordinate * @return the same location */ + @NotNull public Location subtract(double x, double y, double z) { this.x -= x; this.y -= y; @@ -439,7 +452,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return the distance * @throws IllegalArgumentException for differing worlds */ - public double distance(Location o) { + public double distance(@NotNull Location o) { return Math.sqrt(distanceSquared(o)); } @@ -451,7 +464,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return the distance * @throws IllegalArgumentException for differing worlds */ - public double distanceSquared(Location o) { + public double distanceSquared(@NotNull Location o) { if (o == null) { throw new IllegalArgumentException("Cannot measure distance to a null location"); } else if (o.getWorld() == null || getWorld() == null) { @@ -471,6 +484,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @see Vector * @return the same location */ + @NotNull public Location multiply(double m) { x *= m; y *= m; @@ -484,6 +498,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @see Vector * @return the same location */ + @NotNull public Location zero() { x = 0; y = 0; @@ -546,11 +561,13 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return New Vector containing the coordinates represented by this * Location */ + @NotNull public Vector toVector() { return new Vector(x, y, z); } @Override + @NotNull public Location clone() { try { return (Location) super.clone(); @@ -584,6 +601,7 @@ public class Location implements Cloneable, ConfigurationSerializable { } @Utility + @NotNull public Map serialize() { Map data = new HashMap(); data.put("world", this.world.getName()); @@ -606,7 +624,8 @@ public class Location implements Cloneable, ConfigurationSerializable { * @throws IllegalArgumentException if the world don't exists * @see ConfigurationSerializable */ - public static Location deserialize(Map args) { + @NotNull + public static Location deserialize(@NotNull Map args) { World world = Bukkit.getWorld((String) args.get("world")); if (world == null) { throw new IllegalArgumentException("unknown world"); diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 387a0d7cee..f8e78da069 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -68,6 +68,8 @@ import org.bukkit.block.data.type.TripwireHook; import org.bukkit.block.data.type.TurtleEgg; import org.bukkit.block.data.type.WallSign; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An enum of all material IDs accepted by the official server and client @@ -2955,15 +2957,15 @@ public enum Material implements Keyed { this(id, stack, durability, MaterialData.class); } - private Material(final int id, final Class data) { + private Material(final int id, @NotNull final Class data) { this(id, 64, data); } - private Material(final int id, final int stack, final Class data) { + private Material(final int id, final int stack, @NotNull final Class data) { this(id, stack, 0, data); } - private Material(final int id, final int stack, final int durability, final Class data) { + private Material(final int id, final int stack, final int durability, @NotNull final Class data) { this.id = id; this.durability = (short) durability; this.maxStack = stack; @@ -3005,6 +3007,7 @@ public enum Material implements Keyed { return legacy; } + @NotNull @Override public NamespacedKey getKey() { Validate.isTrue(!legacy, "Cannot get key of Legacy Material"); @@ -3035,6 +3038,7 @@ public enum Material implements Keyed { * * @return new data instance */ + @NotNull public BlockData createBlockData() { return Bukkit.createBlockData(this); } @@ -3046,7 +3050,8 @@ public enum Material implements Keyed { * @param consumer consumer to run on new instance before returning * @return new data instance */ - public BlockData createBlockData(Consumer consumer) { + @NotNull + public BlockData createBlockData(@Nullable Consumer 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 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 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 commands) { + public void registerAll(@NotNull String fallbackPrefix, @NotNull List commands) { if (commands != null) { for (Command c : commands) { register(fallbackPrefix, c); @@ -50,14 +52,14 @@ public class SimpleCommandMap implements CommandMap { /** * {@inheritDoc} */ - public boolean register(String fallbackPrefix, Command command) { + public boolean register(@NotNull String fallbackPrefix, @NotNull Command command) { return register(command.getName(), fallbackPrefix, command); } /** * {@inheritDoc} */ - public boolean register(String label, String fallbackPrefix, Command command) { + public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command) { label = label.toLowerCase(java.util.Locale.ENGLISH).trim(); fallbackPrefix = fallbackPrefix.toLowerCase(java.util.Locale.ENGLISH).trim(); boolean registered = register(label, command, false, fallbackPrefix); @@ -91,7 +93,7 @@ public class SimpleCommandMap implements CommandMap { * unique address * @return true if command was registered, false otherwise. */ - private synchronized boolean register(String label, Command command, boolean isAlias, String fallbackPrefix) { + private synchronized boolean register(@NotNull String label, @NotNull Command command, boolean isAlias, @NotNull String fallbackPrefix) { knownCommands.put(fallbackPrefix + ":" + label, command); if ((command instanceof BukkitCommand || isAlias) && knownCommands.containsKey(label)) { // Request is for an alias/fallback command and it conflicts with @@ -119,7 +121,7 @@ public class SimpleCommandMap implements CommandMap { /** * {@inheritDoc} */ - public boolean dispatch(CommandSender sender, String commandLine) throws CommandException { + public boolean dispatch(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException { String[] args = commandLine.split(" "); if (args.length == 0) { @@ -154,16 +156,19 @@ public class SimpleCommandMap implements CommandMap { setDefaultCommands(); } - public Command getCommand(String name) { + @Nullable + public Command getCommand(@NotNull String name) { Command target = knownCommands.get(name.toLowerCase(java.util.Locale.ENGLISH)); return target; } - public List tabComplete(CommandSender sender, String cmdLine) { + @Nullable + public List tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine) { return tabComplete(sender, cmdLine, null); } - public List tabComplete(CommandSender sender, String cmdLine, Location location) { + @Nullable + public List tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine, @Nullable Location location) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(cmdLine, "Command line cannot null"); @@ -215,6 +220,7 @@ public class SimpleCommandMap implements CommandMap { } } + @NotNull public Collection getCommands() { return Collections.unmodifiableCollection(knownCommands.values()); } diff --git a/paper-api/src/main/java/org/bukkit/command/TabCompleter.java b/paper-api/src/main/java/org/bukkit/command/TabCompleter.java index 3752ba9fa2..04c0e87495 100644 --- a/paper-api/src/main/java/org/bukkit/command/TabCompleter.java +++ b/paper-api/src/main/java/org/bukkit/command/TabCompleter.java @@ -1,5 +1,8 @@ package org.bukkit.command; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.List; /** @@ -20,5 +23,6 @@ public interface TabCompleter { * @return A List of possible completions for the final argument, or null * to default to the command executor */ - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args); + @Nullable + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java index 23c8580091..1d8249da2d 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java @@ -3,13 +3,14 @@ package org.bukkit.command.defaults; import java.util.List; import org.bukkit.command.Command; +import org.jetbrains.annotations.NotNull; public abstract class BukkitCommand extends Command { - protected BukkitCommand(String name) { + protected BukkitCommand(@NotNull String name) { super(name); } - protected BukkitCommand(String name, String description, String usageMessage, List aliases) { + protected BukkitCommand(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List aliases) { super(name, description, usageMessage, aliases); } } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/HelpCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/HelpCommand.java index a8f8a19bfd..391283bd4f 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/HelpCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/HelpCommand.java @@ -23,6 +23,8 @@ import org.bukkit.help.IndexHelpTopic; import org.bukkit.util.ChatPaginator; import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class HelpCommand extends BukkitCommand { public HelpCommand() { @@ -34,7 +36,7 @@ public class HelpCommand extends BukkitCommand { } @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; String command; @@ -111,8 +113,9 @@ public class HelpCommand extends BukkitCommand { return true; } + @NotNull @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); @@ -132,7 +135,8 @@ public class HelpCommand extends BukkitCommand { return ImmutableList.of(); } - protected HelpTopic findPossibleMatches(String searchString) { + @Nullable + protected HelpTopic findPossibleMatches(@NotNull String searchString) { int maxDistance = (searchString.length() / 5) + 3; Set possibleMatches = new TreeSet(HelpTopicComparator.helpTopicComparatorInstance()); @@ -172,7 +176,7 @@ public class HelpCommand extends BukkitCommand { * @return The number of substitutions, deletions, insertions, and * transpositions required to get from s1 to s2. */ - protected static int damerauLevenshteinDistance(String s1, String s2) { + protected static int damerauLevenshteinDistance(@Nullable String s1, @Nullable String s2) { if (s1 == null && s2 == null) { return 0; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java index e40b03a72e..6f95bf3ca6 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java @@ -8,9 +8,10 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public class PluginsCommand extends BukkitCommand { - public PluginsCommand(String name) { + public PluginsCommand(@NotNull String name) { super(name); this.description = "Gets a list of plugins running on the server"; this.usageMessage = "/plugins"; @@ -19,18 +20,20 @@ public class PluginsCommand extends BukkitCommand { } @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; sender.sendMessage("Plugins " + getPluginList()); return true; } + @NotNull @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { return Collections.emptyList(); } + @NotNull private String getPluginList() { StringBuilder pluginList = new StringBuilder(); Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java index 0ab7e295d1..1104c60372 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java @@ -8,9 +8,10 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class ReloadCommand extends BukkitCommand { - public ReloadCommand(String name) { + public ReloadCommand(@NotNull String name) { super(name); this.description = "Reloads the server configuration and plugins"; this.usageMessage = "/reload"; @@ -19,7 +20,7 @@ public class ReloadCommand extends BukkitCommand { } @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins."); @@ -30,8 +31,9 @@ public class ReloadCommand extends BukkitCommand { return true; } + @NotNull @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { return Collections.emptyList(); } } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/TimingsCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/TimingsCommand.java index 66ea6345ee..c4f1979a13 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/TimingsCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/TimingsCommand.java @@ -18,11 +18,12 @@ import org.bukkit.plugin.TimedRegisteredListener; import org.bukkit.util.StringUtil; import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.NotNull; public class TimingsCommand extends BukkitCommand { private static final List TIMINGS_SUBCOMMANDS = ImmutableList.of("merged", "reset", "separate"); - public TimingsCommand(String name) { + public TimingsCommand(@NotNull String name) { super(name); this.description = "Records timings for all plugin events"; this.usageMessage = "/timings "; @@ -30,7 +31,7 @@ public class TimingsCommand extends BukkitCommand { } @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; if (args.length != 1) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); @@ -110,8 +111,9 @@ public class TimingsCommand extends BukkitCommand { return true; } + @NotNull @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { 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/defaults/VersionCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java index 5a994953be..0305548e09 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java @@ -22,12 +22,14 @@ import java.net.URLEncoder; import java.util.HashSet; import java.util.Set; import java.util.concurrent.locks.ReentrantLock; + +import org.jetbrains.annotations.NotNull; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; public class VersionCommand extends BukkitCommand { - public VersionCommand(String name) { + public VersionCommand(@NotNull String name) { super(name); this.description = "Gets the version of this server including any plugins in use"; @@ -37,7 +39,7 @@ public class VersionCommand extends BukkitCommand { } @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; if (args.length == 0) { @@ -78,7 +80,7 @@ public class VersionCommand extends BukkitCommand { return true; } - private void describeToSender(Plugin plugin, CommandSender sender) { + private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) { PluginDescriptionFile desc = plugin.getDescription(); sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion()); @@ -99,7 +101,8 @@ public class VersionCommand extends BukkitCommand { } } - private String getAuthors(final PluginDescriptionFile desc) { + @NotNull + private String getAuthors(@NotNull final PluginDescriptionFile desc) { StringBuilder result = new StringBuilder(); List authors = desc.getAuthors(); @@ -121,8 +124,9 @@ public class VersionCommand extends BukkitCommand { return result.toString(); } + @NotNull @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); @@ -147,7 +151,7 @@ public class VersionCommand extends BukkitCommand { private boolean versionTaskStarted = false; private long lastCheck = 0; - private void sendVersion(CommandSender sender) { + private void sendVersion(@NotNull CommandSender sender) { if (hasVersion) { if (System.currentTimeMillis() - lastCheck > 21600000) { lastCheck = System.currentTimeMillis(); @@ -214,7 +218,7 @@ public class VersionCommand extends BukkitCommand { } } - private void setVersionMessage(String msg) { + private void setVersionMessage(@NotNull String msg) { lastCheck = System.currentTimeMillis(); versionMessage = msg; versionLock.lock(); @@ -230,7 +234,7 @@ public class VersionCommand extends BukkitCommand { } } - private static int getDistance(String repo, String hash) { + private static int getDistance(@NotNull String repo, @NotNull String hash) { try { BufferedReader reader = Resources.asCharSource( new URL("https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, "UTF-8") + "&withCounts=true"), diff --git a/paper-api/src/main/java/org/bukkit/configuration/Configuration.java b/paper-api/src/main/java/org/bukkit/configuration/Configuration.java index 52e3ac420c..7f7e3ff717 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/Configuration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/Configuration.java @@ -1,5 +1,8 @@ package org.bukkit.configuration; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Map; /** @@ -20,7 +23,7 @@ public interface Configuration extends ConfigurationSection { * @param value Value to set the default to. * @throws IllegalArgumentException Thrown if path is null. */ - public void addDefault(String path, Object value); + public void addDefault(@NotNull String path, @Nullable Object value); /** * Sets the default values of the given paths as provided. @@ -32,7 +35,7 @@ public interface Configuration extends ConfigurationSection { * @param defaults A map of Path{@literal ->}Values to add to defaults. * @throws IllegalArgumentException Thrown if defaults is null. */ - public void addDefaults(Map defaults); + public void addDefaults(@NotNull Map defaults); /** * Sets the default values of the given paths as provided. @@ -49,7 +52,7 @@ public interface Configuration extends ConfigurationSection { * @param defaults A configuration holding a list of defaults to copy. * @throws IllegalArgumentException Thrown if defaults is null or this. */ - public void addDefaults(Configuration defaults); + public void addDefaults(@NotNull Configuration defaults); /** * Sets the source of all default values for this {@link Configuration}. @@ -60,7 +63,7 @@ public interface Configuration extends ConfigurationSection { * @param defaults New source of default values for this configuration. * @throws IllegalArgumentException Thrown if defaults is null or this. */ - public void setDefaults(Configuration defaults); + public void setDefaults(@NotNull Configuration defaults); /** * Gets the source {@link Configuration} for this configuration. @@ -71,6 +74,7 @@ public interface Configuration extends ConfigurationSection { * * @return Configuration source for default values, or null if none exist. */ + @Nullable public Configuration getDefaults(); /** @@ -80,5 +84,6 @@ public interface Configuration extends ConfigurationSection { * * @return Options for this configuration */ + @NotNull public ConfigurationOptions options(); } diff --git a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationOptions.java b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationOptions.java index 2f59382223..356bad6bc7 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationOptions.java +++ b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationOptions.java @@ -1,5 +1,7 @@ package org.bukkit.configuration; +import org.jetbrains.annotations.NotNull; + /** * Various settings for controlling the input and output of a {@link * Configuration} @@ -9,7 +11,7 @@ public class ConfigurationOptions { private boolean copyDefaults = false; private final Configuration configuration; - protected ConfigurationOptions(Configuration configuration) { + protected ConfigurationOptions(@NotNull Configuration configuration) { this.configuration = configuration; } @@ -18,6 +20,7 @@ public class ConfigurationOptions { * * @return Parent configuration */ + @NotNull public Configuration configuration() { return configuration; } @@ -45,6 +48,7 @@ public class ConfigurationOptions { * @param value Path separator * @return This object, for chaining */ + @NotNull public ConfigurationOptions pathSeparator(char value) { this.pathSeparator = value; return this; @@ -83,6 +87,7 @@ public class ConfigurationOptions { * @param value Whether or not defaults are directly copied * @return This object, for chaining */ + @NotNull public ConfigurationOptions copyDefaults(boolean value) { this.copyDefaults = value; return this; diff --git a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java index d8575d1b37..5dac536911 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java +++ b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java @@ -9,6 +9,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.util.Vector; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a section of a {@link Configuration} @@ -28,6 +30,7 @@ public interface ConfigurationSection { * list. * @return Set of keys contained within this ConfigurationSection. */ + @NotNull public Set getKeys(boolean deep); /** @@ -44,6 +47,7 @@ public interface ConfigurationSection { * list. * @return Map of keys and values of this section. */ + @NotNull public Map getValues(boolean deep); /** @@ -57,7 +61,7 @@ public interface ConfigurationSection { * default or being set. * @throws IllegalArgumentException Thrown when path is null. */ - public boolean contains(String path); + public boolean contains(@NotNull String path); /** * Checks if this {@link ConfigurationSection} contains the given path. @@ -76,7 +80,7 @@ public interface ConfigurationSection { * value exist and the boolean parameter for this method is true. * @throws IllegalArgumentException Thrown when path is null. */ - public boolean contains(String path, boolean ignoreDefault); + public boolean contains(@NotNull String path, boolean ignoreDefault); /** * Checks if this {@link ConfigurationSection} has a value set for the @@ -90,7 +94,7 @@ public interface ConfigurationSection { * having a default. * @throws IllegalArgumentException Thrown when path is null. */ - public boolean isSet(String path); + public boolean isSet(@NotNull String path); /** * Gets the path of this {@link ConfigurationSection} from its root {@link @@ -107,6 +111,7 @@ public interface ConfigurationSection { * * @return Path of this section relative to its root */ + @Nullable public String getCurrentPath(); /** @@ -118,6 +123,7 @@ public interface ConfigurationSection { * * @return Name of this section */ + @NotNull public String getName(); /** @@ -132,6 +138,7 @@ public interface ConfigurationSection { * * @return Root configuration containing this section. */ + @Nullable public Configuration getRoot(); /** @@ -145,6 +152,7 @@ public interface ConfigurationSection { * * @return Parent section containing this section. */ + @Nullable public ConfigurationSection getParent(); /** @@ -157,7 +165,8 @@ public interface ConfigurationSection { * @param path Path of the Object to get. * @return Requested Object. */ - public Object get(String path); + @Nullable + public Object get(@NotNull String path); /** * Gets the requested Object by path, returning a default value if not @@ -171,7 +180,8 @@ public interface ConfigurationSection { * @param def The default value to return if the path is not found. * @return Requested Object. */ - public Object get(String path, Object def); + @Nullable + public Object get(@NotNull String path, @Nullable Object def); /** * Sets the specified path to the given value. @@ -187,7 +197,7 @@ public interface ConfigurationSection { * @param path Path of the object to set. * @param value New value to set the path to. */ - public void set(String path, Object value); + public void set(@NotNull String path, @Nullable Object value); /** * Creates an empty {@link ConfigurationSection} at the specified path. @@ -199,7 +209,8 @@ public interface ConfigurationSection { * @param path Path to create the section at. * @return Newly created section */ - public ConfigurationSection createSection(String path); + @NotNull + public ConfigurationSection createSection(@NotNull String path); /** * Creates a {@link ConfigurationSection} at the specified path, with @@ -213,7 +224,8 @@ public interface ConfigurationSection { * @param map The values to used. * @return Newly created section */ - public ConfigurationSection createSection(String path, Map map); + @NotNull + public ConfigurationSection createSection(@NotNull String path, @NotNull Map map); // Primitives /** @@ -226,7 +238,8 @@ public interface ConfigurationSection { * @param path Path of the String to get. * @return Requested String. */ - public String getString(String path); + @Nullable + public String getString(@NotNull String path); /** * Gets the requested String by path, returning a default value if not @@ -241,7 +254,8 @@ public interface ConfigurationSection { * not a String. * @return Requested String. */ - public String getString(String path, String def); + @Nullable + public String getString(@NotNull String path, @Nullable String def); /** * Checks if the specified path is a String. @@ -254,7 +268,7 @@ public interface ConfigurationSection { * @param path Path of the String to check. * @return Whether or not the specified path is a String. */ - public boolean isString(String path); + public boolean isString(@NotNull String path); /** * Gets the requested int by path. @@ -266,7 +280,7 @@ public interface ConfigurationSection { * @param path Path of the int to get. * @return Requested int. */ - public int getInt(String path); + public int getInt(@NotNull String path); /** * Gets the requested int by path, returning a default value if not found. @@ -280,7 +294,7 @@ public interface ConfigurationSection { * not an int. * @return Requested int. */ - public int getInt(String path, int def); + public int getInt(@NotNull String path, int def); /** * Checks if the specified path is an int. @@ -293,7 +307,7 @@ public interface ConfigurationSection { * @param path Path of the int to check. * @return Whether or not the specified path is an int. */ - public boolean isInt(String path); + public boolean isInt(@NotNull String path); /** * Gets the requested boolean by path. @@ -305,7 +319,7 @@ public interface ConfigurationSection { * @param path Path of the boolean to get. * @return Requested boolean. */ - public boolean getBoolean(String path); + public boolean getBoolean(@NotNull String path); /** * Gets the requested boolean by path, returning a default value if not @@ -320,7 +334,7 @@ public interface ConfigurationSection { * not a boolean. * @return Requested boolean. */ - public boolean getBoolean(String path, boolean def); + public boolean getBoolean(@NotNull String path, boolean def); /** * Checks if the specified path is a boolean. @@ -333,7 +347,7 @@ public interface ConfigurationSection { * @param path Path of the boolean to check. * @return Whether or not the specified path is a boolean. */ - public boolean isBoolean(String path); + public boolean isBoolean(@NotNull String path); /** * Gets the requested double by path. @@ -345,7 +359,7 @@ public interface ConfigurationSection { * @param path Path of the double to get. * @return Requested double. */ - public double getDouble(String path); + public double getDouble(@NotNull String path); /** * Gets the requested double by path, returning a default value if not @@ -360,7 +374,7 @@ public interface ConfigurationSection { * not a double. * @return Requested double. */ - public double getDouble(String path, double def); + public double getDouble(@NotNull String path, double def); /** * Checks if the specified path is a double. @@ -373,7 +387,7 @@ public interface ConfigurationSection { * @param path Path of the double to check. * @return Whether or not the specified path is a double. */ - public boolean isDouble(String path); + public boolean isDouble(@NotNull String path); /** * Gets the requested long by path. @@ -385,7 +399,7 @@ public interface ConfigurationSection { * @param path Path of the long to get. * @return Requested long. */ - public long getLong(String path); + public long getLong(@NotNull String path); /** * Gets the requested long by path, returning a default value if not @@ -400,7 +414,7 @@ public interface ConfigurationSection { * not a long. * @return Requested long. */ - public long getLong(String path, long def); + public long getLong(@NotNull String path, long def); /** * Checks if the specified path is a long. @@ -413,7 +427,7 @@ public interface ConfigurationSection { * @param path Path of the long to check. * @return Whether or not the specified path is a long. */ - public boolean isLong(String path); + public boolean isLong(@NotNull String path); // Java /** @@ -426,7 +440,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List. */ - public List getList(String path); + @Nullable + public List getList(@NotNull String path); /** * Gets the requested List by path, returning a default value if not @@ -441,7 +456,8 @@ public interface ConfigurationSection { * not a List. * @return Requested List. */ - public List getList(String path, List def); + @Nullable + public List getList(@NotNull String path, @Nullable List def); /** * Checks if the specified path is a List. @@ -454,7 +470,7 @@ public interface ConfigurationSection { * @param path Path of the List to check. * @return Whether or not the specified path is a List. */ - public boolean isList(String path); + public boolean isList(@NotNull String path); /** * Gets the requested List of String by path. @@ -469,7 +485,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of String. */ - public List getStringList(String path); + @NotNull + public List getStringList(@NotNull String path); /** * Gets the requested List of Integer by path. @@ -484,7 +501,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Integer. */ - public List getIntegerList(String path); + @NotNull + public List getIntegerList(@NotNull String path); /** * Gets the requested List of Boolean by path. @@ -499,7 +517,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Boolean. */ - public List getBooleanList(String path); + @NotNull + public List getBooleanList(@NotNull String path); /** * Gets the requested List of Double by path. @@ -514,7 +533,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Double. */ - public List getDoubleList(String path); + @NotNull + public List getDoubleList(@NotNull String path); /** * Gets the requested List of Float by path. @@ -529,7 +549,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Float. */ - public List getFloatList(String path); + @NotNull + public List getFloatList(@NotNull String path); /** * Gets the requested List of Long by path. @@ -544,7 +565,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Long. */ - public List getLongList(String path); + @NotNull + public List getLongList(@NotNull String path); /** * Gets the requested List of Byte by path. @@ -559,7 +581,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Byte. */ - public List getByteList(String path); + @NotNull + public List getByteList(@NotNull String path); /** * Gets the requested List of Character by path. @@ -574,7 +597,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Character. */ - public List getCharacterList(String path); + @NotNull + public List getCharacterList(@NotNull String path); /** * Gets the requested List of Short by path. @@ -589,7 +613,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Short. */ - public List getShortList(String path); + @NotNull + public List getShortList(@NotNull String path); /** * Gets the requested List of Maps by path. @@ -604,7 +629,8 @@ public interface ConfigurationSection { * @param path Path of the List to get. * @return Requested List of Maps. */ - public List> getMapList(String path); + @NotNull + public List> getMapList(@NotNull String path); // Bukkit /** @@ -620,7 +646,8 @@ public interface ConfigurationSection { * @param clazz the type of {@link ConfigurationSerializable} * @return Requested {@link ConfigurationSerializable} object */ - public T getSerializable(String path, Class clazz); + @Nullable + public T getSerializable(@NotNull String path, @NotNull Class clazz); /** * Gets the requested {@link ConfigurationSerializable} object at the given @@ -637,7 +664,8 @@ public interface ConfigurationSection { * the path * @return Requested {@link ConfigurationSerializable} object */ - public T getSerializable(String path, Class clazz, T def); + @Nullable + public T getSerializable(@NotNull String path, @NotNull Class clazz, @Nullable T def); /** * Gets the requested Vector by path. @@ -649,7 +677,8 @@ public interface ConfigurationSection { * @param path Path of the Vector to get. * @return Requested Vector. */ - public Vector getVector(String path); + @Nullable + public Vector getVector(@NotNull String path); /** * Gets the requested {@link Vector} by path, returning a default value if @@ -664,7 +693,8 @@ public interface ConfigurationSection { * not a Vector. * @return Requested Vector. */ - public Vector getVector(String path, Vector def); + @Nullable + public Vector getVector(@NotNull String path, @Nullable Vector def); /** * Checks if the specified path is a Vector. @@ -677,7 +707,7 @@ public interface ConfigurationSection { * @param path Path of the Vector to check. * @return Whether or not the specified path is a Vector. */ - public boolean isVector(String path); + public boolean isVector(@NotNull String path); /** * Gets the requested OfflinePlayer by path. @@ -690,7 +720,8 @@ public interface ConfigurationSection { * @param path Path of the OfflinePlayer to get. * @return Requested OfflinePlayer. */ - public OfflinePlayer getOfflinePlayer(String path); + @Nullable + public OfflinePlayer getOfflinePlayer(@NotNull String path); /** * Gets the requested {@link OfflinePlayer} by path, returning a default @@ -705,7 +736,8 @@ public interface ConfigurationSection { * not an OfflinePlayer. * @return Requested OfflinePlayer. */ - public OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def); + @Nullable + public OfflinePlayer getOfflinePlayer(@NotNull String path, @Nullable OfflinePlayer def); /** * Checks if the specified path is an OfflinePlayer. @@ -718,7 +750,7 @@ public interface ConfigurationSection { * @param path Path of the OfflinePlayer to check. * @return Whether or not the specified path is an OfflinePlayer. */ - public boolean isOfflinePlayer(String path); + public boolean isOfflinePlayer(@NotNull String path); /** * Gets the requested ItemStack by path. @@ -730,7 +762,8 @@ public interface ConfigurationSection { * @param path Path of the ItemStack to get. * @return Requested ItemStack. */ - public ItemStack getItemStack(String path); + @Nullable + public ItemStack getItemStack(@NotNull String path); /** * Gets the requested {@link ItemStack} by path, returning a default value @@ -745,7 +778,8 @@ public interface ConfigurationSection { * not an ItemStack. * @return Requested ItemStack. */ - public ItemStack getItemStack(String path, ItemStack def); + @Nullable + public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def); /** * Checks if the specified path is an ItemStack. @@ -758,7 +792,7 @@ public interface ConfigurationSection { * @param path Path of the ItemStack to check. * @return Whether or not the specified path is an ItemStack. */ - public boolean isItemStack(String path); + public boolean isItemStack(@NotNull String path); /** * Gets the requested Color by path. @@ -770,7 +804,8 @@ public interface ConfigurationSection { * @param path Path of the Color to get. * @return Requested Color. */ - public Color getColor(String path); + @Nullable + public Color getColor(@NotNull String path); /** * Gets the requested {@link Color} by path, returning a default value if @@ -785,7 +820,8 @@ public interface ConfigurationSection { * not a Color. * @return Requested Color. */ - public Color getColor(String path, Color def); + @Nullable + public Color getColor(@NotNull String path, @Nullable Color def); /** * Checks if the specified path is a Color. @@ -798,7 +834,7 @@ public interface ConfigurationSection { * @param path Path of the Color to check. * @return Whether or not the specified path is a Color. */ - public boolean isColor(String path); + public boolean isColor(@NotNull String path); /** * Gets the requested ConfigurationSection by path. @@ -811,7 +847,8 @@ public interface ConfigurationSection { * @param path Path of the ConfigurationSection to get. * @return Requested ConfigurationSection. */ - public ConfigurationSection getConfigurationSection(String path); + @Nullable + public ConfigurationSection getConfigurationSection(@NotNull String path); /** * Checks if the specified path is a ConfigurationSection. @@ -825,7 +862,7 @@ public interface ConfigurationSection { * @param path Path of the ConfigurationSection to check. * @return Whether or not the specified path is a ConfigurationSection. */ - public boolean isConfigurationSection(String path); + public boolean isConfigurationSection(@NotNull String path); /** * Gets the equivalent {@link ConfigurationSection} from the default @@ -837,6 +874,7 @@ public interface ConfigurationSection { * * @return Equivalent section in root configuration */ + @Nullable public ConfigurationSection getDefaultSection(); /** @@ -857,5 +895,5 @@ public interface ConfigurationSection { * @param value Value to set the default to. * @throws IllegalArgumentException Thrown if path is null. */ - public void addDefault(String path, Object value); + public void addDefault(@NotNull String path, @Nullable Object value); } diff --git a/paper-api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java index 19c27a1c42..e03108b123 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java @@ -3,6 +3,8 @@ package org.bukkit.configuration; import java.util.Map; import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This is a {@link Configuration} implementation that does not save or load @@ -25,12 +27,12 @@ public class MemoryConfiguration extends MemorySection implements Configuration * @param defaults Default value provider * @throws IllegalArgumentException Thrown if defaults is null */ - public MemoryConfiguration(Configuration defaults) { + public MemoryConfiguration(@Nullable Configuration defaults) { this.defaults = defaults; } @Override - public void addDefault(String path, Object value) { + public void addDefault(@NotNull String path, @Nullable Object value) { Validate.notNull(path, "Path may not be null"); if (defaults == null) { @@ -40,7 +42,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration defaults.set(path, value); } - public void addDefaults(Map defaults) { + public void addDefaults(@NotNull Map defaults) { Validate.notNull(defaults, "Defaults may not be null"); for (Map.Entry entry : defaults.entrySet()) { @@ -48,27 +50,30 @@ public class MemoryConfiguration extends MemorySection implements Configuration } } - public void addDefaults(Configuration defaults) { + public void addDefaults(@NotNull Configuration defaults) { Validate.notNull(defaults, "Defaults may not be null"); addDefaults(defaults.getValues(true)); } - public void setDefaults(Configuration defaults) { + public void setDefaults(@NotNull Configuration defaults) { Validate.notNull(defaults, "Defaults may not be null"); this.defaults = defaults; } + @Nullable public Configuration getDefaults() { return defaults; } + @Nullable @Override public ConfigurationSection getParent() { return null; } + @NotNull public MemoryConfigurationOptions options() { if (options == null) { options = new MemoryConfigurationOptions(this); diff --git a/paper-api/src/main/java/org/bukkit/configuration/MemoryConfigurationOptions.java b/paper-api/src/main/java/org/bukkit/configuration/MemoryConfigurationOptions.java index 44c046c483..ead85f6fae 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/MemoryConfigurationOptions.java +++ b/paper-api/src/main/java/org/bukkit/configuration/MemoryConfigurationOptions.java @@ -1,25 +1,30 @@ package org.bukkit.configuration; +import org.jetbrains.annotations.NotNull; + /** * Various settings for controlling the input and output of a {@link * MemoryConfiguration} */ public class MemoryConfigurationOptions extends ConfigurationOptions { - protected MemoryConfigurationOptions(MemoryConfiguration configuration) { + protected MemoryConfigurationOptions(@NotNull MemoryConfiguration configuration) { super(configuration); } + @NotNull @Override public MemoryConfiguration configuration() { return (MemoryConfiguration) super.configuration(); } + @NotNull @Override public MemoryConfigurationOptions copyDefaults(boolean value) { super.copyDefaults(value); return this; } + @NotNull @Override public MemoryConfigurationOptions pathSeparator(char value) { super.pathSeparator(value); diff --git a/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java b/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java index 3da7da3486..9c7fc51aed 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java +++ b/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java @@ -15,6 +15,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A type of {@link ConfigurationSection} that is stored in memory. @@ -56,7 +58,7 @@ public class MemorySection implements ConfigurationSection { * @throws IllegalArgumentException Thrown is parent or path is null, or * if parent contains no root Configuration. */ - protected MemorySection(ConfigurationSection parent, String path) { + protected MemorySection(@NotNull ConfigurationSection parent, @NotNull String path) { Validate.notNull(parent, "Parent cannot be null"); Validate.notNull(path, "Path cannot be null"); @@ -69,6 +71,7 @@ public class MemorySection implements ConfigurationSection { this.fullPath = createPath(parent, path); } + @NotNull public Set getKeys(boolean deep) { Set result = new LinkedHashSet(); @@ -86,6 +89,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @NotNull public Map getValues(boolean deep) { Map result = new LinkedHashMap(); @@ -103,15 +107,15 @@ public class MemorySection implements ConfigurationSection { return result; } - public boolean contains(String path) { + public boolean contains(@NotNull String path) { return contains(path, false); } - public boolean contains(String path, boolean ignoreDefault) { + public boolean contains(@NotNull String path, boolean ignoreDefault) { return ((ignoreDefault) ? get(path, null) : get(path)) != null; } - public boolean isSet(String path) { + public boolean isSet(@NotNull String path) { Configuration root = getRoot(); if (root == null) { return false; @@ -122,23 +126,27 @@ public class MemorySection implements ConfigurationSection { return get(path, null) != null; } + @NotNull public String getCurrentPath() { return fullPath; } + @NotNull public String getName() { return path; } + @Nullable public Configuration getRoot() { return root; } + @Nullable public ConfigurationSection getParent() { return parent; } - public void addDefault(String path, Object value) { + public void addDefault(@NotNull String path, @Nullable Object value) { Validate.notNull(path, "Path cannot be null"); Configuration root = getRoot(); @@ -151,6 +159,7 @@ public class MemorySection implements ConfigurationSection { root.addDefault(createPath(this, path), value); } + @Nullable public ConfigurationSection getDefaultSection() { Configuration root = getRoot(); Configuration defaults = root == null ? null : root.getDefaults(); @@ -164,7 +173,7 @@ public class MemorySection implements ConfigurationSection { return null; } - public void set(String path, Object value) { + public void set(@NotNull String path, @Nullable Object value) { Validate.notEmpty(path, "Cannot set to an empty path"); Configuration root = getRoot(); @@ -203,11 +212,13 @@ public class MemorySection implements ConfigurationSection { } } - public Object get(String path) { + @Nullable + public Object get(@NotNull String path) { return get(path, getDefault(path)); } - public Object get(String path, Object def) { + @Nullable + public Object get(@NotNull String path, @Nullable Object def) { Validate.notNull(path, "Path cannot be null"); if (path.length() == 0) { @@ -239,7 +250,8 @@ public class MemorySection implements ConfigurationSection { return section.get(key, def); } - public ConfigurationSection createSection(String path) { + @NotNull + public ConfigurationSection createSection(@NotNull String path) { Validate.notEmpty(path, "Cannot create section at empty path"); Configuration root = getRoot(); if (root == null) { @@ -270,7 +282,8 @@ public class MemorySection implements ConfigurationSection { return section.createSection(key); } - public ConfigurationSection createSection(String path, Map map) { + @NotNull + public ConfigurationSection createSection(@NotNull String path, @NotNull Map map) { ConfigurationSection section = createSection(path); for (Map.Entry entry : map.entrySet()) { @@ -285,98 +298,103 @@ public class MemorySection implements ConfigurationSection { } // Primitives - public String getString(String path) { + @Nullable + public String getString(@NotNull String path) { Object def = getDefault(path); return getString(path, def != null ? def.toString() : null); } - public String getString(String path, String def) { + @Nullable + public String getString(@NotNull String path, @Nullable String def) { Object val = get(path, def); return (val != null) ? val.toString() : def; } - public boolean isString(String path) { + public boolean isString(@NotNull String path) { Object val = get(path); return val instanceof String; } - public int getInt(String path) { + public int getInt(@NotNull String path) { Object def = getDefault(path); return getInt(path, (def instanceof Number) ? toInt(def) : 0); } - public int getInt(String path, int def) { + public int getInt(@NotNull String path, int def) { Object val = get(path, def); return (val instanceof Number) ? toInt(val) : def; } - public boolean isInt(String path) { + public boolean isInt(@NotNull String path) { Object val = get(path); return val instanceof Integer; } - public boolean getBoolean(String path) { + public boolean getBoolean(@NotNull String path) { Object def = getDefault(path); return getBoolean(path, (def instanceof Boolean) ? (Boolean) def : false); } - public boolean getBoolean(String path, boolean def) { + public boolean getBoolean(@NotNull String path, boolean def) { Object val = get(path, def); return (val instanceof Boolean) ? (Boolean) val : def; } - public boolean isBoolean(String path) { + public boolean isBoolean(@NotNull String path) { Object val = get(path); return val instanceof Boolean; } - public double getDouble(String path) { + public double getDouble(@NotNull String path) { Object def = getDefault(path); return getDouble(path, (def instanceof Number) ? toDouble(def) : 0); } - public double getDouble(String path, double def) { + public double getDouble(@NotNull String path, double def) { Object val = get(path, def); return (val instanceof Number) ? toDouble(val) : def; } - public boolean isDouble(String path) { + public boolean isDouble(@NotNull String path) { Object val = get(path); return val instanceof Double; } - public long getLong(String path) { + public long getLong(@NotNull String path) { Object def = getDefault(path); return getLong(path, (def instanceof Number) ? toLong(def) : 0); } - public long getLong(String path, long def) { + public long getLong(@NotNull String path, long def) { Object val = get(path, def); return (val instanceof Number) ? toLong(val) : def; } - public boolean isLong(String path) { + public boolean isLong(@NotNull String path) { Object val = get(path); return val instanceof Long; } // Java - public List getList(String path) { + @Nullable + public List getList(@NotNull String path) { Object def = getDefault(path); return getList(path, (def instanceof List) ? (List) def : null); } - public List getList(String path, List def) { + @Nullable + public List getList(@NotNull String path, @Nullable List def) { Object val = get(path, def); return (List) ((val instanceof List) ? val : def); } - public boolean isList(String path) { + public boolean isList(@NotNull String path) { Object val = get(path); return val instanceof List; } - public List getStringList(String path) { + @NotNull + public List getStringList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -394,7 +412,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getIntegerList(String path) { + @NotNull + public List getIntegerList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -421,7 +440,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getBooleanList(String path) { + @NotNull + public List getBooleanList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -445,7 +465,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getDoubleList(String path) { + @NotNull + public List getDoubleList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -472,7 +493,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getFloatList(String path) { + @NotNull + public List getFloatList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -499,7 +521,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getLongList(String path) { + @NotNull + public List getLongList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -526,7 +549,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getByteList(String path) { + @NotNull + public List getByteList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -553,7 +577,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getCharacterList(String path) { + @NotNull + public List getCharacterList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -579,7 +604,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getShortList(String path) { + @NotNull + public List getShortList(@NotNull String path) { List list = getList(path); if (list == null) { @@ -606,7 +632,8 @@ public class MemorySection implements ConfigurationSection { return result; } - public List> getMapList(String path) { + @NotNull + public List> getMapList(@NotNull String path) { List list = getList(path); List> result = new ArrayList>(); @@ -624,69 +651,80 @@ public class MemorySection implements ConfigurationSection { } // Bukkit + @Nullable @Override - public T getSerializable(String path, Class clazz) { + public T getSerializable(@NotNull String path, @NotNull Class clazz) { Validate.notNull(clazz, "ConfigurationSerializable class cannot be null"); Object def = getDefault(path); return getSerializable(path, clazz, (def != null && clazz.isInstance(def)) ? clazz.cast(def) : null); } + @Nullable @Override - public T getSerializable(String path, Class clazz, T def) { + public T getSerializable(@NotNull String path, @NotNull Class clazz, @Nullable T def) { Validate.notNull(clazz, "ConfigurationSerializable class cannot be null"); Object val = get(path); return (val != null && clazz.isInstance(val)) ? clazz.cast(val) : def; } - public Vector getVector(String path) { + @Nullable + public Vector getVector(@NotNull String path) { return getSerializable(path, Vector.class); } - public Vector getVector(String path, Vector def) { + @Nullable + public Vector getVector(@NotNull String path, @Nullable Vector def) { return getSerializable(path, Vector.class, def); } - public boolean isVector(String path) { + public boolean isVector(@NotNull String path) { return getSerializable(path, Vector.class) != null; } - public OfflinePlayer getOfflinePlayer(String path) { + @Nullable + public OfflinePlayer getOfflinePlayer(@NotNull String path) { return getSerializable(path, OfflinePlayer.class); } - public OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def) { + @Nullable + public OfflinePlayer getOfflinePlayer(@NotNull String path, @Nullable OfflinePlayer def) { return getSerializable(path, OfflinePlayer.class, def); } - public boolean isOfflinePlayer(String path) { + public boolean isOfflinePlayer(@NotNull String path) { return getSerializable(path, OfflinePlayer.class) != null; } - public ItemStack getItemStack(String path) { + @Nullable + public ItemStack getItemStack(@NotNull String path) { return getSerializable(path, ItemStack.class); } - public ItemStack getItemStack(String path, ItemStack def) { + @Nullable + public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def) { return getSerializable(path, ItemStack.class, def); } - public boolean isItemStack(String path) { + public boolean isItemStack(@NotNull String path) { return getSerializable(path, ItemStack.class) != null; } - public Color getColor(String path) { + @Nullable + public Color getColor(@NotNull String path) { return getSerializable(path, Color.class); } - public Color getColor(String path, Color def) { + @Nullable + public Color getColor(@NotNull String path, @Nullable Color def) { return getSerializable(path, Color.class, def); } - public boolean isColor(String path) { + public boolean isColor(@NotNull String path) { return getSerializable(path, Color.class) != null; } - public ConfigurationSection getConfigurationSection(String path) { + @Nullable + public ConfigurationSection getConfigurationSection(@NotNull String path) { Object val = get(path, null); if (val != null) { return (val instanceof ConfigurationSection) ? (ConfigurationSection) val : null; @@ -696,19 +734,20 @@ public class MemorySection implements ConfigurationSection { return (val instanceof ConfigurationSection) ? createSection(path) : null; } - public boolean isConfigurationSection(String path) { + public boolean isConfigurationSection(@NotNull String path) { Object val = get(path); return val instanceof ConfigurationSection; } - protected boolean isPrimitiveWrapper(Object input) { + protected boolean isPrimitiveWrapper(@Nullable Object input) { return input instanceof Integer || input instanceof Boolean || input instanceof Character || input instanceof Byte || input instanceof Short || input instanceof Double || input instanceof Long || input instanceof Float; } - protected Object getDefault(String path) { + @Nullable + protected Object getDefault(@NotNull String path) { Validate.notNull(path, "Path cannot be null"); Configuration root = getRoot(); @@ -716,7 +755,7 @@ public class MemorySection implements ConfigurationSection { return (defaults == null) ? null : defaults.get(createPath(this, path)); } - protected void mapChildrenKeys(Set output, ConfigurationSection section, boolean deep) { + protected void mapChildrenKeys(@NotNull Set output, @NotNull ConfigurationSection section, boolean deep) { if (section instanceof MemorySection) { MemorySection sec = (MemorySection) section; @@ -737,7 +776,7 @@ public class MemorySection implements ConfigurationSection { } } - protected void mapChildrenValues(Map output, ConfigurationSection section, boolean deep) { + protected void mapChildrenValues(@NotNull Map output, @NotNull ConfigurationSection section, boolean deep) { if (section instanceof MemorySection) { MemorySection sec = (MemorySection) section; @@ -775,7 +814,8 @@ public class MemorySection implements ConfigurationSection { * @param key Name of the specified section. * @return Full path of the section from its root. */ - public static String createPath(ConfigurationSection section, String key) { + @NotNull + public static String createPath(@NotNull ConfigurationSection section, @Nullable String key) { return createPath(section, key, (section == null) ? null : section.getRoot()); } @@ -791,7 +831,8 @@ public class MemorySection implements ConfigurationSection { * @param relativeTo Section to create the path relative to. * @return Full path of the section from its root. */ - public static String createPath(ConfigurationSection section, String key, ConfigurationSection relativeTo) { + @NotNull + public static String createPath(@NotNull ConfigurationSection section, @Nullable String key, @Nullable ConfigurationSection relativeTo) { Validate.notNull(section, "Cannot create path without a section"); Configuration root = section.getRoot(); if (root == null) { diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java index dd56c41e93..ba3c93fe48 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java @@ -19,6 +19,8 @@ import java.io.Writer; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.MemoryConfiguration; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This is a base class for all File based implementations of {@link @@ -39,7 +41,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * * @param defaults Default value provider */ - public FileConfiguration(Configuration defaults) { + public FileConfiguration(@Nullable Configuration defaults) { super(defaults); } @@ -58,7 +60,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * any reason. * @throws IllegalArgumentException Thrown when file is null. */ - public void save(File file) throws IOException { + public void save(@NotNull File file) throws IOException { Validate.notNull(file, "File cannot be null"); Files.createParentDirs(file); @@ -89,7 +91,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * any reason. * @throws IllegalArgumentException Thrown when file is null. */ - public void save(String file) throws IOException { + public void save(@NotNull String file) throws IOException { Validate.notNull(file, "File cannot be null"); save(new File(file)); @@ -100,6 +102,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * * @return String containing this configuration. */ + @NotNull public abstract String saveToString(); /** @@ -120,7 +123,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * a valid Configuration. * @throws IllegalArgumentException Thrown when file is null. */ - public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException { + public void load(@NotNull File file) throws FileNotFoundException, IOException, InvalidConfigurationException { Validate.notNull(file, "File cannot be null"); final FileInputStream stream = new FileInputStream(file); @@ -141,7 +144,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * represent a valid Configuration * @throws IllegalArgumentException thrown when reader is null */ - public void load(Reader reader) throws IOException, InvalidConfigurationException { + public void load(@NotNull Reader reader) throws IOException, InvalidConfigurationException { BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); StringBuilder builder = new StringBuilder(); @@ -178,7 +181,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * a valid Configuration. * @throws IllegalArgumentException Thrown when file is null. */ - public void load(String file) throws FileNotFoundException, IOException, InvalidConfigurationException { + public void load(@NotNull String file) throws FileNotFoundException, IOException, InvalidConfigurationException { Validate.notNull(file, "File cannot be null"); load(new File(file)); @@ -199,7 +202,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { * invalid. * @throws IllegalArgumentException Thrown if contents is null. */ - public abstract void loadFromString(String contents) throws InvalidConfigurationException; + public abstract void loadFromString(@NotNull String contents) throws InvalidConfigurationException; /** * Compiles the header for this {@link FileConfiguration} and returns the @@ -211,8 +214,10 @@ public abstract class FileConfiguration extends MemoryConfiguration { * * @return Compiled header */ + @NotNull protected abstract String buildHeader(); + @NotNull @Override public FileConfigurationOptions options() { if (options == null) { diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java b/paper-api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java index ccf81e0638..4919f6c939 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java @@ -1,6 +1,8 @@ package org.bukkit.configuration.file; import org.bukkit.configuration.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Various settings for controlling the input and output of a {@link @@ -10,21 +12,24 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { private String header = null; private boolean copyHeader = true; - protected FileConfigurationOptions(MemoryConfiguration configuration) { + protected FileConfigurationOptions(@NotNull MemoryConfiguration configuration) { super(configuration); } + @NotNull @Override public FileConfiguration configuration() { return (FileConfiguration) super.configuration(); } + @NotNull @Override public FileConfigurationOptions copyDefaults(boolean value) { super.copyDefaults(value); return this; } + @NotNull @Override public FileConfigurationOptions pathSeparator(char value) { super.pathSeparator(value); @@ -45,6 +50,7 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { * * @return Header */ + @Nullable public String header() { return header; } @@ -64,7 +70,8 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { * @param value New header * @return This object, for chaining */ - public FileConfigurationOptions header(String value) { + @NotNull + public FileConfigurationOptions header(@Nullable String value) { this.header = value; return this; } @@ -110,6 +117,7 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { * @param value Whether or not to copy the header * @return This object, for chaining */ + @NotNull public FileConfigurationOptions copyHeader(boolean value) { copyHeader = value; diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java index 60eecf4bbe..441e7ff981 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java @@ -12,6 +12,7 @@ import org.bukkit.Bukkit; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; +import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; @@ -28,6 +29,7 @@ public class YamlConfiguration extends FileConfiguration { private final Representer yamlRepresenter = new YamlRepresenter(); private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions); + @NotNull @Override public String saveToString() { yamlOptions.setIndent(options().indent()); @@ -45,7 +47,7 @@ public class YamlConfiguration extends FileConfiguration { } @Override - public void loadFromString(String contents) throws InvalidConfigurationException { + public void loadFromString(@NotNull String contents) throws InvalidConfigurationException { Validate.notNull(contents, "Contents cannot be null"); Map input; @@ -67,7 +69,7 @@ public class YamlConfiguration extends FileConfiguration { } } - protected void convertMapsToSections(Map input, ConfigurationSection section) { + protected void convertMapsToSections(@NotNull Map input, @NotNull ConfigurationSection section) { for (Map.Entry entry : input.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); @@ -80,7 +82,8 @@ public class YamlConfiguration extends FileConfiguration { } } - protected String parseHeader(String input) { + @NotNull + protected String parseHeader(@NotNull String input) { String[] lines = input.split("\r?\n", -1); StringBuilder result = new StringBuilder(); boolean readingHeader = true; @@ -109,6 +112,7 @@ public class YamlConfiguration extends FileConfiguration { return result.toString(); } + @NotNull @Override protected String buildHeader() { String header = options().header(); @@ -147,6 +151,7 @@ public class YamlConfiguration extends FileConfiguration { return builder.toString(); } + @NotNull @Override public YamlConfigurationOptions options() { if (options == null) { @@ -169,7 +174,8 @@ public class YamlConfiguration extends FileConfiguration { * @return Resulting configuration * @throws IllegalArgumentException Thrown if file is null */ - public static YamlConfiguration loadConfiguration(File file) { + @NotNull + public static YamlConfiguration loadConfiguration(@NotNull File file) { Validate.notNull(file, "File cannot be null"); YamlConfiguration config = new YamlConfiguration(); @@ -197,7 +203,8 @@ public class YamlConfiguration extends FileConfiguration { * @return resulting configuration * @throws IllegalArgumentException Thrown if stream is null */ - public static YamlConfiguration loadConfiguration(Reader reader) { + @NotNull + public static YamlConfiguration loadConfiguration(@NotNull Reader reader) { Validate.notNull(reader, "Stream cannot be null"); YamlConfiguration config = new YamlConfiguration(); diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java index 57894e320c..b2bf9785af 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java @@ -1,6 +1,8 @@ package org.bukkit.configuration.file; import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Various settings for controlling the input and output of a {@link @@ -9,33 +11,38 @@ import org.apache.commons.lang.Validate; public class YamlConfigurationOptions extends FileConfigurationOptions { private int indent = 2; - protected YamlConfigurationOptions(YamlConfiguration configuration) { + protected YamlConfigurationOptions(@NotNull YamlConfiguration configuration) { super(configuration); } + @NotNull @Override public YamlConfiguration configuration() { return (YamlConfiguration) super.configuration(); } + @NotNull @Override public YamlConfigurationOptions copyDefaults(boolean value) { super.copyDefaults(value); return this; } + @NotNull @Override public YamlConfigurationOptions pathSeparator(char value) { super.pathSeparator(value); return this; } + @NotNull @Override - public YamlConfigurationOptions header(String value) { + public YamlConfigurationOptions header(@Nullable String value) { super.header(value); return this; } + @NotNull @Override public YamlConfigurationOptions copyHeader(boolean value) { super.copyHeader(value); @@ -61,6 +68,7 @@ public class YamlConfigurationOptions extends FileConfigurationOptions { * @param value New indent * @return This object, for chaining */ + @NotNull public YamlConfigurationOptions indent(int value) { Validate.isTrue(value >= 2, "Indent must be at least 2 characters"); Validate.isTrue(value <= 9, "Indent cannot be greater than 9 characters"); diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java index 73ad722a82..397b58c534 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java @@ -3,6 +3,8 @@ package org.bukkit.configuration.file; import java.util.LinkedHashMap; import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.error.YAMLException; @@ -17,8 +19,10 @@ public class YamlConstructor extends SafeConstructor { } private class ConstructCustomObject extends ConstructYamlMap { + + @Nullable @Override - public Object construct(Node node) { + public Object construct(@NotNull Node node) { if (node.isTwoStepsConstruction()) { throw new YAMLException("Unexpected referential mapping structure. Node: " + node); } @@ -42,7 +46,7 @@ public class YamlConstructor extends SafeConstructor { } @Override - public void construct2ndStep(Node node, Object object) { + public void construct2ndStep(@NotNull Node node, @NotNull Object object) { throw new YAMLException("Unexpected referential mapping structure. Node: " + node); } } diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java index bc9c098d51..63cb35555c 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java @@ -7,6 +7,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; +import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.representer.Representer; @@ -18,15 +19,19 @@ public class YamlRepresenter extends Representer { } private class RepresentConfigurationSection extends RepresentMap { + + @NotNull @Override - public Node representData(Object data) { + public Node representData(@NotNull Object data) { return super.representData(((ConfigurationSection) data).getValues(false)); } } private class RepresentConfigurationSerializable extends RepresentMap { + + @NotNull @Override - public Node representData(Object data) { + public Node representData(@NotNull Object data) { ConfigurationSerializable serializable = (ConfigurationSerializable) data; Map values = new LinkedHashMap(); values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass())); diff --git a/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java b/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java index 74b73f9d05..a666db15e5 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java +++ b/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java @@ -1,5 +1,7 @@ package org.bukkit.configuration.serialization; +import org.jetbrains.annotations.NotNull; + import java.util.Map; /** @@ -31,5 +33,6 @@ public interface ConfigurationSerializable { * * @return Map containing the current state of this class */ + @NotNull public Map serialize(); } diff --git a/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java b/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java index 1803d57ac6..76d9b9662d 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java +++ b/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java @@ -21,6 +21,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.util.BoundingBox; import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Utility class for storing and retrieving classes for {@link Configuration}. @@ -43,11 +45,12 @@ public class ConfigurationSerialization { registerClass(BoundingBox.class); } - protected ConfigurationSerialization(Class clazz) { + protected ConfigurationSerialization(@NotNull Class clazz) { this.clazz = clazz; } - protected Method getMethod(String name, boolean isStatic) { + @Nullable + protected Method getMethod(@NotNull String name, boolean isStatic) { try { Method method = clazz.getDeclaredMethod(name, Map.class); @@ -66,6 +69,7 @@ public class ConfigurationSerialization { } } + @Nullable protected Constructor getConstructor() { try { return clazz.getConstructor(Map.class); @@ -76,7 +80,8 @@ public class ConfigurationSerialization { } } - protected ConfigurationSerializable deserializeViaMethod(Method method, Map args) { + @Nullable + protected ConfigurationSerializable deserializeViaMethod(@NotNull Method method, @NotNull Map args) { try { ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args); @@ -95,7 +100,8 @@ public class ConfigurationSerialization { return null; } - protected ConfigurationSerializable deserializeViaCtor(Constructor ctor, Map args) { + @Nullable + protected ConfigurationSerializable deserializeViaCtor(@NotNull Constructor ctor, @NotNull Map args) { try { return ctor.newInstance(args); } catch (Throwable ex) { @@ -108,7 +114,8 @@ public class ConfigurationSerialization { return null; } - public ConfigurationSerializable deserialize(Map args) { + @Nullable + public ConfigurationSerializable deserialize(@NotNull Map args) { Validate.notNull(args, "Args must not be null"); ConfigurationSerializable result = null; @@ -156,7 +163,8 @@ public class ConfigurationSerialization { * @param clazz Class to deserialize into * @return New instance of the specified class */ - public static ConfigurationSerializable deserializeObject(Map args, Class clazz) { + @Nullable + public static ConfigurationSerializable deserializeObject(@NotNull Map args, @NotNull Class clazz) { return new ConfigurationSerialization(clazz).deserialize(args); } @@ -174,7 +182,8 @@ public class ConfigurationSerialization { * @param args Arguments for deserialization * @return New instance of the specified class */ - public static ConfigurationSerializable deserializeObject(Map args) { + @Nullable + public static ConfigurationSerializable deserializeObject(@NotNull Map args) { Class clazz = null; if (args.containsKey(SERIALIZED_TYPE_KEY)) { @@ -205,7 +214,7 @@ public class ConfigurationSerialization { * * @param clazz Class to register */ - public static void registerClass(Class clazz) { + public static void registerClass(@NotNull Class clazz) { DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class); if (delegate == null) { @@ -222,7 +231,7 @@ public class ConfigurationSerialization { * @param alias Alias to register as * @see SerializableAs */ - public static void registerClass(Class clazz, String alias) { + public static void registerClass(@NotNull Class clazz, @NotNull String alias) { aliases.put(alias, clazz); } @@ -231,7 +240,7 @@ public class ConfigurationSerialization { * * @param alias Alias to unregister */ - public static void unregisterClass(String alias) { + public static void unregisterClass(@NotNull String alias) { aliases.remove(alias); } @@ -241,7 +250,7 @@ public class ConfigurationSerialization { * * @param clazz Class to unregister */ - public static void unregisterClass(Class clazz) { + public static void unregisterClass(@NotNull Class clazz) { while (aliases.values().remove(clazz)) { ; } @@ -254,7 +263,8 @@ public class ConfigurationSerialization { * @param alias Alias of the serializable * @return Registered class, or null if not found */ - public static Class getClassByAlias(String alias) { + @Nullable + public static Class getClassByAlias(@NotNull String alias) { return aliases.get(alias); } @@ -265,7 +275,8 @@ public class ConfigurationSerialization { * @param clazz Class to get alias for * @return Alias to use for the class */ - public static String getAlias(Class clazz) { + @NotNull + public static String getAlias(@NotNull Class clazz) { DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class); if (delegate != null) { diff --git a/paper-api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java b/paper-api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java index 1cfae94f73..2fa5d2dfef 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java +++ b/paper-api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java @@ -1,5 +1,7 @@ package org.bukkit.configuration.serialization; +import org.jetbrains.annotations.NotNull; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -18,5 +20,6 @@ public @interface DelegateDeserialization { * * @return Delegate class */ + @NotNull public Class value(); } diff --git a/paper-api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java b/paper-api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java index c5ee9987a5..9f4e795049 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java +++ b/paper-api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java @@ -1,5 +1,7 @@ package org.bukkit.configuration.serialization; +import org.jetbrains.annotations.NotNull; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -30,5 +32,6 @@ public @interface SerializableAs { * * @return Name to serialize the class as. */ + @NotNull public String value(); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/BooleanPrompt.java b/paper-api/src/main/java/org/bukkit/conversations/BooleanPrompt.java index d8cf801adf..95d054436c 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/BooleanPrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/BooleanPrompt.java @@ -2,6 +2,8 @@ package org.bukkit.conversations; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.BooleanUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * BooleanPrompt is the base class for any prompt that requires a boolean @@ -14,13 +16,14 @@ public abstract class BooleanPrompt extends ValidatingPrompt { } @Override - protected boolean isInputValid(ConversationContext context, String input) { + protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { String[] accepted = {/* Apache values: */"true", "false", "on", "off", "yes", "no",/* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"}; return ArrayUtils.contains(accepted, input.toLowerCase()); } + @Nullable @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { + protected Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) { if (input.equalsIgnoreCase("y") || input.equals("1") || input.equalsIgnoreCase("right") || input.equalsIgnoreCase("correct") || input.equalsIgnoreCase("valid")) input = "true"; return acceptValidatedInput(context, BooleanUtils.toBoolean(input)); } @@ -33,5 +36,6 @@ public abstract class BooleanPrompt extends ValidatingPrompt { * @param input The user's boolean response. * @return The next {@link Prompt} in the prompt graph. */ - protected abstract Prompt acceptValidatedInput(ConversationContext context, boolean input); + @Nullable + protected abstract Prompt acceptValidatedInput(@NotNull ConversationContext context, boolean input); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/Conversable.java b/paper-api/src/main/java/org/bukkit/conversations/Conversable.java index d1e5c7ddcb..914c6388ec 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/Conversable.java +++ b/paper-api/src/main/java/org/bukkit/conversations/Conversable.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * The Conversable interface is used to indicate objects that can have * conversations. @@ -20,7 +22,7 @@ public interface Conversable { * * @param input The input message into the conversation */ - public void acceptConversationInput(String input); + public void acceptConversationInput(@NotNull String input); /** * Enters into a dialog with a Conversation object. @@ -29,14 +31,14 @@ public interface Conversable { * @return True if the conversation should proceed, false if it has been * enqueued */ - public boolean beginConversation(Conversation conversation); + public boolean beginConversation(@NotNull Conversation conversation); /** * Abandons an active conversation. * * @param conversation The conversation to abandon */ - public void abandonConversation(Conversation conversation); + public void abandonConversation(@NotNull Conversation conversation); /** * Abandons an active conversation. @@ -44,12 +46,12 @@ public interface Conversable { * @param conversation The conversation to abandon * @param details Details about why the conversation was abandoned */ - public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details); + public void abandonConversation(@NotNull Conversation conversation, @NotNull ConversationAbandonedEvent details); /** * Sends this sender a message raw * * @param message Message to be displayed */ - public void sendRawMessage(String message); + public void sendRawMessage(@NotNull String message); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/Conversation.java b/paper-api/src/main/java/org/bukkit/conversations/Conversation.java index 6d53ea2e35..cb77dbd3c4 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/Conversation.java +++ b/paper-api/src/main/java/org/bukkit/conversations/Conversation.java @@ -1,6 +1,8 @@ package org.bukkit.conversations; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.HashMap; @@ -51,7 +53,7 @@ public class Conversation { * @param forWhom The entity for whom this conversation is mediating. * @param firstPrompt The first prompt in the conversation graph. */ - public Conversation(Plugin plugin, Conversable forWhom, Prompt firstPrompt) { + public Conversation(@Nullable Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt) { this(plugin, forWhom, firstPrompt, new HashMap()); } @@ -64,7 +66,7 @@ public class Conversation { * @param initialSessionData Any initial values to put in the conversation * context sessionData map. */ - public Conversation(Plugin plugin, Conversable forWhom, Prompt firstPrompt, Map initialSessionData) { + public Conversation(@Nullable Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt, @NotNull Map initialSessionData) { this.firstPrompt = firstPrompt; this.context = new ConversationContext(plugin, forWhom, initialSessionData); this.modal = true; @@ -79,6 +81,7 @@ public class Conversation { * * @return The entity. */ + @NotNull public Conversable getForWhom() { return context.getForWhom(); } @@ -133,6 +136,7 @@ public class Conversation { * * @return The ConversationPrefix in use. */ + @NotNull public ConversationPrefix getPrefix() { return prefix; } @@ -143,7 +147,7 @@ public class Conversation { * * @param prefix The ConversationPrefix to use. */ - void setPrefix(ConversationPrefix prefix) { + void setPrefix(@NotNull ConversationPrefix prefix) { this.prefix = prefix; } @@ -152,7 +156,7 @@ public class Conversation { * * @param canceller The {@link ConversationCanceller} to add. */ - void addConversationCanceller(ConversationCanceller canceller) { + void addConversationCanceller(@NotNull ConversationCanceller canceller) { canceller.setConversation(this); this.cancellers.add(canceller); } @@ -162,6 +166,7 @@ public class Conversation { * * @return The list. */ + @NotNull public List getCancellers() { return cancellers; } @@ -171,6 +176,7 @@ public class Conversation { * * @return The ConversationContext. */ + @NotNull public ConversationContext getContext() { return context; } @@ -192,6 +198,7 @@ public class Conversation { * * @return The current state of the conversation. */ + @NotNull public ConversationState getState() { if (currentPrompt != null) { return ConversationState.STARTED; @@ -208,7 +215,7 @@ public class Conversation { * * @param input The user's chat text. */ - public void acceptInput(String input) { + public void acceptInput(@NotNull String input) { if (currentPrompt != null) { // Echo the user's input @@ -235,7 +242,7 @@ public class Conversation { * * @param listener The listener to add. */ - public synchronized void addConversationAbandonedListener(ConversationAbandonedListener listener) { + public synchronized void addConversationAbandonedListener(@NotNull ConversationAbandonedListener listener) { abandonedListeners.add(listener); } @@ -244,7 +251,7 @@ public class Conversation { * * @param listener The listener to remove. */ - public synchronized void removeConversationAbandonedListener(ConversationAbandonedListener listener) { + public synchronized void removeConversationAbandonedListener(@NotNull ConversationAbandonedListener listener) { abandonedListeners.remove(listener); } @@ -262,7 +269,7 @@ public class Conversation { * * @param details Details about why the conversation was abandoned */ - public synchronized void abandon(ConversationAbandonedEvent details) { + public synchronized void abandon(@NotNull ConversationAbandonedEvent details) { if (!abandoned) { abandoned = true; currentPrompt = null; diff --git a/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java b/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java index 63c4a2aa3a..5c634789db 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java @@ -1,5 +1,8 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.EventObject; /** @@ -11,11 +14,11 @@ public class ConversationAbandonedEvent extends EventObject { private ConversationContext context; private ConversationCanceller canceller; - public ConversationAbandonedEvent(Conversation conversation) { + public ConversationAbandonedEvent(@NotNull Conversation conversation) { this(conversation, null); } - public ConversationAbandonedEvent(Conversation conversation, ConversationCanceller canceller) { + public ConversationAbandonedEvent(@NotNull Conversation conversation, @Nullable ConversationCanceller canceller) { super(conversation); this.context = conversation.getContext(); this.canceller = canceller; @@ -26,6 +29,7 @@ public class ConversationAbandonedEvent extends EventObject { * * @return The object that abandoned the conversation. */ + @Nullable public ConversationCanceller getCanceller() { return canceller; } @@ -35,6 +39,7 @@ public class ConversationAbandonedEvent extends EventObject { * * @return The abandoned conversation's conversation context. */ + @NotNull public ConversationContext getContext() { return context; } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java b/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java index dc046b1f76..48585ce53d 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + import java.util.EventListener; /** @@ -11,5 +13,5 @@ public interface ConversationAbandonedListener extends EventListener { * @param abandonedEvent Contains details about the abandoned * conversation. */ - public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent); + public void conversationAbandoned(@NotNull ConversationAbandonedEvent abandonedEvent); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ConversationCanceller.java b/paper-api/src/main/java/org/bukkit/conversations/ConversationCanceller.java index db43bb1657..bacac14094 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ConversationCanceller.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ConversationCanceller.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * A ConversationCanceller is a class that cancels an active {@link * Conversation}. A Conversation can have more than one ConversationCanceller. @@ -11,7 +13,7 @@ public interface ConversationCanceller extends Cloneable { * * @param conversation A conversation. */ - public void setConversation(Conversation conversation); + public void setConversation(@NotNull Conversation conversation); /** * Cancels a conversation based on user input. @@ -20,7 +22,7 @@ public interface ConversationCanceller extends Cloneable { * @param input The input text from the user. * @return True to cancel the conversation, False otherwise. */ - public boolean cancelBasedOnInput(ConversationContext context, String input); + public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input); /** * Allows the {@link ConversationFactory} to duplicate this @@ -30,5 +32,6 @@ public interface ConversationCanceller extends Cloneable { * * @return A clone. */ + @NotNull public ConversationCanceller clone(); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ConversationContext.java b/paper-api/src/main/java/org/bukkit/conversations/ConversationContext.java index e0781c285b..b192b03be4 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ConversationContext.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ConversationContext.java @@ -1,6 +1,8 @@ package org.bukkit.conversations; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -21,7 +23,7 @@ public class ConversationContext { * @param initialSessionData Any initial values to put in the sessionData * map. */ - public ConversationContext(Plugin plugin, Conversable forWhom, Map initialSessionData) { + public ConversationContext(@Nullable Plugin plugin, @NotNull Conversable forWhom, @NotNull Map initialSessionData) { this.plugin = plugin; this.forWhom = forWhom; this.sessionData = initialSessionData; @@ -32,6 +34,7 @@ public class ConversationContext { * * @return The owning plugin. */ + @Nullable public Plugin getPlugin() { return plugin; } @@ -41,6 +44,7 @@ public class ConversationContext { * * @return The subject of the conversation. */ + @NotNull public Conversable getForWhom() { return forWhom; } @@ -52,6 +56,7 @@ public class ConversationContext { * * @return The full sessionData map. */ + @NotNull public Map getAllSessionData() { return sessionData; } @@ -64,7 +69,8 @@ public class ConversationContext { * @param key The session data key. * @return The requested session data. */ - public Object getSessionData(Object key) { + @Nullable + public Object getSessionData(@NotNull Object key) { return sessionData.get(key); } @@ -76,7 +82,7 @@ public class ConversationContext { * @param key The session data key. * @param value The session data value. */ - public void setSessionData(Object key, Object value) { + public void setSessionData(@NotNull Object key, @Nullable Object value) { sessionData.put(key, value); } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ConversationFactory.java b/paper-api/src/main/java/org/bukkit/conversations/ConversationFactory.java index 8a3b39209f..efaaa7d94d 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ConversationFactory.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ConversationFactory.java @@ -2,6 +2,8 @@ package org.bukkit.conversations; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.HashMap; @@ -35,7 +37,7 @@ public class ConversationFactory { * * @param plugin The plugin that owns the factory. */ - public ConversationFactory(Plugin plugin) { + public ConversationFactory(@NotNull Plugin plugin) { this.plugin = plugin; isModal = true; localEchoEnabled = true; @@ -57,6 +59,7 @@ public class ConversationFactory { * @param modal The modality of all conversations to be created. * @return This object. */ + @NotNull public ConversationFactory withModality(boolean modal) { isModal = modal; return this; @@ -70,6 +73,7 @@ public class ConversationFactory { * @param localEchoEnabled The status of local echo. * @return This object. */ + @NotNull public ConversationFactory withLocalEcho(boolean localEchoEnabled) { this.localEchoEnabled = localEchoEnabled; return this; @@ -84,7 +88,8 @@ public class ConversationFactory { * @param prefix The ConversationPrefix to use. * @return This object. */ - public ConversationFactory withPrefix(ConversationPrefix prefix) { + @NotNull + public ConversationFactory withPrefix(@NotNull ConversationPrefix prefix) { this.prefix = prefix; return this; } @@ -98,6 +103,7 @@ public class ConversationFactory { * @param timeoutSeconds The number of seconds to wait. * @return This object. */ + @NotNull public ConversationFactory withTimeout(int timeoutSeconds) { return withConversationCanceller(new InactivityConversationCanceller(plugin, timeoutSeconds)); } @@ -110,7 +116,8 @@ public class ConversationFactory { * @param firstPrompt The first prompt. * @return This object. */ - public ConversationFactory withFirstPrompt(Prompt firstPrompt) { + @NotNull + public ConversationFactory withFirstPrompt(@Nullable Prompt firstPrompt) { this.firstPrompt = firstPrompt; return this; } @@ -123,7 +130,8 @@ public class ConversationFactory { * sessionData. * @return This object. */ - public ConversationFactory withInitialSessionData(Map initialSessionData) { + @NotNull + public ConversationFactory withInitialSessionData(@NotNull Map initialSessionData) { this.initialSessionData = initialSessionData; return this; } @@ -135,7 +143,8 @@ public class ConversationFactory { * @param escapeSequence Input to terminate the conversation. * @return This object. */ - public ConversationFactory withEscapeSequence(String escapeSequence) { + @NotNull + public ConversationFactory withEscapeSequence(@NotNull String escapeSequence) { return withConversationCanceller(new ExactMatchConversationCanceller(escapeSequence)); } @@ -145,7 +154,8 @@ public class ConversationFactory { * @param canceller The {@link ConversationCanceller} to add. * @return This object. */ - public ConversationFactory withConversationCanceller(ConversationCanceller canceller) { + @NotNull + public ConversationFactory withConversationCanceller(@NotNull ConversationCanceller canceller) { cancellers.add(canceller); return this; } @@ -158,7 +168,8 @@ public class ConversationFactory { * starting a conversation. * @return This object. */ - public ConversationFactory thatExcludesNonPlayersWithMessage(String playerOnlyMessage) { + @NotNull + public ConversationFactory thatExcludesNonPlayersWithMessage(@Nullable String playerOnlyMessage) { this.playerOnlyMessage = playerOnlyMessage; return this; } @@ -170,7 +181,8 @@ public class ConversationFactory { * @param listener The listener to add. * @return This object. */ - public ConversationFactory addConversationAbandonedListener(ConversationAbandonedListener listener) { + @NotNull + public ConversationFactory addConversationAbandonedListener(@NotNull ConversationAbandonedListener listener) { abandonedListeners.add(listener); return this; } @@ -182,7 +194,8 @@ public class ConversationFactory { * @param forWhom The entity for whom the new conversation is mediating. * @return A new conversation. */ - public Conversation buildConversation(Conversable forWhom) { + @NotNull + public Conversation buildConversation(@NotNull Conversable forWhom) { //Abort conversation construction if we aren't supposed to talk to non-players if (playerOnlyMessage != null && !(forWhom instanceof Player)) { return new Conversation(plugin, forWhom, new NotPlayerMessagePrompt()); @@ -213,12 +226,14 @@ public class ConversationFactory { private class NotPlayerMessagePrompt extends MessagePrompt { - public String getPromptText(ConversationContext context) { + @NotNull + public String getPromptText(@NotNull ConversationContext context) { return playerOnlyMessage; } + @Nullable @Override - protected Prompt getNextPrompt(ConversationContext context) { + protected Prompt getNextPrompt(@NotNull ConversationContext context) { return Prompt.END_OF_CONVERSATION; } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ConversationPrefix.java b/paper-api/src/main/java/org/bukkit/conversations/ConversationPrefix.java index 3febfa6a18..0c65f3365c 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ConversationPrefix.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ConversationPrefix.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * A ConversationPrefix implementation prepends all output from the * conversation to the player. The ConversationPrefix can be used to display @@ -13,5 +15,6 @@ public interface ConversationPrefix { * @param context Context information about the conversation. * @return The prefix text. */ - String getPrefix(ConversationContext context); + @NotNull + String getPrefix(@NotNull ConversationContext context); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java b/paper-api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java index 327b9d9993..9a30914b60 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * An ExactMatchConversationCanceller cancels a conversation if the user * enters an exact input string @@ -13,16 +15,17 @@ public class ExactMatchConversationCanceller implements ConversationCanceller { * @param escapeSequence The string that, if entered by the user, will * cancel the conversation. */ - public ExactMatchConversationCanceller(String escapeSequence) { + public ExactMatchConversationCanceller(@NotNull String escapeSequence) { this.escapeSequence = escapeSequence; } - public void setConversation(Conversation conversation) {} + public void setConversation(@NotNull Conversation conversation) {} - public boolean cancelBasedOnInput(ConversationContext context, String input) { + public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) { return input.equals(escapeSequence); } + @NotNull public ConversationCanceller clone() { return new ExactMatchConversationCanceller(escapeSequence); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java b/paper-api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java index b867c116cb..a1dd102856 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java @@ -1,6 +1,8 @@ package org.bukkit.conversations; import org.apache.commons.lang.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.List; @@ -21,7 +23,7 @@ public abstract class FixedSetPrompt extends ValidatingPrompt { * @param fixedSet A fixed set of strings, one of which the user must * type. */ - public FixedSetPrompt(String... fixedSet) { + public FixedSetPrompt(@NotNull String... fixedSet) { super(); this.fixedSet = Arrays.asList(fixedSet); } @@ -29,7 +31,7 @@ public abstract class FixedSetPrompt extends ValidatingPrompt { private FixedSetPrompt() {} @Override - protected boolean isInputValid(ConversationContext context, String input) { + protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { return fixedSet.contains(input); } @@ -40,6 +42,7 @@ public abstract class FixedSetPrompt extends ValidatingPrompt { * @return the options formatted like "[bar, cheese, panda]" if bar, * cheese, and panda were the options used */ + @NotNull protected String formatFixedSet() { return "[" + StringUtils.join(fixedSet, ", ") + "]"; } diff --git a/paper-api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java b/paper-api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java index 617e26d8e2..cfe2b69f68 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java +++ b/paper-api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java @@ -1,6 +1,7 @@ package org.bukkit.conversations; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * An InactivityConversationCanceller will cancel a {@link Conversation} after @@ -18,23 +19,24 @@ public class InactivityConversationCanceller implements ConversationCanceller { * @param plugin The owning plugin. * @param timeoutSeconds The number of seconds of inactivity to wait. */ - public InactivityConversationCanceller(Plugin plugin, int timeoutSeconds) { + public InactivityConversationCanceller(@NotNull Plugin plugin, int timeoutSeconds) { this.plugin = plugin; this.timeoutSeconds = timeoutSeconds; } - public void setConversation(Conversation conversation) { + public void setConversation(@NotNull Conversation conversation) { this.conversation = conversation; startTimer(); } - public boolean cancelBasedOnInput(ConversationContext context, String input) { + public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) { // Reset the inactivity timer stopTimer(); startTimer(); return false; } + @NotNull public ConversationCanceller clone() { return new InactivityConversationCanceller(plugin, timeoutSeconds); } @@ -72,7 +74,7 @@ public class InactivityConversationCanceller implements ConversationCanceller { * * @param conversation The conversation being abandoned. */ - protected void cancelling(Conversation conversation) { + protected void cancelling(@NotNull Conversation conversation) { } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java b/paper-api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java index 1272f22c93..2c351a0651 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java @@ -1,19 +1,22 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * The ManuallyAbandonedConversationCanceller is only used as part of a {@link * ConversationAbandonedEvent} to indicate that the conversation was manually * abandoned by programmatically calling the abandon() method on it. */ public class ManuallyAbandonedConversationCanceller implements ConversationCanceller { - public void setConversation(Conversation conversation) { + public void setConversation(@NotNull Conversation conversation) { throw new UnsupportedOperationException(); } - public boolean cancelBasedOnInput(ConversationContext context, String input) { + public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) { throw new UnsupportedOperationException(); } + @NotNull public ConversationCanceller clone() { throw new UnsupportedOperationException(); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/MessagePrompt.java b/paper-api/src/main/java/org/bukkit/conversations/MessagePrompt.java index 6d379bec10..69b19b9204 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/MessagePrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/MessagePrompt.java @@ -1,5 +1,8 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * MessagePrompt is the base class for any prompt that only displays a message * to the user and requires no input. @@ -16,7 +19,7 @@ public abstract class MessagePrompt implements Prompt { * @param context Context information about the conversation. * @return Always false. */ - public boolean blocksForInput(ConversationContext context) { + public boolean blocksForInput(@NotNull ConversationContext context) { return false; } @@ -28,7 +31,8 @@ public abstract class MessagePrompt implements Prompt { * @param input Ignored. * @return The next prompt in the prompt graph. */ - public Prompt acceptInput(ConversationContext context, String input) { + @Nullable + public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) { return getNextPrompt(context); } @@ -38,5 +42,6 @@ public abstract class MessagePrompt implements Prompt { * @param context Context information about the conversation. * @return The next prompt in the prompt graph. */ - protected abstract Prompt getNextPrompt(ConversationContext context); + @Nullable + protected abstract Prompt getNextPrompt(@NotNull ConversationContext context); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java b/paper-api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java index 57d777e78f..ce1b20cdea 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java +++ b/paper-api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * NullConversationPrefix is a {@link ConversationPrefix} implementation that * displays nothing in front of conversation output. @@ -12,7 +14,8 @@ public class NullConversationPrefix implements ConversationPrefix { * @param context Context information about the conversation. * @return An empty string. */ - public String getPrefix(ConversationContext context) { + @NotNull + public String getPrefix(@NotNull ConversationContext context) { return ""; } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/NumericPrompt.java b/paper-api/src/main/java/org/bukkit/conversations/NumericPrompt.java index 7154bda357..5da28a3b43 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/NumericPrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/NumericPrompt.java @@ -1,6 +1,8 @@ package org.bukkit.conversations; import org.apache.commons.lang.math.NumberUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * NumericPrompt is the base class for any prompt that requires a {@link @@ -12,7 +14,7 @@ public abstract class NumericPrompt extends ValidatingPrompt { } @Override - protected boolean isInputValid(ConversationContext context, String input) { + protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { return NumberUtils.isNumber(input) && isNumberValid(context, NumberUtils.createNumber(input)); } @@ -24,12 +26,13 @@ public abstract class NumericPrompt extends ValidatingPrompt { * @param input The number the player provided. * @return The validity of the player's input. */ - protected boolean isNumberValid(ConversationContext context, Number input) { + protected boolean isNumberValid(@NotNull ConversationContext context, @NotNull Number input) { return true; } + @Nullable @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { + protected Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) { try { return acceptValidatedInput(context, NumberUtils.createNumber(input)); } catch (NumberFormatException e) { @@ -45,10 +48,12 @@ public abstract class NumericPrompt extends ValidatingPrompt { * @param input The user's response as a {@link Number}. * @return The next {@link Prompt} in the prompt graph. */ - protected abstract Prompt acceptValidatedInput(ConversationContext context, Number input); + @Nullable + protected abstract Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull Number input); + @Nullable @Override - protected String getFailedValidationText(ConversationContext context, String invalidInput) { + protected String getFailedValidationText(@NotNull ConversationContext context, @NotNull String invalidInput) { if (NumberUtils.isNumber(invalidInput)) { return getFailedValidationText(context, NumberUtils.createNumber(invalidInput)); } else { @@ -64,7 +69,8 @@ public abstract class NumericPrompt extends ValidatingPrompt { * @param invalidInput The invalid input provided by the user. * @return A message explaining how to correct the input. */ - protected String getInputNotNumericText(ConversationContext context, String invalidInput) { + @Nullable + protected String getInputNotNumericText(@NotNull ConversationContext context, @NotNull String invalidInput) { return null; } @@ -76,7 +82,8 @@ public abstract class NumericPrompt extends ValidatingPrompt { * @param invalidInput The invalid input provided by the user. * @return A message explaining how to correct the input. */ - protected String getFailedValidationText(ConversationContext context, Number invalidInput) { + @Nullable + protected String getFailedValidationText(@NotNull ConversationContext context, @NotNull Number invalidInput) { return null; } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/PlayerNamePrompt.java b/paper-api/src/main/java/org/bukkit/conversations/PlayerNamePrompt.java index dcf8090d70..86d51c488e 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/PlayerNamePrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/PlayerNamePrompt.java @@ -2,6 +2,8 @@ package org.bukkit.conversations; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * PlayerNamePrompt is the base class for any prompt that requires the player @@ -10,18 +12,19 @@ import org.bukkit.plugin.Plugin; public abstract class PlayerNamePrompt extends ValidatingPrompt { private Plugin plugin; - public PlayerNamePrompt(Plugin plugin) { + public PlayerNamePrompt(@NotNull Plugin plugin) { super(); this.plugin = plugin; } @Override - protected boolean isInputValid(ConversationContext context, String input) { + protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { return plugin.getServer().getPlayer(input) != null; } + @Nullable @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { + protected Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) { return acceptValidatedInput(context, plugin.getServer().getPlayer(input)); } @@ -33,5 +36,6 @@ public abstract class PlayerNamePrompt extends ValidatingPrompt { * @param input The user's player name response. * @return The next {@link Prompt} in the prompt graph. */ - protected abstract Prompt acceptValidatedInput(ConversationContext context, Player input); + @Nullable + protected abstract Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull Player input); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java b/paper-api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java index dcb7e24a52..ed1f3b6860 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java +++ b/paper-api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java @@ -2,6 +2,7 @@ package org.bukkit.conversations; import org.bukkit.ChatColor; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * PluginNameConversationPrefix is a {@link ConversationPrefix} implementation @@ -15,11 +16,11 @@ public class PluginNameConversationPrefix implements ConversationPrefix { private String cachedPrefix; - public PluginNameConversationPrefix(Plugin plugin) { + public PluginNameConversationPrefix(@NotNull Plugin plugin) { this(plugin, " > ", ChatColor.LIGHT_PURPLE); } - public PluginNameConversationPrefix(Plugin plugin, String separator, ChatColor prefixColor) { + public PluginNameConversationPrefix(@NotNull Plugin plugin, @NotNull String separator, @NotNull ChatColor prefixColor) { this.separator = separator; this.prefixColor = prefixColor; this.plugin = plugin; @@ -33,7 +34,8 @@ public class PluginNameConversationPrefix implements ConversationPrefix { * @param context Context information about the conversation. * @return An empty string. */ - public String getPrefix(ConversationContext context) { + @NotNull + public String getPrefix(@NotNull ConversationContext context) { return cachedPrefix; } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/Prompt.java b/paper-api/src/main/java/org/bukkit/conversations/Prompt.java index 7519c84370..fcca208c0f 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/Prompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/Prompt.java @@ -1,5 +1,8 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * A Prompt is the main constituent of a {@link Conversation}. Each prompt * displays text to the user and optionally waits for a user's response. @@ -21,7 +24,8 @@ public interface Prompt extends Cloneable { * @param context Context information about the conversation. * @return The text to display. */ - String getPromptText(ConversationContext context); + @NotNull + String getPromptText(@NotNull ConversationContext context); /** * Checks to see if this prompt implementation should wait for user input @@ -29,9 +33,9 @@ public interface Prompt extends Cloneable { * * @param context Context information about the conversation. * @return If true, the {@link Conversation} will wait for input before - * continuing. + * continuing. If false, {@link #acceptInput(ConversationContext, String)} will be called immediately with {@code null} input. */ - boolean blocksForInput(ConversationContext context); + boolean blocksForInput(@NotNull ConversationContext context); /** * Accepts and processes input from the user. Using the input, the next @@ -41,5 +45,6 @@ public interface Prompt extends Cloneable { * @param input The input text from the user. * @return The next Prompt in the prompt graph. */ - Prompt acceptInput(ConversationContext context, String input); + @Nullable + Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input); } diff --git a/paper-api/src/main/java/org/bukkit/conversations/RegexPrompt.java b/paper-api/src/main/java/org/bukkit/conversations/RegexPrompt.java index a3c7d1f1a5..a081c19aef 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/RegexPrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/RegexPrompt.java @@ -1,5 +1,8 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.regex.Pattern; /** @@ -10,11 +13,11 @@ public abstract class RegexPrompt extends ValidatingPrompt { private Pattern pattern; - public RegexPrompt(String regex) { + public RegexPrompt(@NotNull String regex) { this(Pattern.compile(regex)); } - public RegexPrompt(Pattern pattern) { + public RegexPrompt(@NotNull Pattern pattern) { super(); this.pattern = pattern; } @@ -22,7 +25,7 @@ public abstract class RegexPrompt extends ValidatingPrompt { private RegexPrompt() {} @Override - protected boolean isInputValid(ConversationContext context, String input) { + protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { return pattern.matcher(input).matches(); } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/StringPrompt.java b/paper-api/src/main/java/org/bukkit/conversations/StringPrompt.java index 3e3e5e9e41..89efb9131d 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/StringPrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/StringPrompt.java @@ -1,5 +1,7 @@ package org.bukkit.conversations; +import org.jetbrains.annotations.NotNull; + /** * StringPrompt is the base class for any prompt that accepts an arbitrary * string from the user. @@ -12,7 +14,7 @@ public abstract class StringPrompt implements Prompt { * @param context Context information about the conversation. * @return True. */ - public boolean blocksForInput(ConversationContext context) { + public boolean blocksForInput(@NotNull ConversationContext context) { return true; } } diff --git a/paper-api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java b/paper-api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java index f41adb4acf..3ecfa59a45 100644 --- a/paper-api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java +++ b/paper-api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java @@ -1,6 +1,8 @@ package org.bukkit.conversations; import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * ValidatingPrompt is the base class for any prompt that requires validation. @@ -21,7 +23,8 @@ public abstract class ValidatingPrompt implements Prompt { * @param input The input text from the user. * @return This prompt or the next Prompt in the prompt graph. */ - public Prompt acceptInput(ConversationContext context, String input) { + @Nullable + public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) { if (isInputValid(context, input)) { return acceptValidatedInput(context, input); } else { @@ -40,7 +43,7 @@ public abstract class ValidatingPrompt implements Prompt { * @param context Context information about the conversation. * @return True. */ - public boolean blocksForInput(ConversationContext context) { + public boolean blocksForInput(@NotNull ConversationContext context) { return true; } @@ -51,7 +54,7 @@ public abstract class ValidatingPrompt implements Prompt { * @param input The player's raw console input. * @return True or false depending on the validity of the input. */ - protected abstract boolean isInputValid(ConversationContext context, String input); + protected abstract boolean isInputValid(@NotNull ConversationContext context, @NotNull String input); /** * Override this method to accept and processes the validated input from @@ -62,7 +65,8 @@ public abstract class ValidatingPrompt implements Prompt { * @param input The validated input text from the user. * @return The next Prompt in the prompt graph. */ - protected abstract Prompt acceptValidatedInput(ConversationContext context, String input); + @Nullable + protected abstract Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input); /** * Optionally override this method to display an additional message if the @@ -72,7 +76,8 @@ public abstract class ValidatingPrompt implements Prompt { * @param invalidInput The invalid input provided by the user. * @return A message explaining how to correct the input. */ - protected String getFailedValidationText(ConversationContext context, String invalidInput) { + @Nullable + protected String getFailedValidationText(@NotNull ConversationContext context, @NotNull String invalidInput) { return null; } } diff --git a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java index f546b8c0e5..705b948e17 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -6,6 +6,9 @@ import java.util.Map; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The various type of enchantments that may be added to armour or weapons @@ -188,10 +191,11 @@ public abstract class Enchantment implements Keyed { private static boolean acceptingNew = true; private final NamespacedKey key; - public Enchantment(NamespacedKey key) { + public Enchantment(@NotNull NamespacedKey key) { this.key = key; } + @NotNull @Override public NamespacedKey getKey() { return key; @@ -203,6 +207,7 @@ public abstract class Enchantment implements Keyed { * @return Unique name * @deprecated enchantments are badly named, use {@link #getKey()}. */ + @NotNull @Deprecated public abstract String getName(); @@ -225,6 +230,7 @@ public abstract class Enchantment implements Keyed { * * @return Target type of the Enchantment */ + @NotNull public abstract EnchantmentTarget getItemTarget(); /** @@ -256,7 +262,7 @@ public abstract class Enchantment implements Keyed { * @param other The enchantment to check against * @return True if there is a conflict. */ - public abstract boolean conflictsWith(Enchantment other); + public abstract boolean conflictsWith(@NotNull Enchantment other); /** * Checks if this Enchantment may be applied to the given {@link @@ -268,7 +274,7 @@ public abstract class Enchantment implements Keyed { * @param item Item to test * @return True if the enchantment may be applied, otherwise False */ - public abstract boolean canEnchantItem(ItemStack item); + public abstract boolean canEnchantItem(@NotNull ItemStack item); @Override public boolean equals(Object obj) { @@ -302,7 +308,7 @@ public abstract class Enchantment implements Keyed { * * @param enchantment Enchantment to register */ - public static void registerEnchantment(Enchantment enchantment) { + public static void registerEnchantment(@NotNull Enchantment enchantment) { if (byKey.containsKey(enchantment.key) || byName.containsKey(enchantment.getName())) { throw new IllegalArgumentException("Cannot set already-set enchantment"); } else if (!isAcceptingRegistrations()) { @@ -335,7 +341,9 @@ public abstract class Enchantment implements Keyed { * @param key key to fetch * @return Resulting Enchantment, or null if not found */ - public static Enchantment getByKey(NamespacedKey key) { + @Contract("null -> null") + @Nullable + public static Enchantment getByKey(@Nullable NamespacedKey key) { return byKey.get(key); } @@ -347,7 +355,9 @@ public abstract class Enchantment implements Keyed { * @deprecated enchantments are badly named, use {@link #getByKey(org.bukkit.NamespacedKey)}. */ @Deprecated - public static Enchantment getByName(String name) { + @Contract("null -> null") + @Nullable + public static Enchantment getByName(@Nullable String name) { return byName.get(name); } @@ -356,6 +366,7 @@ public abstract class Enchantment implements Keyed { * * @return Array of enchantments */ + @NotNull public static Enchantment[] values() { return byName.values().toArray(new Enchantment[byName.size()]); } diff --git a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java index 92e4f04f7f..a830610dc1 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java @@ -1,6 +1,7 @@ package org.bukkit.enchantments; import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; /** * A class for the available enchantment offers in the enchantment table. @@ -11,7 +12,7 @@ public class EnchantmentOffer { private int enchantmentLevel; private int cost; - public EnchantmentOffer(Enchantment enchantment, int enchantmentLevel, int cost) { + public EnchantmentOffer(@NotNull Enchantment enchantment, int enchantmentLevel, int cost) { this.enchantment = enchantment; this.enchantmentLevel = enchantmentLevel; this.cost = cost; @@ -22,6 +23,7 @@ public class EnchantmentOffer { * * @return type of enchantment */ + @NotNull public Enchantment getEnchantment() { return enchantment; } @@ -31,7 +33,7 @@ public class EnchantmentOffer { * * @param enchantment type of the enchantment */ - public void setEnchantment(Enchantment enchantment) { + public void setEnchantment(@NotNull Enchantment enchantment) { Validate.notNull(enchantment, "The enchantment may not be null!"); this.enchantment = enchantment; diff --git a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java index 3e326adb12..9f30c869e9 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java @@ -2,6 +2,7 @@ package org.bukkit.enchantments; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Represents the applicable target for a {@link Enchantment} @@ -12,7 +13,7 @@ public enum EnchantmentTarget { */ ALL { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return true; } }, @@ -22,7 +23,7 @@ public enum EnchantmentTarget { */ ARMOR { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return ARMOR_FEET.includes(item) || ARMOR_LEGS.includes(item) || ARMOR_HEAD.includes(item) @@ -35,7 +36,7 @@ public enum EnchantmentTarget { */ ARMOR_FEET { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.LEATHER_BOOTS) || item.equals(Material.CHAINMAIL_BOOTS) || item.equals(Material.IRON_BOOTS) @@ -49,7 +50,7 @@ public enum EnchantmentTarget { */ ARMOR_LEGS { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.LEATHER_LEGGINGS) || item.equals(Material.CHAINMAIL_LEGGINGS) || item.equals(Material.IRON_LEGGINGS) @@ -63,7 +64,7 @@ public enum EnchantmentTarget { */ ARMOR_TORSO { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.LEATHER_CHESTPLATE) || item.equals(Material.CHAINMAIL_CHESTPLATE) || item.equals(Material.IRON_CHESTPLATE) @@ -77,7 +78,7 @@ public enum EnchantmentTarget { */ ARMOR_HEAD { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.LEATHER_HELMET) || item.equals(Material.CHAINMAIL_HELMET) || item.equals(Material.DIAMOND_HELMET) @@ -91,7 +92,7 @@ public enum EnchantmentTarget { */ WEAPON { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.WOODEN_SWORD) || item.equals(Material.STONE_SWORD) || item.equals(Material.IRON_SWORD) @@ -106,7 +107,7 @@ public enum EnchantmentTarget { */ TOOL { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.WOODEN_SHOVEL) || item.equals(Material.STONE_SHOVEL) || item.equals(Material.IRON_SHOVEL) @@ -137,7 +138,7 @@ public enum EnchantmentTarget { */ BOW { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.BOW); } }, @@ -147,7 +148,7 @@ public enum EnchantmentTarget { */ FISHING_ROD { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.FISHING_ROD); } }, @@ -157,7 +158,7 @@ public enum EnchantmentTarget { */ BREAKABLE { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.getMaxDurability() > 0 && item.getMaxStackSize() == 1; } }, @@ -167,7 +168,7 @@ public enum EnchantmentTarget { */ WEARABLE { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return ARMOR.includes(item) || item.equals(Material.ELYTRA) || item.equals(Material.PUMPKIN) @@ -187,7 +188,7 @@ public enum EnchantmentTarget { */ TRIDENT { @Override - public boolean includes(Material item) { + public boolean includes(@NotNull Material item) { return item.equals(Material.TRIDENT); } }; @@ -198,7 +199,7 @@ public enum EnchantmentTarget { * @param item The item to check * @return True if the target includes the item */ - public abstract boolean includes(Material item); + public abstract boolean includes(@NotNull Material item); /** * Check whether this target includes the specified item. @@ -206,7 +207,7 @@ public enum EnchantmentTarget { * @param item The item to check * @return True if the target includes the item */ - public boolean includes(ItemStack item) { + public boolean includes(@NotNull ItemStack item) { return includes(item.getType()); } } diff --git a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java index 8fc8dfd608..9566e4306a 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java @@ -2,12 +2,13 @@ package org.bukkit.enchantments; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * A simple wrapper for ease of selecting {@link Enchantment}s */ public class EnchantmentWrapper extends Enchantment { - public EnchantmentWrapper(String name) { + public EnchantmentWrapper(@NotNull String name) { super(NamespacedKey.minecraft(name)); } @@ -16,6 +17,7 @@ public class EnchantmentWrapper extends Enchantment { * * @return Enchantment */ + @NotNull public Enchantment getEnchantment() { return Enchantment.getByKey(getKey()); } @@ -30,16 +32,18 @@ public class EnchantmentWrapper extends Enchantment { return getEnchantment().getStartLevel(); } + @NotNull @Override public EnchantmentTarget getItemTarget() { return getEnchantment().getItemTarget(); } @Override - public boolean canEnchantItem(ItemStack item) { + public boolean canEnchantItem(@NotNull ItemStack item) { return getEnchantment().canEnchantItem(item); } + @NotNull @Override public String getName() { return getEnchantment().getName(); @@ -56,7 +60,7 @@ public class EnchantmentWrapper extends Enchantment { } @Override - public boolean conflictsWith(Enchantment other) { + public boolean conflictsWith(@NotNull Enchantment other) { return getEnchantment().conflictsWith(other); } } diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractHorse.java b/paper-api/src/main/java/org/bukkit/entity/AbstractHorse.java index 1075745469..2f1956724c 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AbstractHorse.java +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractHorse.java @@ -2,6 +2,8 @@ package org.bukkit.entity; import org.bukkit.inventory.AbstractHorseInventory; import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; /** * Represents a Horse-like creature. @@ -19,6 +21,7 @@ public interface AbstractHorse extends Animals, Vehicle, InventoryHolder, Tameab * @deprecated different variants are different classes */ @Deprecated + @NotNull public Horse.Variant getVariant(); /** @@ -26,6 +29,7 @@ public interface AbstractHorse extends Animals, Vehicle, InventoryHolder, Tameab * @deprecated you are required to spawn a different entity */ @Deprecated + @Contract("_ -> fail") public void setVariant(Horse.Variant variant); /** @@ -98,6 +102,7 @@ public interface AbstractHorse extends Animals, Vehicle, InventoryHolder, Tameab */ public void setJumpStrength(double strength); + @NotNull @Override public AbstractHorseInventory getInventory(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java b/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java index 5f74f0d85b..9f1eed9ba5 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java +++ b/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java @@ -1,5 +1,8 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.UUID; public interface AnimalTamer { @@ -9,6 +12,7 @@ public interface AnimalTamer { * * @return The name to reference on tamed animals or null if a name cannot be obtained */ + @Nullable public String getName(); /** @@ -16,5 +20,6 @@ public interface AnimalTamer { * * @return The UUID to reference on tamed animals */ + @NotNull public UUID getUniqueId(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Animals.java b/paper-api/src/main/java/org/bukkit/entity/Animals.java index 12a2ab9022..3d4f8c3d46 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Animals.java +++ b/paper-api/src/main/java/org/bukkit/entity/Animals.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Nullable; + import java.util.UUID; /** @@ -13,6 +15,7 @@ public interface Animals extends Ageable { * * @return uuid if set, or null */ + @Nullable UUID getBreedCause(); /** @@ -21,7 +24,7 @@ public interface Animals extends Ageable { * * @param uuid new uuid, or null */ - void setBreedCause(UUID uuid); + void setBreedCause(@Nullable UUID uuid); /** * Get whether or not this entity is in love mode and will produce diff --git a/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java b/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java index 9a569d3a3a..d258e734ec 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java +++ b/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java @@ -7,6 +7,8 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an area effect cloud which will imbue a potion effect onto @@ -123,6 +125,7 @@ public interface AreaEffectCloud extends Entity { * * @return particle the set particle type */ + @NotNull Particle getParticle(); /** @@ -130,7 +133,7 @@ public interface AreaEffectCloud extends Entity { * * @param particle the new particle type */ - void setParticle(Particle particle); + void setParticle(@NotNull Particle particle); /** * Sets the particle which this cloud will be composed of @@ -139,20 +142,21 @@ public interface AreaEffectCloud extends Entity { * @param data the data to use for the particle or null, * the type of this depends on {@link Particle#getDataType()} */ - void setParticle(Particle particle, T data); + void setParticle(@NotNull Particle particle, @Nullable T data); /** * Sets the underlying potion data * * @param data PotionData to set the base potion state to */ - void setBasePotionData(PotionData data); + void setBasePotionData(@NotNull PotionData data); /** * Returns the potion data about the base potion * * @return a PotionData object */ + @NotNull PotionData getBasePotionData(); /** @@ -171,6 +175,7 @@ public interface AreaEffectCloud extends Entity { * * @return the immutable list of custom potion effects */ + @NotNull List getCustomEffects(); /** @@ -181,7 +186,7 @@ public interface AreaEffectCloud extends Entity { * overwritten * @return true if the effect was added as a result of this call */ - boolean addCustomEffect(PotionEffect effect, boolean overwrite); + boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite); /** * Removes a custom potion effect from this cloud. @@ -189,7 +194,7 @@ public interface AreaEffectCloud extends Entity { * @param type the potion effect type to remove * @return true if the an effect was removed as a result of this call */ - boolean removeCustomEffect(PotionEffectType type); + boolean removeCustomEffect(@NotNull PotionEffectType type); /** * Checks for a specific custom potion effect type on this cloud. @@ -197,7 +202,7 @@ public interface AreaEffectCloud extends Entity { * @param type the potion effect type to check for * @return true if the potion has this effect */ - boolean hasCustomEffect(PotionEffectType type); + boolean hasCustomEffect(@Nullable PotionEffectType type); /** * Removes all custom potion effects from this cloud. @@ -209,6 +214,7 @@ public interface AreaEffectCloud extends Entity { * * @return cloud color */ + @NotNull Color getColor(); /** @@ -216,13 +222,14 @@ public interface AreaEffectCloud extends Entity { * * @param color cloud color */ - void setColor(Color color); + void setColor(@NotNull Color color); /** * Retrieve the original source of this cloud. * * @return the {@link ProjectileSource} that threw the LingeringPotion */ + @Nullable public ProjectileSource getSource(); /** @@ -230,5 +237,5 @@ public interface AreaEffectCloud extends Entity { * * @param source the {@link ProjectileSource} that threw the LingeringPotion */ - public void setSource(ProjectileSource source); + public void setSource(@Nullable ProjectileSource source); } diff --git a/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java b/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java index b4f045178a..d04e52fbe3 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java +++ b/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java @@ -2,6 +2,8 @@ package org.bukkit.entity; import org.bukkit.inventory.ItemStack; import org.bukkit.util.EulerAngle; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface ArmorStand extends LivingEntity { @@ -11,6 +13,7 @@ public interface ArmorStand extends LivingEntity { * * @return the held item */ + @NotNull ItemStack getItemInHand(); /** @@ -19,7 +22,7 @@ public interface ArmorStand extends LivingEntity { * * @param item the item to hold */ - void setItemInHand(ItemStack item); + void setItemInHand(@Nullable ItemStack item); /** * Returns the item currently being worn @@ -27,6 +30,7 @@ public interface ArmorStand extends LivingEntity { * * @return the worn item */ + @NotNull ItemStack getBoots(); /** @@ -35,7 +39,7 @@ public interface ArmorStand extends LivingEntity { * * @param item the item to wear */ - void setBoots(ItemStack item); + void setBoots(@Nullable ItemStack item); /** * Returns the item currently being worn @@ -43,6 +47,7 @@ public interface ArmorStand extends LivingEntity { * * @return the worn item */ + @NotNull ItemStack getLeggings(); /** @@ -51,7 +56,7 @@ public interface ArmorStand extends LivingEntity { * * @param item the item to wear */ - void setLeggings(ItemStack item); + void setLeggings(@Nullable ItemStack item); /** * Returns the item currently being worn @@ -59,6 +64,7 @@ public interface ArmorStand extends LivingEntity { * * @return the worn item */ + @NotNull ItemStack getChestplate(); /** @@ -67,7 +73,7 @@ public interface ArmorStand extends LivingEntity { * * @param item the item to wear */ - void setChestplate(ItemStack item); + void setChestplate(@Nullable ItemStack item); /** * Returns the item currently being worn @@ -75,6 +81,7 @@ public interface ArmorStand extends LivingEntity { * * @return the worn item */ + @NotNull ItemStack getHelmet(); /** @@ -83,7 +90,7 @@ public interface ArmorStand extends LivingEntity { * * @param item the item to wear */ - void setHelmet(ItemStack item); + void setHelmet(@Nullable ItemStack item); /** * Returns the armor stand's body's @@ -91,6 +98,7 @@ public interface ArmorStand extends LivingEntity { * * @return the current pose */ + @NotNull EulerAngle getBodyPose(); /** @@ -99,7 +107,7 @@ public interface ArmorStand extends LivingEntity { * * @param pose the current pose */ - void setBodyPose(EulerAngle pose); + void setBodyPose(@NotNull EulerAngle pose); /** * Returns the armor stand's left arm's @@ -107,6 +115,7 @@ public interface ArmorStand extends LivingEntity { * * @return the current pose */ + @NotNull EulerAngle getLeftArmPose(); /** @@ -115,7 +124,7 @@ public interface ArmorStand extends LivingEntity { * * @param pose the current pose */ - void setLeftArmPose(EulerAngle pose); + void setLeftArmPose(@NotNull EulerAngle pose); /** * Returns the armor stand's right arm's @@ -123,6 +132,7 @@ public interface ArmorStand extends LivingEntity { * * @return the current pose */ + @NotNull EulerAngle getRightArmPose(); /** @@ -131,7 +141,7 @@ public interface ArmorStand extends LivingEntity { * * @param pose the current pose */ - void setRightArmPose(EulerAngle pose); + void setRightArmPose(@NotNull EulerAngle pose); /** * Returns the armor stand's left leg's @@ -139,6 +149,7 @@ public interface ArmorStand extends LivingEntity { * * @return the current pose */ + @NotNull EulerAngle getLeftLegPose(); /** @@ -147,7 +158,7 @@ public interface ArmorStand extends LivingEntity { * * @param pose the current pose */ - void setLeftLegPose(EulerAngle pose); + void setLeftLegPose(@NotNull EulerAngle pose); /** * Returns the armor stand's right leg's @@ -155,6 +166,7 @@ public interface ArmorStand extends LivingEntity { * * @return the current pose */ + @NotNull EulerAngle getRightLegPose(); /** @@ -163,7 +175,7 @@ public interface ArmorStand extends LivingEntity { * * @param pose the current pose */ - void setRightLegPose(EulerAngle pose); + void setRightLegPose(@NotNull EulerAngle pose); /** * Returns the armor stand's head's @@ -171,6 +183,7 @@ public interface ArmorStand extends LivingEntity { * * @return the current pose */ + @NotNull EulerAngle getHeadPose(); /** @@ -179,7 +192,7 @@ public interface ArmorStand extends LivingEntity { * * @param pose the current pose */ - void setHeadPose(EulerAngle pose); + void setHeadPose(@NotNull EulerAngle pose); /** * Returns whether the armor stand has diff --git a/paper-api/src/main/java/org/bukkit/entity/Arrow.java b/paper-api/src/main/java/org/bukkit/entity/Arrow.java index bf0d362d5e..ef6e348b5f 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Arrow.java +++ b/paper-api/src/main/java/org/bukkit/entity/Arrow.java @@ -1,6 +1,8 @@ package org.bukkit.entity; import org.bukkit.block.Block; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an arrow. @@ -74,6 +76,7 @@ public interface Arrow extends Projectile { * * @return the attached block or null if not attached */ + @Nullable public Block getAttachedBlock(); /** @@ -81,6 +84,7 @@ public interface Arrow extends Projectile { * * @return the pickup status of this arrow. */ + @NotNull public PickupStatus getPickupStatus(); /** @@ -88,7 +92,7 @@ public interface Arrow extends Projectile { * * @param status new pickup status of this arrow. */ - public void setPickupStatus(PickupStatus status); + public void setPickupStatus(@NotNull PickupStatus status); /** * Represents the pickup status of this arrow. diff --git a/paper-api/src/main/java/org/bukkit/entity/Boat.java b/paper-api/src/main/java/org/bukkit/entity/Boat.java index db02115e9a..00001621b4 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Boat.java +++ b/paper-api/src/main/java/org/bukkit/entity/Boat.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.TreeSpecies; +import org.jetbrains.annotations.NotNull; /** * Represents a boat entity. @@ -12,6 +13,7 @@ public interface Boat extends Vehicle { * * @return the wood type */ + @NotNull TreeSpecies getWoodType(); /** @@ -19,7 +21,7 @@ public interface Boat extends Vehicle { * * @param species the new wood type */ - void setWoodType(TreeSpecies species); + void setWoodType(@NotNull TreeSpecies species); /** * Gets the maximum speed of a boat. The speed is unrelated to the diff --git a/paper-api/src/main/java/org/bukkit/entity/Boss.java b/paper-api/src/main/java/org/bukkit/entity/Boss.java index 78105359cb..ba459279c6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Boss.java +++ b/paper-api/src/main/java/org/bukkit/entity/Boss.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.boss.BossBar; +import org.jetbrains.annotations.Nullable; /** * Represents the Boss Entity. @@ -12,5 +13,6 @@ public interface Boss extends Entity { * * @return the {@link BossBar} of the entity */ + @Nullable BossBar getBossBar(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/ComplexEntityPart.java b/paper-api/src/main/java/org/bukkit/entity/ComplexEntityPart.java index f4ab0bbd32..937f53499a 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ComplexEntityPart.java +++ b/paper-api/src/main/java/org/bukkit/entity/ComplexEntityPart.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + /** * Represents a single part of a {@link ComplexLivingEntity} */ @@ -10,5 +12,6 @@ public interface ComplexEntityPart extends Entity { * * @return Parent complex entity */ + @NotNull public ComplexLivingEntity getParent(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java index f74411c365..038bcb6dc7 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + import java.util.Set; /** @@ -12,5 +14,6 @@ public interface ComplexLivingEntity extends LivingEntity { * * @return List of parts */ + @NotNull public Set getParts(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Damageable.java b/paper-api/src/main/java/org/bukkit/entity/Damageable.java index e173cf0114..b0fe044234 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Damageable.java +++ b/paper-api/src/main/java/org/bukkit/entity/Damageable.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.attribute.Attribute; +import org.jetbrains.annotations.Nullable; /** * Represents an {@link Entity} that has health and can take damage. @@ -20,7 +21,7 @@ public interface Damageable extends Entity { * @param amount Amount of damage to deal * @param source Entity which to attribute this damage from */ - void damage(double amount, Entity source); + void damage(double amount, @Nullable Entity source); /** * Gets the entity's health from 0 to {@link #getMaxHealth()}, where 0 is dead. diff --git a/paper-api/src/main/java/org/bukkit/entity/EnderCrystal.java b/paper-api/src/main/java/org/bukkit/entity/EnderCrystal.java index 684dd764f9..febc7b3f4c 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EnderCrystal.java +++ b/paper-api/src/main/java/org/bukkit/entity/EnderCrystal.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.Location; +import org.jetbrains.annotations.Nullable; /** * A crystal that heals nearby EnderDragons @@ -28,6 +29,7 @@ public interface EnderCrystal extends Entity { * * @return the location that the beam is pointed to, or null if the beam is not shown */ + @Nullable Location getBeamTarget(); /** @@ -37,5 +39,5 @@ public interface EnderCrystal extends Entity { * @param location the location to point the beam to * @throws IllegalArgumentException for differing worlds */ - void setBeamTarget(Location location); + void setBeamTarget(@Nullable Location location); } diff --git a/paper-api/src/main/java/org/bukkit/entity/EnderDragon.java b/paper-api/src/main/java/org/bukkit/entity/EnderDragon.java index 7170d37aad..fa13b38d36 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EnderDragon.java +++ b/paper-api/src/main/java/org/bukkit/entity/EnderDragon.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + /** * Represents an Ender Dragon */ @@ -67,6 +69,7 @@ public interface EnderDragon extends ComplexLivingEntity, Boss { * * @return the current phase */ + @NotNull Phase getPhase(); /** @@ -74,5 +77,5 @@ public interface EnderDragon extends ComplexLivingEntity, Boss { * * @param phase the next phase */ - void setPhase(Phase phase); + void setPhase(@NotNull Phase phase); } diff --git a/paper-api/src/main/java/org/bukkit/entity/EnderDragonPart.java b/paper-api/src/main/java/org/bukkit/entity/EnderDragonPart.java index 9516f566f2..77fc93378e 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EnderDragonPart.java +++ b/paper-api/src/main/java/org/bukkit/entity/EnderDragonPart.java @@ -1,8 +1,11 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + /** * Represents an ender dragon part */ public interface EnderDragonPart extends ComplexEntityPart, Damageable { + @NotNull public EnderDragon getParent(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/EnderSignal.java b/paper-api/src/main/java/org/bukkit/entity/EnderSignal.java index 8e2723f8c5..e90bca8227 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EnderSignal.java +++ b/paper-api/src/main/java/org/bukkit/entity/EnderSignal.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; /** * Represents an EnderSignal, which is created upon throwing an ender eye. @@ -12,6 +13,7 @@ public interface EnderSignal extends Entity { * * @return the {@link Location} this EnderSignal is moving towards. */ + @NotNull public Location getTargetLocation(); /** @@ -22,7 +24,7 @@ public interface EnderSignal extends Entity { * * @param location the new target location */ - public void setTargetLocation(Location location); + public void setTargetLocation(@NotNull Location location); /** * Gets if the EnderSignal should drop an item on death.
diff --git a/paper-api/src/main/java/org/bukkit/entity/Enderman.java b/paper-api/src/main/java/org/bukkit/entity/Enderman.java index edb49a20c5..bb325d9c80 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Enderman.java +++ b/paper-api/src/main/java/org/bukkit/entity/Enderman.java @@ -2,6 +2,8 @@ package org.bukkit.entity; import org.bukkit.block.data.BlockData; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an Enderman. @@ -13,6 +15,7 @@ public interface Enderman extends Monster { * * @return MaterialData containing the id and data of the block */ + @NotNull public MaterialData getCarriedMaterial(); /** @@ -20,13 +23,14 @@ public interface Enderman extends Monster { * * @param material data to set the carried block to */ - public void setCarriedMaterial(MaterialData material); + public void setCarriedMaterial(@NotNull MaterialData material); /** * Gets the data of the block that the Enderman is carrying. * * @return BlockData containing the carried block, or null if none */ + @Nullable public BlockData getCarriedBlock(); /** @@ -34,5 +38,5 @@ public interface Enderman extends Monster { * * @param blockData data to set the carried block to, or null to remove */ - public void setCarriedBlock(BlockData blockData); + public void setCarriedBlock(@Nullable BlockData blockData); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 1a7ec6da88..6d32ef7150 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -1,7 +1,7 @@ package org.bukkit.entity; -import org.bukkit.Location; import org.bukkit.EntityEffect; +import org.bukkit.Location; import org.bukkit.Nameable; import org.bukkit.Server; import org.bukkit.World; @@ -18,6 +18,9 @@ import java.util.UUID; import org.bukkit.block.PistonMoveReaction; import org.bukkit.command.CommandSender; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a base entity in the world @@ -29,6 +32,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return a new copy of Location containing the position of this entity */ + @NotNull public Location getLocation(); /** @@ -40,20 +44,23 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param loc the location to copy into * @return The Location object provided or null */ - public Location getLocation(Location loc); + @Contract("null -> null; !null -> !null") + @Nullable + public Location getLocation(@Nullable Location loc); /** * Sets this entity's velocity * * @param velocity New velocity to travel with */ - public void setVelocity(Vector velocity); + public void setVelocity(@NotNull Vector velocity); /** * Gets this entity's current velocity * * @return Current traveling velocity of this entity */ + @NotNull public Vector getVelocity(); /** @@ -78,6 +85,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return the entity's current bounding box */ + @NotNull public BoundingBox getBoundingBox(); /** @@ -94,6 +102,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return World */ + @NotNull public World getWorld(); /** @@ -103,7 +112,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param location New location to teleport this entity to * @return true if the teleport was successful */ - public boolean teleport(Location location); + public boolean teleport(@NotNull Location location); /** * Teleports this entity to the given location. If this entity is riding a @@ -113,7 +122,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param cause The cause of this teleportation * @return true if the teleport was successful */ - public boolean teleport(Location location, TeleportCause cause); + public boolean teleport(@NotNull Location location, @NotNull TeleportCause cause); /** * Teleports this entity to the target Entity. If this entity is riding a @@ -122,7 +131,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param destination Entity to teleport this entity to * @return true if the teleport was successful */ - public boolean teleport(Entity destination); + public boolean teleport(@NotNull Entity destination); /** * Teleports this entity to the target Entity. If this entity is riding a @@ -132,7 +141,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param cause The cause of this teleportation * @return true if the teleport was successful */ - public boolean teleport(Entity destination, TeleportCause cause); + public boolean teleport(@NotNull Entity destination, @NotNull TeleportCause cause); /** * Returns a list of entities within a bounding box centered around this @@ -143,6 +152,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param z 1/2 the size of the box along z axis * @return {@code List} List of entities nearby */ + @NotNull public List getNearbyEntities(double x, double y, double z); /** @@ -200,6 +210,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return Server instance running this Entity */ + @NotNull public Server getServer(); /** @@ -242,6 +253,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * {@link #getPassengers()} */ @Deprecated + @Nullable public Entity getPassenger(); /** @@ -253,7 +265,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * {@link #getPassengers()} */ @Deprecated - public boolean setPassenger(Entity passenger); + public boolean setPassenger(@NotNull Entity passenger); /** * Gets a list of passengers of this vehicle. @@ -263,6 +275,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return list of entities corresponding to current passengers. */ + @NotNull public List getPassengers(); /** @@ -271,7 +284,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param passenger The passenger to add * @return false if it could not be done for whatever reason */ - public boolean addPassenger(Entity passenger); + public boolean addPassenger(@NotNull Entity passenger); /** * Remove a passenger from the vehicle. @@ -279,7 +292,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param passenger The passenger to remove * @return false if it could not be done for whatever reason */ - public boolean removePassenger(Entity passenger); + public boolean removePassenger(@NotNull Entity passenger); /** * Check if a vehicle has passengers. @@ -314,7 +327,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @param event a {@link EntityDamageEvent} */ - public void setLastDamageCause(EntityDamageEvent event); + public void setLastDamageCause(@Nullable EntityDamageEvent event); /** * Retrieve the last {@link EntityDamageEvent} inflicted on this entity. @@ -323,6 +336,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @return the last known {@link EntityDamageEvent} or null if hitherto * unharmed */ + @Nullable public EntityDamageEvent getLastDamageCause(); /** @@ -330,6 +344,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return unique id */ + @NotNull public UUID getUniqueId(); /** @@ -360,13 +375,14 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @param type Effect to play. */ - public void playEffect(EntityEffect type); + public void playEffect(@NotNull EntityEffect type); /** * Get the type of the entity. * * @return The entity type. */ + @NotNull public EntityType getType(); /** @@ -391,6 +407,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return The current vehicle. */ + @Nullable public Entity getVehicle(); /** @@ -496,6 +513,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return a set of tags for this entity */ + @NotNull Set getScoreboardTags(); /** @@ -506,7 +524,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param tag the tag to add * @return true if the tag was successfully added */ - boolean addScoreboardTag(String tag); + boolean addScoreboardTag(@NotNull String tag); /** * Removes a given tag from this entity. @@ -514,13 +532,14 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @param tag the tag to remove * @return true if the tag was successfully removed */ - boolean removeScoreboardTag(String tag); + boolean removeScoreboardTag(@NotNull String tag); /** * Returns the reaction of the entity when moved by a piston. * * @return reaction */ + @NotNull PistonMoveReaction getPistonMoveReaction(); /** @@ -537,5 +556,6 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * @see Hanging * @see Directional#getFacing() */ + @NotNull BlockFace getFacing(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index b17f2b74f1..510dcfd9de 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -14,6 +14,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; public enum EntityType { @@ -309,11 +311,11 @@ public enum EntityType { NAME_MAP.put("ender_crystal", ENDER_CRYSTAL); } - private EntityType(String name, Class clazz, int typeId) { + private EntityType(@Nullable String name, @Nullable Class clazz, int typeId) { this(name, clazz, typeId, true); } - private EntityType(String name, Class clazz, int typeId, boolean independent) { + private EntityType(@Nullable String name, @Nullable Class clazz, int typeId, boolean independent) { this.name = name; this.clazz = clazz; this.typeId = (short) typeId; @@ -329,10 +331,12 @@ public enum EntityType { * @deprecated Magic value */ @Deprecated + @Nullable public String getName() { return name; } + @Nullable public Class getEntityClass() { return clazz; } @@ -354,7 +358,9 @@ public enum EntityType { * @deprecated Magic value */ @Deprecated - public static EntityType fromName(String name) { + @Contract("null -> null") + @Nullable + public static EntityType fromName(@Nullable String name) { if (name == null) { return null; } @@ -368,6 +374,7 @@ public enum EntityType { * @deprecated Magic value */ @Deprecated + @Nullable public static EntityType fromId(int id) { if (id > Short.MAX_VALUE) { return null; diff --git a/paper-api/src/main/java/org/bukkit/entity/Evoker.java b/paper-api/src/main/java/org/bukkit/entity/Evoker.java index 7fd32bf448..f8d173adc0 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Evoker.java +++ b/paper-api/src/main/java/org/bukkit/entity/Evoker.java @@ -1,5 +1,8 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Represents an Evoker "Illager". */ @@ -49,6 +52,7 @@ public interface Evoker extends Spellcaster { * */ @Deprecated + @NotNull Spell getCurrentSpell(); /** @@ -59,5 +63,5 @@ public interface Evoker extends Spellcaster { * entities. */ @Deprecated - void setCurrentSpell(Spell spell); + void setCurrentSpell(@Nullable Spell spell); } diff --git a/paper-api/src/main/java/org/bukkit/entity/EvokerFangs.java b/paper-api/src/main/java/org/bukkit/entity/EvokerFangs.java index 6b6c1b9765..7cc1dcdab9 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EvokerFangs.java +++ b/paper-api/src/main/java/org/bukkit/entity/EvokerFangs.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Nullable; + /** * Represents Evoker Fangs. */ @@ -10,6 +12,7 @@ public interface EvokerFangs extends Entity { * * @return the {@link LivingEntity} which summoned the fangs */ + @Nullable LivingEntity getOwner(); /** @@ -17,5 +20,5 @@ public interface EvokerFangs extends Entity { * * @param owner the {@link LivingEntity} which summoned the fangs */ - void setOwner(LivingEntity owner); + void setOwner(@Nullable LivingEntity owner); } diff --git a/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java b/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java index 0cd830d901..64f9d3fd87 100644 --- a/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java +++ b/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java @@ -2,6 +2,7 @@ package org.bukkit.entity; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import org.jetbrains.annotations.NotNull; /** * Represents a falling block @@ -15,6 +16,7 @@ public interface FallingBlock extends Entity { * @deprecated use {@link #getBlockData()} */ @Deprecated + @NotNull Material getMaterial(); /** @@ -22,6 +24,7 @@ public interface FallingBlock extends Entity { * * @return data of the block */ + @NotNull BlockData getBlockData(); /** diff --git a/paper-api/src/main/java/org/bukkit/entity/Fireball.java b/paper-api/src/main/java/org/bukkit/entity/Fireball.java index 56ed578920..7a44707f23 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Fireball.java +++ b/paper-api/src/main/java/org/bukkit/entity/Fireball.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Represents a Fireball. @@ -12,13 +13,14 @@ public interface Fireball extends Projectile, Explosive { * * @param direction the direction this fireball is flying toward */ - public void setDirection(Vector direction); + public void setDirection(@NotNull Vector direction); /** * Retrieve the direction this fireball is heading toward * * @return the direction */ + @NotNull public Vector getDirection(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Firework.java b/paper-api/src/main/java/org/bukkit/entity/Firework.java index b8a8c07538..1c55f03389 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Firework.java +++ b/paper-api/src/main/java/org/bukkit/entity/Firework.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.inventory.meta.FireworkMeta; +import org.jetbrains.annotations.NotNull; public interface Firework extends Entity { @@ -9,6 +10,7 @@ public interface Firework extends Entity { * * @return A copy of the current Firework meta */ + @NotNull FireworkMeta getFireworkMeta(); /** @@ -16,7 +18,7 @@ public interface Firework extends Entity { * * @param meta The FireworkMeta to apply */ - void setFireworkMeta(FireworkMeta meta); + void setFireworkMeta(@NotNull FireworkMeta meta); /** * Cause this firework to explode at earliest opportunity, as if it has no diff --git a/paper-api/src/main/java/org/bukkit/entity/Hanging.java b/paper-api/src/main/java/org/bukkit/entity/Hanging.java index 67e9b615f9..2f07efac03 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Hanging.java +++ b/paper-api/src/main/java/org/bukkit/entity/Hanging.java @@ -2,6 +2,7 @@ package org.bukkit.entity; import org.bukkit.block.BlockFace; import org.bukkit.material.Attachable; +import org.jetbrains.annotations.NotNull; /** * Represents a Hanging entity @@ -18,5 +19,5 @@ public interface Hanging extends Entity, Attachable { * @return False if force was false and there was no block for it to * attach to in order to face the given direction. */ - public boolean setFacingDirection(BlockFace face, boolean force); + public boolean setFacingDirection(@NotNull BlockFace face, boolean force); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Horse.java b/paper-api/src/main/java/org/bukkit/entity/Horse.java index cfce8fa578..734f5ac7bd 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Horse.java +++ b/paper-api/src/main/java/org/bukkit/entity/Horse.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.inventory.HorseInventory; +import org.jetbrains.annotations.NotNull; /** * Represents a Horse. @@ -109,6 +110,7 @@ public interface Horse extends AbstractHorse { * * @return a {@link Color} representing the horse's group */ + @NotNull public Color getColor(); /** @@ -119,7 +121,7 @@ public interface Horse extends AbstractHorse { * * @param color a {@link Color} for this horse */ - public void setColor(Color color); + public void setColor(@NotNull Color color); /** * Gets the horse's style. @@ -130,6 +132,7 @@ public interface Horse extends AbstractHorse { * * @return a {@link Style} representing the horse's style */ + @NotNull public Style getStyle(); /** @@ -141,7 +144,7 @@ public interface Horse extends AbstractHorse { * * @param style a {@link Style} for this horse */ - public void setStyle(Style style); + public void setStyle(@NotNull Style style); /** * @return carrying chest status @@ -157,6 +160,7 @@ public interface Horse extends AbstractHorse { @Deprecated public void setCarryingChest(boolean chest); + @NotNull @Override public HorseInventory getInventory(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java index 8fc5c83cf3..f76bc85c40 100644 --- a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -12,6 +12,8 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a human entity, such as an NPC or a player @@ -23,6 +25,8 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return Player name */ + @NotNull + @Override public String getName(); /** @@ -31,6 +35,8 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return The inventory of the player, this also contains the armor * slots. */ + @NotNull + @Override public PlayerInventory getInventory(); /** @@ -38,6 +44,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return The EnderChest of the player */ + @NotNull public Inventory getEnderChest(); /** @@ -45,6 +52,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return the players main hand */ + @NotNull public MainHand getMainHand(); /** @@ -55,7 +63,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param value The value to set the property to. * @return True if the property was successfully set. */ - public boolean setWindowProperty(InventoryView.Property prop, int value); + public boolean setWindowProperty(@NotNull InventoryView.Property prop, int value); /** * Gets the inventory view the player is currently viewing. If they do not @@ -63,6 +71,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return The inventory view. */ + @NotNull public InventoryView getOpenInventory(); /** @@ -72,7 +81,8 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param inventory The inventory to open * @return The newly opened inventory view */ - public InventoryView openInventory(Inventory inventory); + @Nullable + public InventoryView openInventory(@NotNull Inventory inventory); /** * Opens an empty workbench inventory window with the player's inventory @@ -85,7 +95,8 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return The newly opened inventory view, or null if it could not be * opened. */ - public InventoryView openWorkbench(Location location, boolean force); + @Nullable + public InventoryView openWorkbench(@Nullable Location location, boolean force); /** * Opens an empty enchanting inventory window with the player's inventory @@ -98,14 +109,15 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return The newly opened inventory view, or null if it could not be * opened. */ - public InventoryView openEnchanting(Location location, boolean force); + @Nullable + public InventoryView openEnchanting(@Nullable Location location, boolean force); /** * Opens an inventory window to the specified inventory view. * * @param inventory The view to open */ - public void openInventory(InventoryView inventory); + public void openInventory(@NotNull InventoryView inventory); /** * Starts a trade between the player and the villager. @@ -118,7 +130,8 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return The newly opened inventory view, or null if it could not be * opened. */ - public InventoryView openMerchant(Villager trader, boolean force); + @Nullable + public InventoryView openMerchant(@NotNull Villager trader, boolean force); /** * Starts a trade between the player and the merchant. @@ -131,7 +144,8 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return The newly opened inventory view, or null if it could not be * opened. */ - public InventoryView openMerchant(Merchant merchant, boolean force); + @Nullable + public InventoryView openMerchant(@NotNull Merchant merchant, boolean force); /** * Force-closes the currently open inventory view for this player, if any. @@ -146,6 +160,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * methods in {@link PlayerInventory}. */ @Deprecated + @NotNull public ItemStack getItemInHand(); /** @@ -157,7 +172,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * methods in {@link PlayerInventory}. */ @Deprecated - public void setItemInHand(ItemStack item); + public void setItemInHand(@Nullable ItemStack item); /** * Returns the ItemStack currently on your cursor, can be empty. Will @@ -165,6 +180,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return The ItemStack of the item you are currently moving around. */ + @NotNull public ItemStack getItemOnCursor(); /** @@ -174,7 +190,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @param item The ItemStack which will end up in the hand */ - public void setItemOnCursor(ItemStack item); + public void setItemOnCursor(@Nullable ItemStack item); /** * Check whether a cooldown is active on the specified material. @@ -182,7 +198,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param material the material to check * @return if a cooldown is active on the material */ - public boolean hasCooldown(Material material); + public boolean hasCooldown(@NotNull Material material); /** * Get the cooldown time in ticks remaining for the specified material. @@ -190,7 +206,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param material the material to check * @return the remaining cooldown time in ticks */ - public int getCooldown(Material material); + public int getCooldown(@NotNull Material material); /** * Set a cooldown on the specified material for a certain amount of ticks. @@ -205,7 +221,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param material the material to set the cooldown for * @param ticks the amount of ticks to set or 0 to remove */ - public void setCooldown(Material material, int ticks); + public void setCooldown(@NotNull Material material, int ticks); /** * Returns whether this player is slumbering. @@ -227,6 +243,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return Bed Spawn Location if bed exists, otherwise null. */ + @Nullable public Location getBedSpawnLocation(); /** @@ -234,7 +251,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @param location where to set the respawn location */ - public void setBedSpawnLocation(Location location); + public void setBedSpawnLocation(@Nullable Location location); /** * Sets the Location where the player will spawn at their bed. @@ -243,7 +260,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @param force whether to forcefully set the respawn location even if a * valid bed is not present */ - public void setBedSpawnLocation(Location location, boolean force); + public void setBedSpawnLocation(@Nullable Location location, boolean force); /** * Attempts to make the entity sleep at the given location. @@ -257,7 +274,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * normally possible * @return whether the sleep was successful */ - public boolean sleep(Location location, boolean force); + public boolean sleep(@NotNull Location location, boolean force); /** * Causes the player to wakeup if they are currently sleeping. @@ -274,6 +291,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return location * @throws IllegalStateException if not sleeping */ + @NotNull public Location getBedLocation(); /** @@ -281,6 +299,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return Current game mode */ + @NotNull public GameMode getGameMode(); /** @@ -288,7 +307,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @param mode New game mode */ - public void setGameMode(GameMode mode); + public void setGameMode(@NotNull GameMode mode); /** * Check if the player is currently blocking (ie with a shield). @@ -321,7 +340,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * * @return whether or not the recipe was newly discovered */ - public boolean discoverRecipe(NamespacedKey recipe); + public boolean discoverRecipe(@NotNull NamespacedKey recipe); /** * Discover a collection of recipes for this player such that they have not @@ -335,7 +354,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * none were newly discovered and a number equal to {@code recipes.size()} * indicates that all were new */ - public int discoverRecipes(Collection recipes); + public int discoverRecipes(@NotNull Collection recipes); /** * Undiscover a recipe for this player such that it has already been @@ -347,7 +366,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * @return whether or not the recipe was successfully undiscovered (i.e. it * was previously discovered) */ - public boolean undiscoverRecipe(NamespacedKey recipe); + public boolean undiscoverRecipe(@NotNull NamespacedKey recipe); /** * Undiscover a collection of recipes for this player such that they have @@ -361,7 +380,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * were undiscovered and a number equal to {@code recipes.size()} indicates * that all were undiscovered */ - public int undiscoverRecipes(Collection recipes); + public int undiscoverRecipes(@NotNull Collection recipes); /** * Gets the entity currently perched on the left shoulder or null if no @@ -375,6 +394,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * serialized entities in Bukkit. Use with care. */ @Deprecated + @Nullable public Entity getShoulderEntityLeft(); /** @@ -392,7 +412,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * serialized entities in Bukkit. Use with care. */ @Deprecated - public void setShoulderEntityLeft(Entity entity); + public void setShoulderEntityLeft(@Nullable Entity entity); /** * Gets the entity currently perched on the right shoulder or null if no @@ -406,6 +426,7 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * serialized entities in Bukkit. Use with care. */ @Deprecated + @Nullable public Entity getShoulderEntityRight(); /** @@ -423,5 +444,5 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder * serialized entities in Bukkit. Use with care. */ @Deprecated - public void setShoulderEntityRight(Entity entity); + public void setShoulderEntityRight(@Nullable Entity entity); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Item.java b/paper-api/src/main/java/org/bukkit/entity/Item.java index 90260b7e59..00c58c1d94 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Item.java +++ b/paper-api/src/main/java/org/bukkit/entity/Item.java @@ -1,9 +1,11 @@ package org.bukkit.entity; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** - * Represents an Item. + * Represents a dropped item. */ public interface Item extends Entity { @@ -12,6 +14,7 @@ public interface Item extends Entity { * * @return An item stack. */ + @NotNull public ItemStack getItemStack(); /** @@ -19,7 +22,7 @@ public interface Item extends Entity { * * @param stack An item stack. */ - public void setItemStack(ItemStack stack); + public void setItemStack(@Nullable ItemStack stack); /** * Gets the delay before this Item is available to be picked up by players diff --git a/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java b/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java index 6ff651adea..e876bd20a2 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java +++ b/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java @@ -2,6 +2,8 @@ package org.bukkit.entity; import org.bukkit.Rotation; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an Item Frame @@ -13,6 +15,7 @@ public interface ItemFrame extends Hanging { * * @return a defensive copy the item in this item frame */ + @NotNull public ItemStack getItem(); /** @@ -20,7 +23,7 @@ public interface ItemFrame extends Hanging { * * @param item the new item */ - public void setItem(ItemStack item); + public void setItem(@Nullable ItemStack item); /** * Set the item in this frame @@ -28,13 +31,14 @@ public interface ItemFrame extends Hanging { * @param item the new item * @param playSound whether or not to play the item placement sound */ - public void setItem(ItemStack item, boolean playSound); + public void setItem(@Nullable ItemStack item, boolean playSound); /** * Get the rotation of the frame's item * * @return the direction */ + @NotNull public Rotation getRotation(); /** @@ -43,5 +47,5 @@ public interface ItemFrame extends Hanging { * @param rotation the new rotation * @throws IllegalArgumentException if rotation is null */ - public void setRotation(Rotation rotation) throws IllegalArgumentException; + public void setRotation(@NotNull Rotation rotation) throws IllegalArgumentException; } diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 8cf98673d2..af8ea5ca07 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -16,6 +16,8 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a living entity, such as a monster or player @@ -43,6 +45,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * * @return a location at the eyes of the living entity */ + @NotNull public Location getEyeLocation(); /** @@ -58,7 +61,8 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return list containing all blocks along the living entity's line of * sight */ - public List getLineOfSight(Set transparent, int maxDistance); + @NotNull + public List getLineOfSight(@Nullable Set transparent, int maxDistance); /** * Gets the block that the living entity has targeted. @@ -73,7 +77,8 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * by server by at least 100 blocks, no less) * @return block that the living entity has targeted */ - public Block getTargetBlock(Set transparent, int maxDistance); + @NotNull + public Block getTargetBlock(@Nullable Set transparent, int maxDistance); /** * Gets the last two blocks along the living entity's line of sight. @@ -88,7 +93,8 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return list containing the last 2 blocks along the living entity's * line of sight */ - public List getLastTwoTargetBlocks(Set transparent, int maxDistance); + @NotNull + public List getLastTwoTargetBlocks(@Nullable Set transparent, int maxDistance); /** * Gets the block that the living entity has targeted. @@ -103,6 +109,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return block that the living entity has targeted * @see #getTargetBlockExact(int, org.bukkit.FluidCollisionMode) */ + @Nullable public Block getTargetBlockExact(int maxDistance); /** @@ -118,7 +125,8 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return block that the living entity has targeted * @see #rayTraceBlocks(double, FluidCollisionMode) */ - public Block getTargetBlockExact(int maxDistance, FluidCollisionMode fluidCollisionMode); + @Nullable + public Block getTargetBlockExact(int maxDistance, @NotNull FluidCollisionMode fluidCollisionMode); /** * Performs a ray trace that provides information on the targeted block. @@ -134,6 +142,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * is no targeted block in range * @see #rayTraceBlocks(double, FluidCollisionMode) */ + @Nullable public RayTraceResult rayTraceBlocks(double maxDistance); /** @@ -150,7 +159,8 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * is no targeted block in range * @see World#rayTraceBlocks(Location, Vector, double, FluidCollisionMode) */ - public RayTraceResult rayTraceBlocks(double maxDistance, FluidCollisionMode fluidCollisionMode); + @Nullable + public RayTraceResult rayTraceBlocks(double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode); /** * Returns the amount of air that the living entity has remaining, in @@ -237,6 +247,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * * @return killer player, or null if none found */ + @Nullable public Player getKiller(); /** @@ -248,7 +259,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param effect PotionEffect to be added * @return whether the effect could be added */ - public boolean addPotionEffect(PotionEffect effect); + public boolean addPotionEffect(@NotNull PotionEffect effect); /** * Adds the given {@link PotionEffect} to the living entity. @@ -260,7 +271,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param force whether conflicting effects should be removed * @return whether the effect could be added */ - public boolean addPotionEffect(PotionEffect effect, boolean force); + public boolean addPotionEffect(@NotNull PotionEffect effect, boolean force); /** * Attempts to add all of the given {@link PotionEffect} to the living @@ -269,7 +280,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param effects the effects to add * @return whether all of the effects could be added */ - public boolean addPotionEffects(Collection effects); + public boolean addPotionEffects(@NotNull Collection effects); /** * Returns whether the living entity already has an existing effect of @@ -278,7 +289,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param type the potion type to check * @return whether the living entity has this potion effect active on them */ - public boolean hasPotionEffect(PotionEffectType type); + public boolean hasPotionEffect(@NotNull PotionEffectType type); /** * Returns the active {@link PotionEffect} of the specified type. @@ -288,14 +299,15 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param type the potion type to check * @return the effect active on this entity, or null if not active. */ - public PotionEffect getPotionEffect(PotionEffectType type); + @Nullable + public PotionEffect getPotionEffect(@NotNull PotionEffectType type); /** * Removes any effects present of the given {@link PotionEffectType}. * * @param type the potion type to remove */ - public void removePotionEffect(PotionEffectType type); + public void removePotionEffect(@NotNull PotionEffectType type); /** * Returns all currently active {@link PotionEffect}s on the living @@ -303,6 +315,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * * @return a collection of {@link PotionEffect}s */ + @NotNull public Collection getActivePotionEffects(); /** @@ -314,7 +327,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param other the entity to determine line of sight to * @return true if there is a line of sight, false if not */ - public boolean hasLineOfSight(Entity other); + public boolean hasLineOfSight(@NotNull Entity other); /** * Returns if the living entity despawns when away from players or not. @@ -338,6 +351,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * * @return the living entity's inventory */ + @Nullable public EntityEquipment getEquipment(); /** @@ -367,6 +381,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return the entity holding the leash * @throws IllegalStateException if not currently leashed */ + @NotNull public Entity getLeashHolder() throws IllegalStateException; /** @@ -376,10 +391,10 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * Non-living entities excluding leashes will not persist as leash * holders. * - * @param holder the entity to leash this entity to + * @param holder the entity to leash this entity to, or null to unleash * @return whether the operation was successful */ - public boolean setLeashHolder(Entity holder); + public boolean setLeashHolder(@Nullable Entity holder); /** * Checks to see if an entity is gliding, such as using an Elytra. diff --git a/paper-api/src/main/java/org/bukkit/entity/Llama.java b/paper-api/src/main/java/org/bukkit/entity/Llama.java index 9422d56cd2..c438542985 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Llama.java +++ b/paper-api/src/main/java/org/bukkit/entity/Llama.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.inventory.LlamaInventory; +import org.jetbrains.annotations.NotNull; /** * Represents a Llama. @@ -35,6 +36,7 @@ public interface Llama extends ChestedHorse { * * @return a {@link Color} representing the llama's color */ + @NotNull Color getColor(); /** @@ -42,7 +44,7 @@ public interface Llama extends ChestedHorse { * * @param color a {@link Color} for this llama */ - void setColor(Color color); + void setColor(@NotNull Color color); /** * Gets the llama's strength. A higher strength llama will have more @@ -61,6 +63,7 @@ public interface Llama extends ChestedHorse { */ void setStrength(int strength); + @NotNull @Override LlamaInventory getInventory(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Minecart.java b/paper-api/src/main/java/org/bukkit/entity/Minecart.java index 22e8dcafdb..5a07493ad8 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Minecart.java +++ b/paper-api/src/main/java/org/bukkit/entity/Minecart.java @@ -3,6 +3,8 @@ package org.bukkit.entity; import org.bukkit.block.data.BlockData; import org.bukkit.material.MaterialData; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a minecart entity. @@ -62,6 +64,7 @@ public interface Minecart extends Vehicle { * * @return The vector factor */ + @NotNull public Vector getFlyingVelocityMod(); /** @@ -71,7 +74,7 @@ public interface Minecart extends Vehicle { * * @param flying velocity modifier vector */ - public void setFlyingVelocityMod(Vector flying); + public void setFlyingVelocityMod(@NotNull Vector flying); /** * Gets the derailed velocity modifier. Used for minecarts that are on the @@ -81,6 +84,7 @@ public interface Minecart extends Vehicle { * * @return derailed visible speed */ + @NotNull public Vector getDerailedVelocityMod(); /** @@ -90,7 +94,7 @@ public interface Minecart extends Vehicle { * * @param derailed visible speed */ - public void setDerailedVelocityMod(Vector derailed); + public void setDerailedVelocityMod(@NotNull Vector derailed); /** * Sets the display block for this minecart. @@ -98,7 +102,7 @@ public interface Minecart extends Vehicle { * * @param material the material to set as display block. */ - public void setDisplayBlock(MaterialData material); + public void setDisplayBlock(@Nullable MaterialData material); /** * Gets the display block for this minecart. @@ -106,6 +110,7 @@ public interface Minecart extends Vehicle { * * @return the block displayed by this minecart. */ + @NotNull public MaterialData getDisplayBlock(); /** @@ -114,7 +119,7 @@ public interface Minecart extends Vehicle { * * @param blockData the material to set as display block. */ - public void setDisplayBlockData(BlockData blockData); + public void setDisplayBlockData(@Nullable BlockData blockData); /** * Gets the display block for this minecart. @@ -122,6 +127,7 @@ public interface Minecart extends Vehicle { * * @return the block displayed by this minecart. */ + @NotNull public BlockData getDisplayBlockData(); /** diff --git a/paper-api/src/main/java/org/bukkit/entity/Mob.java b/paper-api/src/main/java/org/bukkit/entity/Mob.java index d029d34ea9..838440ff8a 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Mob.java +++ b/paper-api/src/main/java/org/bukkit/entity/Mob.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.loot.Lootable; +import org.jetbrains.annotations.Nullable; /** * Represents a Mob. Mobs are living entities with simple AI. @@ -15,12 +16,13 @@ public interface Mob extends LivingEntity, Lootable { * * @param target New LivingEntity to target, or null to clear the target */ - public void setTarget(LivingEntity target); + public void setTarget(@Nullable LivingEntity target); /** * Gets the current target of this Mob * * @return Current target of this creature, or null if none exists */ + @Nullable public LivingEntity getTarget(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Ocelot.java b/paper-api/src/main/java/org/bukkit/entity/Ocelot.java index 0005970a7f..fe75169e58 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Ocelot.java +++ b/paper-api/src/main/java/org/bukkit/entity/Ocelot.java @@ -1,6 +1,9 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * A wild tameable cat */ @@ -11,6 +14,7 @@ public interface Ocelot extends Animals, Tameable, Sittable { * * @return Type of the cat. */ + @NotNull public Type getCatType(); /** @@ -18,7 +22,7 @@ public interface Ocelot extends Animals, Tameable, Sittable { * * @param type New type of this cat. */ - public void setCatType(Type type); + public void setCatType(@NotNull Type type); /** * Represents the various different cat types there are. @@ -61,6 +65,7 @@ public interface Ocelot extends Animals, Tameable, Sittable { * @deprecated Magic value */ @Deprecated + @Nullable public static Type getType(int id) { return (id >= types.length) ? null : types[id]; } diff --git a/paper-api/src/main/java/org/bukkit/entity/Painting.java b/paper-api/src/main/java/org/bukkit/entity/Painting.java index 6afa117e2c..19e9582017 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Painting.java +++ b/paper-api/src/main/java/org/bukkit/entity/Painting.java @@ -2,6 +2,7 @@ package org.bukkit.entity; import org.bukkit.Art; import org.bukkit.event.hanging.HangingBreakEvent; +import org.jetbrains.annotations.NotNull; /** * Represents a Painting. @@ -13,6 +14,7 @@ public interface Painting extends Hanging { * * @return The art */ + @NotNull public Art getArt(); /** @@ -22,7 +24,7 @@ public interface Painting extends Hanging { * @return False if the new art won't fit at the painting's current * location */ - public boolean setArt(Art art); + public boolean setArt(@NotNull Art art); /** * Set the art on this painting @@ -35,5 +37,5 @@ public interface Painting extends Hanging { * @return False if force was false and the new art won't fit at the * painting's current location */ - public boolean setArt(Art art, boolean force); + public boolean setArt(@NotNull Art art, boolean force); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Parrot.java b/paper-api/src/main/java/org/bukkit/entity/Parrot.java index ccd3d1ff62..95d95cdcc9 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Parrot.java +++ b/paper-api/src/main/java/org/bukkit/entity/Parrot.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + /** * Represents a Parrot. */ @@ -10,6 +12,7 @@ public interface Parrot extends Animals, Tameable, Sittable { * * @return parrot variant */ + @NotNull public Variant getVariant(); /** @@ -17,7 +20,7 @@ public interface Parrot extends Animals, Tameable, Sittable { * * @param variant parrot variant */ - public void setVariant(Variant variant); + public void setVariant(@NotNull Variant variant); /** * Represents the variant of a parrot - ie its color. diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index b7aff5cb4b..e77eb822c5 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -3,7 +3,6 @@ package org.bukkit.entity; import java.net.InetSocketAddress; import org.bukkit.Achievement; -import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Instrument; @@ -25,6 +24,8 @@ import org.bukkit.map.MapView; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.PluginMessageRecipient; import org.bukkit.scoreboard.Scoreboard; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a player, connected or not @@ -40,6 +41,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @return the friendly name */ + @NotNull public String getDisplayName(); /** @@ -51,13 +53,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param name The new display name. */ - public void setDisplayName(String name); + public void setDisplayName(@Nullable String name); /** * Gets the name that is shown on the player list. * * @return the player list name */ + @NotNull public String getPlayerListName(); /** @@ -67,13 +70,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param name new player list name */ - public void setPlayerListName(String name); + public void setPlayerListName(@Nullable String name); /** * Gets the currently displayed player list header for this player. * * @return player list header or null */ + @Nullable public String getPlayerListHeader(); /** @@ -81,6 +85,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @return player list header or null */ + @Nullable public String getPlayerListFooter(); /** @@ -88,14 +93,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param header player list header, null for empty */ - public void setPlayerListHeader(String header); + public void setPlayerListHeader(@Nullable String header); /** * Sets the currently displayed player list footer for this player. * * @param footer player list footer, null for empty */ - public void setPlayerListFooter(String footer); + public void setPlayerListFooter(@Nullable String footer); /** * Sets the currently displayed player list header and footer for this @@ -104,20 +109,21 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param header player list header, null for empty * @param footer player list footer, null for empty */ - public void setPlayerListHeaderFooter(String header, String footer); + public void setPlayerListHeaderFooter(@Nullable String header, @Nullable String footer); /** * Set the target of the player's compass. * * @param loc Location to point to */ - public void setCompassTarget(Location loc); + public void setCompassTarget(@NotNull Location loc); /** * Get the previously set compass target. * * @return location of the target */ + @NotNull public Location getCompassTarget(); /** @@ -125,6 +131,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @return the player's address */ + @Nullable public InetSocketAddress getAddress(); /** @@ -132,21 +139,21 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param message Message to be displayed */ - public void sendRawMessage(String message); + public void sendRawMessage(@NotNull String message); /** * Kicks player with custom kick message. * * @param message kick message */ - public void kickPlayer(String message); + public void kickPlayer(@Nullable String message); /** * Says a message (or runs a command). * * @param msg message to print */ - public void chat(String msg); + public void chat(@NotNull String msg); /** * Makes the player perform the given command @@ -154,7 +161,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param command Command to perform * @return true if the command was successful, otherwise false */ - public boolean performCommand(String command); + public boolean performCommand(@NotNull String command); /** * Returns if the player is in sneak mode @@ -229,7 +236,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated Magic value */ @Deprecated - public void playNote(Location loc, byte instrument, byte note); + public void playNote(@NotNull Location loc, byte instrument, byte note); /** * Play a note for a player at a location. This requires a note block @@ -240,7 +247,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param instrument The instrument * @param note The note */ - public void playNote(Location loc, Instrument instrument, Note note); + public void playNote(@NotNull Location loc, @NotNull Instrument instrument, @NotNull Note note); /** @@ -253,7 +260,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param volume The volume of the sound * @param pitch The pitch of the sound */ - public void playSound(Location location, Sound sound, float volume, float pitch); + public void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch); /** * Play a sound for a player at the location. @@ -267,7 +274,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param volume the volume of the sound * @param pitch the pitch of the sound */ - public void playSound(Location location, String sound, float volume, float pitch); + public void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch); /** * Play a sound for a player at the location. @@ -280,7 +287,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param volume The volume of the sound * @param pitch The pitch of the sound */ - public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch); + public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch); /** * Play a sound for a player at the location. @@ -295,21 +302,21 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param volume the volume of the sound * @param pitch the pitch of the sound */ - public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch); + public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch); /** * Stop the specified sound from playing. * * @param sound the sound to stop */ - public void stopSound(Sound sound); + public void stopSound(@NotNull Sound sound); /** * Stop the specified sound from playing. * * @param sound the sound to stop */ - public void stopSound(String sound); + public void stopSound(@NotNull String sound); /** * Stop the specified sound from playing. @@ -317,7 +324,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param sound the sound to stop * @param category the category of the sound */ - public void stopSound(Sound sound, SoundCategory category); + public void stopSound(@NotNull Sound sound, @Nullable SoundCategory category); /** * Stop the specified sound from playing. @@ -325,7 +332,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param sound the sound to stop * @param category the category of the sound */ - public void stopSound(String sound, SoundCategory category); + public void stopSound(@NotNull String sound, @Nullable SoundCategory category); /** * Plays an effect to just this player. @@ -336,7 +343,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated Magic value */ @Deprecated - public void playEffect(Location loc, Effect effect, int data); + public void playEffect(@NotNull Location loc, @NotNull Effect effect, int data); /** * Plays an effect to just this player. @@ -346,7 +353,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param effect the {@link Effect} * @param data a data bit needed for some effects */ - public void playEffect(Location loc, Effect effect, T data); + public void playEffect(@NotNull Location loc, @NotNull Effect effect, @Nullable T data); /** * Send a block change. This fakes a block change packet for a user at a @@ -358,7 +365,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated Magic value */ @Deprecated - public void sendBlockChange(Location loc, Material material, byte data); + public void sendBlockChange(@NotNull Location loc, @NotNull Material material, byte data); /** * Send a block change. This fakes a block change packet for a user at a @@ -367,7 +374,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param loc The location of the changed block * @param block The new block */ - public void sendBlockChange(Location loc, BlockData block); + public void sendBlockChange(@NotNull Location loc, @NotNull BlockData block); /** * Send a chunk change. This fakes a chunk change packet for a user at a @@ -387,7 +394,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated Magic value */ @Deprecated - public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data); + public boolean sendChunkChange(@NotNull Location loc, int sx, int sy, int sz, @NotNull byte[] data); /** * Send a sign change. This fakes a sign change packet for a user at @@ -404,7 +411,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if location is null * @throws IllegalArgumentException if lines is non-null and has a length less than 4 */ - public void sendSignChange(Location loc, String[] lines) throws IllegalArgumentException; + public void sendSignChange(@NotNull Location loc, @Nullable String[] lines) throws IllegalArgumentException; /** * Render a map and send it to the player in its entirety. This may be @@ -412,7 +419,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param map The map to be sent */ - public void sendMap(MapView map); + public void sendMap(@NotNull MapView map); /** * Forces an update of the player's entire inventory. @@ -432,7 +439,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated future versions of Minecraft do not have achievements */ @Deprecated - public void awardAchievement(Achievement achievement); + public void awardAchievement(@NotNull Achievement achievement); /** * Removes the given achievement and any children achievements that the @@ -443,7 +450,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated future versions of Minecraft do not have achievements */ @Deprecated - public void removeAchievement(Achievement achievement); + public void removeAchievement(@NotNull Achievement achievement); /** * Gets whether this player has the given achievement. @@ -454,7 +461,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated future versions of Minecraft do not have achievements */ @Deprecated - public boolean hasAchievement(Achievement achievement); + public boolean hasAchievement(@NotNull Achievement achievement); /** * Increments the given statistic for this player. @@ -467,7 +474,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the statistic requires an * additional parameter */ - public void incrementStatistic(Statistic statistic) throws IllegalArgumentException; + public void incrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException; /** * Decrements the given statistic for this player. @@ -480,7 +487,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the statistic requires an * additional parameter */ - public void decrementStatistic(Statistic statistic) throws IllegalArgumentException; + public void decrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException; /** * Increments the given statistic for this player. @@ -492,7 +499,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the statistic requires an * additional parameter */ - public void incrementStatistic(Statistic statistic, int amount) throws IllegalArgumentException; + public void incrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException; /** * Decrements the given statistic for this player. @@ -504,7 +511,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the statistic requires an * additional parameter */ - public void decrementStatistic(Statistic statistic, int amount) throws IllegalArgumentException; + public void decrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException; /** * Sets the given statistic for this player. @@ -516,7 +523,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the statistic requires an * additional parameter */ - public void setStatistic(Statistic statistic, int newValue) throws IllegalArgumentException; + public void setStatistic(@NotNull Statistic statistic, int newValue) throws IllegalArgumentException; /** * Gets the value of the given statistic for this player. @@ -527,7 +534,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the statistic requires an * additional parameter */ - public int getStatistic(Statistic statistic) throws IllegalArgumentException; + public int getStatistic(@NotNull Statistic statistic) throws IllegalArgumentException; /** * Increments the given statistic for this player for the given material. @@ -542,7 +549,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void incrementStatistic(Statistic statistic, Material material) throws IllegalArgumentException; + public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException; /** * Decrements the given statistic for this player for the given material. @@ -557,7 +564,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void decrementStatistic(Statistic statistic, Material material) throws IllegalArgumentException; + public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException; /** * Gets the value of the given statistic for this player. @@ -570,7 +577,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public int getStatistic(Statistic statistic, Material material) throws IllegalArgumentException; + public int getStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException; /** * Increments the given statistic for this player for the given material. @@ -584,7 +591,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void incrementStatistic(Statistic statistic, Material material, int amount) throws IllegalArgumentException; + public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException; /** * Decrements the given statistic for this player for the given material. @@ -598,7 +605,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void decrementStatistic(Statistic statistic, Material material, int amount) throws IllegalArgumentException; + public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException; /** * Sets the given statistic for this player for the given material. @@ -612,7 +619,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void setStatistic(Statistic statistic, Material material, int newValue) throws IllegalArgumentException; + public void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int newValue) throws IllegalArgumentException; /** * Increments the given statistic for this player for the given entity. @@ -627,7 +634,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void incrementStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException; + public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException; /** * Decrements the given statistic for this player for the given entity. @@ -642,7 +649,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void decrementStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException; + public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException; /** * Gets the value of the given statistic for this player. @@ -655,7 +662,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public int getStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException; + public int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException; /** * Increments the given statistic for this player for the given entity. @@ -669,7 +676,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) throws IllegalArgumentException; + public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) throws IllegalArgumentException; /** * Decrements the given statistic for this player for the given entity. @@ -683,7 +690,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void decrementStatistic(Statistic statistic, EntityType entityType, int amount); + public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount); /** * Sets the given statistic for this player for the given entity. @@ -697,7 +704,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException if the given parameter is not valid * for the statistic */ - public void setStatistic(Statistic statistic, EntityType entityType, int newValue); + public void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue); /** * Sets the current time on the player's client. When relative is true the @@ -755,7 +762,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param type The WeatherType enum type the player should experience */ - public void setPlayerWeather(WeatherType type); + public void setPlayerWeather(@NotNull WeatherType type); /** * Returns the type of weather the player is currently experiencing. @@ -763,6 +770,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @return The WeatherType that the player is currently experiencing or * null if player is seeing server weather. */ + @Nullable public WeatherType getPlayerWeather(); /** @@ -910,7 +918,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated see {@link #hidePlayer(Plugin, Player)} */ @Deprecated - public void hidePlayer(Player player); + public void hidePlayer(@NotNull Player player); /** * Hides a player from this player @@ -918,7 +926,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param plugin Plugin that wants to hide the player * @param player Player to hide */ - public void hidePlayer(Plugin plugin, Player player); + public void hidePlayer(@NotNull Plugin plugin, @NotNull Player player); /** * Allows this player to see a player that was previously hidden @@ -927,7 +935,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated see {@link #showPlayer(Plugin, Player)} */ @Deprecated - public void showPlayer(Player player); + public void showPlayer(@NotNull Player player); /** * Allows this player to see a player that was previously hidden. If @@ -937,7 +945,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param plugin Plugin that wants to show the player * @param player Player to show */ - public void showPlayer(Plugin plugin, Player player); + public void showPlayer(@NotNull Plugin plugin, @NotNull Player player); /** * Checks to see if a player has been hidden from this player @@ -946,7 +954,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @return True if the provided player is not being hidden from this * player */ - public boolean canSee(Player player); + public boolean canSee(@NotNull Player player); /** * Checks to see if this player is currently flying or not. @@ -1030,7 +1038,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * should use {@link #setResourcePack(String)}. */ @Deprecated - public void setTexturePack(String url); + public void setTexturePack(@NotNull String url); /** * Request that the player's client download and switch resource packs. @@ -1064,7 +1072,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException Thrown if the URL is too long. The * length restriction is an implementation specific arbitrary value. */ - public void setResourcePack(String url); + public void setResourcePack(@NotNull String url); /** * Request that the player's client download and switch resource packs. @@ -1101,13 +1109,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalArgumentException Thrown if the hash is not 20 bytes * long. */ - public void setResourcePack(String url, byte[] hash); + public void setResourcePack(@NotNull String url, @NotNull byte[] hash); /** * Gets the Scoreboard displayed to this player * * @return The current scoreboard seen by this player */ + @NotNull public Scoreboard getScoreboard(); /** @@ -1120,7 +1129,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalStateException if this is a player that is not logged * yet or has logged out */ - public void setScoreboard(Scoreboard scoreboard) throws IllegalArgumentException, IllegalStateException; + public void setScoreboard(@NotNull Scoreboard scoreboard) throws IllegalArgumentException, IllegalStateException; /** * Gets if the client is displayed a 'scaled' health, that is, health on a @@ -1173,6 +1182,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @return the followed entity, or null if not in spectator mode or not * following a specific entity. */ + @Nullable public Entity getSpectatorTarget(); /** @@ -1183,7 +1193,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @throws IllegalStateException if the player is not in * {@link GameMode#SPECTATOR} */ - public void setSpectatorTarget(Entity entity); + public void setSpectatorTarget(@Nullable Entity entity); /** * Sends a title and a subtitle message to the player. If either of these @@ -1197,7 +1207,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @deprecated API behavior subject to change */ @Deprecated - public void sendTitle(String title, String subtitle); + public void sendTitle(@Nullable String title, @Nullable String subtitle); /** * Sends a title and a subtitle message to the player. If either of these @@ -1214,7 +1224,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param stay time in ticks for titles to stay. Defaults to 70. * @param fadeOut time in ticks for titles to fade out. Defaults to 20. */ - public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut); + public void sendTitle(@Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut); /** * Resets the title displayed to the player. This will clear the displayed @@ -1230,7 +1240,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1242,7 +1252,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1254,7 +1264,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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); /** @@ -1269,7 +1279,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1284,7 +1294,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1301,7 +1311,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1318,7 +1328,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1337,7 +1347,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1354,7 +1364,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1373,7 +1383,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1392,7 +1402,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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) @@ -1413,7 +1423,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @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); /** * Return the player's progression on the specified advancement. @@ -1421,7 +1431,8 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param advancement advancement * @return object detailing the player's progress */ - public AdvancementProgress getAdvancementProgress(Advancement advancement); + @NotNull + public AdvancementProgress getAdvancementProgress(@NotNull Advancement advancement); /** * Get the player's current client side view distance. @@ -1444,6 +1455,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @return the player's locale */ + @NotNull public String getLocale(); /** diff --git a/paper-api/src/main/java/org/bukkit/entity/Projectile.java b/paper-api/src/main/java/org/bukkit/entity/Projectile.java index 4ab2332fa3..c854860c13 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Projectile.java +++ b/paper-api/src/main/java/org/bukkit/entity/Projectile.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.projectiles.ProjectileSource; +import org.jetbrains.annotations.Nullable; /** * Represents a shootable entity. @@ -12,6 +13,7 @@ public interface Projectile extends Entity { * * @return the {@link ProjectileSource} that shot this projectile */ + @Nullable public ProjectileSource getShooter(); /** @@ -19,7 +21,7 @@ public interface Projectile extends Entity { * * @param source the {@link ProjectileSource} that shot this projectile */ - public void setShooter(ProjectileSource source); + public void setShooter(@Nullable ProjectileSource source); /** * Determine if this projectile should bounce or not when it hits. diff --git a/paper-api/src/main/java/org/bukkit/entity/Rabbit.java b/paper-api/src/main/java/org/bukkit/entity/Rabbit.java index 1c8d1fccd8..e88154283a 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Rabbit.java +++ b/paper-api/src/main/java/org/bukkit/entity/Rabbit.java @@ -1,16 +1,19 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + public interface Rabbit extends Animals { /** * @return The type of rabbit. */ + @NotNull public Type getRabbitType(); /** * @param type Sets the type of rabbit for this entity. */ - public void setRabbitType(Type type); + public void setRabbitType(@NotNull Type type); /** * Represents the various types a Rabbit might be. diff --git a/paper-api/src/main/java/org/bukkit/entity/ShulkerBullet.java b/paper-api/src/main/java/org/bukkit/entity/ShulkerBullet.java index f285c0a894..4623e0d767 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ShulkerBullet.java +++ b/paper-api/src/main/java/org/bukkit/entity/ShulkerBullet.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Nullable; + public interface ShulkerBullet extends Projectile { /** @@ -7,6 +9,7 @@ public interface ShulkerBullet extends Projectile { * * @return the targeted entity */ + @Nullable Entity getTarget(); /** @@ -14,5 +17,5 @@ public interface ShulkerBullet extends Projectile { * * @param target the entity to target */ - void setTarget(Entity target); + void setTarget(@Nullable Entity target); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java index 2a02ab855e..2a0b010976 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java +++ b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java @@ -1,5 +1,8 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + /** * Represents a Skeleton. */ @@ -12,12 +15,14 @@ public interface Skeleton extends Monster { * @deprecated should check what class instance this is */ @Deprecated + @NotNull public SkeletonType getSkeletonType(); /** * @deprecated Must spawn a new subtype variant */ @Deprecated + @Contract("_ -> fail") public void setSkeletonType(SkeletonType type); /* diff --git a/paper-api/src/main/java/org/bukkit/entity/Spellcaster.java b/paper-api/src/main/java/org/bukkit/entity/Spellcaster.java index 3150722522..d5c107d4f3 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Spellcaster.java +++ b/paper-api/src/main/java/org/bukkit/entity/Spellcaster.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + /** * Represents a spell casting "Illager". */ @@ -41,6 +43,7 @@ public interface Spellcaster extends Illager { * * @return the current spell */ + @NotNull Spell getSpell(); /** @@ -48,5 +51,5 @@ public interface Spellcaster extends Illager { * * @param spell the spell the entity should be using */ - void setSpell(Spell spell); + void setSpell(@NotNull Spell spell); } diff --git a/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java b/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java index a439eaf56e..5a87893248 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java +++ b/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.Location; +import org.jetbrains.annotations.Nullable; /** * Represents a Primed TNT. @@ -36,5 +37,6 @@ public interface TNTPrimed extends Explosive { * * @return the source of this primed TNT */ + @Nullable public Entity getSource(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Tameable.java b/paper-api/src/main/java/org/bukkit/entity/Tameable.java index 44497aa3c4..0c066bdfc9 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Tameable.java +++ b/paper-api/src/main/java/org/bukkit/entity/Tameable.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Nullable; + public interface Tameable extends Entity { /** @@ -28,6 +30,7 @@ public interface Tameable extends Entity { * * @return the owning AnimalTamer, or null if not owned */ + @Nullable public AnimalTamer getOwner(); /** @@ -39,6 +42,6 @@ public interface Tameable extends Entity { * * @param tamer the AnimalTamer who should own this */ - public void setOwner(AnimalTamer tamer); + public void setOwner(@Nullable AnimalTamer tamer); } diff --git a/paper-api/src/main/java/org/bukkit/entity/ThrownPotion.java b/paper-api/src/main/java/org/bukkit/entity/ThrownPotion.java index 81dcecb8d7..02218457ae 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ThrownPotion.java +++ b/paper-api/src/main/java/org/bukkit/entity/ThrownPotion.java @@ -4,6 +4,7 @@ import java.util.Collection; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; +import org.jetbrains.annotations.NotNull; /** * Represents a thrown potion bottle @@ -15,6 +16,7 @@ public interface ThrownPotion extends Projectile { * * @return The potion effects */ + @NotNull public Collection getEffects(); /** @@ -26,6 +28,7 @@ public interface ThrownPotion extends Projectile { * * @return A copy of the ItemStack for this thrown potion. */ + @NotNull public ItemStack getItem(); /** @@ -37,5 +40,5 @@ public interface ThrownPotion extends Projectile { * * @param item New ItemStack */ - public void setItem(ItemStack item); + public void setItem(@NotNull ItemStack item); } diff --git a/paper-api/src/main/java/org/bukkit/entity/TippedArrow.java b/paper-api/src/main/java/org/bukkit/entity/TippedArrow.java index 09b5dd43c4..d53b40d34d 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TippedArrow.java +++ b/paper-api/src/main/java/org/bukkit/entity/TippedArrow.java @@ -6,6 +6,8 @@ import org.bukkit.Color; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface TippedArrow extends Arrow { @@ -14,13 +16,14 @@ public interface TippedArrow extends Arrow { * * @param data PotionData to set the base potion state to */ - void setBasePotionData(PotionData data); + void setBasePotionData(@NotNull PotionData data); /** * Returns the potion data about the base potion * * @return a PotionData object */ + @NotNull PotionData getBasePotionData(); /** @@ -28,6 +31,7 @@ public interface TippedArrow extends Arrow { * * @return arrow color */ + @NotNull Color getColor(); /** @@ -35,7 +39,7 @@ public interface TippedArrow extends Arrow { * * @param color arrow color */ - void setColor(Color color); + void setColor(@NotNull Color color); /** * Checks for the presence of custom potion effects. @@ -53,6 +57,7 @@ public interface TippedArrow extends Arrow { * * @return the immutable list of custom potion effects */ + @NotNull List getCustomEffects(); /** @@ -63,7 +68,7 @@ public interface TippedArrow extends Arrow { * overwritten * @return true if the effect was added as a result of this call */ - boolean addCustomEffect(PotionEffect effect, boolean overwrite); + boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite); /** * Removes a custom potion effect from this arrow. @@ -73,7 +78,7 @@ public interface TippedArrow extends Arrow { * @throws IllegalArgumentException if this operation would leave the Arrow * in a state with no Custom Effects and PotionType.UNCRAFTABLE */ - boolean removeCustomEffect(PotionEffectType type); + boolean removeCustomEffect(@NotNull PotionEffectType type); /** * Checks for a specific custom potion effect type on this arrow. @@ -81,7 +86,7 @@ public interface TippedArrow extends Arrow { * @param type the potion effect type to check for * @return true if the potion has this effect */ - boolean hasCustomEffect(PotionEffectType type); + boolean hasCustomEffect(@Nullable PotionEffectType type); /** * Removes all custom potion effects from this arrow. diff --git a/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java b/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java index 51142170e9..bc5055f2d9 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java +++ b/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.DyeColor; +import org.jetbrains.annotations.NotNull; /** * Tropical fish. @@ -12,6 +13,7 @@ public interface TropicalFish extends Fish { * * @return pattern color */ + @NotNull DyeColor getPatternColor(); /** @@ -19,13 +21,14 @@ public interface TropicalFish extends Fish { * * @param color pattern color */ - void setPatternColor(DyeColor color); + void setPatternColor(@NotNull DyeColor color); /** * Gets the color of the fish's body. * * @return pattern color */ + @NotNull DyeColor getBodyColor(); /** @@ -33,13 +36,14 @@ public interface TropicalFish extends Fish { * * @param color body color */ - void setBodyColor(DyeColor color); + void setBodyColor(@NotNull DyeColor color); /** * Gets the fish's pattern. * * @return pattern */ + @NotNull Pattern getPattern(); /** @@ -47,7 +51,7 @@ public interface TropicalFish extends Fish { * * @param pattern new pattern */ - void setPattern(Pattern pattern); + void setPattern(@NotNull Pattern pattern); /** * Enumeration of all different fish patterns. Refer to the diff --git a/paper-api/src/main/java/org/bukkit/entity/Vehicle.java b/paper-api/src/main/java/org/bukkit/entity/Vehicle.java index 7d7607c454..c73ee6cbd1 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Vehicle.java +++ b/paper-api/src/main/java/org/bukkit/entity/Vehicle.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Represents a vehicle entity. @@ -12,6 +13,7 @@ public interface Vehicle extends Entity { * * @return velocity vector */ + @NotNull public Vector getVelocity(); /** @@ -19,5 +21,5 @@ public interface Vehicle extends Entity { * * @param vel velocity vector */ - public void setVelocity(Vector vel); + public void setVelocity(@NotNull Vector vel); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Villager.java b/paper-api/src/main/java/org/bukkit/entity/Villager.java index f2095f6180..4f6e1ca188 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Villager.java +++ b/paper-api/src/main/java/org/bukkit/entity/Villager.java @@ -7,6 +7,8 @@ import java.util.List; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.Merchant; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a villager NPC @@ -18,6 +20,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * * @return Current profession. */ + @NotNull public Profession getProfession(); /** @@ -25,13 +28,14 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * * @param profession New profession. */ - public void setProfession(Profession profession); + public void setProfession(@NotNull Profession profession); /** * Get the current {@link Career} for this Villager. * * @return the {@link Career} */ + @NotNull public Career getCareer(); /** @@ -42,7 +46,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * @throws IllegalArgumentException when the new {@link Career} cannot be * used with this Villager's current {@link Profession}. */ - public void setCareer(Career career); + public void setCareer(@Nullable Career career); /** * Set the new {@link Career} for this Villager. @@ -53,7 +57,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * @throws IllegalArgumentException when the new {@link Career} cannot be * used with this Villager's current {@link Profession}. */ - public void setCareer(Career career, boolean resetTrades); + public void setCareer(@Nullable Career career, boolean resetTrades); /** * Gets this villager's inventory. @@ -63,6 +67,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * * {@inheritDoc} */ + @NotNull @Override Inventory getInventory(); @@ -147,6 +152,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * @return an immutable list of careers for this profession, or an empty * map if this Profession has no careers. */ + @NotNull public List getCareers() { return Career.getCareers(this); } @@ -230,7 +236,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { private static final Multimap careerMap = LinkedListMultimap.create(); private final Profession profession; - private Career(Profession profession) { + private Career(@NotNull Profession profession) { this.profession = profession; } @@ -239,6 +245,7 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * * @return the {@link Profession}. */ + @NotNull public Profession getProfession() { return profession; } @@ -251,7 +258,8 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { * @return an immutable list of Careers that can be used by a * profession, or an empty map if the profession was not found */ - public static List getCareers(Profession profession) { + @NotNull + public static List getCareers(@NotNull Profession profession) { return careerMap.containsKey(profession) ? ImmutableList.copyOf(careerMap.get(profession)) : ImmutableList.of(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Wolf.java b/paper-api/src/main/java/org/bukkit/entity/Wolf.java index 63e7292886..f07d519418 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Wolf.java +++ b/paper-api/src/main/java/org/bukkit/entity/Wolf.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.DyeColor; +import org.jetbrains.annotations.NotNull; /** * Represents a Wolf @@ -31,6 +32,7 @@ public interface Wolf extends Animals, Tameable, Sittable { * * @return the color of the collar */ + @NotNull public DyeColor getCollarColor(); /** @@ -38,5 +40,5 @@ public interface Wolf extends Animals, Tameable, Sittable { * * @param color the color to apply */ - public void setCollarColor(DyeColor color); + public void setCollarColor(@NotNull DyeColor color); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Zombie.java b/paper-api/src/main/java/org/bukkit/entity/Zombie.java index bdc6206aff..756f285eb4 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Zombie.java +++ b/paper-api/src/main/java/org/bukkit/entity/Zombie.java @@ -1,5 +1,8 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; + /** * Represents a Zombie. */ @@ -33,6 +36,7 @@ public interface Zombie extends Monster { * @deprecated must spawn {@link ZombieVillager}. */ @Deprecated + @Contract("_ -> fail") public void setVillager(boolean flag); /** @@ -40,6 +44,7 @@ public interface Zombie extends Monster { * @see ZombieVillager#getVillagerProfession() */ @Deprecated + @Contract("_ -> fail") public void setVillagerProfession(Villager.Profession profession); /** @@ -47,6 +52,8 @@ public interface Zombie extends Monster { * @see ZombieVillager#getVillagerProfession() */ @Deprecated + @Nullable + @Contract("-> null") public Villager.Profession getVillagerProfession(); /** diff --git a/paper-api/src/main/java/org/bukkit/entity/ZombieVillager.java b/paper-api/src/main/java/org/bukkit/entity/ZombieVillager.java index 256e7cc231..f8ff3b6556 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ZombieVillager.java +++ b/paper-api/src/main/java/org/bukkit/entity/ZombieVillager.java @@ -1,5 +1,7 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Nullable; + /** * Represents a {@link Zombie} which was once a {@link Villager}. */ @@ -9,7 +11,7 @@ public interface ZombieVillager extends Zombie { * Sets the villager profession of this zombie. */ @Override - void setVillagerProfession(Villager.Profession profession); + void setVillagerProfession(@Nullable Villager.Profession profession); /** * Returns the villager profession of this zombie. @@ -17,6 +19,7 @@ public interface ZombieVillager extends Zombie { * @return the profession or null */ @Override + @Nullable Villager.Profession getVillagerProfession(); /** diff --git a/paper-api/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java b/paper-api/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java index 75649cf360..63c80b4ee1 100644 --- a/paper-api/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java +++ b/paper-api/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java @@ -1,6 +1,8 @@ package org.bukkit.entity.minecart; import org.bukkit.entity.Minecart; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface CommandMinecart extends Minecart { @@ -11,6 +13,7 @@ public interface CommandMinecart extends Minecart { * * @return Command that this CommandMinecart will run when powered. */ + @NotNull public String getCommand(); /** @@ -21,7 +24,7 @@ public interface CommandMinecart extends Minecart { * @param command Command that this CommandMinecart will run when * activated. */ - public void setCommand(String command); + public void setCommand(@Nullable String command); /** * Sets the name of this CommandMinecart. The name is used with commands @@ -30,6 +33,6 @@ public interface CommandMinecart extends Minecart { * * @param name New name for this CommandMinecart. */ - public void setName(String name); + public void setName(@Nullable String name); } diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index 6677e1bd6f..18d0636b74 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -1,6 +1,8 @@ package org.bukkit.event; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; +import org.jetbrains.annotations.NotNull; /** * Represents an event. @@ -40,6 +42,7 @@ public abstract class Event { * * @return name of this event */ + @NotNull public String getEventName() { if (name == null) { name = getClass().getSimpleName(); @@ -47,6 +50,7 @@ public abstract class Event { return name; } + @NotNull public abstract HandlerList getHandlers(); /** diff --git a/paper-api/src/main/java/org/bukkit/event/HandlerList.java b/paper-api/src/main/java/org/bukkit/event/HandlerList.java index 7d5efffbb9..e73e8d4c34 100644 --- a/paper-api/src/main/java/org/bukkit/event/HandlerList.java +++ b/paper-api/src/main/java/org/bukkit/event/HandlerList.java @@ -2,6 +2,7 @@ package org.bukkit.event; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredListener; +import org.jetbrains.annotations.NotNull; import java.util.*; import java.util.Map.Entry; @@ -63,7 +64,7 @@ public class HandlerList { * * @param plugin plugin to unregister */ - public static void unregisterAll(Plugin plugin) { + public static void unregisterAll(@NotNull Plugin plugin) { synchronized (allLists) { for (HandlerList h : allLists) { h.unregister(plugin); @@ -76,7 +77,7 @@ public class HandlerList { * * @param listener listener to unregister */ - public static void unregisterAll(Listener listener) { + public static void unregisterAll(@NotNull Listener listener) { synchronized (allLists) { for (HandlerList h : allLists) { h.unregister(listener); @@ -104,7 +105,7 @@ public class HandlerList { * * @param listener listener to register */ - public synchronized void register(RegisteredListener listener) { + public synchronized void register(@NotNull RegisteredListener listener) { if (handlerslots.get(listener.getPriority()).contains(listener)) throw new IllegalStateException("This listener is already registered to priority " + listener.getPriority().toString()); handlers = null; @@ -116,7 +117,7 @@ public class HandlerList { * * @param listeners listeners to register */ - public void registerAll(Collection listeners) { + public void registerAll(@NotNull Collection listeners) { for (RegisteredListener listener : listeners) { register(listener); } @@ -127,7 +128,7 @@ public class HandlerList { * * @param listener listener to remove */ - public synchronized void unregister(RegisteredListener listener) { + public synchronized void unregister(@NotNull RegisteredListener listener) { if (handlerslots.get(listener.getPriority()).remove(listener)) { handlers = null; } @@ -138,7 +139,7 @@ public class HandlerList { * * @param plugin plugin to remove */ - public synchronized void unregister(Plugin plugin) { + public synchronized void unregister(@NotNull Plugin plugin) { boolean changed = false; for (List list : handlerslots.values()) { for (ListIterator i = list.listIterator(); i.hasNext();) { @@ -156,7 +157,7 @@ public class HandlerList { * * @param listener listener to remove */ - public synchronized void unregister(Listener listener) { + public synchronized void unregister(@NotNull Listener listener) { boolean changed = false; for (List list : handlerslots.values()) { for (ListIterator i = list.listIterator(); i.hasNext();) { @@ -186,6 +187,7 @@ public class HandlerList { * * @return the array of registered listeners */ + @NotNull public RegisteredListener[] getRegisteredListeners() { RegisteredListener[] handlers; while ((handlers = this.handlers) == null) bake(); // This prevents fringe cases of returning null @@ -199,7 +201,8 @@ public class HandlerList { * @param plugin the plugin to get the listeners of * @return the list of registered listeners */ - public static ArrayList getRegisteredListeners(Plugin plugin) { + @NotNull + public static ArrayList getRegisteredListeners(@NotNull Plugin plugin) { ArrayList listeners = new ArrayList(); synchronized (allLists) { for (HandlerList h : allLists) { @@ -223,6 +226,7 @@ public class HandlerList { * @return the list of all handler lists */ @SuppressWarnings("unchecked") + @NotNull public static ArrayList getHandlerLists() { synchronized (allLists) { return (ArrayList) allLists.clone(); diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java index d1b5f7c5b4..ef5048ef1a 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.NotNull; /** * Called when a block is broken by a player. @@ -30,7 +31,7 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable { private boolean dropItems; private boolean cancel; - public BlockBreakEvent(final Block theBlock, final Player player) { + public BlockBreakEvent(@NotNull final Block theBlock, @NotNull final Player player) { super(theBlock, 0); this.player = player; @@ -42,6 +43,7 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable { * * @return The Player that is breaking the block involved in this event */ + @NotNull public Player getPlayer() { return player; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java index e7934d2a42..3fc9c57163 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java @@ -3,6 +3,8 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a block is destroyed as a result of being burnt by fire. @@ -16,11 +18,11 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { private final Block ignitingBlock; @Deprecated - public BlockBurnEvent(final Block block) { + public BlockBurnEvent(@NotNull final Block block) { this(block, null); } - public BlockBurnEvent(final Block block, final Block ignitingBlock) { + public BlockBurnEvent(@NotNull final Block block, @Nullable final Block ignitingBlock) { super(block); this.ignitingBlock = ignitingBlock; } @@ -31,6 +33,7 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { * @return The Block that ignited and burned this block, or null if no * source block exists */ + @Nullable public Block getIgnitingBlock() { return ignitingBlock; } @@ -43,11 +46,13 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java index 58f4cceb04..3c9903c045 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java @@ -5,6 +5,8 @@ import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when we try to place a block, to see if we can build it here or not. @@ -25,7 +27,7 @@ public class BlockCanBuildEvent extends BlockEvent { private final Player player; @Deprecated - public BlockCanBuildEvent(final Block block, final BlockData type, final boolean canBuild) { + public BlockCanBuildEvent(@NotNull final Block block, @NotNull final BlockData type, final boolean canBuild) { this(block, null, type, canBuild); } @@ -36,7 +38,7 @@ public class BlockCanBuildEvent extends BlockEvent { * @param type the id of the block to place * @param canBuild whether we can build */ - public BlockCanBuildEvent(final Block block, final Player player, final BlockData type, final boolean canBuild) { + public BlockCanBuildEvent(@NotNull final Block block, @Nullable final Player player, @NotNull final BlockData type, final boolean canBuild) { super(block); this.player = player; this.buildable = canBuild; @@ -70,6 +72,7 @@ public class BlockCanBuildEvent extends BlockEvent { * * @return The Material that we are trying to place */ + @NotNull public Material getMaterial() { return blockData.getMaterial(); } @@ -79,6 +82,7 @@ public class BlockCanBuildEvent extends BlockEvent { * * @return The BlockData that we are trying to place */ + @NotNull public BlockData getBlockData() { return blockData; } @@ -90,15 +94,18 @@ public class BlockCanBuildEvent extends BlockEvent { * * @return The Player who placed the block involved in this event */ + @Nullable public Player getPlayer() { return player; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java index d80e00ecf1..9fbe23ab24 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when a block is damaged by a player. @@ -18,7 +19,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { private boolean cancel; private final ItemStack itemstack; - public BlockDamageEvent(final Player player, final Block block, final ItemStack itemInHand, final boolean instaBreak) { + public BlockDamageEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final ItemStack itemInHand, final boolean instaBreak) { super(block); this.instaBreak = instaBreak; this.player = player; @@ -31,6 +32,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { * * @return The player damaging the block involved in this event */ + @NotNull public Player getPlayer() { return player; } @@ -60,6 +62,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { * * @return The ItemStack for the item currently in the player's hand */ + @NotNull public ItemStack getItemInHand() { return itemstack; } @@ -72,11 +75,13 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java index 47180f173f..57b831979c 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Called when an equippable item is dispensed from a block and equipped on a @@ -16,7 +17,7 @@ public class BlockDispenseArmorEvent extends BlockDispenseEvent { private final LivingEntity target; - public BlockDispenseArmorEvent(Block block, ItemStack dispensed, LivingEntity target) { + public BlockDispenseArmorEvent(@NotNull Block block, @NotNull ItemStack dispensed, @NotNull LivingEntity target) { super(block, dispensed, new Vector(0, 0, 0)); this.target = target; } @@ -26,6 +27,7 @@ public class BlockDispenseArmorEvent extends BlockDispenseEvent { * * @return the target entity */ + @NotNull public LivingEntity getTargetEntity() { return target; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java index 16ee59b53a..23c428d2db 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Called when an item is dispensed from a block. @@ -18,7 +19,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { private ItemStack item; private Vector velocity; - public BlockDispenseEvent(final Block block, final ItemStack dispensed, final Vector velocity) { + public BlockDispenseEvent(@NotNull final Block block, @NotNull final ItemStack dispensed, @NotNull final Vector velocity) { super(block); this.item = dispensed; this.velocity = velocity; @@ -31,6 +32,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { * * @return An ItemStack for the item being dispensed */ + @NotNull public ItemStack getItem() { return item.clone(); } @@ -40,7 +42,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { * * @param item the item being dispensed */ - public void setItem(ItemStack item) { + public void setItem(@NotNull ItemStack item) { this.item = item; } @@ -52,6 +54,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { * * @return A Vector for the dispensed item's velocity */ + @NotNull public Vector getVelocity() { return velocity.clone(); } @@ -61,7 +64,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { * * @param vel the velocity of the item being dispensed */ - public void setVelocity(Vector vel) { + public void setVelocity(@NotNull Vector vel) { velocity = vel; } @@ -73,11 +76,13 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java index ec24941770..6328e66bdb 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called if a block broken by a player drops an item. @@ -36,7 +37,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { private final BlockState blockState; private final List items; - public BlockDropItemEvent(Block block, BlockState blockState, Player player, List items) { + public BlockDropItemEvent(@NotNull Block block, @NotNull BlockState blockState, @NotNull Player player, @NotNull List items) { super(block); this.blockState = blockState; this.player = player; @@ -48,6 +49,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { * * @return The Player that is breaking the block involved in this event */ + @NotNull public Player getPlayer() { return player; } @@ -58,6 +60,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { * * @return The BlockState of the block involved in this event */ + @NotNull public BlockState getBlockState() { return blockState; } @@ -70,6 +73,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { * * @return The Item the block caused to drop */ + @NotNull public List getItems() { return items; } @@ -78,6 +82,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { * @deprecated very temporary compatibility measure */ @Deprecated + @NotNull public Item getItem() { return items.get(0); } @@ -92,11 +97,13 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java index 240520514c..62a4d13453 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents a block related event. @@ -9,7 +10,7 @@ import org.bukkit.event.Event; public abstract class BlockEvent extends Event { protected Block block; - public BlockEvent(final Block theBlock) { + public BlockEvent(@NotNull final Block theBlock) { block = theBlock; } @@ -18,6 +19,7 @@ public abstract class BlockEvent extends Event { * * @return The Block which block is involved in this event */ + @NotNull public final Block getBlock() { return block; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java index 08636a29d3..c5d9bf3c27 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * An event that's called when a block yields experience. @@ -10,7 +11,7 @@ public class BlockExpEvent extends BlockEvent { private static final HandlerList handlers = new HandlerList(); private int exp; - public BlockExpEvent(Block block, int exp) { + public BlockExpEvent(@NotNull Block block, int exp) { super(block); this.exp = exp; @@ -35,10 +36,12 @@ public class BlockExpEvent extends BlockEvent { this.exp = exp; } + @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 5f15e299e8..635d4bc0e2 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -15,7 +16,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { private final List blocks; private float yield; - public BlockExplodeEvent(final Block what, final List blocks, final float yield) { + public BlockExplodeEvent(@NotNull final Block what, @NotNull final List blocks, final float yield) { super(what); this.blocks = blocks; this.yield = yield; @@ -36,6 +37,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { * * @return All blown-up blocks */ + @NotNull public List blockList() { return blocks; } @@ -58,11 +60,13 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { this.yield = yield; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java index 80dc9d6fde..844dc823fa 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a block fades, melts or disappears based on world conditions @@ -25,7 +26,7 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { private boolean cancelled; private final BlockState newState; - public BlockFadeEvent(final Block block, final BlockState newState) { + public BlockFadeEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block); this.newState = newState; this.cancelled = false; @@ -38,6 +39,7 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { * @return The block state of the block that will be fading, melting or * disappearing */ + @NotNull public BlockState getNewState() { return newState; } @@ -50,11 +52,13 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java index 906c603f2f..1d12e68ccd 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java @@ -1,12 +1,15 @@ package org.bukkit.event.block; import java.util.List; + import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.world.StructureGrowEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called with the block changes resulting from a player fertilizing a given @@ -21,7 +24,7 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { private final Player player; private final List blocks; - public BlockFertilizeEvent(Block theBlock, Player player, List blocks) { + public BlockFertilizeEvent(@NotNull Block theBlock, @Nullable Player player, @NotNull List blocks) { super(theBlock); this.player = player; this.blocks = blocks; @@ -32,6 +35,7 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { * * @return triggering player, or null if not applicable */ + @Nullable public Player getPlayer() { return player; } @@ -41,6 +45,7 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { * * @return list of all changed blocks */ + @NotNull public List getBlocks() { return blocks; } @@ -55,11 +60,13 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java index e765a4eaed..0106780414 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a block is formed or spreads based on world conditions. @@ -25,15 +26,17 @@ import org.bukkit.event.HandlerList; public class BlockFormEvent extends BlockGrowEvent { private static final HandlerList handlers = new HandlerList(); - public BlockFormEvent(final Block block, final BlockState newState) { + public BlockFormEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block, newState); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java index f976bea43c..2fb4a214a9 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Represents events with a source block and a destination block, currently @@ -18,13 +19,13 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { protected BlockFace face; protected boolean cancel; - public BlockFromToEvent(final Block block, final BlockFace face) { + public BlockFromToEvent(@NotNull final Block block, @NotNull final BlockFace face) { super(block); this.face = face; this.cancel = false; } - public BlockFromToEvent(final Block block, final Block toBlock) { + public BlockFromToEvent(@NotNull final Block block, @NotNull final Block toBlock) { super(block); this.to = toBlock; this.face = BlockFace.SELF; @@ -36,6 +37,7 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { * * @return The BlockFace that the block is moving to */ + @NotNull public BlockFace getFace() { return face; } @@ -45,6 +47,7 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { * * @return The faced Block */ + @NotNull public Block getToBlock() { if (to == null) { to = block.getRelative(face); @@ -60,11 +63,13 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java index 9afba7adeb..d3679795aa 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a block grows naturally in the world. @@ -25,7 +26,7 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable { private final BlockState newState; private boolean cancelled = false; - public BlockGrowEvent(final Block block, final BlockState newState) { + public BlockGrowEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block); this.newState = newState; } @@ -35,6 +36,7 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable { * * @return The block state for this events block */ + @NotNull public BlockState getNewState() { return newState; } @@ -47,10 +49,12 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java index b7435608f4..5dc2bc1f5b 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a block is ignited. If you want to catch when a Player places @@ -19,15 +21,15 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { private final Block ignitingBlock; private boolean cancel; - public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity) { + public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @NotNull final Entity ignitingEntity) { this(theBlock, cause, ignitingEntity, null); } - public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Block ignitingBlock) { + public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @NotNull final Block ignitingBlock) { this(theBlock, cause, null, ignitingBlock); } - public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity, final Block ignitingBlock) { + public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity, @Nullable final Block ignitingBlock) { super(theBlock); this.cause = cause; this.ignitingEntity = ignitingEntity; @@ -48,6 +50,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { * * @return An IgniteCause value detailing the cause of block ignition */ + @NotNull public IgniteCause getCause() { return cause; } @@ -57,6 +60,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { * * @return The Player that placed/ignited the fire block, or null if not ignited by a Player. */ + @Nullable public Player getPlayer() { if (ignitingEntity instanceof Player) { return (Player) ignitingEntity; @@ -70,6 +74,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { * * @return The Entity that placed/ignited the fire block, or null if not ignited by a Entity. */ + @Nullable public Entity getIgnitingEntity() { return ignitingEntity; } @@ -79,6 +84,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { * * @return The Block that placed/ignited the fire block, or null if not ignited by a Block. */ + @Nullable public Block getIgnitingBlock() { return ignitingBlock; } @@ -118,11 +124,13 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { EXPLOSION, } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java index d16e4be717..e4f7ca66d2 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java @@ -5,6 +5,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -18,7 +19,7 @@ import java.util.List; public class BlockMultiPlaceEvent extends BlockPlaceEvent { private final List states; - public BlockMultiPlaceEvent(List states, Block clicked, ItemStack itemInHand, Player thePlayer, boolean canBuild) { + public BlockMultiPlaceEvent(@NotNull List states, @NotNull Block clicked, @NotNull ItemStack itemInHand, @NotNull Player thePlayer, boolean canBuild) { super(states.get(0).getBlock(), states.get(0), clicked, itemInHand, thePlayer, canBuild); this.states = ImmutableList.copyOf(states); } @@ -30,6 +31,7 @@ public class BlockMultiPlaceEvent extends BlockPlaceEvent { * * @return immutable list of replaced BlockStates */ + @NotNull public List getReplacedBlockStates() { return states; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java index a34359ed37..75d4e70f5e 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Thrown when a block physics check is called. @@ -31,11 +32,11 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { private final Block sourceBlock; private boolean cancel = false; - public BlockPhysicsEvent(final Block block, final BlockData changed) { + public BlockPhysicsEvent(@NotNull final Block block, @NotNull final BlockData changed) { this(block, changed, block); } - public BlockPhysicsEvent(final Block block, final BlockData changed, final Block sourceBlock) { + public BlockPhysicsEvent(@NotNull final Block block, @NotNull final BlockData changed, @NotNull final Block sourceBlock) { super(block); this.changed = changed; this.sourceBlock = sourceBlock; @@ -48,6 +49,7 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { * * @return The source block */ + @NotNull public Block getSourceBlock() { return sourceBlock; } @@ -57,6 +59,7 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { * * @return Changed block's type */ + @NotNull public Material getChangedType() { return changed.getMaterial(); } @@ -69,11 +72,13 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java index e5f11cbd06..47191c8f25 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.NotNull; /** * Called when a piston block is triggered @@ -12,7 +13,7 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable private boolean cancelled; private final BlockFace direction; - public BlockPistonEvent(final Block block, final BlockFace direction) { + public BlockPistonEvent(@NotNull final Block block, @NotNull final BlockFace direction) { super(block); this.direction = direction; } @@ -39,6 +40,7 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable * * @return direction of the piston */ + @NotNull public BlockFace getDirection() { // Both are meh! // return ((PistonBaseMaterial) block.getType().getNewData(block.getData())).getFacing(); diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java index 682ce60aef..51bca6515c 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a piston extends @@ -17,13 +18,13 @@ public class BlockPistonExtendEvent extends BlockPistonEvent { private List blocks; @Deprecated - public BlockPistonExtendEvent(final Block block, final int length, final BlockFace direction) { + public BlockPistonExtendEvent(@NotNull final Block block, final int length, @NotNull final BlockFace direction) { super(block, direction); this.length = length; } - public BlockPistonExtendEvent(final Block block, final List blocks, final BlockFace direction) { + public BlockPistonExtendEvent(@NotNull final Block block, @NotNull final List blocks, @NotNull final BlockFace direction) { super(block, direction); this.length = blocks.size(); @@ -48,6 +49,7 @@ public class BlockPistonExtendEvent extends BlockPistonEvent { * * @return Immutable list of the moved blocks. */ + @NotNull public List getBlocks() { if (blocks == null) { ArrayList tmp = new ArrayList(); @@ -59,11 +61,13 @@ public class BlockPistonExtendEvent extends BlockPistonEvent { return blocks; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java index 6d42917491..4744e0fa59 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java @@ -5,6 +5,7 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a piston retracts @@ -13,7 +14,7 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { private static final HandlerList handlers = new HandlerList(); private List blocks; - public BlockPistonRetractEvent(final Block block, final List blocks, final BlockFace direction) { + public BlockPistonRetractEvent(@NotNull final Block block, @NotNull final List blocks, @NotNull final BlockFace direction) { super(block, direction); this.blocks = blocks; @@ -26,6 +27,7 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { * @return The possible location of the possibly moving block. */ @Deprecated + @NotNull public Location getRetractLocation() { return getBlock().getRelative(getDirection(), 2).getLocation(); } @@ -36,15 +38,18 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { * * @return Immutable list of the moved blocks. */ + @NotNull public List getBlocks() { return blocks; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index 0ee9e465e2..586e3c8edc 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -7,6 +7,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when a block is placed by a player. @@ -24,11 +25,11 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { protected EquipmentSlot hand; @Deprecated - public BlockPlaceEvent(final Block placedBlock, final BlockState replacedBlockState, final Block placedAgainst, final ItemStack itemInHand, final Player thePlayer, final boolean canBuild) { + public BlockPlaceEvent(@NotNull final Block placedBlock, @NotNull final BlockState replacedBlockState, @NotNull final Block placedAgainst, @NotNull final ItemStack itemInHand, @NotNull final Player thePlayer, final boolean canBuild) { this(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, EquipmentSlot.HAND); } - public BlockPlaceEvent(final Block placedBlock, final BlockState replacedBlockState, final Block placedAgainst, final ItemStack itemInHand, final Player thePlayer, final boolean canBuild, final EquipmentSlot hand) { + public BlockPlaceEvent(@NotNull final Block placedBlock, @NotNull final BlockState replacedBlockState, @NotNull final Block placedAgainst, @NotNull final ItemStack itemInHand, @NotNull final Player thePlayer, final boolean canBuild, @NotNull final EquipmentSlot hand) { super(placedBlock); this.placedAgainst = placedAgainst; this.itemInHand = itemInHand; @@ -52,6 +53,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { * * @return The Player who placed the block involved in this event */ + @NotNull public Player getPlayer() { return player; } @@ -62,6 +64,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { * * @return The Block that was placed */ + @NotNull public Block getBlockPlaced() { return getBlock(); } @@ -72,6 +75,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { * * @return The BlockState for the block which was replaced. */ + @NotNull public BlockState getBlockReplacedState() { return this.replacedBlockState; } @@ -81,6 +85,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { * * @return Block the block that the new block was placed against */ + @NotNull public Block getBlockAgainst() { return placedAgainst; } @@ -91,6 +96,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { * @return The ItemStack for the item in the player's hand when they * placed the block */ + @NotNull public ItemStack getItemInHand() { return itemInHand; } @@ -99,6 +105,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { * Gets the hand which placed the block * @return Main or off-hand, depending on which hand was used to place the block */ + @NotNull public EquipmentSlot getHand() { return this.hand; } @@ -126,11 +133,13 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { this.canBuild = canBuild; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java index 625ec9024f..e46419b8c7 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a redstone current changes @@ -11,7 +12,7 @@ public class BlockRedstoneEvent extends BlockEvent { private final int oldCurrent; private int newCurrent; - public BlockRedstoneEvent(final Block block, final int oldCurrent, final int newCurrent) { + public BlockRedstoneEvent(@NotNull final Block block, final int oldCurrent, final int newCurrent) { super(block); this.oldCurrent = oldCurrent; this.newCurrent = newCurrent; @@ -44,11 +45,13 @@ public class BlockRedstoneEvent extends BlockEvent { this.newCurrent = newCurrent; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java index a1fb363409..e9239caec9 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a block spreads based on world conditions. @@ -24,7 +25,7 @@ public class BlockSpreadEvent extends BlockFormEvent { private static final HandlerList handlers = new HandlerList(); private final Block source; - public BlockSpreadEvent(final Block block, final Block source, final BlockState newState) { + public BlockSpreadEvent(@NotNull final Block block, @NotNull final Block source, @NotNull final BlockState newState) { super(block, newState); this.source = source; } @@ -34,15 +35,18 @@ public class BlockSpreadEvent extends BlockFormEvent { * * @return the Block for the source block involved in this event. */ + @NotNull public Block getSource() { return source; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java index 3a0fbba589..4aaa78afdd 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java @@ -5,6 +5,8 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable { @@ -16,7 +18,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable private final int oldLevel; private int newLevel; - public CauldronLevelChangeEvent(Block block, Entity entity, ChangeReason reason, int oldLevel, int newLevel) { + public CauldronLevelChangeEvent(@NotNull Block block, @Nullable Entity entity, @NotNull ChangeReason reason, int oldLevel, int newLevel) { super(block); this.entity = entity; this.reason = reason; @@ -29,10 +31,12 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable * * @return acting entity */ + @Nullable public Entity getEntity() { return entity; } + @NotNull public ChangeReason getReason() { return reason; } @@ -60,11 +64,13 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java b/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java index 4ce034fe92..741aead8b7 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; /** * Called when a block is formed by entities. @@ -16,7 +17,7 @@ import org.bukkit.entity.Entity; public class EntityBlockFormEvent extends BlockFormEvent { private final Entity entity; - public EntityBlockFormEvent(final Entity entity, final Block block, final BlockState blockstate) { + public EntityBlockFormEvent(@NotNull final Entity entity, @NotNull final Block block, @NotNull final BlockState blockstate) { super(block, blockstate); this.entity = entity; @@ -27,6 +28,7 @@ public class EntityBlockFormEvent extends BlockFormEvent { * * @return Entity involved in event */ + @NotNull public Entity getEntity() { return entity; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java index 01992668cf..9bd0440c37 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java @@ -5,6 +5,7 @@ import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when the fluid level of a block changes due to changes in adjacent @@ -17,7 +18,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { // private BlockData newData; - public FluidLevelChangeEvent(Block theBlock, BlockData newData) { + public FluidLevelChangeEvent(@NotNull Block theBlock, @NotNull BlockData newData) { super(theBlock); this.newData = newData; } @@ -27,6 +28,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { * * @return new data */ + @NotNull public BlockData getNewData() { return newData; } @@ -37,7 +39,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { * * @param newData the new data */ - public void setNewData(BlockData newData) { + public void setNewData(@NotNull BlockData newData) { Preconditions.checkArgument(newData != null, "newData null"); Preconditions.checkArgument(this.newData.getMaterial().equals(newData.getMaterial()), "Cannot change fluid type"); @@ -54,11 +56,13 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java index 84d8cfd9af..538e4246cc 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when leaves are decaying naturally. @@ -13,7 +14,7 @@ public class LeavesDecayEvent extends BlockEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; - public LeavesDecayEvent(final Block block) { + public LeavesDecayEvent(@NotNull final Block block) { super(block); } @@ -25,11 +26,13 @@ public class LeavesDecayEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java index f91cafa02b..bf5de52e79 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when the moisture level of a soil block changes. @@ -14,7 +15,7 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable { private boolean cancelled; private final BlockState newState; - public MoistureChangeEvent(final Block block, final BlockState newState) { + public MoistureChangeEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block); this.newState = newState; this.cancelled = false; @@ -25,6 +26,7 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable { * * @return new block state */ + @NotNull public BlockState getNewState() { return newState; } @@ -39,11 +41,13 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java b/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java index 627505f519..ad8b89e2bd 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java @@ -5,6 +5,7 @@ import org.bukkit.Note; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a note block is being played through player interaction or a @@ -17,7 +18,7 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { private Note note; private boolean cancelled = false; - public NotePlayEvent(Block block, Instrument instrument, Note note) { + public NotePlayEvent(@NotNull Block block, @NotNull Instrument instrument, @NotNull Note note) { super(block); this.instrument = instrument; this.note = note; @@ -34,8 +35,9 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { /** * Gets the {@link Instrument} to be used. * - * @return the Instrument; + * @return the Instrument */ + @NotNull public Instrument getInstrument() { return instrument; } @@ -43,8 +45,9 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { /** * Gets the {@link Note} to be played. * - * @return the Note. + * @return the Note */ + @NotNull public Note getNote() { return note; } @@ -56,11 +59,10 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { * @deprecated no effect on newer Minecraft versions */ @Deprecated - public void setInstrument(Instrument instrument) { + public void setInstrument(@NotNull Instrument instrument) { if (instrument != null) { this.instrument = instrument; } - } /** @@ -70,17 +72,19 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { * @deprecated no effect on newer Minecraft versions */ @Deprecated - public void setNote(Note note) { + public void setNote(@NotNull Note note) { if (note != null) { this.note = note; } } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java index 83188cf583..8b78d4de5c 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java @@ -4,6 +4,8 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a sign is changed by a player. @@ -16,7 +18,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { private final Player player; private final String[] lines; - public SignChangeEvent(final Block theBlock, final Player thePlayer, final String[] theLines) { + public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines) { super(theBlock); this.player = thePlayer; this.lines = theLines; @@ -27,6 +29,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { * * @return the Player involved in this event */ + @NotNull public Player getPlayer() { return player; } @@ -36,6 +39,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { * * @return the String array for the sign's lines new text */ + @NotNull public String[] getLines() { return lines; } @@ -49,6 +53,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { * @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3 * or < 0} */ + @Nullable public String getLine(int index) throws IndexOutOfBoundsException { return lines[index]; } @@ -61,7 +66,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { * @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3 * or < 0} */ - public void setLine(int index, String line) throws IndexOutOfBoundsException { + public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException { lines[index] = line; } @@ -73,11 +78,13 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java index 2611d0698b..ab98bba61a 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java @@ -6,6 +6,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import java.util.List; import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; /** * Called when a sponge absorbs water from the world. @@ -22,7 +23,7 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { private boolean cancelled; private final List blocks; - public SpongeAbsorbEvent(Block block, List waterblocks) { + public SpongeAbsorbEvent(@NotNull Block block, @NotNull List waterblocks) { super(block); this.blocks = waterblocks; } @@ -35,6 +36,7 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { * * @return list of the to be removed blocks. */ + @NotNull public List getBlocks() { return blocks; } @@ -49,11 +51,13 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java b/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java index de28f1d953..ac1b1cb9a0 100644 --- a/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java @@ -11,6 +11,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when an ItemStack is successfully enchanted (currently at @@ -26,7 +27,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { private final Player enchanter; private int button; - public EnchantItemEvent(final Player enchanter, final InventoryView view, final Block table, final ItemStack item, final int level, final Map enchants, final int i) { + public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map enchants, final int i) { super(view); this.enchanter = enchanter; this.table = table; @@ -42,6 +43,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * * @return enchanting player */ + @NotNull public Player getEnchanter() { return enchanter; } @@ -51,6 +53,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * * @return the block used for enchanting */ + @NotNull public Block getEnchantBlock() { return table; } @@ -60,6 +63,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * * @return ItemStack of item */ + @NotNull public ItemStack getItem() { return item; } @@ -89,6 +93,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * * @return map of enchantment levels, keyed by enchantment */ + @NotNull public Map getEnchantsToAdd() { return enchants; } @@ -110,11 +115,13 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java b/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java index 6995b6e0a6..2ff1b13085 100644 --- a/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java @@ -8,6 +8,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when an ItemStack is inserted in an enchantment table - can be @@ -22,7 +23,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab private boolean cancelled; private final Player enchanter; - public PrepareItemEnchantEvent(final Player enchanter, InventoryView view, final Block table, final ItemStack item, final EnchantmentOffer[] offers, final int bonus) { + public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, @NotNull final EnchantmentOffer[] offers, final int bonus) { super(view); this.enchanter = enchanter; this.table = table; @@ -36,6 +37,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * * @return enchanting player */ + @NotNull public Player getEnchanter() { return enchanter; } @@ -45,6 +47,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * * @return the block used for enchanting */ + @NotNull public Block getEnchantBlock() { return table; } @@ -54,6 +57,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * * @return ItemStack of item */ + @NotNull public ItemStack getItem() { return item; } @@ -64,6 +68,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * @return experience level costs offered * @deprecated Use {@link #getOffers()} instead of this method */ + @NotNull public int[] getExpLevelCostsOffered() { int[] levelOffers = new int[offers.length]; for (int i = 0; i < offers.length; i++) { @@ -80,6 +85,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * * @return list of available enchantment offers */ + @NotNull public EnchantmentOffer[] getOffers() { return offers; } @@ -103,11 +109,13 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java index 374b7407f4..618db8ed31 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a lingering potion applies it's effects. Happens @@ -16,7 +17,7 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl private final List affectedEntities; private boolean cancelled = false; - public AreaEffectCloudApplyEvent(final AreaEffectCloud entity, final List affectedEntities) { + public AreaEffectCloudApplyEvent(@NotNull final AreaEffectCloud entity, @NotNull final List affectedEntities) { super(entity); this.affectedEntities = affectedEntities; } @@ -32,6 +33,7 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl } @Override + @NotNull public AreaEffectCloud getEntity() { return (AreaEffectCloud) entity; } @@ -46,15 +48,18 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl * * @return the affected entity list */ + @NotNull public List getAffectedEntities() { return affectedEntities; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java index 9da222c750..5a5615d172 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Bat; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a bat attempts to sleep or wake up from its slumber. @@ -17,7 +18,7 @@ public class BatToggleSleepEvent extends EntityEvent implements Cancellable { private boolean cancel = false; private final boolean awake; - public BatToggleSleepEvent(Bat what, boolean awake) { + public BatToggleSleepEvent(@NotNull Bat what, boolean awake) { super(what); this.awake = awake; } @@ -41,11 +42,13 @@ public class BatToggleSleepEvent extends EntityEvent implements Cancellable { return cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index 20d537734e..3c48c2a3d9 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -1,7 +1,7 @@ package org.bukkit.event.entity; -import org.bukkit.Location; import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; /** * Called when a creature is spawned into a world. @@ -11,11 +11,12 @@ import org.bukkit.entity.LivingEntity; public class CreatureSpawnEvent extends EntitySpawnEvent { private final SpawnReason spawnReason; - public CreatureSpawnEvent(final LivingEntity spawnee, final SpawnReason spawnReason) { + public CreatureSpawnEvent(@NotNull final LivingEntity spawnee, @NotNull final SpawnReason spawnReason) { super(spawnee); this.spawnReason = spawnReason; } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -27,6 +28,7 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { * @return A SpawnReason value detailing the reason for the creature being * spawned */ + @NotNull public SpawnReason getSpawnReason() { return spawnReason; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java index b103a6aef2..5828a52b15 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Creeper; import org.bukkit.entity.LightningStrike; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a Creeper is struck by lightning. @@ -16,12 +18,12 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { private final PowerCause cause; private LightningStrike bolt; - public CreeperPowerEvent(final Creeper creeper, final LightningStrike bolt, final PowerCause cause) { + public CreeperPowerEvent(@NotNull final Creeper creeper, @NotNull final LightningStrike bolt, @NotNull final PowerCause cause) { this(creeper, cause); this.bolt = bolt; } - public CreeperPowerEvent(final Creeper creeper, final PowerCause cause) { + public CreeperPowerEvent(@NotNull final Creeper creeper, @NotNull final PowerCause cause) { super(creeper); this.cause = cause; } @@ -34,6 +36,7 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { canceled = cancel; } + @NotNull @Override public Creeper getEntity() { return (Creeper) entity; @@ -44,6 +47,7 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { * * @return The Entity for the lightning bolt which is striking the Creeper */ + @Nullable public LightningStrike getLightning() { return bolt; } @@ -53,15 +57,18 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { * * @return A PowerCause value detailing the cause of change in power. */ + @NotNull public PowerCause getCause() { return cause; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java index 92b9615f9e..1b654fa990 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java @@ -4,6 +4,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.entity.EnderDragon; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an EnderDragon switches controller phase. @@ -15,12 +17,13 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella private final EnderDragon.Phase currentPhase; private EnderDragon.Phase newPhase; - public EnderDragonChangePhaseEvent(EnderDragon enderDragon, EnderDragon.Phase currentPhase, EnderDragon.Phase newPhase) { + public EnderDragonChangePhaseEvent(@NotNull EnderDragon enderDragon, @Nullable EnderDragon.Phase currentPhase, @NotNull EnderDragon.Phase newPhase) { super(enderDragon); this.currentPhase = currentPhase; this.setNewPhase(newPhase); } + @NotNull @Override public EnderDragon getEntity() { return (EnderDragon) entity; @@ -32,6 +35,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella * * @return the current dragon phase */ + @Nullable public EnderDragon.Phase getCurrentPhase() { return currentPhase; } @@ -41,6 +45,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella * * @return the new dragon phase */ + @NotNull public EnderDragon.Phase getNewPhase() { return newPhase; } @@ -50,7 +55,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella * * @param newPhase the new dragon phase */ - public void setNewPhase(EnderDragon.Phase newPhase) { + public void setNewPhase(@NotNull EnderDragon.Phase newPhase) { Validate.notNull(newPhase, "New dragon phase cannot be null"); this.newPhase = newPhase; } @@ -65,11 +70,13 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java index 0c9de8e303..cd20a4aa4a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when the amount of air an entity has remaining changes. @@ -15,7 +16,7 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable { // private boolean cancelled; - public EntityAirChangeEvent(Entity what, int amount) { + public EntityAirChangeEvent(@NotNull Entity what, int amount) { super(what); this.amount = amount; } @@ -48,11 +49,13 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java index b877f1ba33..30b9bdca89 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; /** * Called when an {@link Entity} breaks a door @@ -11,10 +12,11 @@ import org.bukkit.entity.LivingEntity; * Cancelling the event will cause the event to be delayed */ public class EntityBreakDoorEvent extends EntityChangeBlockEvent { - public EntityBreakDoorEvent(final LivingEntity entity, final Block targetBlock) { + public EntityBreakDoorEvent(@NotNull final LivingEntity entity, @NotNull final Block targetBlock) { super(entity, targetBlock, Material.AIR.createBlockData()); } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java index f8b58e23d0..ded0693f90 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java @@ -5,6 +5,8 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when one Entity breeds with another Entity. @@ -21,7 +23,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { // private boolean cancel; - public EntityBreedEvent(LivingEntity child, LivingEntity mother, LivingEntity father, LivingEntity breeder, ItemStack bredWith, int experience) { + public EntityBreedEvent(@NotNull LivingEntity child, @NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable LivingEntity breeder, @Nullable ItemStack bredWith, int experience) { super(child); Validate.notNull(child, "Cannot have null child"); @@ -37,6 +39,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { setExperience(experience); } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -47,6 +50,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { * * @return The "birth" parent */ + @NotNull public LivingEntity getMother() { return mother; } @@ -56,6 +60,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { * * @return the other parent */ + @NotNull public LivingEntity getFather() { return father; } @@ -66,6 +71,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { * * @return The Entity who initiated breeding. */ + @Nullable public LivingEntity getBreeder() { return breeder; } @@ -75,6 +81,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { * * @return ItemStack used to initiate breeding. */ + @Nullable public ItemStack getBredWith() { return bredWith; } @@ -108,11 +115,13 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java index 0fa1d0ce1c..62fba99a09 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when any Entity, excluding players, changes a block. @@ -16,7 +17,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { private boolean cancel; private final BlockData to; - public EntityChangeBlockEvent(final Entity what, final Block block, final BlockData to) { + public EntityChangeBlockEvent(@NotNull final Entity what, @NotNull final Block block, @NotNull final BlockData to) { super(what); this.block = block; this.cancel = false; @@ -28,6 +29,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { * * @return the block that is changing */ + @NotNull public Block getBlock() { return block; } @@ -45,6 +47,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { * * @return the material that the block is changing into */ + @NotNull public Material getTo() { return to.getMaterial(); } @@ -54,15 +57,18 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { * * @return the data for the block that would be changed into */ + @NotNull public BlockData getBlockData() { return to; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java index c84bda9edb..5886ee448a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java @@ -2,6 +2,8 @@ package org.bukkit.event.entity; import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a block causes an entity to combust. @@ -9,7 +11,7 @@ import org.bukkit.entity.Entity; public class EntityCombustByBlockEvent extends EntityCombustEvent { private final Block combuster; - public EntityCombustByBlockEvent(final Block combuster, final Entity combustee, final int duration) { + public EntityCombustByBlockEvent(@Nullable final Block combuster, @NotNull final Entity combustee, final int duration) { super(combustee, duration); this.combuster = combuster; } @@ -21,6 +23,7 @@ public class EntityCombustByBlockEvent extends EntityCombustEvent { * * @return the Block that set the combustee alight. */ + @Nullable public Block getCombuster() { return combuster; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java index 639567bda6..0b67364e13 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; /** * Called when an entity causes another entity to combust. @@ -8,7 +9,7 @@ import org.bukkit.entity.Entity; public class EntityCombustByEntityEvent extends EntityCombustEvent { private final Entity combuster; - public EntityCombustByEntityEvent(final Entity combuster, final Entity combustee, final int duration) { + public EntityCombustByEntityEvent(@NotNull final Entity combuster, @NotNull final Entity combustee, final int duration) { super(combustee, duration); this.combuster = combuster; } @@ -18,6 +19,7 @@ public class EntityCombustByEntityEvent extends EntityCombustEvent { * * @return the Entity that set the combustee alight. */ + @NotNull public Entity getCombuster() { return combuster; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java index 43c4482917..4b4c7bb524 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity combusts. @@ -14,7 +15,7 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { private int duration; private boolean cancel; - public EntityCombustEvent(final Entity combustee, final int duration) { + public EntityCombustEvent(@NotNull final Entity combustee, final int duration) { super(combustee); this.duration = duration; this.cancel = false; @@ -48,11 +49,13 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { this.duration = duration; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java index 286c206d6a..4de0983410 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Thrown when a Living Entity creates a portal in a world. @@ -16,13 +17,14 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable private boolean cancelled = false; private PortalType type = PortalType.CUSTOM; - public EntityCreatePortalEvent(final LivingEntity what, final List blocks, final PortalType type) { + public EntityCreatePortalEvent(@NotNull final LivingEntity what, @NotNull final List blocks, @NotNull final PortalType type) { super(what); this.blocks = blocks; this.type = type; } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -33,6 +35,7 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable * * @return List of blocks that will be changed. */ + @NotNull public List getBlocks() { return blocks; } @@ -50,15 +53,18 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable * * @return Type of portal. */ + @NotNull public PortalType getPortalType() { return type; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java index 0afc9d4349..4c519eba84 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java @@ -5,6 +5,8 @@ import java.util.Map; import com.google.common.base.Function; import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an entity is damaged by a block @@ -12,12 +14,12 @@ import org.bukkit.entity.Entity; public class EntityDamageByBlockEvent extends EntityDamageEvent { private final Block damager; - public EntityDamageByBlockEvent(final Block damager, final Entity damagee, final DamageCause cause, final double damage) { + public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { super(damagee, cause, damage); this.damager = damager; } - public EntityDamageByBlockEvent(final Block damager, final Entity damagee, final DamageCause cause, final Map modifiers, final Map> modifierFunctions) { + public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { super(damagee, cause, modifiers, modifierFunctions); this.damager = damager; } @@ -27,6 +29,7 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent { * * @return Block that damaged the player */ + @Nullable public Block getDamager() { return damager; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java index 83a6bebc1a..b6e8669626 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java @@ -4,6 +4,7 @@ import java.util.Map; import com.google.common.base.Function; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; /** * Called when an entity is damaged by an entity @@ -11,12 +12,12 @@ import org.bukkit.entity.Entity; public class EntityDamageByEntityEvent extends EntityDamageEvent { private final Entity damager; - public EntityDamageByEntityEvent(final Entity damager, final Entity damagee, final DamageCause cause, final double damage) { + public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { super(damagee, cause, damage); this.damager = damager; } - public EntityDamageByEntityEvent(final Entity damager, final Entity damagee, final DamageCause cause, final Map modifiers, final Map> modifierFunctions) { + public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { super(damagee, cause, modifiers, modifierFunctions); this.damager = damager; } @@ -26,6 +27,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent { * * @return Entity that damaged the defender. */ + @NotNull public Entity getDamager() { return damager; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index 26c4c2568b..477ecfbc84 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -13,6 +13,7 @@ import org.bukkit.event.HandlerList; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.NotNull; /** * Stores data for damage events @@ -27,11 +28,11 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { private boolean cancelled; private final DamageCause cause; - public EntityDamageEvent(final Entity damagee, final DamageCause cause, final double damage) { + public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { this(damagee, cause, new EnumMap(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap>(ImmutableMap.of(DamageModifier.BASE, ZERO))); } - public EntityDamageEvent(final Entity damagee, final DamageCause cause, final Map modifiers, final Map> modifierFunctions) { + public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { super(damagee); Validate.isTrue(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing"); Validate.isTrue(!modifiers.containsKey(null), "Cannot have null DamageModifier"); @@ -60,7 +61,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * @return the original damage * @throws IllegalArgumentException if type is null */ - public double getOriginalDamage(DamageModifier type) throws IllegalArgumentException { + public double getOriginalDamage(@NotNull DamageModifier type) throws IllegalArgumentException { final Double damage = originals.get(type); if (damage != null) { return damage; @@ -82,7 +83,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * the particular DamageModifier, or to rephrase, when {@link * #isApplicable(DamageModifier)} returns false */ - public void setDamage(DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException { + public void setDamage(@NotNull DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException { if (!modifiers.containsKey(type)) { throw type == null ? new IllegalArgumentException("Cannot have null DamageModifier") : new UnsupportedOperationException(type + " is not applicable to " + getEntity()); } @@ -97,7 +98,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * @throws IllegalArgumentException if type is null * @see DamageModifier#BASE */ - public double getDamage(DamageModifier type) throws IllegalArgumentException { + public double getDamage(@NotNull DamageModifier type) throws IllegalArgumentException { Validate.notNull(type, "Cannot have null DamageModifier"); final Double damage = modifiers.get(type); return damage == null ? 0 : damage; @@ -114,7 +115,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * @return true if the modifier is supported by the caller, false otherwise * @throws IllegalArgumentException if type is null */ - public boolean isApplicable(DamageModifier type) throws IllegalArgumentException { + public boolean isApplicable(@NotNull DamageModifier type) throws IllegalArgumentException { Validate.notNull(type, "Cannot have null DamageModifier"); return modifiers.containsKey(type); } @@ -185,15 +186,18 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * * @return A DamageCause value detailing the cause of the damage. */ + @NotNull public DamageCause getCause() { return cause; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java index ab9e81fd26..a5984ab06c 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java @@ -4,6 +4,7 @@ import java.util.List; import org.bukkit.entity.LivingEntity; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Thrown whenever a LivingEntity dies @@ -13,16 +14,17 @@ public class EntityDeathEvent extends EntityEvent { private final List drops; private int dropExp = 0; - public EntityDeathEvent(final LivingEntity entity, final List drops) { + public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull final List drops) { this(entity, drops, 0); } - public EntityDeathEvent(final LivingEntity what, final List drops, final int droppedExp) { + public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull final List drops, final int droppedExp) { super(what); this.drops = drops; this.dropExp = droppedExp; } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -57,15 +59,18 @@ public class EntityDeathEvent extends EntityEvent { * * @return Items to drop when the entity dies */ + @NotNull public List getDrops() { return drops; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java index 943dea6808..3ccdcc755e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Thrown when an entity creates an item drop. @@ -14,7 +15,7 @@ public class EntityDropItemEvent extends EntityEvent implements Cancellable { private final Item drop; private boolean cancel = false; - public EntityDropItemEvent(final Entity entity, final Item drop) { + public EntityDropItemEvent(@NotNull final Entity entity, @NotNull final Item drop) { super(entity); this.drop = drop; } @@ -24,6 +25,7 @@ public class EntityDropItemEvent extends EntityEvent implements Cancellable { * * @return Item created by the entity */ + @NotNull public Item getItemDrop() { return drop; } @@ -38,11 +40,13 @@ public class EntityDropItemEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java index c9a4ab300d..e3a9e32933 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents an Entity-related event @@ -10,7 +11,7 @@ import org.bukkit.event.Event; public abstract class EntityEvent extends Event { protected Entity entity; - public EntityEvent(final Entity what) { + public EntityEvent(@NotNull final Entity what) { entity = what; } @@ -19,6 +20,7 @@ public abstract class EntityEvent extends Event { * * @return Entity who is involved in this event */ + @NotNull public Entity getEntity() { return entity; } @@ -28,6 +30,7 @@ public abstract class EntityEvent extends Event { * * @return EntityType of the Entity involved in this event */ + @NotNull public EntityType getEntityType() { return entity.getType(); } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java index 287035d112..21eb09293f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -5,6 +5,8 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -18,7 +20,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { private final List blocks; private float yield; - public EntityExplodeEvent(final Entity what, final Location location, final List blocks, final float yield) { + public EntityExplodeEvent(@NotNull final Entity what, @NotNull final Location location, @NotNull final List blocks, final float yield) { super(what); this.location = location; this.blocks = blocks; @@ -40,6 +42,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { * * @return All blown-up blocks */ + @NotNull public List blockList() { return blocks; } @@ -52,6 +55,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { * * @return The location of the explosion */ + @NotNull public Location getLocation() { return location; } @@ -74,11 +78,13 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { this.yield = yield; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java index 1c4e100355..97ef2481de 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity interacts with an object @@ -13,7 +14,7 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable { protected Block block; private boolean cancelled; - public EntityInteractEvent(final Entity entity, final Block block) { + public EntityInteractEvent(@NotNull final Entity entity, @NotNull final Block block) { super(entity); this.block = block; } @@ -31,15 +32,18 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable { * * @return the block clicked with this item. */ + @NotNull public Block getBlock() { return block; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java index 20f2d538f8..b583accbb5 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Thrown when a entity picks an item up from the ground @@ -14,12 +15,13 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { private boolean cancel = false; private final int remaining; - public EntityPickupItemEvent(final LivingEntity entity, final Item item, final int remaining) { + public EntityPickupItemEvent(@NotNull final LivingEntity entity, @NotNull final Item item, final int remaining) { super(entity); this.item = item; this.remaining = remaining; } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -30,6 +32,7 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { * * @return Item */ + @NotNull public Item getItem() { return item; } @@ -51,11 +54,13 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java index 9e911733c7..ea21069b94 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java @@ -7,6 +7,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Triggered when a entity is created in the world by a player "placing" an item @@ -27,7 +29,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { private final Block block; private final BlockFace blockFace; - public EntityPlaceEvent(final Entity entity, final Player player, final Block block, final BlockFace blockFace) { + public EntityPlaceEvent(@NotNull final Entity entity, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) { super(entity); this.player = player; this.block = block; @@ -39,6 +41,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { * * @return the player placing the entity */ + @Nullable public Player getPlayer() { return player; } @@ -48,6 +51,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { * * @return the block that the entity was placed on */ + @NotNull public Block getBlock() { return block; } @@ -57,6 +61,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { * * @return the face of the block that the entity was placed on */ + @NotNull public BlockFace getBlockFace() { return blockFace; } @@ -71,11 +76,13 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java index 87d57b0130..e949072bad 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.Location; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity comes into contact with a portal @@ -11,7 +12,7 @@ public class EntityPortalEnterEvent extends EntityEvent { private static final HandlerList handlers = new HandlerList(); private final Location location; - public EntityPortalEnterEvent(final Entity entity, final Location location) { + public EntityPortalEnterEvent(@NotNull final Entity entity, @NotNull final Location location) { super(entity); this.location = location; } @@ -21,15 +22,18 @@ public class EntityPortalEnterEvent extends EntityEvent { * * @return The portal block the entity is touching */ + @NotNull public Location getLocation() { return location; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java index 835c054822..ec759948f2 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java @@ -4,6 +4,8 @@ import org.bukkit.Location; import org.bukkit.TravelAgent; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a non-player entity is about to teleport because it is in @@ -16,7 +18,7 @@ public class EntityPortalEvent extends EntityTeleportEvent { protected boolean useTravelAgent = true; protected TravelAgent travelAgent; - public EntityPortalEvent(final Entity entity, final Location from, final Location to, final TravelAgent pta) { + public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) { super(entity, from, to); this.travelAgent = pta; } @@ -58,6 +60,7 @@ public class EntityPortalEvent extends EntityTeleportEvent { * * @return the Travel Agent used (or not) in this event */ + @NotNull public TravelAgent getPortalTravelAgent() { return this.travelAgent; } @@ -67,15 +70,17 @@ public class EntityPortalEvent extends EntityTeleportEvent { * * @param travelAgent the Travel Agent used (or not) in this event */ - public void setPortalTravelAgent(TravelAgent travelAgent) { + public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) { this.travelAgent = travelAgent; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java index 41edef6b15..f124d43f07 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Called before an entity exits a portal. @@ -16,7 +17,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { private Vector before; private Vector after; - public EntityPortalExitEvent(final Entity entity, final Location from, final Location to, final Vector before, final Vector after) { + public EntityPortalExitEvent(@NotNull final Entity entity, @NotNull final Location from, @NotNull final Location to, @NotNull final Vector before, @NotNull final Vector after) { super(entity, from, to); this.before = before; this.after = after; @@ -28,6 +29,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { * * @return velocity of entity before entering the portal */ + @NotNull public Vector getBefore() { return this.before.clone(); } @@ -38,6 +40,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { * * @return velocity of entity after exiting the portal */ + @NotNull public Vector getAfter() { return this.after.clone(); } @@ -47,15 +50,17 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { * * @param after the velocity after exiting the portal */ - public void setAfter(Vector after) { + public void setAfter(@NotNull Vector after) { this.after = after.clone(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java index 56625d517e..d5f8bde3b2 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java @@ -5,6 +5,9 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a potion effect is modified on an entity. @@ -21,7 +24,8 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable private final Action action; private boolean override; - public EntityPotionEffectEvent(LivingEntity livingEntity, PotionEffect oldEffect, PotionEffect newEffect, Cause cause, Action action, boolean override) { + @Contract("_, null, null, _, _, _ -> fail") + public EntityPotionEffectEvent(@NotNull LivingEntity livingEntity, @Nullable PotionEffect oldEffect, @Nullable PotionEffect newEffect, @NotNull Cause cause, @NotNull Action action, boolean override) { super(livingEntity); this.oldEffect = oldEffect; this.newEffect = newEffect; @@ -36,6 +40,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable * @return The old potion effect or null if the entity did not have the * changed effect type. */ + @Nullable public PotionEffect getOldEffect() { return oldEffect; } @@ -46,6 +51,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable * @return The new potion effect or null if the effect of the changed type * will be removed. */ + @Nullable public PotionEffect getNewEffect() { return newEffect; } @@ -55,6 +61,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable * * @return A Cause value why the effect has changed. */ + @NotNull public Cause getCause() { return cause; } @@ -64,6 +71,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable * * @return An action to be performed on the potion effect type. */ + @NotNull public Action getAction() { return action; } @@ -73,6 +81,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable * * @return The effect type which will be modified on the entity. */ + @NotNull public PotionEffectType getModifiedType() { return (oldEffect == null) ? ((newEffect == null) ? null : newEffect.getType()) : oldEffect.getType(); } @@ -107,11 +116,13 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java index 976b80b7e4..8feb6698f9 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores data for health-regain events @@ -13,7 +14,7 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable private double amount; private final RegainReason regainReason; - public EntityRegainHealthEvent(final Entity entity, final double amount, final RegainReason regainReason) { + public EntityRegainHealthEvent(@NotNull final Entity entity, final double amount, @NotNull final RegainReason regainReason) { super(entity); this.amount = amount; this.regainReason = regainReason; @@ -53,15 +54,18 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable * @return A RegainReason detailing the reason for the entity regaining * health */ + @NotNull public RegainReason getRegainReason() { return regainReason; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java index 17cd6657f7..fa6b6c3b04 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity dies and may have the opportunity to be resurrected. @@ -15,10 +16,11 @@ public class EntityResurrectEvent extends EntityEvent implements Cancellable { // private boolean cancelled; - public EntityResurrectEvent(LivingEntity what) { + public EntityResurrectEvent(@NotNull LivingEntity what) { super(what); } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -34,11 +36,13 @@ public class EntityResurrectEvent extends EntityEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java index f8c91a13b9..57f6203d45 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java @@ -6,6 +6,8 @@ import org.bukkit.entity.Projectile; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a LivingEntity shoots a bow firing an arrow @@ -17,13 +19,14 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { private final float force; private boolean cancelled; - public EntityShootBowEvent(final LivingEntity shooter, final ItemStack bow, final Projectile projectile, final float force) { + public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Projectile projectile, final float force) { super(shooter); this.bow = bow; this.projectile = projectile; this.force = force; } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -34,6 +37,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { * * @return the bow involved in this event */ + @Nullable public ItemStack getBow() { return bow; } @@ -43,6 +47,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { * * @return the launched projectile */ + @NotNull public Entity getProjectile() { return projectile; } @@ -52,7 +57,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { * * @param projectile the new projectile */ - public void setProjectile(Entity projectile) { + public void setProjectile(@NotNull Entity projectile) { this.projectile = projectile; } @@ -73,11 +78,13 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java index 73ea074cd3..961ee51134 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity is spawned into a world. @@ -15,7 +16,7 @@ public class EntitySpawnEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean canceled; - public EntitySpawnEvent(final Entity spawnee) { + public EntitySpawnEvent(@NotNull final Entity spawnee) { super(spawnee); } @@ -34,15 +35,18 @@ public class EntitySpawnEvent extends EntityEvent implements Cancellable { * * @return The location at which the entity is spawning */ + @NotNull public Location getLocation() { return getEntity().getLocation(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java index f105817a97..0698fa6939 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Thrown when a LivingEntity is tamed @@ -13,11 +14,12 @@ public class EntityTameEvent extends EntityEvent implements Cancellable { private boolean cancelled; private final AnimalTamer owner; - public EntityTameEvent(final LivingEntity entity, final AnimalTamer owner) { + public EntityTameEvent(@NotNull final LivingEntity entity, @NotNull final AnimalTamer owner) { super(entity); this.owner = owner; } + @NotNull @Override public LivingEntity getEntity() { return (LivingEntity) entity; @@ -36,15 +38,18 @@ public class EntityTameEvent extends EntityEvent implements Cancellable { * * @return the owning AnimalTamer */ + @NotNull public AnimalTamer getOwner() { return owner; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java index 9fe25715ef..37d0ffa1b7 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java @@ -3,6 +3,8 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a creature targets or untargets another entity @@ -13,7 +15,7 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { private Entity target; private final TargetReason reason; - public EntityTargetEvent(final Entity entity, final Entity target, final TargetReason reason) { + public EntityTargetEvent(@NotNull final Entity entity, @Nullable final Entity target, @NotNull final TargetReason reason) { super(entity); this.target = target; this.reason = reason; @@ -32,6 +34,7 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { * * @return The reason */ + @NotNull public TargetReason getReason() { return reason; } @@ -44,6 +47,7 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { * * @return The entity */ + @Nullable public Entity getTarget() { return target; } @@ -60,15 +64,17 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { * * @param target The entity to target */ - public void setTarget(Entity target) { + public void setTarget(@Nullable Entity target) { this.target = target; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java index cd9aea1cf2..f309986f36 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java @@ -2,16 +2,19 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an Entity targets a {@link LivingEntity} and can only target * LivingEntity's. */ public class EntityTargetLivingEntityEvent extends EntityTargetEvent{ - public EntityTargetLivingEntityEvent(final Entity entity, final LivingEntity target, final TargetReason reason) { + public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @Nullable final TargetReason reason) { super(entity, target, reason); } + @Nullable public LivingEntity getTarget() { return (LivingEntity) super.getTarget(); } @@ -26,7 +29,7 @@ public class EntityTargetLivingEntityEvent extends EntityTargetEvent{ * * @param target The entity to target */ - public void setTarget(Entity target) { + public void setTarget(@Nullable Entity target) { if (target == null || target instanceof LivingEntity) { super.setTarget(target); } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java index 9645b4bb9a..310259fe89 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java @@ -4,6 +4,8 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Thrown when a non-player entity is teleported from one location to another. @@ -17,7 +19,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { private Location from; private Location to; - public EntityTeleportEvent(Entity what, Location from, Location to) { + public EntityTeleportEvent(@NotNull Entity what, @NotNull Location from, @Nullable Location to) { super(what); this.from = from; this.to = to; @@ -37,6 +39,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { * * @return Location this entity moved from */ + @NotNull public Location getFrom() { return from; } @@ -46,7 +49,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { * * @param from New location this entity moved from */ - public void setFrom(Location from) { + public void setFrom(@NotNull Location from) { this.from = from; } @@ -55,6 +58,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { * * @return Location the entity moved to */ + @Nullable public Location getTo() { return to; } @@ -64,15 +68,17 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { * * @param to New Location this entity moved to */ - public void setTo(Location to) { + public void setTo(@Nullable Location to) { this.to = to; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java index 67fbf8fb13..1478cdbb42 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Sent when an entity's gliding status is toggled with an Elytra. @@ -19,7 +20,7 @@ public class EntityToggleGlideEvent extends EntityEvent implements Cancellable { private boolean cancel = false; private final boolean isGliding; - public EntityToggleGlideEvent(LivingEntity who, final boolean isGliding) { + public EntityToggleGlideEvent(@NotNull LivingEntity who, final boolean isGliding) { super(who); this.isGliding = isGliding; } @@ -38,11 +39,13 @@ public class EntityToggleGlideEvent extends EntityEvent implements Cancellable { return isGliding; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java index 87b110449a..7b3fc4cadb 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Sent when an entity's swimming status is toggled. @@ -13,7 +14,7 @@ public class EntityToggleSwimEvent extends EntityEvent implements Cancellable { private boolean cancel = false; private final boolean isSwimming; - public EntityToggleSwimEvent(LivingEntity who, final boolean isSwimming) { + public EntityToggleSwimEvent(@NotNull LivingEntity who, final boolean isSwimming) { super(who); this.isSwimming = isSwimming; } @@ -32,11 +33,13 @@ public class EntityToggleSwimEvent extends EntityEvent implements Cancellable { return isSwimming; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java index f2a9b33ec8..1370380ae2 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java @@ -5,6 +5,7 @@ import java.util.List; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity is about to be replaced by another entity. @@ -17,7 +18,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { private final List convertedList; private final TransformReason transformReason; - public EntityTransformEvent(Entity original, List convertedList, TransformReason transformReason) { + public EntityTransformEvent(@NotNull Entity original, @NotNull List convertedList, @NotNull TransformReason transformReason) { super(original); this.convertedList = Collections.unmodifiableList(convertedList); this.converted = convertedList.get(0); @@ -32,6 +33,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { * @return The transformed entity. * @see #getTransformedEntities() */ + @NotNull public Entity getTransformedEntity() { return converted; } @@ -41,6 +43,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { * * @return The transformed entities. */ + @NotNull public List getTransformedEntities() { return convertedList; } @@ -50,6 +53,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { * * @return The reason for conversion that has occurred. */ + @NotNull public TransformReason getTransformReason() { return transformReason; } @@ -64,11 +68,13 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java index da7e46c329..a33986a0c4 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called immediately prior to an entity being unleashed. @@ -10,7 +11,7 @@ public class EntityUnleashEvent extends EntityEvent { private static final HandlerList handlers = new HandlerList(); private final UnleashReason reason; - public EntityUnleashEvent(Entity entity, UnleashReason reason) { + public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason) { super(entity); this.reason = reason; } @@ -20,15 +21,18 @@ public class EntityUnleashEvent extends EntityEvent { * * @return The reason */ + @NotNull public UnleashReason getReason() { return reason; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java index 4f64424e5a..6417c2fd47 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.ThrownExpBottle; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a ThrownExpBottle hits and releases experience. @@ -11,11 +12,12 @@ public class ExpBottleEvent extends ProjectileHitEvent { private int exp; private boolean showEffect = true; - public ExpBottleEvent(final ThrownExpBottle bottle, final int exp) { + public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, final int exp) { super(bottle); this.exp = exp; } + @NotNull @Override public ThrownExpBottle getEntity() { return (ThrownExpBottle) entity; @@ -64,11 +66,13 @@ public class ExpBottleEvent extends ProjectileHitEvent { this.exp = exp; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java index 7ca6a5560a..31fdb30144 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Explosive; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when an entity has made a decision to explode. @@ -14,14 +15,14 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { private float radius; private boolean fire; - public ExplosionPrimeEvent(final Entity what, final float radius, final boolean fire) { + public ExplosionPrimeEvent(@NotNull final Entity what, final float radius, final boolean fire) { super(what); this.cancel = false; this.radius = radius; this.fire = fire; } - public ExplosionPrimeEvent(final Explosive explosive) { + public ExplosionPrimeEvent(@NotNull final Explosive explosive) { this(explosive, explosive.getYield(), explosive.isIncendiary()); } @@ -69,11 +70,13 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { this.fire = fire; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java index 81b1c483e0..51ad0e6bfc 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Firework; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a firework explodes. @@ -12,7 +13,7 @@ public class FireworkExplodeEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel; - public FireworkExplodeEvent(final Firework what) { + public FireworkExplodeEvent(@NotNull final Firework what) { super(what); } @@ -33,16 +34,19 @@ public class FireworkExplodeEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public Firework getEntity() { return (Firework) super.getEntity(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java index 1feb0e8f89..f5b9906124 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a human entity's food level changes @@ -12,11 +13,12 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { private boolean cancel = false; private int level; - public FoodLevelChangeEvent(final HumanEntity what, final int level) { + public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) { super(what); this.level = level; } + @NotNull @Override public HumanEntity getEntity() { return (HumanEntity) entity; @@ -55,11 +57,13 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java index 1794913683..74588fc8f7 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.entity.AbstractHorse; +import org.jetbrains.annotations.NotNull; /** * Called when a horse jumps. @@ -12,7 +13,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { private boolean cancelled; private float power; - public HorseJumpEvent(final AbstractHorse horse, final float power) { + public HorseJumpEvent(@NotNull final AbstractHorse horse, final float power) { super(horse); this.power = power; } @@ -29,6 +30,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public AbstractHorse getEntity() { return (AbstractHorse) entity; @@ -73,11 +75,13 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { this.power = power; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java index 356e4bd91e..93e6f5ee7f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Item; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called when a {@link org.bukkit.entity.Item} is removed from @@ -17,7 +18,7 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable { private boolean canceled; private final Location location; - public ItemDespawnEvent(final Item despawnee, final Location loc) { + public ItemDespawnEvent(@NotNull final Item despawnee, @NotNull final Location loc) { super(despawnee); location = loc; } @@ -30,6 +31,7 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable { canceled = cancel; } + @NotNull @Override public Item getEntity() { return (Item) entity; @@ -40,15 +42,18 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable { * * @return The location at which the item is despawning */ + @NotNull public Location getLocation() { return location; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java index dadf221049..e378cc29b4 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Item; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class ItemMergeEvent extends EntityEvent implements Cancellable { @@ -10,7 +11,7 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable { private boolean cancelled; private final Item target; - public ItemMergeEvent(Item item, Item target) { + public ItemMergeEvent(@NotNull Item item, @NotNull Item target) { super(item); this.target = target; } @@ -25,6 +26,7 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public Item getEntity() { return (Item) entity; @@ -35,15 +37,18 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable { * * @return The Item being merged with */ + @NotNull public Item getTarget() { return target; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java index 1435d3e4b2..657589da85 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java @@ -1,7 +1,9 @@ package org.bukkit.event.entity; import org.bukkit.Location; +import org.bukkit.UndefinedNullability; import org.bukkit.entity.Item; +import org.jetbrains.annotations.NotNull; /** * Called when an item is spawned into a world @@ -9,14 +11,15 @@ import org.bukkit.entity.Item; public class ItemSpawnEvent extends EntitySpawnEvent { @Deprecated - public ItemSpawnEvent(final Item spawnee, final Location loc) { + public ItemSpawnEvent(@NotNull final Item spawnee, final Location loc) { this(spawnee); } - public ItemSpawnEvent(final Item spawnee) { + public ItemSpawnEvent(@NotNull final Item spawnee) { super(spawnee); } + @NotNull @Override public Item getEntity() { return (Item) entity; diff --git a/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java index dda37d6bf3..31606399a9 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a splash potion hits an area @@ -14,11 +15,12 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca private boolean cancelled; private final AreaEffectCloud entity; - public LingeringPotionSplashEvent(final ThrownPotion potion, final AreaEffectCloud entity) { + public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) { super(potion); this.entity = entity; } + @NotNull @Override public LingeringPotion getEntity() { return (LingeringPotion) super.getEntity(); @@ -29,6 +31,7 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca * * @return The spawned AreaEffectCloud */ + @NotNull public AreaEffectCloud getAreaEffectCloud() { return entity; } @@ -41,11 +44,13 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java index c1d4b30a92..0074423fd3 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.PigZombie; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores data for pigs being zapped @@ -17,7 +18,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { private final PigZombie pigzombie; private final LightningStrike bolt; - public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) { + public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) { super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING); this.bolt = bolt; this.pigzombie = pigzombie; @@ -31,6 +32,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { canceled = cancel; } + @NotNull @Override public Pig getEntity() { return (Pig) entity; @@ -41,6 +43,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { * * @return lightning entity */ + @NotNull public LightningStrike getLightning() { return bolt; } @@ -52,16 +55,19 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { * @return resulting entity * @deprecated use {@link EntityTransformEvent#getTransformedEntity()} */ + @NotNull @Deprecated public PigZombie getPigZombie() { return pigzombie; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java index 7c96463f9b..bb4f13bbb2 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.PigZombie; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a Pig Zombie is angered by another entity. @@ -17,7 +19,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { private final Entity target; private int newAnger; - public PigZombieAngerEvent(final PigZombie pigZombie, final Entity target, final int newAnger) { + public PigZombieAngerEvent(@NotNull final PigZombie pigZombie, @Nullable final Entity target, final int newAnger) { super(pigZombie); this.target = target; this.newAnger = newAnger; @@ -28,6 +30,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { * * @return triggering entity, or null */ + @Nullable public Entity getTarget() { return target; } @@ -52,6 +55,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { this.newAnger = newAnger; } + @NotNull @Override public PigZombie getEntity() { return (PigZombie) entity; @@ -67,11 +71,13 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { canceled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java index aad0354952..5b0ef1eb16 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -4,6 +4,8 @@ import java.util.List; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Thrown whenever a {@link Player} dies @@ -16,15 +18,15 @@ public class PlayerDeathEvent extends EntityDeathEvent { private boolean keepLevel = false; private boolean keepInventory = false; - public PlayerDeathEvent(final Player player, final List drops, final int droppedExp, final String deathMessage) { + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { this(player, drops, droppedExp, 0, deathMessage); } - public PlayerDeathEvent(final Player player, final List drops, final int droppedExp, final int newExp, final String deathMessage) { + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, @Nullable final String deathMessage) { this(player, drops, droppedExp, newExp, 0, 0, deathMessage); } - public PlayerDeathEvent(final Player player, final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final String deathMessage) { + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { super(player, drops, droppedExp); this.newExp = newExp; this.newTotalExp = newTotalExp; @@ -32,6 +34,7 @@ public class PlayerDeathEvent extends EntityDeathEvent { this.deathMessage = deathMessage; } + @NotNull @Override public Player getEntity() { return (Player) entity; @@ -42,7 +45,7 @@ public class PlayerDeathEvent extends EntityDeathEvent { * * @param deathMessage Message to appear to other players on the server. */ - public void setDeathMessage(String deathMessage) { + public void setDeathMessage(@Nullable String deathMessage) { this.deathMessage = deathMessage; } @@ -51,6 +54,7 @@ public class PlayerDeathEvent extends EntityDeathEvent { * * @return Message to appear to other players on the server. */ + @Nullable public String getDeathMessage() { return deathMessage; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java index 74d458a81e..e087e1418b 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called immediately prior to a creature being leashed by a player. @@ -16,7 +17,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { private boolean cancelled = false; private final Player player; - public PlayerLeashEntityEvent(Entity what, Entity leashHolder, Player leasher) { + public PlayerLeashEntityEvent(@NotNull Entity what, @NotNull Entity leashHolder, @NotNull Player leasher) { this.leashHolder = leashHolder; this.entity = what; this.player = leasher; @@ -27,6 +28,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { * * @return The leash holder */ + @NotNull public Entity getLeashHolder() { return leashHolder; } @@ -36,6 +38,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { * * @return The entity */ + @NotNull public Entity getEntity() { return entity; } @@ -45,15 +48,18 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { * * @return Player who is involved in this event */ + @NotNull public final Player getPlayer() { return player; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java index b9840de17f..45d224ec9b 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java @@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a splash potion hits an area @@ -18,12 +19,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable private boolean cancelled; private final Map affectedEntities; - public PotionSplashEvent(final ThrownPotion potion, final Map affectedEntities) { + public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map affectedEntities) { super(potion); this.affectedEntities = affectedEntities; } + @NotNull @Override public ThrownPotion getEntity() { return (ThrownPotion) entity; @@ -34,6 +36,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable * * @return The thrown potion entity */ + @NotNull public ThrownPotion getPotion() { return (ThrownPotion) getEntity(); } @@ -43,6 +46,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable * * @return A fresh copy of the affected entity list */ + @NotNull public Collection getAffectedEntities() { return new ArrayList(affectedEntities.keySet()); } @@ -55,7 +59,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable * @return intensity relative to maximum effect; 0.0: not affected; 1.0: * fully hit by potion effects */ - public double getIntensity(LivingEntity entity) { + public double getIntensity(@NotNull LivingEntity entity) { Double intensity = affectedEntities.get(entity); return intensity != null ? intensity : 0.0; } @@ -66,7 +70,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable * @param entity For which entity to define a new intensity * @param intensity relative to maximum effect */ - public void setIntensity(LivingEntity entity, double intensity) { + public void setIntensity(@NotNull LivingEntity entity, double intensity) { Validate.notNull(entity, "You must specify a valid entity."); if (intensity <= 0.0) { affectedEntities.remove(entity); @@ -83,11 +87,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java index 4b29753d75..809c1098c1 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java @@ -5,6 +5,8 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a projectile hits an object @@ -15,29 +17,30 @@ public class ProjectileHitEvent extends EntityEvent { private final Block hitBlock; private final BlockFace hitFace; - public ProjectileHitEvent(final Projectile projectile) { + public ProjectileHitEvent(@NotNull final Projectile projectile) { this(projectile, null, null); } - public ProjectileHitEvent(final Projectile projectile, Entity hitEntity) { + public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity) { this(projectile, hitEntity, null); } - public ProjectileHitEvent(final Projectile projectile, Block hitBlock) { + public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Block hitBlock) { this(projectile, null, hitBlock); } - public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock) { + public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity, @Nullable Block hitBlock) { this(projectile, hitEntity, hitBlock, null); } - public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock, BlockFace hitFace) { + public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace) { super(projectile); this.hitEntity = hitEntity; this.hitBlock = hitBlock; this.hitFace = hitFace; } + @NotNull @Override public Projectile getEntity() { return (Projectile) entity; @@ -48,6 +51,7 @@ public class ProjectileHitEvent extends EntityEvent { * * @return hit block or else null */ + @Nullable public Block getHitBlock() { return hitBlock; } @@ -58,6 +62,7 @@ public class ProjectileHitEvent extends EntityEvent { * * @return hit face or else null */ + @Nullable public BlockFace getHitBlockFace() { return hitFace; } @@ -67,15 +72,18 @@ public class ProjectileHitEvent extends EntityEvent { * * @return hit entity or else null */ + @Nullable public Entity getHitEntity() { return hitEntity; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java index 1d4c07eb5e..f7a4bc4bd8 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.NotNull; /** * Called when a projectile is launched. @@ -10,7 +11,7 @@ import org.bukkit.event.Cancellable; public class ProjectileLaunchEvent extends EntitySpawnEvent implements Cancellable { private boolean cancelled; - public ProjectileLaunchEvent(Entity what) { + public ProjectileLaunchEvent(@NotNull Entity what) { super(what); } @@ -22,6 +23,7 @@ public class ProjectileLaunchEvent extends EntitySpawnEvent implements Cancellab cancelled = cancel; } + @NotNull @Override public Projectile getEntity() { return (Projectile) entity; diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java index 4c17fea3e9..60c648ee6a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java @@ -4,6 +4,7 @@ import org.bukkit.DyeColor; import org.bukkit.entity.Sheep; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a sheep's wool is dyed @@ -13,7 +14,7 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { private boolean cancel; private DyeColor color; - public SheepDyeWoolEvent(final Sheep sheep, final DyeColor color) { + public SheepDyeWoolEvent(@NotNull final Sheep sheep, @NotNull final DyeColor color) { super(sheep); this.cancel = false; this.color = color; @@ -27,6 +28,7 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public Sheep getEntity() { return (Sheep) entity; @@ -37,6 +39,7 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { * * @return the DyeColor the sheep is being dyed */ + @NotNull public DyeColor getColor() { return color; } @@ -46,15 +49,17 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { * * @param color the DyeColor the sheep will be dyed */ - public void setColor(DyeColor color) { + public void setColor(@NotNull DyeColor color) { this.color = color; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java index e836f7b328..428ca4c9c2 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Sheep; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a sheep regrows its wool @@ -11,7 +12,7 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel; - public SheepRegrowWoolEvent(final Sheep sheep) { + public SheepRegrowWoolEvent(@NotNull final Sheep sheep) { super(sheep); this.cancel = false; } @@ -24,16 +25,19 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public Sheep getEntity() { return (Sheep) entity; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java index 4b9958717f..6e634dd7fe 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Slime; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a Slime splits into smaller Slimes upon death @@ -12,7 +13,7 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { private boolean cancel = false; private int count; - public SlimeSplitEvent(final Slime slime, final int count) { + public SlimeSplitEvent(@NotNull final Slime slime, final int count) { super(slime); this.count = count; } @@ -25,6 +26,7 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public Slime getEntity() { return (Slime) entity; @@ -48,11 +50,13 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { this.count = count; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java index a63271ebb6..95740eb7f3 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Villager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; +import org.jetbrains.annotations.NotNull; /** * Called whenever a villager acquires a new trade. @@ -15,7 +16,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl // private MerchantRecipe recipe; - public VillagerAcquireTradeEvent(Villager what, MerchantRecipe recipe) { + public VillagerAcquireTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe) { super(what); this.recipe = recipe; } @@ -25,6 +26,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl * * @return the new recipe */ + @NotNull public MerchantRecipe getRecipe() { return recipe; } @@ -34,7 +36,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl * * @param recipe the new recipe */ - public void setRecipe(MerchantRecipe recipe) { + public void setRecipe(@NotNull MerchantRecipe recipe) { this.recipe = recipe; } @@ -48,16 +50,19 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl this.cancelled = cancel; } + @NotNull @Override public Villager getEntity() { return (Villager) super.getEntity(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java index 1bb39ca601..738469dd3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Villager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; +import org.jetbrains.annotations.NotNull; /** * Called when a villager's trade's maximum uses is increased, due to a player's @@ -19,7 +20,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella private MerchantRecipe recipe; private int bonus; - public VillagerReplenishTradeEvent(Villager what, MerchantRecipe recipe, int bonus) { + public VillagerReplenishTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe, int bonus) { super(what); this.recipe = recipe; this.bonus = bonus; @@ -30,6 +31,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella * * @return the replenished recipe */ + @NotNull public MerchantRecipe getRecipe() { return recipe; } @@ -39,7 +41,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella * * @param recipe the replenished recipe */ - public void setRecipe(MerchantRecipe recipe) { + public void setRecipe(@NotNull MerchantRecipe recipe) { this.recipe = recipe; } @@ -73,16 +75,19 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella this.cancelled = cancel; } + @NotNull @Override public Villager getEntity() { return (Villager) super.getEntity(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java index d371168792..68517811f6 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java @@ -2,6 +2,8 @@ package org.bukkit.event.hanging; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Triggered when a hanging entity is removed by an entity @@ -9,20 +11,22 @@ import org.bukkit.entity.Hanging; public class HangingBreakByEntityEvent extends HangingBreakEvent { private final Entity remover; - public HangingBreakByEntityEvent(final Hanging hanging, final Entity remover) { + public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @Nullable final Entity remover) { this(hanging, remover, HangingBreakEvent.RemoveCause.ENTITY); } - public HangingBreakByEntityEvent(final Hanging hanging, final Entity remover, final HangingBreakEvent.RemoveCause cause) { + public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @Nullable final Entity remover, @NotNull final HangingBreakEvent.RemoveCause cause) { super(hanging, cause); this.remover = remover; } /** - * Gets the entity that removed the hanging entity + * Gets the entity that removed the hanging entity. + * May be null, for example when broken by an explosion. * * @return the entity that removed the hanging entity */ + @Nullable public Entity getRemover() { return remover; } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java index 87bbdcbaca..8c43c890e0 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.hanging; import org.bukkit.entity.Hanging; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Triggered when a hanging entity is removed @@ -12,7 +13,7 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { private boolean cancelled; private final HangingBreakEvent.RemoveCause cause; - public HangingBreakEvent(final Hanging hanging, final HangingBreakEvent.RemoveCause cause) { + public HangingBreakEvent(@NotNull final Hanging hanging, @NotNull final HangingBreakEvent.RemoveCause cause) { super(hanging); this.cause = cause; } @@ -22,6 +23,7 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { * * @return the RemoveCause for the hanging entity's removal */ + @NotNull public HangingBreakEvent.RemoveCause getCause() { return cause; } @@ -60,11 +62,13 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { DEFAULT, } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java index b370afe70b..f01a1a0f04 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.hanging; import org.bukkit.entity.Hanging; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents a hanging entity-related event. @@ -9,7 +10,7 @@ import org.bukkit.event.Event; public abstract class HangingEvent extends Event { protected Hanging hanging; - protected HangingEvent(final Hanging painting) { + protected HangingEvent(@NotNull final Hanging painting) { this.hanging = painting; } @@ -18,6 +19,7 @@ public abstract class HangingEvent extends Event { * * @return the hanging entity */ + @NotNull public Hanging getEntity() { return hanging; } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java index b511c5555c..8ce33024fa 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java @@ -6,6 +6,8 @@ import org.bukkit.entity.Hanging; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Triggered when a hanging entity is created in the world @@ -17,7 +19,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { private final Block block; private final BlockFace blockFace; - public HangingPlaceEvent(final Hanging hanging, final Player player, final Block block, final BlockFace blockFace) { + public HangingPlaceEvent(@NotNull final Hanging hanging, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) { super(hanging); this.player = player; this.block = block; @@ -29,6 +31,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { * * @return the player placing the hanging entity */ + @Nullable public Player getPlayer() { return player; } @@ -38,6 +41,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { * * @return the block that the hanging entity was placed on */ + @NotNull public Block getBlock() { return block; } @@ -47,6 +51,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { * * @return the face of the block that the hanging entity was placed on */ + @NotNull public BlockFace getBlockFace() { return blockFace; } @@ -59,11 +64,13 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java index e3df5bb5fd..140fc92081 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.BrewerInventory; +import org.jetbrains.annotations.NotNull; /** * Called when the brewing of the contents inside the Brewing Stand is @@ -16,7 +17,7 @@ public class BrewEvent extends BlockEvent implements Cancellable { private int fuelLevel; private boolean cancelled; - public BrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) { + public BrewEvent(@NotNull Block brewer, @NotNull BrewerInventory contents, int fuelLevel) { super(brewer); this.contents = contents; this.fuelLevel = fuelLevel; @@ -27,6 +28,7 @@ public class BrewEvent extends BlockEvent implements Cancellable { * * @return the contents */ + @NotNull public BrewerInventory getContents() { return contents; } @@ -48,11 +50,13 @@ public class BrewEvent extends BlockEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java index 7e8ff9c352..633ec51871 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when an ItemStack is about to increase the fuel level of a brewing @@ -18,7 +19,7 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { private boolean cancelled; private boolean consuming = true; - public BrewingStandFuelEvent(Block brewingStand, ItemStack fuel, int fuelPower) { + public BrewingStandFuelEvent(@NotNull Block brewingStand, @NotNull ItemStack fuel, int fuelPower) { super(brewingStand); this.fuel = fuel; this.fuelPower = fuelPower; @@ -29,6 +30,7 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { * * @return the fuel ItemStack */ + @NotNull public ItemStack getFuel() { return fuel; } @@ -81,11 +83,13 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java index dafaf41e34..cab13877fb 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java @@ -4,6 +4,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.Recipe; +import org.jetbrains.annotations.NotNull; /** * Called when the recipe of an Item is completed inside a crafting matrix. @@ -11,12 +12,12 @@ import org.bukkit.inventory.Recipe; public class CraftItemEvent extends InventoryClickEvent { private Recipe recipe; - public CraftItemEvent(Recipe recipe, InventoryView what, SlotType type, int slot, ClickType click, InventoryAction action) { + public CraftItemEvent(@NotNull Recipe recipe, @NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { super(what, type, slot, click, action); this.recipe = recipe; } - public CraftItemEvent(Recipe recipe, InventoryView what, SlotType type, int slot, ClickType click, InventoryAction action, int key) { + public CraftItemEvent(@NotNull Recipe recipe, @NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { super(what, type, slot, click, action, key); this.recipe = recipe; } @@ -24,10 +25,12 @@ public class CraftItemEvent extends InventoryClickEvent { /** * @return A copy of the current recipe on the crafting matrix. */ + @NotNull public Recipe getRecipe() { return recipe; } + @NotNull @Override public CraftingInventory getInventory() { return (CraftingInventory) super.getInventory(); diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java index 7cc77392a6..46a67e6711 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when an ItemStack is successfully burned as fuel in a furnace. @@ -16,7 +17,7 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { private boolean cancelled; private boolean burning; - public FurnaceBurnEvent(final Block furnace, final ItemStack fuel, final int burnTime) { + public FurnaceBurnEvent(@NotNull final Block furnace, @NotNull final ItemStack fuel, final int burnTime) { super(furnace); this.fuel = fuel; this.burnTime = burnTime; @@ -29,6 +30,7 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { * * @return the fuel ItemStack */ + @NotNull public ItemStack getFuel() { return fuel; } @@ -77,11 +79,13 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java index b7381fa159..020739697a 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockExpEvent; +import org.jetbrains.annotations.NotNull; /** * This event is called when a player takes items out of the furnace @@ -13,7 +14,7 @@ public class FurnaceExtractEvent extends BlockExpEvent { private final Material itemType; private final int itemAmount; - public FurnaceExtractEvent(Player player, Block block, Material itemType, int itemAmount, int exp) { + public FurnaceExtractEvent(@NotNull Player player, @NotNull Block block, @NotNull Material itemType, int itemAmount, int exp) { super(block, exp); this.player = player; this.itemType = itemType; @@ -25,6 +26,7 @@ public class FurnaceExtractEvent extends BlockExpEvent { * * @return the relevant player */ + @NotNull public Player getPlayer() { return player; } @@ -34,6 +36,7 @@ public class FurnaceExtractEvent extends BlockExpEvent { * * @return the material of the item */ + @NotNull public Material getItemType() { return itemType; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java index 5ad317962e..98196837b5 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when an ItemStack is successfully smelted in a furnace. @@ -15,7 +16,7 @@ public class FurnaceSmeltEvent extends BlockEvent implements Cancellable { private ItemStack result; private boolean cancelled; - public FurnaceSmeltEvent(final Block furnace, final ItemStack source, final ItemStack result) { + public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result) { super(furnace); this.source = source; this.result = result; @@ -27,6 +28,7 @@ public class FurnaceSmeltEvent extends BlockEvent implements Cancellable { * * @return smelting source ItemStack */ + @NotNull public ItemStack getSource() { return source; } @@ -36,6 +38,7 @@ public class FurnaceSmeltEvent extends BlockEvent implements Cancellable { * * @return smelting result ItemStack */ + @NotNull public ItemStack getResult() { return result; } @@ -45,7 +48,7 @@ public class FurnaceSmeltEvent extends BlockEvent implements Cancellable { * * @param result new result ItemStack */ - public void setResult(ItemStack result) { + public void setResult(@NotNull ItemStack result) { this.result = result; } @@ -57,11 +60,13 @@ public class FurnaceSmeltEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java index a040e29b8f..5aec15a903 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java @@ -10,6 +10,8 @@ import org.bukkit.Location; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This event is called when a player clicks a slot in an inventory. @@ -53,7 +55,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { private ItemStack current = null; private int hotbarKey = -1; - public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) { + public InventoryClickEvent(@NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { super(view); this.slot_type = type; this.rawSlot = slot; @@ -62,7 +64,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { this.action = action; } - public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action, int key) { + public InventoryClickEvent(@NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { this(view, type, slot, click, action); this.hotbarKey = key; } @@ -72,6 +74,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @return the slot type */ + @NotNull public SlotType getSlotType() { return slot_type; } @@ -81,6 +84,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @return the cursor ItemStack */ + @Nullable public ItemStack getCursor() { return getView().getCursor(); } @@ -90,6 +94,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @return the item in the clicked */ + @Nullable public ItemStack getCurrentItem() { if (slot_type == SlotType.OUTSIDE) { return current; @@ -140,7 +145,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * make unexpected changes in the behavior of the clicked Inventory. */ @Deprecated - public void setCursor(ItemStack stack) { + public void setCursor(@Nullable ItemStack stack) { getView().setCursor(stack); } @@ -149,7 +154,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @param stack the item to be placed in the current slot */ - public void setCurrentItem(ItemStack stack) { + public void setCurrentItem(@Nullable ItemStack stack) { if (slot_type == SlotType.OUTSIDE) { current = stack; } else { @@ -163,6 +168,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * @see InventoryView#getInventory(int) * @return inventory, or null if clicked outside */ + @Nullable public Inventory getClickedInventory() { return getView().getInventory(rawSlot); } @@ -208,6 +214,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @return the InventoryAction that triggered this event. */ + @NotNull public InventoryAction getAction() { return action; } @@ -219,15 +226,18 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @return the type of inventory click */ + @NotNull public ClickType getClick() { return click; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java index 19889b278a..5861247c1b 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java @@ -4,6 +4,7 @@ package org.bukkit.event.inventory; import org.bukkit.entity.HumanEntity; import org.bukkit.event.HandlerList; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.NotNull; /** * Represents a player related inventory event @@ -11,7 +12,7 @@ import org.bukkit.inventory.InventoryView; public class InventoryCloseEvent extends InventoryEvent { private static final HandlerList handlers = new HandlerList(); - public InventoryCloseEvent(InventoryView transaction) { + public InventoryCloseEvent(@NotNull InventoryView transaction) { super(transaction); } @@ -20,15 +21,18 @@ public class InventoryCloseEvent extends InventoryEvent { * * @return Player who is involved in this event */ + @NotNull public final HumanEntity getPlayer() { return transaction.getPlayer(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java index da7dffc06e..bc1e13b761 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.inventory; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * This event is called when a player in creative mode puts down or picks up @@ -12,16 +13,17 @@ import org.bukkit.inventory.ItemStack; public class InventoryCreativeEvent extends InventoryClickEvent { private ItemStack item; - public InventoryCreativeEvent(InventoryView what, SlotType type, int slot, ItemStack newItem) { + public InventoryCreativeEvent(@NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ItemStack newItem) { super(what, type, slot, ClickType.CREATIVE, InventoryAction.PLACE_ALL); this.item = newItem; } + @NotNull public ItemStack getCursor() { return item; } - public void setCursor(ItemStack item) { + public void setCursor(@NotNull ItemStack item) { this.item = item; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java index e7e54a75ff..1716369a77 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java @@ -16,6 +16,8 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; import com.google.common.collect.ImmutableSet; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This event is called when the player drags an item in their cursor across @@ -62,7 +64,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { private final ItemStack oldCursor; private ItemStack newCursor; - public InventoryDragEvent(InventoryView what, ItemStack newCursor, ItemStack oldCursor, boolean right, Map slots) { + public InventoryDragEvent(@NotNull InventoryView what, @Nullable ItemStack newCursor, @NotNull ItemStack oldCursor, boolean right, @NotNull Map slots) { super(what); Validate.notNull(oldCursor); @@ -84,6 +86,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { * * @return map from raw slot id to new ItemStack */ + @NotNull public Map getNewItems() { return Collections.unmodifiableMap(addedItems); } @@ -93,6 +96,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { * * @return list of raw slot ids, suitable for getView().getItem(int) */ + @NotNull public Set getRawSlots() { return addedItems.keySet(); } @@ -103,6 +107,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { * @return list of converted slot ids, suitable for {@link * org.bukkit.inventory.Inventory#getItem(int)}. */ + @NotNull public Set getInventorySlots() { return containerSlots; } @@ -113,6 +118,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { * * @return the result cursor */ + @Nullable public ItemStack getCursor() { return newCursor; } @@ -126,7 +132,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { * * @param newCursor the new cursor ItemStack */ - public void setCursor(ItemStack newCursor) { + public void setCursor(@Nullable ItemStack newCursor) { this.newCursor = newCursor; } @@ -136,6 +142,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { * * @return the original cursor */ + @NotNull public ItemStack getOldCursor() { return oldCursor.clone(); } @@ -149,15 +156,18 @@ public class InventoryDragEvent extends InventoryInteractEvent { * * @return the DragType of this InventoryDragEvent */ + @NotNull public DragType getType() { return type; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java index 973c392e48..cc534420d7 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java @@ -8,6 +8,7 @@ import org.bukkit.entity.HumanEntity; import org.bukkit.event.Event; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.NotNull; /** * Represents a player related inventory event @@ -16,7 +17,7 @@ public class InventoryEvent extends Event { private static final HandlerList handlers = new HandlerList(); protected InventoryView transaction; - public InventoryEvent(InventoryView transaction) { + public InventoryEvent(@NotNull InventoryView transaction) { this.transaction = transaction; } @@ -25,6 +26,7 @@ public class InventoryEvent extends Event { * * @return The upper inventory. */ + @NotNull public Inventory getInventory() { return transaction.getTopInventory(); } @@ -35,6 +37,7 @@ public class InventoryEvent extends Event { * * @return A list of people viewing. */ + @NotNull public List getViewers() { return transaction.getTopInventory().getViewers(); } @@ -44,15 +47,18 @@ public class InventoryEvent extends Event { * * @return InventoryView */ + @NotNull public InventoryView getView() { return transaction; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java index 19e67a7089..3b1d14365b 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.inventory; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.NotNull; /** * An abstract base class for events that describe an interaction between a @@ -11,7 +12,7 @@ import org.bukkit.inventory.InventoryView; public abstract class InventoryInteractEvent extends InventoryEvent implements Cancellable { private Result result = Result.DEFAULT; - public InventoryInteractEvent(InventoryView transaction) { + public InventoryInteractEvent(@NotNull InventoryView transaction) { super(transaction); } @@ -20,6 +21,7 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C * * @return The clicking player. */ + @NotNull public HumanEntity getWhoClicked() { return getView().getPlayer(); } @@ -31,7 +33,7 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C * @see #isCancelled() * @param newResult the new {@link org.bukkit.event.Event.Result} for this event */ - public void setResult(Result newResult) { + public void setResult(@NotNull Result newResult) { result = newResult; } @@ -42,6 +44,7 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C * * @return the Result of this event. */ + @NotNull public Result getResult() { return result; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java index 06ec99aeb4..2bb57d2342 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java @@ -6,6 +6,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when some entity or block (e.g. hopper) tries to move items directly @@ -31,7 +32,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { private ItemStack itemStack; private final boolean didSourceInitiate; - public InventoryMoveItemEvent(final Inventory sourceInventory, final ItemStack itemStack, final Inventory destinationInventory, final boolean didSourceInitiate) { + public InventoryMoveItemEvent(@NotNull final Inventory sourceInventory, @NotNull final ItemStack itemStack, @NotNull final Inventory destinationInventory, final boolean didSourceInitiate) { Validate.notNull(itemStack, "ItemStack cannot be null"); this.sourceInventory = sourceInventory; this.itemStack = itemStack; @@ -44,6 +45,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { * * @return Inventory that the ItemStack is being taken from */ + @NotNull public Inventory getSource() { return sourceInventory; } @@ -54,6 +56,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { * * @return ItemStack */ + @NotNull public ItemStack getItem() { return itemStack.clone(); } @@ -65,7 +68,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { * * @param itemStack The ItemStack */ - public void setItem(ItemStack itemStack) { + public void setItem(@NotNull ItemStack itemStack) { Validate.notNull(itemStack, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred."); this.itemStack = itemStack.clone(); } @@ -75,6 +78,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { * * @return Inventory that the ItemStack is being put into */ + @NotNull public Inventory getDestination() { return destinationInventory; } @@ -85,6 +89,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { * * @return Inventory that initiated the transfer */ + @NotNull public Inventory getInitiator() { return didSourceInitiate ? sourceInventory : destinationInventory; } @@ -97,11 +102,13 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java index c3570aae6a..331a1bd73e 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java @@ -4,6 +4,7 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Represents a player related inventory event @@ -12,7 +13,7 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - public InventoryOpenEvent(InventoryView transaction) { + public InventoryOpenEvent(@NotNull InventoryView transaction) { super(transaction); this.cancelled = false; } @@ -22,6 +23,7 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { * * @return Player who is involved in this event */ + @NotNull public final HumanEntity getPlayer() { return transaction.getPlayer(); } @@ -52,11 +54,13 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java index af6ad5b75c..b761c0224c 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.NotNull; /** * Called when a hopper or hopper minecart picks up a dropped item. @@ -15,7 +16,7 @@ public class InventoryPickupItemEvent extends Event implements Cancellable { private final Inventory inventory; private final Item item; - public InventoryPickupItemEvent(final Inventory inventory, final Item item) { + public InventoryPickupItemEvent(@NotNull final Inventory inventory, @NotNull final Item item) { super(); this.inventory = inventory; this.item = item; @@ -26,6 +27,7 @@ public class InventoryPickupItemEvent extends Event implements Cancellable { * * @return Inventory */ + @NotNull public Inventory getInventory() { return inventory; } @@ -35,6 +37,7 @@ public class InventoryPickupItemEvent extends Event implements Cancellable { * * @return Item */ + @NotNull public Item getItem() { return item; } @@ -47,11 +50,13 @@ public class InventoryPickupItemEvent extends Event implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryType.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryType.java index 60eaeffc24..6216e64112 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryType.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryType.java @@ -1,6 +1,7 @@ package org.bukkit.event.inventory; import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.NotNull; /** * Represents the different kinds of inventories available in Bukkit. @@ -97,11 +98,11 @@ public enum InventoryType { private final String title; private final boolean isCreatable; - private InventoryType(int defaultSize, String defaultTitle) { + private InventoryType(int defaultSize, @NotNull String defaultTitle) { this(defaultSize, defaultTitle, true); } - private InventoryType(int defaultSize, String defaultTitle, boolean isCreatable) { + private InventoryType(int defaultSize, @NotNull String defaultTitle, boolean isCreatable) { size = defaultSize; title = defaultTitle; this.isCreatable = isCreatable; @@ -111,6 +112,7 @@ public enum InventoryType { return size; } + @NotNull public String getDefaultTitle() { return title; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java index ce496767f6..77109a07f0 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java @@ -4,6 +4,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an item is put in a slot for repair by an anvil. @@ -13,11 +15,12 @@ public class PrepareAnvilEvent extends InventoryEvent { private static final HandlerList handlers = new HandlerList(); private ItemStack result; - public PrepareAnvilEvent(InventoryView inventory, ItemStack result) { + public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { super(inventory); this.result = result; } + @NotNull @Override public AnvilInventory getInventory() { return (AnvilInventory) super.getInventory(); @@ -28,19 +31,22 @@ public class PrepareAnvilEvent extends InventoryEvent { * * @return result item */ + @Nullable public ItemStack getResult() { return result; } - public void setResult(ItemStack result) { + public void setResult(@Nullable ItemStack result) { this.result = result; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java index 573119040e..efd29d198d 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java @@ -4,13 +4,15 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.Recipe; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class PrepareItemCraftEvent extends InventoryEvent { private static final HandlerList handlers = new HandlerList(); private boolean repair; private CraftingInventory matrix; - public PrepareItemCraftEvent(CraftingInventory what, InventoryView view, boolean isRepair) { + public PrepareItemCraftEvent(@NotNull CraftingInventory what, @NotNull InventoryView view, boolean isRepair) { super(view); this.matrix = what; this.repair = isRepair; @@ -23,6 +25,7 @@ public class PrepareItemCraftEvent extends InventoryEvent { * * @return The recipe being crafted. */ + @Nullable public Recipe getRecipe() { return matrix.getRecipe(); } @@ -30,6 +33,7 @@ public class PrepareItemCraftEvent extends InventoryEvent { /** * @return The crafting inventory on which the recipe was formed. */ + @NotNull @Override public CraftingInventory getInventory() { return matrix; @@ -45,11 +49,13 @@ public class PrepareItemCraftEvent extends InventoryEvent { return repair; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java index 680a632e06..cc3049e82d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java @@ -6,6 +6,7 @@ import java.util.Set; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event will sometimes fire synchronously, depending on how it was @@ -38,7 +39,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * @param players the players to receive the message. This may be a lazy * or unmodifiable collection. */ - public AsyncPlayerChatEvent(final boolean async, final Player who, final String message, final Set players) { + public AsyncPlayerChatEvent(final boolean async, @NotNull final Player who, @NotNull final String message, @NotNull final Set players) { super(who, async); this.message = message; recipients = players; @@ -50,6 +51,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * * @return Message the player is attempting to send */ + @NotNull public String getMessage() { return message; } @@ -60,7 +62,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * * @param message New message that the player will send */ - public void setMessage(String message) { + public void setMessage(@NotNull String message) { this.message = message; } @@ -74,6 +76,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * @return {@link String#format(String, Object...)} compatible format * string */ + @NotNull public String getFormat() { return format; } @@ -92,7 +95,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * @throws NullPointerException if format is null * @see String#format(String, Object...) */ - public void setFormat(final String format) throws IllegalFormatException, NullPointerException { + public void setFormat(@NotNull final String format) throws IllegalFormatException, NullPointerException { // Oh for a better way to do this! try { String.format(format, player, message); @@ -117,6 +120,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * * @return All Players who will see this chat message */ + @NotNull public Set getRecipients() { return recipients; } @@ -129,11 +133,13 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java index 1d57188997..a090973636 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java @@ -5,6 +5,7 @@ import java.util.UUID; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores details for players attempting to log in. @@ -20,11 +21,11 @@ public class AsyncPlayerPreLoginEvent extends Event { private final UUID uniqueId; @Deprecated - public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress) { + public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) { this(name, ipAddress, null); } - public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress, final UUID uniqueId) { + public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { super(true); this.result = Result.ALLOWED; this.message = ""; @@ -38,6 +39,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @return Current Result of the login */ + @NotNull public Result getLoginResult() { return result; } @@ -51,6 +53,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * @see #getLoginResult() */ @Deprecated + @NotNull public PlayerPreLoginEvent.Result getResult() { return result == null ? null : result.old(); } @@ -60,7 +63,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @param result New result to set */ - public void setLoginResult(final Result result) { + public void setLoginResult(@NotNull final Result result) { this.result = result; } @@ -73,7 +76,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * @see #setLoginResult(Result) */ @Deprecated - public void setResult(final PlayerPreLoginEvent.Result result) { + public void setResult(@NotNull final PlayerPreLoginEvent.Result result) { this.result = result == null ? null : Result.valueOf(result.name()); } @@ -83,6 +86,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @return Current kick message */ + @NotNull public String getKickMessage() { return message; } @@ -92,7 +96,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @param message New kick message */ - public void setKickMessage(final String message) { + public void setKickMessage(@NotNull final String message) { this.message = message; } @@ -110,7 +114,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * @param result New result for disallowing the player * @param message Kick message to display to the user */ - public void disallow(final Result result, final String message) { + public void disallow(@NotNull final Result result, @NotNull final String message) { this.result = result; this.message = message; } @@ -125,7 +129,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * @see #disallow(Result, String) */ @Deprecated - public void disallow(final PlayerPreLoginEvent.Result result, final String message) { + public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final String message) { this.result = result == null ? null : Result.valueOf(result.name()); this.message = message; } @@ -135,6 +139,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @return the player's name */ + @NotNull public String getName() { return name; } @@ -144,6 +149,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @return The IP address */ + @NotNull public InetAddress getAddress() { return ipAddress; } @@ -153,15 +159,18 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @return The unique ID */ + @NotNull public UUID getUniqueId() { return uniqueId; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } @@ -194,6 +203,7 @@ public class AsyncPlayerPreLoginEvent extends Event { KICK_OTHER; @Deprecated + @NotNull private PlayerPreLoginEvent.Result old() { return PlayerPreLoginEvent.Result.valueOf(name()); } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java index a57a93d74d..fae6a901bd 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Achievement; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player earns an achievement. @@ -37,6 +38,7 @@ public class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancel this.isCancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java index d925a18fa7..21ff095afb 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.advancement.Advancement; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player has completed all criteria in an advancement. @@ -13,7 +14,7 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent { // private final Advancement advancement; - public PlayerAdvancementDoneEvent(Player who, Advancement advancement) { + public PlayerAdvancementDoneEvent(@NotNull Player who, @NotNull Advancement advancement) { super(who); this.advancement = advancement; } @@ -23,15 +24,18 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent { * * @return completed advancement */ + @NotNull public Advancement getAdvancement() { return advancement; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java index cabe77dd39..4affca1275 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Represents a player animation event @@ -17,7 +18,7 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { * * @param player The player instance */ - public PlayerAnimationEvent(final Player player) { + public PlayerAnimationEvent(@NotNull final Player player) { super(player); // Only supported animation type for now: @@ -29,6 +30,7 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { * * @return the animation type */ + @NotNull public PlayerAnimationType getAnimationType() { return animationType; } @@ -41,11 +43,13 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { this.isCancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java index a9950e0e2f..7f12156b5e 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.ArmorStand; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when a player interacts with an armor stand and will either swap, retrieve or place an item. @@ -17,7 +18,7 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent { private final ItemStack armorStandItem; private final EquipmentSlot slot; - public PlayerArmorStandManipulateEvent(final Player who, final ArmorStand clickedEntity, final ItemStack playerItem, final ItemStack armorStandItem, final EquipmentSlot slot) { + public PlayerArmorStandManipulateEvent(@NotNull final Player who, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot) { super(who, clickedEntity); this.playerItem = playerItem; this.armorStandItem = armorStandItem; @@ -33,6 +34,7 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent { * In the case that the event is cancelled the original items will remain the same. * @return the item held by the player. */ + @NotNull public ItemStack getPlayerItem() { return this.playerItem; } @@ -46,6 +48,7 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent { * In the case that the event is cancelled the original items will remain the same. * @return the item held by the armor stand. */ + @NotNull public ItemStack getArmorStandItem() { return this.armorStandItem; } @@ -55,20 +58,24 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent { * * @return the index of the item obtained or placed of the armor stand. */ + @NotNull public EquipmentSlot getSlot() { return this.slot; } + @NotNull @Override public ArmorStand getRightClicked() { return (ArmorStand) this.clickedEntity; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index e77daed9e2..c7d57e286c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is fired when the player is almost about to enter the bed. @@ -51,14 +52,14 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { private final BedEnterResult bedEnterResult; private Result useBed = Result.DEFAULT; - public PlayerBedEnterEvent(Player who, Block bed, BedEnterResult bedEnterResult) { + public PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult) { super(who); this.bed = bed; this.bedEnterResult = bedEnterResult; } @Deprecated - public PlayerBedEnterEvent(Player who, Block bed) { + public PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed) { this(who, bed, BedEnterResult.OK); } @@ -67,6 +68,7 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { * * @return the bed enter result representing the default outcome of this event */ + @NotNull public BedEnterResult getBedEnterResult() { return bedEnterResult; } @@ -80,6 +82,7 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { * @return the action to take with the interacted bed * @see #setUseBed(org.bukkit.event.Event.Result) */ + @NotNull public Result useBed() { return useBed; } @@ -99,7 +102,7 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { * @param useBed the action to take with the interacted bed * @see #useBed() */ - public void setUseBed(Result useBed) { + public void setUseBed(@NotNull Result useBed) { this.useBed = useBed; } @@ -139,15 +142,18 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { * * @return the bed block involved in this event */ + @NotNull public Block getBed() { return bed; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java index 0b57635faa..8244bf09c1 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is fired when the player is leaving a bed. @@ -13,7 +14,7 @@ public class PlayerBedLeaveEvent extends PlayerEvent { private final Block bed; private boolean setBedSpawn; - public PlayerBedLeaveEvent(final Player who, final Block bed, boolean setBedSpawn) { + public PlayerBedLeaveEvent(@NotNull final Player who, @NotNull final Block bed, boolean setBedSpawn) { super(who); this.bed = bed; this.setBedSpawn = setBedSpawn; @@ -24,6 +25,7 @@ public class PlayerBedLeaveEvent extends PlayerEvent { * * @return the bed block involved in this event */ + @NotNull public Block getBed() { return bed; } @@ -60,11 +62,13 @@ public class PlayerBedLeaveEvent extends PlayerEvent { this.setBedSpawn = setBedSpawn; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java index 8fb121a917..cdf2e2016b 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when a player empties a bucket @@ -13,15 +14,17 @@ import org.bukkit.inventory.ItemStack; public class PlayerBucketEmptyEvent extends PlayerBucketEvent { private static final HandlerList handlers = new HandlerList(); - public PlayerBucketEmptyEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) { + public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who, blockClicked, blockFace, bucket, itemInHand); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java index 56584687f9..d0ccba0603 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java @@ -6,6 +6,8 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player interacts with a Bucket @@ -17,7 +19,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab private final BlockFace blockFace; private final Material bucket; - public PlayerBucketEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) { + public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who); this.blockClicked = blockClicked; this.blockFace = blockFace; @@ -30,6 +32,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab * * @return the used bucket */ + @NotNull public Material getBucket() { return bucket; } @@ -37,8 +40,9 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab /** * Get the resulting item in hand after the bucket event * - * @return Itemstack hold in hand after the event. + * @return ItemStack hold in hand after the event. */ + @Nullable public ItemStack getItemStack() { return itemStack; } @@ -46,9 +50,9 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab /** * Set the item in hand after the event * - * @param itemStack the new held itemstack after the bucket event. + * @param itemStack the new held ItemStack after the bucket event. */ - public void setItemStack(ItemStack itemStack) { + public void setItemStack(@Nullable ItemStack itemStack) { this.itemStack = itemStack; } @@ -57,6 +61,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab * * @return the clicked block */ + @NotNull public Block getBlockClicked() { return blockClicked; } @@ -66,6 +71,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab * * @return the clicked face */ + @NotNull public BlockFace getBlockFace() { return blockFace; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java index 94e042a36f..cc1b03eb27 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when a player fills a bucket @@ -13,15 +14,17 @@ import org.bukkit.inventory.ItemStack; public class PlayerBucketFillEvent extends PlayerBucketEvent { private static final HandlerList handlers = new HandlerList(); - public PlayerBucketFillEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) { + public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who, blockClicked, blockFace, bucket, itemInHand); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java index 2a154462ba..6070b1323c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MainHand; +import org.jetbrains.annotations.NotNull; /** * Called when a player changes their main hand in the client settings. @@ -13,7 +14,7 @@ public class PlayerChangedMainHandEvent extends PlayerEvent { // private final MainHand mainHand; - public PlayerChangedMainHandEvent(Player who, MainHand mainHand) { + public PlayerChangedMainHandEvent(@NotNull Player who, @NotNull MainHand mainHand) { super(who); this.mainHand = mainHand; } @@ -24,15 +25,18 @@ public class PlayerChangedMainHandEvent extends PlayerEvent { * * @return the new {@link MainHand} of the player */ + @NotNull public MainHand getMainHand() { return mainHand; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java index 76c9c209bf..f1d1d1e9bd 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player switches to another world. @@ -11,7 +12,7 @@ public class PlayerChangedWorldEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final World from; - public PlayerChangedWorldEvent(final Player player, final World from) { + public PlayerChangedWorldEvent(@NotNull final Player player, @NotNull final World from) { super(player); this.from = from; } @@ -21,15 +22,18 @@ public class PlayerChangedWorldEvent extends PlayerEvent { * * @return player's previous world */ + @NotNull public World getFrom() { return from; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java index 054efbc37f..9316a525f9 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called after a player registers or unregisters a new plugin @@ -11,20 +12,23 @@ public abstract class PlayerChannelEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final String channel; - public PlayerChannelEvent(final Player player, final String channel) { + public PlayerChannelEvent(@NotNull final Player player, @NotNull final String channel) { super(player); this.channel = channel; } + @NotNull public final String getChannel() { return channel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java index 1fb5cd7520..fec303c9c8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java @@ -8,6 +8,7 @@ import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Holds information for player chat and commands @@ -28,14 +29,14 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { private String format; private final Set recipients; - public PlayerChatEvent(final Player player, final String message) { + public PlayerChatEvent(@NotNull final Player player, @NotNull final String message) { super(player); this.message = message; this.format = "<%1$s> %2$s"; this.recipients = new HashSet(player.getServer().getOnlinePlayers()); } - public PlayerChatEvent(final Player player, final String message, final String format, final Set recipients) { + public PlayerChatEvent(@NotNull final Player player, @NotNull final String message, @NotNull final String format, @NotNull final Set recipients) { super(player); this.message = message; this.format = format; @@ -55,6 +56,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { * * @return Message the player is attempting to send */ + @NotNull public String getMessage() { return message; } @@ -64,7 +66,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { * * @param message New message that the player will send */ - public void setMessage(String message) { + public void setMessage(@NotNull String message) { this.message = message; } @@ -74,7 +76,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { * * @param player New player which this event will execute as */ - public void setPlayer(final Player player) { + public void setPlayer(@NotNull final Player player) { Validate.notNull(player, "Player cannot be null"); this.player = player; } @@ -84,6 +86,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { * * @return String.Format compatible format string */ + @NotNull public String getFormat() { return format; } @@ -93,7 +96,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { * * @param format String.Format compatible format string */ - public void setFormat(final String format) { + public void setFormat(@NotNull final String format) { // Oh for a better way to do this! try { String.format(format, player, message); @@ -110,15 +113,18 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { * * @return All Players who will see this chat message */ + @NotNull public Set getRecipients() { return recipients; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java index 44cc051862..c3ac379284 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java @@ -6,6 +6,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player attempts to tab-complete a chat message. @@ -20,7 +21,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { private final String lastToken; private final Collection completions; - public PlayerChatTabCompleteEvent(final Player who, final String message, final Collection completions) { + public PlayerChatTabCompleteEvent(@NotNull final Player who, @NotNull final String message, @NotNull final Collection completions) { super(who); Validate.notNull(message, "Message cannot be null"); Validate.notNull(completions, "Completions cannot be null"); @@ -39,6 +40,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { * * @return the chat message */ + @NotNull public String getChatMessage() { return message; } @@ -51,6 +53,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { * * @return The last token for the chat message */ + @NotNull public String getLastToken() { return lastToken; } @@ -60,15 +63,18 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { * * @return the current completions */ + @NotNull public Collection getTabCompletions() { return completions; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java index a128e2055f..66c930da05 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java @@ -7,6 +7,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called whenever a player runs a command (by placing a slash @@ -51,13 +52,13 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell private String message; private final Set recipients; - public PlayerCommandPreprocessEvent(final Player player, final String message) { + public PlayerCommandPreprocessEvent(@NotNull final Player player, @NotNull final String message) { super(player); this.recipients = new HashSet(player.getServer().getOnlinePlayers()); this.message = message; } - public PlayerCommandPreprocessEvent(final Player player, final String message, final Set recipients) { + public PlayerCommandPreprocessEvent(@NotNull final Player player, @NotNull final String message, @NotNull final Set recipients) { super(player); this.recipients = recipients; this.message = message; @@ -79,6 +80,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell * * @return Message the player is attempting to send */ + @NotNull public String getMessage() { return message; } @@ -92,7 +94,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell * @param command New message that the player will send * @throws IllegalArgumentException if command is null or empty */ - public void setMessage(String command) throws IllegalArgumentException { + public void setMessage(@NotNull String command) throws IllegalArgumentException { Validate.notNull(command, "Command cannot be null"); Validate.notEmpty(command, "Command cannot be empty"); this.message = command; @@ -104,7 +106,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell * @param player New player which this event will execute as * @throws IllegalArgumentException if the player provided is null */ - public void setPlayer(final Player player) throws IllegalArgumentException { + public void setPlayer(@NotNull final Player player) throws IllegalArgumentException { Validate.notNull(player, "Player cannot be null"); this.player = player; } @@ -123,16 +125,19 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell * guarantee to the effect of viewing or modifying the set. * @return All Players who will see this chat message */ + @NotNull @Deprecated public Set getRecipients() { return recipients; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java index 6ab24ba44b..762825997f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import java.util.Collection; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called when the list of available server commands is sent to @@ -18,7 +19,7 @@ public class PlayerCommandSendEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final Collection commands; - public PlayerCommandSendEvent(final Player player, final Collection commands) { + public PlayerCommandSendEvent(@NotNull final Player player, @NotNull final Collection commands) { super(player); this.commands = commands; } @@ -31,15 +32,18 @@ public class PlayerCommandSendEvent extends PlayerEvent { * * @return collection of all commands */ + @NotNull public Collection getCommands() { return commands; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java index 5b41b652c3..4ac31e1228 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Thrown when a player drops an item from their inventory @@ -13,7 +14,7 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { private final Item drop; private boolean cancel = false; - public PlayerDropItemEvent(final Player player, final Item drop) { + public PlayerDropItemEvent(@NotNull final Player player, @NotNull final Item drop) { super(player); this.drop = drop; } @@ -23,6 +24,7 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { * * @return ItemDrop created by the player */ + @NotNull public Item getItemDrop() { return drop; } @@ -35,11 +37,13 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java index 24a98af110..44e62e61b6 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.meta.BookMeta; +import org.jetbrains.annotations.NotNull; /** * Called when a player edits or signs a book and quill item. If the event is @@ -20,7 +21,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { private boolean isSigning; private boolean cancel; - public PlayerEditBookEvent(Player who, int slot, BookMeta previousBookMeta, BookMeta newBookMeta, boolean isSigning) { + public PlayerEditBookEvent(@NotNull Player who, int slot, @NotNull BookMeta previousBookMeta, @NotNull BookMeta newBookMeta, boolean isSigning) { super(who); Validate.isTrue(slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive"); @@ -44,6 +45,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { * * @return the book meta currently on the book */ + @NotNull public BookMeta getPreviousBookMeta() { return previousBookMeta.clone(); } @@ -57,6 +59,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { * * @return the book meta that the player is attempting to add */ + @NotNull public BookMeta getNewBookMeta() { return newBookMeta.clone(); } @@ -82,7 +85,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { * @param newBookMeta new book meta * @throws IllegalArgumentException if the new book meta is null */ - public void setNewBookMeta(BookMeta newBookMeta) throws IllegalArgumentException { + public void setNewBookMeta(@NotNull BookMeta newBookMeta) throws IllegalArgumentException { Validate.notNull(newBookMeta, "New book meta must not be null"); Bukkit.getItemFactory().equals(newBookMeta, null); this.newBookMeta = newBookMeta.clone(); @@ -108,11 +111,13 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { isSigning = signing; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java index 4b5075b0f5..1712dae892 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Egg; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player throws an egg and it might hatch @@ -15,7 +16,7 @@ public class PlayerEggThrowEvent extends PlayerEvent { private EntityType hatchType; private byte numHatches; - public PlayerEggThrowEvent(final Player player, final Egg egg, final boolean hatching, final byte numHatches, final EntityType hatchingType) { + public PlayerEggThrowEvent(@NotNull final Player player, @NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) { super(player); this.egg = egg; this.hatching = hatching; @@ -28,6 +29,7 @@ public class PlayerEggThrowEvent extends PlayerEvent { * * @return the egg involved in this event */ + @NotNull public Egg getEgg() { return egg; } @@ -57,6 +59,7 @@ public class PlayerEggThrowEvent extends PlayerEvent { * * @return The type of the mob being hatched by the egg */ + @NotNull public EntityType getHatchingType() { return hatchType; } @@ -66,7 +69,7 @@ public class PlayerEggThrowEvent extends PlayerEvent { * * @param hatchType The type of the mob being hatched by the egg */ - public void setHatchingType(EntityType hatchType) { + public void setHatchingType(@NotNull EntityType hatchType) { if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!"); this.hatchType = hatchType; } @@ -98,11 +101,13 @@ public class PlayerEggThrowEvent extends PlayerEvent { this.numHatches = numHatches; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java index 0d4833f608..793b661b6d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents a player related event @@ -9,11 +10,11 @@ import org.bukkit.event.Event; public abstract class PlayerEvent extends Event { protected Player player; - public PlayerEvent(final Player who) { + public PlayerEvent(@NotNull final Player who) { player = who; } - PlayerEvent(final Player who, boolean async) { + PlayerEvent(@NotNull final Player who, boolean async) { super(async); player = who; @@ -24,6 +25,7 @@ public abstract class PlayerEvent extends Event { * * @return Player who is involved in this event */ + @NotNull public final Player getPlayer() { return player; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java index f37491d71f..c99c9281e9 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a players experience changes naturally @@ -10,7 +11,7 @@ public class PlayerExpChangeEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private int exp; - public PlayerExpChangeEvent(final Player player, final int expAmount) { + public PlayerExpChangeEvent(@NotNull final Player player, final int expAmount) { super(player); exp = expAmount; } @@ -33,11 +34,13 @@ public class PlayerExpChangeEvent extends PlayerEvent { exp = amount; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java index 91439b8e4f..e31c1492c3 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java @@ -5,6 +5,8 @@ import org.bukkit.event.Cancellable; import org.bukkit.entity.Entity; import org.bukkit.entity.FishHook; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Thrown when a player is fishing @@ -17,7 +19,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { private final State state; private final FishHook hookEntity; - public PlayerFishEvent(final Player player, final Entity entity, final FishHook hookEntity, final State state) { + public PlayerFishEvent(@NotNull final Player player, @Nullable final Entity entity, @NotNull final FishHook hookEntity, @NotNull final State state) { super(player); this.entity = entity; this.hookEntity = hookEntity; @@ -33,6 +35,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * @return Entity caught by the player, Entity if fishing, and null if * bobber has gotten stuck in the ground or nothing has been caught */ + @Nullable public Entity getCaught() { return entity; } @@ -42,6 +45,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * * @return the entity representing the fishing hook/bobber. */ + @NotNull public FishHook getHook() { return hookEntity; } @@ -83,15 +87,18 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * * @return A State detailing the state of the fishing */ + @NotNull public State getState() { return state; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java index 8c9afa8d97..020faee1cc 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when the GameMode of the player is changed. @@ -13,7 +14,7 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl private boolean cancelled; private final GameMode newGameMode; - public PlayerGameModeChangeEvent(final Player player, final GameMode newGameMode) { + public PlayerGameModeChangeEvent(@NotNull final Player player, @NotNull final GameMode newGameMode) { super(player); this.newGameMode = newGameMode; } @@ -31,15 +32,18 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl * * @return player's new GameMode */ + @NotNull public GameMode getNewGameMode() { return newGameMode; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java index 431715de8e..1075dbb813 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Represents an event that is called when a player right clicks an entity that @@ -17,24 +18,27 @@ public class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent { private static final HandlerList handlers = new HandlerList(); private final Vector position; - public PlayerInteractAtEntityEvent(Player who, Entity clickedEntity, Vector position) { + public PlayerInteractAtEntityEvent(@NotNull Player who, @NotNull Entity clickedEntity, @NotNull Vector position) { this(who, clickedEntity, position, EquipmentSlot.HAND); } - public PlayerInteractAtEntityEvent(Player who, Entity clickedEntity, Vector position, EquipmentSlot hand) { + public PlayerInteractAtEntityEvent(@NotNull Player who, @NotNull Entity clickedEntity, @NotNull Vector position, @NotNull EquipmentSlot hand) { super(who, clickedEntity, hand); this.position = position; } + @NotNull public Vector getClickedPosition() { return position.clone(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java index 94609579ef..c4406610fe 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; +import org.jetbrains.annotations.NotNull; /** * Represents an event that is called when a player right clicks an entity. @@ -15,11 +16,11 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl boolean cancelled = false; private EquipmentSlot hand; - public PlayerInteractEntityEvent(final Player who, final Entity clickedEntity) { + public PlayerInteractEntityEvent(@NotNull final Player who, @NotNull final Entity clickedEntity) { this(who, clickedEntity, EquipmentSlot.HAND); } - public PlayerInteractEntityEvent(final Player who, final Entity clickedEntity, final EquipmentSlot hand) { + public PlayerInteractEntityEvent(@NotNull final Player who, @NotNull final Entity clickedEntity, @NotNull final EquipmentSlot hand) { super(who); this.clickedEntity = clickedEntity; this.hand = hand; @@ -34,10 +35,11 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl } /** - * Gets the entity that was rightclicked by the player. + * Gets the entity that was right-clicked by the player. * * @return entity right clicked by player */ + @NotNull public Entity getRightClicked() { return this.clickedEntity; } @@ -47,15 +49,18 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl * * @return the hand used to interact */ + @NotNull public EquipmentSlot getHand() { return hand; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java index fdad4cd351..3563aac37b 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java @@ -10,6 +10,8 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.inventory.EquipmentSlot; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an event that is called when a player interacts with an object or @@ -33,11 +35,11 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { private Result useItemInHand; private EquipmentSlot hand; - public PlayerInteractEvent(final Player who, final Action action, final ItemStack item, final Block clickedBlock, final BlockFace clickedFace) { + public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace) { this(who, action, item, clickedBlock, clickedFace, EquipmentSlot.HAND); } - public PlayerInteractEvent(final Player who, final Action action, final ItemStack item, final Block clickedBlock, final BlockFace clickedFace, final EquipmentSlot hand) { + public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand) { super(who); this.action = action; this.item = item; @@ -54,6 +56,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return Action returns the type of interaction */ + @NotNull public Action getAction() { return action; } @@ -88,6 +91,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return ItemStack the item used */ + @Nullable public ItemStack getItem() { return this.item; } @@ -98,6 +102,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return Material the material of the item used */ + @NotNull public Material getMaterial() { if (!hasItem()) { return Material.AIR; @@ -143,6 +148,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return Block returns the block clicked with this item. */ + @Nullable public Block getClickedBlock() { return blockClicked; } @@ -152,6 +158,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return BlockFace returns the face of the block that was clicked */ + @NotNull public BlockFace getBlockFace() { return blockFace; } @@ -163,6 +170,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return the action to take with the interacted block */ + @NotNull public Result useInteractedBlock() { return useClickedBlock; } @@ -170,7 +178,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { /** * @param useInteractedBlock the action to take with the interacted block */ - public void setUseInteractedBlock(Result useInteractedBlock) { + public void setUseInteractedBlock(@NotNull Result useInteractedBlock) { this.useClickedBlock = useInteractedBlock; } @@ -182,6 +190,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return the action to take with the item in hand */ + @NotNull public Result useItemInHand() { return useItemInHand; } @@ -189,7 +198,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { /** * @param useItemInHand the action to take with the item in hand */ - public void setUseItemInHand(Result useItemInHand) { + public void setUseItemInHand(@NotNull Result useItemInHand) { this.useItemInHand = useItemInHand; } @@ -199,15 +208,18 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @return the hand used to interact. May be null. */ + @Nullable public EquipmentSlot getHand() { return hand; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java index 176cd918ee..a16c9f576c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Fired when a player's item breaks (such as a shovel or flint and steel). @@ -14,7 +15,7 @@ public class PlayerItemBreakEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final ItemStack brokenItem; - public PlayerItemBreakEvent(final Player player, final ItemStack brokenItem) { + public PlayerItemBreakEvent(@NotNull final Player player, @NotNull final ItemStack brokenItem) { super(player); this.brokenItem = brokenItem; } @@ -24,15 +25,18 @@ public class PlayerItemBreakEvent extends PlayerEvent { * * @return The broken item */ + @NotNull public ItemStack getBrokenItem() { return brokenItem; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java index 8ab76b1d4f..ee0f95b109 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This event will fire when a player is finishing consuming an item (food, @@ -25,7 +27,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { * @param player the player consuming * @param item the ItemStack being consumed */ - public PlayerItemConsumeEvent(final Player player, final ItemStack item) { + public PlayerItemConsumeEvent(@NotNull final Player player, @NotNull final ItemStack item) { super(player); this.item = item; @@ -38,6 +40,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { * * @return an ItemStack for the item being consumed */ + @NotNull public ItemStack getItem() { return item.clone(); } @@ -47,7 +50,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { * * @param item the item being consumed */ - public void setItem(ItemStack item) { + public void setItem(@Nullable ItemStack item) { if (item == null) { this.item = new ItemStack(Material.AIR); } else { @@ -63,11 +66,13 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { this.isCancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java index 0ece784a63..2d04963399 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when an item used by the player takes durability damage as a result of @@ -16,7 +17,7 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { private int damage; private boolean cancelled = false; - public PlayerItemDamageEvent(Player player, ItemStack what, int damage) { + public PlayerItemDamageEvent(@NotNull Player player, @NotNull ItemStack what, int damage) { super(player); this.item = what; this.damage = damage; @@ -27,6 +28,7 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { * * @return the item */ + @NotNull public ItemStack getItem() { return item; } @@ -54,11 +56,13 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java index f0d055a0e4..d5100d8fec 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Fired when a player changes their currently held item @@ -13,7 +14,7 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable { private final int previous; private final int current; - public PlayerItemHeldEvent(final Player player, final int previous, final int current) { + public PlayerItemHeldEvent(@NotNull final Player player, final int previous, final int current) { super(player); this.previous = previous; this.current = current; @@ -45,11 +46,13 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java index ae9e1c9074..2f0cbf9287 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Represents when a player has an item repaired via the Mending enchantment. @@ -21,7 +22,7 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { private int repairAmount; private boolean cancelled; - public PlayerItemMendEvent(Player who, ItemStack item, ExperienceOrb experienceOrb, int repairAmount) { + public PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull ExperienceOrb experienceOrb, int repairAmount) { super(who); this.item = item; this.experienceOrb = experienceOrb; @@ -35,6 +36,7 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { * * @return the item to be repaired */ + @NotNull public ItemStack getItem() { return item; } @@ -44,6 +46,7 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { * * @return the experience orb */ + @NotNull public ExperienceOrb getExperienceOrb() { return experienceOrb; } @@ -81,11 +84,13 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java index e7481f92c7..4c0920e210 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player joins a server @@ -10,7 +11,7 @@ public class PlayerJoinEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private String joinMessage; - public PlayerJoinEvent(final Player playerJoined, final String joinMessage) { + public PlayerJoinEvent(@NotNull final Player playerJoined, @NotNull final String joinMessage) { super(playerJoined); this.joinMessage = joinMessage; } @@ -20,6 +21,7 @@ public class PlayerJoinEvent extends PlayerEvent { * * @return string join message */ + @NotNull public String getJoinMessage() { return joinMessage; } @@ -29,15 +31,17 @@ public class PlayerJoinEvent extends PlayerEvent { * * @param joinMessage join message */ - public void setJoinMessage(String joinMessage) { + public void setJoinMessage(@NotNull String joinMessage) { this.joinMessage = joinMessage; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index 39e81b6784..fa1105f4e9 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player gets kicked from the server @@ -13,7 +14,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { private String kickReason; private Boolean cancel; - public PlayerKickEvent(final Player playerKicked, final String kickReason, final String leaveMessage) { + public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) { super(playerKicked); this.kickReason = kickReason; this.leaveMessage = leaveMessage; @@ -25,6 +26,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * * @return string kick reason */ + @NotNull public String getReason() { return kickReason; } @@ -34,6 +36,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * * @return string kick reason */ + @NotNull public String getLeaveMessage() { return leaveMessage; } @@ -51,7 +54,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * * @param kickReason kick reason */ - public void setReason(String kickReason) { + public void setReason(@NotNull String kickReason) { this.kickReason = kickReason; } @@ -60,15 +63,17 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * * @param leaveMessage leave message */ - public void setLeaveMessage(String leaveMessage) { + public void setLeaveMessage(@NotNull String leaveMessage) { this.leaveMessage = leaveMessage; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java index 68254279d4..00481d7330 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a players level changes @@ -11,7 +12,7 @@ public class PlayerLevelChangeEvent extends PlayerEvent { private final int oldLevel; private final int newLevel; - public PlayerLevelChangeEvent(final Player player, final int oldLevel, final int newLevel) { + public PlayerLevelChangeEvent(@NotNull final Player player, final int oldLevel, final int newLevel) { super(player); this.oldLevel = oldLevel; this.newLevel = newLevel; @@ -35,11 +36,13 @@ public class PlayerLevelChangeEvent extends PlayerEvent { return newLevel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java index fbbfccccfa..1db386bb70 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player changes their locale in the client settings. @@ -12,7 +13,7 @@ public class PlayerLocaleChangeEvent extends PlayerEvent { // private final String locale; - public PlayerLocaleChangeEvent(Player who, String locale) { + public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) { super(who); this.locale = locale; } @@ -22,15 +23,18 @@ public class PlayerLocaleChangeEvent extends PlayerEvent { * * @return the player's new locale */ + @NotNull public String getLocale() { return locale; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java index 6368c2123f..dccffa03cc 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java @@ -4,6 +4,7 @@ import java.net.InetAddress; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores details for players attempting to log in. @@ -28,7 +29,7 @@ public class PlayerLoginEvent extends PlayerEvent { * @param address The address the player used to connect, provided for * timing issues */ - public PlayerLoginEvent(final Player player, final String hostname, final InetAddress address) { + public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address) { super(player); this.hostname = hostname; this.address = address; @@ -44,7 +45,7 @@ public class PlayerLoginEvent extends PlayerEvent { * @param result The result status for this event * @param message The message to be displayed if result denies login */ - public PlayerLoginEvent(final Player player, String hostname, final InetAddress address, final Result result, final String message) { + public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message) { this(player, hostname, address); this.result = result; this.message = message; @@ -55,6 +56,7 @@ public class PlayerLoginEvent extends PlayerEvent { * * @return Current Result of the login */ + @NotNull public Result getResult() { return result; } @@ -64,7 +66,7 @@ public class PlayerLoginEvent extends PlayerEvent { * * @param result New result to set */ - public void setResult(final Result result) { + public void setResult(@NotNull final Result result) { this.result = result; } @@ -74,6 +76,7 @@ public class PlayerLoginEvent extends PlayerEvent { * * @return Current kick message */ + @NotNull public String getKickMessage() { return message; } @@ -83,7 +86,7 @@ public class PlayerLoginEvent extends PlayerEvent { * * @param message New kick message */ - public void setKickMessage(final String message) { + public void setKickMessage(@NotNull final String message) { this.message = message; } @@ -93,6 +96,7 @@ public class PlayerLoginEvent extends PlayerEvent { * * @return The hostname */ + @NotNull public String getHostname() { return hostname; } @@ -111,7 +115,7 @@ public class PlayerLoginEvent extends PlayerEvent { * @param result New result for disallowing the player * @param message Kick message to display to the user */ - public void disallow(final Result result, final String message) { + public void disallow(@NotNull final Result result, @NotNull final String message) { this.result = result; this.message = message; } @@ -124,15 +128,18 @@ public class PlayerLoginEvent extends PlayerEvent { * @return The address for this player. For legacy compatibility, this may * be null. */ + @NotNull public InetAddress getAddress() { return address; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java index d56b7e40ae..8b90184517 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java @@ -5,6 +5,8 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Holds information for player movement events @@ -15,7 +17,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { private Location from; private Location to; - public PlayerMoveEvent(final Player player, final Location from, final Location to) { + public PlayerMoveEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) { super(player); this.from = from; this.to = to; @@ -54,6 +56,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @return Location the player moved from */ + @NotNull public Location getFrom() { return from; } @@ -63,7 +66,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @param from New location to mark as the players previous location */ - public void setFrom(Location from) { + public void setFrom(@NotNull Location from) { validateLocation(from); this.from = from; } @@ -73,6 +76,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @return Location the player moved to */ + @Nullable public Location getTo() { return to; } @@ -82,21 +86,23 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @param to New Location this player will move to */ - public void setTo(Location to) { + public void setTo(@NotNull Location to) { validateLocation(to); this.to = to; } - private void validateLocation(Location loc) { + private void validateLocation(@NotNull Location loc) { Preconditions.checkArgument(loc != null, "Cannot use null location!"); Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!"); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java index 97399ed621..01870a063d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Arrow; import org.bukkit.entity.Item; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; /** * Thrown when a player picks up an arrow from the ground. @@ -11,7 +12,7 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent { private final Arrow arrow; - public PlayerPickupArrowEvent(final Player player, final Item item, final Arrow arrow) { + public PlayerPickupArrowEvent(@NotNull final Player player, @NotNull final Item item, @NotNull final Arrow arrow) { super(player, item, 0); this.arrow = arrow; } @@ -21,6 +22,7 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent { * * @return The arrow being picked up */ + @NotNull public Arrow getArrow() { return arrow; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java index c76f423e29..c7599116f8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityPickupItemEvent; +import org.jetbrains.annotations.NotNull; /** * Thrown when a player picks an item up from the ground @@ -19,7 +20,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { private boolean cancel = false; private final int remaining; - public PlayerPickupItemEvent(final Player player, final Item item, final int remaining) { + public PlayerPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) { super(player); this.item = item; this.remaining = remaining; @@ -30,6 +31,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { * * @return Item */ + @NotNull public Item getItem() { return item; } @@ -51,11 +53,13 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java index 330311dfc1..f8821c78e9 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java @@ -4,6 +4,8 @@ import org.bukkit.Location; import org.bukkit.TravelAgent; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player is about to teleport because it is in contact with a @@ -16,12 +18,12 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { protected boolean useTravelAgent = true; protected TravelAgent travelAgent; - public PlayerPortalEvent(final Player player, final Location from, final Location to, final TravelAgent pta) { + public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) { super(player, from, to); this.travelAgent = pta; } - public PlayerPortalEvent(Player player, Location from, Location to, TravelAgent pta, TeleportCause cause) { + public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TravelAgent pta, @NotNull TeleportCause cause) { super(player, from, to, cause); this.travelAgent = pta; } @@ -63,6 +65,7 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { * * @return the Travel Agent used (or not) in this event */ + @NotNull public TravelAgent getPortalTravelAgent() { return this.travelAgent; } @@ -72,15 +75,17 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { * * @param travelAgent the Travel Agent used (or not) in this event */ - public void setPortalTravelAgent(TravelAgent travelAgent) { + public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) { this.travelAgent = travelAgent; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java index e8553f0f36..a23a06a4b4 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java @@ -6,6 +6,7 @@ import java.util.UUID; import org.bukkit.Warning; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores details for players attempting to log in @@ -25,11 +26,11 @@ public class PlayerPreLoginEvent extends Event { private final UUID uniqueId; @Deprecated - public PlayerPreLoginEvent(final String name, final InetAddress ipAddress) { + public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) { this(name, ipAddress, null); } - public PlayerPreLoginEvent(final String name, final InetAddress ipAddress, final UUID uniqueId) { + public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { this.result = Result.ALLOWED; this.message = ""; this.name = name; @@ -42,6 +43,7 @@ public class PlayerPreLoginEvent extends Event { * * @return Current Result of the login */ + @NotNull public Result getResult() { return result; } @@ -51,7 +53,7 @@ public class PlayerPreLoginEvent extends Event { * * @param result New result to set */ - public void setResult(final Result result) { + public void setResult(@NotNull final Result result) { this.result = result; } @@ -61,6 +63,7 @@ public class PlayerPreLoginEvent extends Event { * * @return Current kick message */ + @NotNull public String getKickMessage() { return message; } @@ -70,7 +73,7 @@ public class PlayerPreLoginEvent extends Event { * * @param message New kick message */ - public void setKickMessage(final String message) { + public void setKickMessage(@NotNull final String message) { this.message = message; } @@ -88,7 +91,7 @@ public class PlayerPreLoginEvent extends Event { * @param result New result for disallowing the player * @param message Kick message to display to the user */ - public void disallow(final Result result, final String message) { + public void disallow(@NotNull final Result result, @NotNull final String message) { this.result = result; this.message = message; } @@ -98,6 +101,7 @@ public class PlayerPreLoginEvent extends Event { * * @return the player's name */ + @NotNull public String getName() { return name; } @@ -107,10 +111,12 @@ public class PlayerPreLoginEvent extends Event { * * @return The IP address */ + @NotNull public InetAddress getAddress() { return ipAddress; } + @NotNull @Override public HandlerList getHandlers() { return handlers; @@ -121,10 +127,12 @@ public class PlayerPreLoginEvent extends Event { * * @return The unique ID */ + @NotNull public UUID getUniqueId() { return uniqueId; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java index 5c8dc1b91c..8e55e83934 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player leaves a server @@ -10,7 +11,7 @@ public class PlayerQuitEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private String quitMessage; - public PlayerQuitEvent(final Player who, final String quitMessage) { + public PlayerQuitEvent(@NotNull final Player who, @NotNull final String quitMessage) { super(who); this.quitMessage = quitMessage; } @@ -20,6 +21,7 @@ public class PlayerQuitEvent extends PlayerEvent { * * @return string quit message */ + @NotNull public String getQuitMessage() { return quitMessage; } @@ -29,15 +31,17 @@ public class PlayerQuitEvent extends PlayerEvent { * * @param quitMessage quit message */ - public void setQuitMessage(String quitMessage) { + public void setQuitMessage(@NotNull String quitMessage) { this.quitMessage = quitMessage; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java index 68d1d1297e..f41c29e98a 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java @@ -4,6 +4,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player discovers a new recipe in the recipe book. @@ -15,7 +16,7 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl private boolean cancel = false; private final NamespacedKey recipe; - public PlayerRecipeDiscoverEvent(Player who, NamespacedKey recipe) { + public PlayerRecipeDiscoverEvent(@NotNull Player who, @NotNull NamespacedKey recipe) { super(who); this.recipe = recipe; } @@ -25,6 +26,7 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl * * @return the discovered recipe */ + @NotNull public NamespacedKey getRecipe() { return recipe; } @@ -39,11 +41,13 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java index 442ac7fbbf..97ae244fa8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java @@ -1,13 +1,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; /** * This is called immediately after a player registers for a plugin channel. */ public class PlayerRegisterChannelEvent extends PlayerChannelEvent { - public PlayerRegisterChannelEvent(final Player player, final String channel) { + public PlayerRegisterChannelEvent(@NotNull final Player player, @NotNull final String channel) { super(player, channel); } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java index 4c498016f4..b98195650d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player takes action on a resource pack request sent via @@ -12,7 +13,7 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final Status status; - public PlayerResourcePackStatusEvent(final Player who, Status resourcePackStatus) { + public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull Status resourcePackStatus) { super(who); this.status = resourcePackStatus; } @@ -22,15 +23,18 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent { * * @return the current status */ + @NotNull public Status getStatus() { return status; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java index 35900dd127..71b566e448 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java @@ -4,6 +4,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player respawns. @@ -13,7 +14,7 @@ public class PlayerRespawnEvent extends PlayerEvent { private Location respawnLocation; private final boolean isBedSpawn; - public PlayerRespawnEvent(final Player respawnPlayer, final Location respawnLocation, final boolean isBedSpawn) { + public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn) { super(respawnPlayer); this.respawnLocation = respawnLocation; this.isBedSpawn = isBedSpawn; @@ -24,6 +25,7 @@ public class PlayerRespawnEvent extends PlayerEvent { * * @return Location current respawn location */ + @NotNull public Location getRespawnLocation() { return this.respawnLocation; } @@ -33,7 +35,7 @@ public class PlayerRespawnEvent extends PlayerEvent { * * @param respawnLocation new location for the respawn */ - public void setRespawnLocation(Location respawnLocation) { + public void setRespawnLocation(@NotNull Location respawnLocation) { Validate.notNull(respawnLocation, "Respawn location can not be null"); Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null"); @@ -49,11 +51,13 @@ public class PlayerRespawnEvent extends PlayerEvent { return this.isBedSpawn; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java index 2bfad901e7..c23142a72b 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * This event is fired when the player activates the riptide enchantment, using @@ -16,7 +17,7 @@ public class PlayerRiptideEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final ItemStack item; - public PlayerRiptideEvent(final Player who, final ItemStack item) { + public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item) { super(who); this.item = item; } @@ -26,15 +27,18 @@ public class PlayerRiptideEvent extends PlayerEvent { * * @return held enchanted item */ + @NotNull public ItemStack getItem() { return item; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java index 38afb3ce19..8743491389 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player shears an entity @@ -13,7 +14,7 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { private boolean cancel; private final Entity what; - public PlayerShearEntityEvent(final Player who, final Entity what) { + public PlayerShearEntityEvent(@NotNull final Player who, @NotNull final Entity what) { super(who); this.cancel = false; this.what = what; @@ -32,15 +33,18 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { * * @return the entity the player is shearing */ + @NotNull public Entity getEntity() { return what; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java index bc809efec1..ae7d0e6e3b 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java @@ -6,6 +6,8 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player statistic is incremented. @@ -23,7 +25,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel private final EntityType entityType; private final Material material; - public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue) { + public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue) { super(player); this.statistic = statistic; this.initialValue = initialValue; @@ -32,7 +34,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel this.material = null; } - public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, EntityType entityType) { + public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue, @NotNull EntityType entityType) { super(player); this.statistic = statistic; this.initialValue = initialValue; @@ -41,7 +43,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel this.material = null; } - public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, Material material) { + public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue, @NotNull Material material) { super(player); this.statistic = statistic; this.initialValue = initialValue; @@ -55,6 +57,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel * * @return the incremented statistic */ + @NotNull public Statistic getStatistic() { return statistic; } @@ -83,6 +86,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel * * @return the EntityType of the statistic */ + @Nullable public EntityType getEntityType() { return entityType; } @@ -93,6 +97,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel * * @return the Material of the statistic */ + @Nullable public Material getMaterial() { return material; } @@ -105,11 +110,13 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel this.isCancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java index 483eb17e5c..9f592317c9 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player swap items between main hand and off hand using the @@ -17,7 +19,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable private ItemStack offHandItem; private boolean cancelled; - public PlayerSwapHandItemsEvent(Player player, ItemStack mainHandItem, ItemStack offHandItem) { + public PlayerSwapHandItemsEvent(@NotNull Player player, @NotNull ItemStack mainHandItem, @NotNull ItemStack offHandItem) { super(player); this.mainHandItem = mainHandItem; @@ -29,6 +31,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable * * @return item in the main hand */ + @Nullable public ItemStack getMainHandItem() { return mainHandItem; } @@ -38,7 +41,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable * * @param mainHandItem new item in the main hand */ - public void setMainHandItem(ItemStack mainHandItem) { + public void setMainHandItem(@Nullable ItemStack mainHandItem) { this.mainHandItem = mainHandItem; } @@ -47,6 +50,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable * * @return item in the off hand */ + @Nullable public ItemStack getOffHandItem() { return offHandItem; } @@ -56,7 +60,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable * * @param offHandItem new item in the off hand */ - public void setOffHandItem(ItemStack offHandItem) { + public void setOffHandItem(@Nullable ItemStack offHandItem) { this.offHandItem = offHandItem; } @@ -70,11 +74,13 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java index 6e823f0adf..553d774048 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java @@ -3,6 +3,8 @@ package org.bukkit.event.player; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Holds information for player teleport events @@ -11,11 +13,11 @@ public class PlayerTeleportEvent extends PlayerMoveEvent { private static final HandlerList handlers = new HandlerList(); private TeleportCause cause = TeleportCause.UNKNOWN; - public PlayerTeleportEvent(final Player player, final Location from, final Location to) { + public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) { super(player, from, to); } - public PlayerTeleportEvent(final Player player, final Location from, final Location to, final TeleportCause cause) { + public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause) { this(player, from, to); this.cause = cause; @@ -26,6 +28,7 @@ public class PlayerTeleportEvent extends PlayerMoveEvent { * * @return Cause of the event */ + @NotNull public TeleportCause getCause() { return cause; } @@ -77,11 +80,13 @@ public class PlayerTeleportEvent extends PlayerMoveEvent { UNKNOWN; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java index 1c5ec37eeb..3e53cf9c4f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player toggles their flying state @@ -12,7 +13,7 @@ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable private final boolean isFlying; private boolean cancel = false; - public PlayerToggleFlightEvent(final Player player, final boolean isFlying) { + public PlayerToggleFlightEvent(@NotNull final Player player, final boolean isFlying) { super(player); this.isFlying = isFlying; } @@ -34,11 +35,13 @@ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java index 667acad28a..68d902ae28 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player toggles their sneaking state @@ -12,7 +13,7 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { private final boolean isSneaking; private boolean cancel = false; - public PlayerToggleSneakEvent(final Player player, final boolean isSneaking) { + public PlayerToggleSneakEvent(@NotNull final Player player, final boolean isSneaking) { super(player); this.isSneaking = isSneaking; } @@ -34,11 +35,13 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java index 1558f8f720..3b84960d6d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player toggles their sprinting state @@ -12,7 +13,7 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable private final boolean isSprinting; private boolean cancel = false; - public PlayerToggleSprintEvent(final Player player, final boolean isSprinting) { + public PlayerToggleSprintEvent(@NotNull final Player player, final boolean isSprinting) { super(player); this.isSprinting = isSprinting; } @@ -34,11 +35,13 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java index f6aebefb1a..e2672aac19 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.entity.EntityUnleashEvent; +import org.jetbrains.annotations.NotNull; /** * Called prior to an entity being unleashed due to a player's action. @@ -12,7 +13,7 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc private final Player player; private boolean cancelled = false; - public PlayerUnleashEntityEvent(Entity entity, Player player) { + public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player) { super(entity, UnleashReason.PLAYER_UNLEASH); this.player = player; } @@ -22,6 +23,7 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc * * @return The player */ + @NotNull public Player getPlayer() { return player; } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java index 11c77e3560..b22bc21f5f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java @@ -1,13 +1,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; /** * This is called immediately after a player unregisters for a plugin channel. */ public class PlayerUnregisterChannelEvent extends PlayerChannelEvent { - public PlayerUnregisterChannelEvent(final Player player, final String channel) { + public PlayerUnregisterChannelEvent(@NotNull final Player player, @NotNull final String channel) { super(player, channel); } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java index 69d2fce4a9..c081c03ee8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; /** * Called when the velocity of a player changes. @@ -13,7 +14,7 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { private boolean cancel = false; private Vector velocity; - public PlayerVelocityEvent(final Player player, final Vector velocity) { + public PlayerVelocityEvent(@NotNull final Player player, @NotNull final Vector velocity) { super(player); this.velocity = velocity; } @@ -31,6 +32,7 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { * * @return Vector the player will get */ + @NotNull public Vector getVelocity() { return velocity; } @@ -40,15 +42,17 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { * * @param velocity The velocity vector that will be sent to the player */ - public void setVelocity(Vector velocity) { + public void setVelocity(@NotNull Vector velocity) { this.velocity = velocity; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java index ae5631144b..4bf9d5d827 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java @@ -4,6 +4,7 @@ import java.util.Set; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Event triggered for server broadcast messages such as from @@ -16,7 +17,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { private final Set recipients; private boolean cancelled = false; - public BroadcastMessageEvent(String message, Set recipients) { + public BroadcastMessageEvent(@NotNull String message, @NotNull Set recipients) { this.message = message; this.recipients = recipients; } @@ -26,6 +27,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { * * @return Message to broadcast */ + @NotNull public String getMessage() { return message; } @@ -35,7 +37,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { * * @param message New message to broadcast */ - public void setMessage(String message) { + public void setMessage(@NotNull String message) { this.message = message; } @@ -52,6 +54,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { * * @return All CommandSenders who will see this chat message */ + @NotNull public Set getRecipients() { return recipients; } @@ -66,11 +69,13 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java b/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java index 8834489b50..dc7440d2eb 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.map.MapView; +import org.jetbrains.annotations.NotNull; /** * Called when a map is initialized. @@ -10,7 +11,7 @@ public class MapInitializeEvent extends ServerEvent { private static final HandlerList handlers = new HandlerList(); private final MapView mapView; - public MapInitializeEvent(final MapView mapView) { + public MapInitializeEvent(@NotNull final MapView mapView) { this.mapView = mapView; } @@ -19,15 +20,18 @@ public class MapInitializeEvent extends ServerEvent { * * @return Map for this event */ + @NotNull public MapView getMap() { return mapView; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java index 932c4fda3e..a4fe2d7b85 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Called when a plugin is disabled. @@ -9,15 +10,17 @@ import org.bukkit.plugin.Plugin; public class PluginDisableEvent extends PluginEvent { private static final HandlerList handlers = new HandlerList(); - public PluginDisableEvent(final Plugin plugin) { + public PluginDisableEvent(@NotNull final Plugin plugin) { super(plugin); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java index 865316de0c..fe78757d6a 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Called when a plugin is enabled. @@ -9,15 +10,17 @@ import org.bukkit.plugin.Plugin; public class PluginEnableEvent extends PluginEvent { private static final HandlerList handlers = new HandlerList(); - public PluginEnableEvent(final Plugin plugin) { + public PluginEnableEvent(@NotNull final Plugin plugin) { super(plugin); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java index 1ad656d69a..89487b359a 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.server; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Used for plugin enable and disable events @@ -8,7 +9,7 @@ import org.bukkit.plugin.Plugin; public abstract class PluginEvent extends ServerEvent { private final Plugin plugin; - public PluginEvent(final Plugin plugin) { + public PluginEvent(@NotNull final Plugin plugin) { this.plugin = plugin; } @@ -17,6 +18,7 @@ public abstract class PluginEvent extends ServerEvent { * * @return Plugin for this event */ + @NotNull public Plugin getPlugin() { return plugin; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java b/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java index 80ab4a9af7..2dac594c5c 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called when a command is received over RCON. See the javadocs @@ -10,15 +11,17 @@ import org.bukkit.event.HandlerList; public class RemoteServerCommandEvent extends ServerCommandEvent { private static final HandlerList handlers = new HandlerList(); - public RemoteServerCommandEvent(final CommandSender sender, final String command) { + public RemoteServerCommandEvent(@NotNull final CommandSender sender, @NotNull final String command) { super(sender, command); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java index 21250d4d37..617459afae 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.server; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called when a command is run by a non-player. It is @@ -44,7 +45,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable { private final CommandSender sender; private boolean cancel = false; - public ServerCommandEvent(final CommandSender sender, final String command) { + public ServerCommandEvent(@NotNull final CommandSender sender, @NotNull final String command) { this.command = command; this.sender = sender; } @@ -55,6 +56,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable { * * @return Command the user is attempting to execute */ + @NotNull public String getCommand() { return command; } @@ -64,7 +66,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable { * * @param message New message that the server will execute */ - public void setCommand(String message) { + public void setCommand(@NotNull String message) { this.command = message; } @@ -73,15 +75,18 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable { * * @return The sender */ + @NotNull public CommandSender getSender() { return sender; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java index 343f238fbb..d873763df7 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -4,9 +4,11 @@ import java.net.InetAddress; import java.util.Iterator; import org.apache.commons.lang.Validate; +import org.bukkit.UndefinedNullability; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.util.CachedServerIcon; +import org.jetbrains.annotations.NotNull; /** * Called when a server list ping is coming in. Displayed players can be @@ -20,7 +22,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable private final int numPlayers; private int maxPlayers; - public ServerListPingEvent(final InetAddress address, final String motd, final int numPlayers, final int maxPlayers) { + public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) { Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); this.address = address; this.motd = motd; @@ -37,7 +39,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * @param motd the message of the day * @param maxPlayers the max number of players */ - protected ServerListPingEvent(final InetAddress address, final String motd, final int maxPlayers) { + protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) { this.numPlayers = MAGIC_PLAYER_COUNT; this.address = address; this.motd = motd; @@ -49,6 +51,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * * @return the address */ + @NotNull public InetAddress getAddress() { return address; } @@ -58,6 +61,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * * @return the message of the day */ + @NotNull public String getMotd() { return motd; } @@ -67,7 +71,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * * @param motd the message of the day */ - public void setMotd(String motd) { + public void setMotd(@NotNull String motd) { this.motd = motd; } @@ -115,15 +119,17 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * @throws UnsupportedOperationException if the caller of this event does * not support setting the server icon */ - public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException { + public void setServerIcon(@UndefinedNullability("implementation dependent") CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException { throw new UnsupportedOperationException(); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } @@ -139,6 +145,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * @throws UnsupportedOperationException if the caller of this event does * not support removing players */ + @NotNull @Override public Iterator iterator() throws UnsupportedOperationException { throw new UnsupportedOperationException(); diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java index 722f862052..c9a252d7e2 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is called when either the server startup or reload has completed. @@ -22,7 +23,7 @@ public class ServerLoadEvent extends ServerEvent { * * @param type the context in which the server was loaded */ - public ServerLoadEvent(LoadType type) { + public ServerLoadEvent(@NotNull LoadType type) { this.type = type; } @@ -31,15 +32,18 @@ public class ServerLoadEvent extends ServerEvent { * * @return the context in which the server was loaded */ + @NotNull public LoadType getType() { return type; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java index 69bf8723f3..bbc2de5048 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.server; import org.bukkit.plugin.RegisteredServiceProvider; +import org.jetbrains.annotations.NotNull; /** * An event relating to a registered service. This is called in a {@link @@ -9,10 +10,11 @@ import org.bukkit.plugin.RegisteredServiceProvider; public abstract class ServiceEvent extends ServerEvent { private final RegisteredServiceProvider provider; - public ServiceEvent(final RegisteredServiceProvider provider) { + public ServiceEvent(@NotNull final RegisteredServiceProvider provider) { this.provider = provider; } + @NotNull public RegisteredServiceProvider getProvider() { return provider; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java index 7dfadde1ba..d7f9227ef5 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.RegisteredServiceProvider; +import org.jetbrains.annotations.NotNull; /** * This event is called when a service is registered. @@ -12,15 +13,17 @@ import org.bukkit.plugin.RegisteredServiceProvider; public class ServiceRegisterEvent extends ServiceEvent { private static final HandlerList handlers = new HandlerList(); - public ServiceRegisterEvent(RegisteredServiceProvider registeredProvider) { + public ServiceRegisterEvent(@NotNull RegisteredServiceProvider registeredProvider) { super(registeredProvider); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java index db61d236fd..f286799eeb 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.RegisteredServiceProvider; +import org.jetbrains.annotations.NotNull; /** * This event is called when a service is unregistered. @@ -12,15 +13,17 @@ import org.bukkit.plugin.RegisteredServiceProvider; public class ServiceUnregisterEvent extends ServiceEvent { private static final HandlerList handlers = new HandlerList(); - public ServiceUnregisterEvent(RegisteredServiceProvider serviceProvider) { + public ServiceUnregisterEvent(@NotNull RegisteredServiceProvider serviceProvider) { super(serviceProvider); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java index a6229839c4..d1a9956a15 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java @@ -7,6 +7,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerCommandSendEvent; +import org.jetbrains.annotations.NotNull; /** * Called when a {@link CommandSender} of any description (ie: player or @@ -27,7 +28,7 @@ public class TabCompleteEvent extends Event implements Cancellable { private List completions; private boolean cancelled; - public TabCompleteEvent(CommandSender sender, String buffer, List completions) { + public TabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, @NotNull List completions) { Validate.notNull(sender, "sender"); Validate.notNull(buffer, "buffer"); Validate.notNull(completions, "completions"); @@ -42,6 +43,7 @@ public class TabCompleteEvent extends Event implements Cancellable { * * @return the {@link CommandSender} instance */ + @NotNull public CommandSender getSender() { return sender; } @@ -51,6 +53,7 @@ public class TabCompleteEvent extends Event implements Cancellable { * * @return command buffer, as entered */ + @NotNull public String getBuffer() { return buffer; } @@ -61,6 +64,7 @@ public class TabCompleteEvent extends Event implements Cancellable { * * @return a list of offered completions */ + @NotNull public List getCompletions() { return completions; } @@ -70,7 +74,7 @@ public class TabCompleteEvent extends Event implements Cancellable { * * @param completions the new completions */ - public void setCompletions(List completions) { + public void setCompletions(@NotNull List completions) { Validate.notNull(completions); this.completions = completions; } @@ -85,11 +89,13 @@ public class TabCompleteEvent extends Event implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java index b643b57535..316f625aa5 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.vehicle; import org.bukkit.block.Block; import org.bukkit.entity.Vehicle; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle collides with a block. @@ -11,7 +12,7 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { private static final HandlerList handlers = new HandlerList(); private final Block block; - public VehicleBlockCollisionEvent(final Vehicle vehicle, final Block block) { + public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block) { super(vehicle); this.block = block; } @@ -21,15 +22,18 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { * * @return the block the vehicle collided with */ + @NotNull public Block getBlock() { return block; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java index 9dd0579228..9d493c155a 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java @@ -1,12 +1,13 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; +import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle collides. */ public abstract class VehicleCollisionEvent extends VehicleEvent { - public VehicleCollisionEvent(final Vehicle vehicle) { + public VehicleCollisionEvent(@NotNull final Vehicle vehicle) { super(vehicle); } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java index eb55c1f17d..c1f107db9e 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle is created. @@ -11,7 +12,7 @@ public class VehicleCreateEvent extends VehicleEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; - public VehicleCreateEvent(final Vehicle vehicle) { + public VehicleCreateEvent(@NotNull final Vehicle vehicle) { super(vehicle); } @@ -25,11 +26,13 @@ public class VehicleCreateEvent extends VehicleEvent implements Cancellable { this.cancelled = cancelled; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java index dec18b8337..ced91e4e4b 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Raised when a vehicle receives damage. @@ -14,7 +16,7 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { private double damage; private boolean cancelled; - public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final double damage) { + public VehicleDamageEvent(@NotNull final Vehicle vehicle, @Nullable final Entity attacker, final double damage) { super(vehicle); this.attacker = attacker; this.damage = damage; @@ -25,6 +27,7 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { * * @return the Entity that is attacking the vehicle */ + @Nullable public Entity getAttacker() { return attacker; } @@ -55,11 +58,13 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java index f1176fd2a5..2ee6ffd0f8 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Raised when a vehicle is destroyed, which could be caused by either a @@ -15,7 +17,7 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { private final Entity attacker; private boolean cancelled; - public VehicleDestroyEvent(final Vehicle vehicle, final Entity attacker) { + public VehicleDestroyEvent(@NotNull final Vehicle vehicle, @Nullable final Entity attacker) { super(vehicle); this.attacker = attacker; } @@ -25,6 +27,7 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { * * @return the Entity that has destroyed the vehicle, potentially null */ + @Nullable public Entity getAttacker() { return attacker; } @@ -37,11 +40,13 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java index 85c9b210b8..066992f0af 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Raised when an entity enters a vehicle. @@ -13,7 +14,7 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { private boolean cancelled; private final Entity entered; - public VehicleEnterEvent(final Vehicle vehicle, final Entity entered) { + public VehicleEnterEvent(@NotNull final Vehicle vehicle, @NotNull final Entity entered) { super(vehicle); this.entered = entered; } @@ -23,6 +24,7 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { * * @return the Entity that entered the vehicle */ + @NotNull public Entity getEntered() { return entered; } @@ -35,11 +37,13 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java index 4d4d0e25f1..235c687277 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle collides with an entity. @@ -15,11 +16,12 @@ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implement private boolean cancelledPickup = false; private boolean cancelledCollision = false; - public VehicleEntityCollisionEvent(final Vehicle vehicle, final Entity entity) { + public VehicleEntityCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Entity entity) { super(vehicle); this.entity = entity; } + @NotNull public Entity getEntity() { return entity; } @@ -48,11 +50,13 @@ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implement cancelledCollision = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java index b8255c013c..63df270565 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents a vehicle-related event. @@ -9,7 +10,7 @@ import org.bukkit.event.Event; public abstract class VehicleEvent extends Event { protected Vehicle vehicle; - public VehicleEvent(final Vehicle vehicle) { + public VehicleEvent(@NotNull final Vehicle vehicle) { this.vehicle = vehicle; } @@ -18,6 +19,7 @@ public abstract class VehicleEvent extends Event { * * @return the vehicle */ + @NotNull public final Vehicle getVehicle() { return vehicle; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java index 364451b56e..69c9e499af 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Raised when a living entity exits a vehicle. @@ -13,7 +14,7 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable { private boolean cancelled; private final LivingEntity exited; - public VehicleExitEvent(final Vehicle vehicle, final LivingEntity exited) { + public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) { super(vehicle); this.exited = exited; } @@ -23,6 +24,7 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable { * * @return The entity. */ + @NotNull public LivingEntity getExited() { return exited; } @@ -35,11 +37,13 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable { this.cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java index 9a13e2965d..7bfb84d394 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.vehicle; import org.bukkit.Location; import org.bukkit.entity.Vehicle; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle moves. @@ -12,7 +13,7 @@ public class VehicleMoveEvent extends VehicleEvent { private final Location from; private final Location to; - public VehicleMoveEvent(final Vehicle vehicle, final Location from, final Location to) { + public VehicleMoveEvent(@NotNull final Vehicle vehicle, @NotNull final Location from, @NotNull final Location to) { super(vehicle); this.from = from; @@ -24,6 +25,7 @@ public class VehicleMoveEvent extends VehicleEvent { * * @return Old position. */ + @NotNull public Location getFrom() { return from; } @@ -33,16 +35,19 @@ public class VehicleMoveEvent extends VehicleEvent { * * @return New position. */ + @NotNull public Location getTo() { return to; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java index eebfdb157e..098192a5e7 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a vehicle updates @@ -9,15 +10,17 @@ import org.bukkit.event.HandlerList; public class VehicleUpdateEvent extends VehicleEvent { private static final HandlerList handlers = new HandlerList(); - public VehicleUpdateEvent(final Vehicle vehicle) { + public VehicleUpdateEvent(@NotNull final Vehicle vehicle) { super(vehicle); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java index 47642af606..45f26a7b3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.World; import org.bukkit.entity.LightningStrike; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores data for lightning striking @@ -15,11 +16,11 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { private final Cause cause; @Deprecated - public LightningStrikeEvent(final World world, final LightningStrike bolt) { + public LightningStrikeEvent(@NotNull final World world, @NotNull final LightningStrike bolt) { this(world, bolt, Cause.UNKNOWN); } - public LightningStrikeEvent(final World world, final LightningStrike bolt, final Cause cause) { + public LightningStrikeEvent(@NotNull final World world, @NotNull final LightningStrike bolt, @NotNull final Cause cause) { super(world); this.bolt = bolt; this.cause = cause; @@ -38,6 +39,7 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { * * @return lightning entity */ + @NotNull public LightningStrike getLightning() { return bolt; } @@ -47,15 +49,18 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { * * @return strike cause */ + @NotNull public Cause getCause() { return cause; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java index 5e3716e92c..641769dfea 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.weather; import org.bukkit.World; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores data for thunder state changing in a world @@ -12,7 +13,7 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { private boolean canceled; private final boolean to; - public ThunderChangeEvent(final World world, final boolean to) { + public ThunderChangeEvent(@NotNull final World world, final boolean to) { super(world); this.to = to; } @@ -34,11 +35,13 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { return to; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java index 5d1234e5ab..db19e79090 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.weather; import org.bukkit.World; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Stores data for weather changing in a world @@ -12,7 +13,7 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { private boolean canceled; private final boolean to; - public WeatherChangeEvent(final World world, final boolean to) { + public WeatherChangeEvent(@NotNull final World world, final boolean to) { super(world); this.to = to; } @@ -34,11 +35,13 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { return to; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java index 0cae9bcb45..e1854d8073 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.weather; import org.bukkit.World; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents a Weather-related event @@ -9,7 +10,7 @@ import org.bukkit.event.Event; public abstract class WeatherEvent extends Event { protected World world; - public WeatherEvent(final World where) { + public WeatherEvent(@NotNull final World where) { world = where; } @@ -18,6 +19,7 @@ public abstract class WeatherEvent extends Event { * * @return World this event is occurring in */ + @NotNull public final World getWorld() { return world; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java index 4710d40fdd..7ffc6a77ba 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.world; import org.bukkit.Chunk; +import org.jetbrains.annotations.NotNull; /** * Represents a Chunk related event @@ -8,7 +9,7 @@ import org.bukkit.Chunk; public abstract class ChunkEvent extends WorldEvent { protected Chunk chunk; - protected ChunkEvent(final Chunk chunk) { + protected ChunkEvent(@NotNull final Chunk chunk) { super(chunk.getWorld()); this.chunk = chunk; } @@ -18,6 +19,7 @@ public abstract class ChunkEvent extends WorldEvent { * * @return Chunk that triggered this event */ + @NotNull public Chunk getChunk() { return chunk; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java index a45b1cd41f..ae8ef33925 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.world; import org.bukkit.Chunk; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a chunk is loaded @@ -10,7 +11,7 @@ public class ChunkLoadEvent extends ChunkEvent { private static final HandlerList handlers = new HandlerList(); private final boolean newChunk; - public ChunkLoadEvent(final Chunk chunk, final boolean newChunk) { + public ChunkLoadEvent(@NotNull final Chunk chunk, final boolean newChunk) { super(chunk); this.newChunk = newChunk; } @@ -26,11 +27,13 @@ public class ChunkLoadEvent extends ChunkEvent { return newChunk; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java index 705d95561a..46d91403cd 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.Chunk; import org.bukkit.event.HandlerList; import org.bukkit.generator.BlockPopulator; +import org.jetbrains.annotations.NotNull; /** * Thrown when a new chunk has finished being populated. @@ -13,15 +14,17 @@ import org.bukkit.generator.BlockPopulator; public class ChunkPopulateEvent extends ChunkEvent { private static final HandlerList handlers = new HandlerList(); - public ChunkPopulateEvent(final Chunk chunk) { + public ChunkPopulateEvent(@NotNull final Chunk chunk) { super(chunk); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java index aa8573dcec..145cbe2ebe 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.Chunk; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a chunk is unloaded @@ -12,11 +13,11 @@ public class ChunkUnloadEvent extends ChunkEvent implements Cancellable { private boolean cancel = false; private boolean saveChunk; - public ChunkUnloadEvent(final Chunk chunk) { + public ChunkUnloadEvent(@NotNull final Chunk chunk) { this(chunk, true); } - public ChunkUnloadEvent(Chunk chunk, boolean save) { + public ChunkUnloadEvent(@NotNull Chunk chunk, boolean save) { super(chunk); this.saveChunk = save; } @@ -47,11 +48,13 @@ public class ChunkUnloadEvent extends ChunkEvent implements Cancellable { this.cancel = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java index d83d7a9981..7142726625 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.World; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -17,7 +18,7 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { private final ArrayList blocks = new ArrayList(); private CreateReason reason = CreateReason.FIRE; - public PortalCreateEvent(final Collection blocks, final World world, CreateReason reason) { + public PortalCreateEvent(@NotNull final Collection blocks, @NotNull final World world, @NotNull CreateReason reason) { super(world); this.blocks.addAll(blocks); @@ -29,6 +30,7 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { * * @return array list of all the blocks associated with the created portal */ + @NotNull public ArrayList getBlocks() { return this.blocks; } @@ -46,15 +48,18 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { * * @return CreateReason for the portal's creation */ + @NotNull public CreateReason getReason() { return reason; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java index e99c3c0107..4c49c7619a 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.Location; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * An event that is called when a world's spawn changes. The world's previous @@ -12,7 +13,7 @@ public class SpawnChangeEvent extends WorldEvent { private static final HandlerList handlers = new HandlerList(); private final Location previousLocation; - public SpawnChangeEvent(final World world, final Location previousLocation) { + public SpawnChangeEvent(@NotNull final World world, @NotNull final Location previousLocation) { super(world); this.previousLocation = previousLocation; } @@ -22,15 +23,18 @@ public class SpawnChangeEvent extends WorldEvent { * * @return Location that used to be spawn */ + @NotNull public Location getPreviousLocation() { return previousLocation; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java b/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java index 7bf82e391d..578337699a 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java @@ -7,6 +7,8 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Event that is called when an organic structure attempts to grow (Sapling {@literal ->} @@ -21,7 +23,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { private final Player player; private final List blocks; - public StructureGrowEvent(final Location location, final TreeType species, final boolean bonemeal, final Player player, final List blocks) { + public StructureGrowEvent(@NotNull final Location location, @NotNull final TreeType species, final boolean bonemeal, @Nullable final Player player, @NotNull final List blocks) { super(location.getWorld()); this.location = location; this.species = species; @@ -35,6 +37,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { * * @return Location of the structure */ + @NotNull public Location getLocation() { return location; } @@ -45,6 +48,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { * * @return Structure species */ + @NotNull public TreeType getSpecies() { return species; } @@ -64,6 +68,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { * @return Player that created the structure, null if was not created * manually */ + @Nullable public Player getPlayer() { return player; } @@ -73,6 +78,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { * * @return list of all blocks associated with the structure. */ + @NotNull public List getBlocks() { return blocks; } @@ -85,11 +91,13 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { cancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java index bd89b81dd9..cffeff33f0 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; /** * Represents events within a world @@ -9,7 +10,7 @@ import org.bukkit.event.Event; public abstract class WorldEvent extends Event { private final World world; - public WorldEvent(final World world) { + public WorldEvent(@NotNull final World world) { this.world = world; } @@ -18,6 +19,7 @@ public abstract class WorldEvent extends Event { * * @return World which caused this event */ + @NotNull public World getWorld() { return world; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java index 6bf13e0664..8b521dedad 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a World is initializing @@ -9,15 +10,17 @@ import org.bukkit.event.HandlerList; public class WorldInitEvent extends WorldEvent { private static final HandlerList handlers = new HandlerList(); - public WorldInitEvent(final World world) { + public WorldInitEvent(@NotNull final World world) { super(world); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java index c5545aa1d3..552e15cd4a 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a World is loaded @@ -9,15 +10,17 @@ import org.bukkit.event.HandlerList; public class WorldLoadEvent extends WorldEvent { private static final HandlerList handlers = new HandlerList(); - public WorldLoadEvent(final World world) { + public WorldLoadEvent(@NotNull final World world) { super(world); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java index d46b413c17..9a9bb1362b 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a World is saved. @@ -9,15 +10,17 @@ import org.bukkit.event.HandlerList; public class WorldSaveEvent extends WorldEvent { private static final HandlerList handlers = new HandlerList(); - public WorldSaveEvent(final World world) { + public WorldSaveEvent(@NotNull final World world) { super(world); } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java index 110544b73c..d1cb72116c 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a World is unloaded @@ -11,7 +12,7 @@ public class WorldUnloadEvent extends WorldEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean isCancelled; - public WorldUnloadEvent(final World world) { + public WorldUnloadEvent(@NotNull final World world) { super(world); } @@ -23,11 +24,13 @@ public class WorldUnloadEvent extends WorldEvent implements Cancellable { this.isCancelled = cancel; } + @NotNull @Override public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/paper-api/src/main/java/org/bukkit/generator/BlockPopulator.java b/paper-api/src/main/java/org/bukkit/generator/BlockPopulator.java index 6a70bdb8d4..e5e3a6a548 100644 --- a/paper-api/src/main/java/org/bukkit/generator/BlockPopulator.java +++ b/paper-api/src/main/java/org/bukkit/generator/BlockPopulator.java @@ -3,6 +3,7 @@ package org.bukkit.generator; import java.util.Random; import org.bukkit.Chunk; import org.bukkit.World; +import org.jetbrains.annotations.NotNull; /** * A block populator is responsible for generating a small area of blocks. @@ -25,5 +26,5 @@ public abstract class BlockPopulator { * @param random The random generator to use * @param source The chunk to generate for */ - public abstract void populate(World world, Random random, Chunk source); + public abstract void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source); } diff --git a/paper-api/src/main/java/org/bukkit/generator/ChunkGenerator.java b/paper-api/src/main/java/org/bukkit/generator/ChunkGenerator.java index 6caef0074d..9a18a05bb3 100644 --- a/paper-api/src/main/java/org/bukkit/generator/ChunkGenerator.java +++ b/paper-api/src/main/java/org/bukkit/generator/ChunkGenerator.java @@ -11,6 +11,8 @@ import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A chunk generator is responsible for the initial shaping of an entire @@ -35,6 +37,7 @@ public abstract class ChunkGenerator { * @param z - 0-15 * @return Biome value */ + @NotNull Biome getBiome(int x, int z); /** @@ -44,7 +47,7 @@ public abstract class ChunkGenerator { * @param z - 0-15 * @param bio - Biome value */ - void setBiome(int x, int z, Biome bio); + void setBiome(int x, int z, @NotNull Biome bio); } /** @@ -71,7 +74,8 @@ public abstract class ChunkGenerator { * @return ChunkData containing the types for each block created by this * generator */ - public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) { + @NotNull + public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) { throw new UnsupportedOperationException("Custom generator is missing required method generateChunkData"); } @@ -80,7 +84,8 @@ public abstract class ChunkGenerator { * @param world the world the ChunkData is for * @return a new ChunkData for world */ - protected final ChunkData createChunkData(World world) { + @NotNull + protected final ChunkData createChunkData(@NotNull World world) { return Bukkit.getServer().createChunkData(world); } @@ -92,7 +97,7 @@ public abstract class ChunkGenerator { * @param z Z-coordinate of the block to test * @return true if the location is valid, otherwise false */ - public boolean canSpawn(World world, int x, int z) { + public boolean canSpawn(@NotNull World world, int x, int z) { Block highest = world.getBlockAt(x, world.getHighestBlockYAt(x, z), z); switch (world.getEnvironment()) { @@ -113,7 +118,8 @@ public abstract class ChunkGenerator { * @param world World to apply to * @return List containing any amount of BlockPopulators */ - public List getDefaultPopulators(World world) { + @NotNull + public List getDefaultPopulators(@NotNull World world) { return new ArrayList(); } @@ -127,7 +133,8 @@ public abstract class ChunkGenerator { * @param random Random generator to use in the calculation * @return Location containing a new spawn point, otherwise null */ - public Location getFixedSpawnLocation(World world, Random random) { + @Nullable + public Location getFixedSpawnLocation(@NotNull World world, @NotNull Random random) { return null; } @@ -154,7 +161,7 @@ public abstract class ChunkGenerator { * @param z the z location in the chunk from 0-15 inclusive * @param material the type to set the block to */ - public void setBlock(int x, int y, int z, Material material); + public void setBlock(int x, int y, int z, @NotNull Material material); /** * Set the block at x,y,z in the chunk data to material. @@ -166,7 +173,7 @@ public abstract class ChunkGenerator { * @param z the z location in the chunk from 0-15 inclusive * @param material the type to set the block to */ - public void setBlock(int x, int y, int z, MaterialData material); + public void setBlock(int x, int y, int z, @NotNull MaterialData material); /** * Set the block at x,y,z in the chunk data to material. @@ -178,7 +185,7 @@ public abstract class ChunkGenerator { * @param z the z location in the chunk from 0-15 inclusive * @param blockData the type to set the block to */ - public void setBlock(int x, int y, int z, BlockData blockData); + public void setBlock(int x, int y, int z, @NotNull BlockData blockData); /** * Set a region of this chunk from xMin, yMin, zMin (inclusive) @@ -194,7 +201,7 @@ public abstract class ChunkGenerator { * @param zMax maximum z location (exclusive) in the chunk to set * @param material the type to set the blocks to */ - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material); + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material); /** * Set a region of this chunk from xMin, yMin, zMin (inclusive) @@ -210,7 +217,7 @@ public abstract class ChunkGenerator { * @param zMax maximum z location (exclusive) in the chunk to set * @param material the type to set the blocks to */ - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material); + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material); /** * Set a region of this chunk from xMin, yMin, zMin (inclusive) to xMax, @@ -226,7 +233,7 @@ public abstract class ChunkGenerator { * @param zMax maximum z location (exclusive) in the chunk to set * @param blockData the type to set the blocks to */ - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData); + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData); /** * Get the type of the block at x, y, z. @@ -238,10 +245,11 @@ public abstract class ChunkGenerator { * @param z the z location in the chunk from 0-15 inclusive * @return the type of the block or Material.AIR if x, y or z are outside the chunk's bounds */ + @NotNull public Material getType(int x, int y, int z); /** - * Get the type and data of the block at x, y ,z. + * Get the type and data of the block at x, y, z. * * Getting blocks outside the chunk's bounds returns air. * @@ -250,18 +258,20 @@ public abstract class ChunkGenerator { * @param z the z location in the chunk from 0-15 inclusive * @return the type and data of the block or the MaterialData for air if x, y or z are outside the chunk's bounds */ + @NotNull public MaterialData getTypeAndData(int x, int y, int z); /** - * Get the type and data of the block at x, y ,z. + * Get the type and data of the block at x, y, z. * * Getting blocks outside the chunk's bounds returns air. * * @param x the x location in the chunk from 0-15 inclusive * @param y the y location in the chunk from 0 (inclusive) - maxHeight (exclusive) * @param z the z location in the chunk from 0-15 inclusive - * @return the data of the block or the MaterialData for air if x, y or z are outside the chunk's bounds + * @return the data of the block or the BlockData for air if x, y or z are outside the chunk's bounds */ + @NotNull public BlockData getBlockData(int x, int y, int z); /** diff --git a/paper-api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java b/paper-api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java index 8f9a25c1ff..b05f570a8e 100644 --- a/paper-api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java +++ b/paper-api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java @@ -5,6 +5,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.apache.commons.lang.StringUtils; import org.bukkit.command.ConsoleCommandSender; +import org.jetbrains.annotations.NotNull; /** * Lacking an alternative, the help system will create instances of @@ -16,7 +17,7 @@ public class GenericCommandHelpTopic extends HelpTopic { protected Command command; - public GenericCommandHelpTopic(Command command) { + public GenericCommandHelpTopic(@NotNull Command command) { this.command = command; if (command.getLabel().startsWith("/")) { @@ -58,7 +59,7 @@ public class GenericCommandHelpTopic extends HelpTopic { fullText = sb.toString(); } - public boolean canSee(CommandSender sender) { + public boolean canSee(@NotNull CommandSender sender) { if (!command.isRegistered()) { // Unregistered commands should not show up in the help return false; diff --git a/paper-api/src/main/java/org/bukkit/help/HelpMap.java b/paper-api/src/main/java/org/bukkit/help/HelpMap.java index 43017c841b..45845238e4 100644 --- a/paper-api/src/main/java/org/bukkit/help/HelpMap.java +++ b/paper-api/src/main/java/org/bukkit/help/HelpMap.java @@ -1,5 +1,8 @@ package org.bukkit.help; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Collection; import java.util.List; @@ -24,13 +27,15 @@ public interface HelpMap { * @return A {@link HelpTopic} object matching the topic name or null if * none can be found. */ - public HelpTopic getHelpTopic(String topicName); + @Nullable + public HelpTopic getHelpTopic(@NotNull String topicName); /** * Returns a collection of all the registered help topics. * * @return All the registered help topics. */ + @NotNull public Collection getHelpTopics(); /** @@ -38,7 +43,7 @@ public interface HelpMap { * * @param topic The new help topic to add. */ - public void addTopic(HelpTopic topic); + public void addTopic(@NotNull HelpTopic topic); /** * Clears out the contents of the help index. Normally called during @@ -63,7 +68,7 @@ public interface HelpMap { * @throws IllegalArgumentException Thrown if {@code commandClass} does * not derive from a legal base class. */ - public void registerHelpTopicFactory(Class commandClass, HelpTopicFactory factory); + public void registerHelpTopicFactory(@NotNull Class commandClass, @NotNull HelpTopicFactory factory); /** * Gets the list of plugins the server administrator has chosen to exclude @@ -75,5 +80,6 @@ public interface HelpMap { * * @return A list of plugins that should be excluded from the help index. */ + @NotNull public List getIgnoredPlugins(); } diff --git a/paper-api/src/main/java/org/bukkit/help/HelpTopic.java b/paper-api/src/main/java/org/bukkit/help/HelpTopic.java index a2ba5f56a3..2e2e1af50d 100644 --- a/paper-api/src/main/java/org/bukkit/help/HelpTopic.java +++ b/paper-api/src/main/java/org/bukkit/help/HelpTopic.java @@ -2,6 +2,8 @@ package org.bukkit.help; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * HelpTopic implementations are displayed to the user when the user uses the @@ -16,11 +18,11 @@ import org.bukkit.entity.Player; * the methods in this class. */ public abstract class HelpTopic { - protected String name; - protected String shortText; - protected String fullText; - protected String amendedPermission; - + protected String name = ""; + protected String shortText = ""; + protected String fullText = ""; + protected String amendedPermission = null; + /** * Determines if a {@link Player} is allowed to see this help topic. *

@@ -30,7 +32,7 @@ public abstract class HelpTopic { * @param player The Player in question. * @return True of the Player can see this help topic, false otherwise. */ - public abstract boolean canSee(CommandSender player); + public abstract boolean canSee(@NotNull CommandSender player); /** * Allows the server administrator to override the permission required to @@ -43,7 +45,7 @@ public abstract class HelpTopic { * @param amendedPermission The permission node the server administrator * wishes to apply to this topic. */ - public void amendCanSee(String amendedPermission) { + public void amendCanSee(@Nullable String amendedPermission) { this.amendedPermission = amendedPermission; } @@ -52,6 +54,7 @@ public abstract class HelpTopic { * * @return The topic name. */ + @NotNull public String getName() { return name; } @@ -61,6 +64,7 @@ public abstract class HelpTopic { * * @return A brief topic description. */ + @NotNull public String getShortText() { return shortText; } @@ -77,7 +81,8 @@ public abstract class HelpTopic { * * @return A full topic description. */ - public String getFullText(CommandSender forWho) { + @NotNull + public String getFullText(@NotNull CommandSender forWho) { return fullText; } @@ -95,7 +100,7 @@ public abstract class HelpTopic { * @param amendedFullText The new topic full text to use, or null to leave * alone. */ - public void amendTopic(String amendedShortText, String amendedFullText) { + public void amendTopic(@Nullable String amendedShortText, @Nullable String amendedFullText) { shortText = applyAmendment(shortText, amendedShortText); fullText = applyAmendment(fullText, amendedFullText); } @@ -111,7 +116,8 @@ public abstract class HelpTopic { * @return The application of the amending text to the existing text, * according to the expected rules of amendTopic(). */ - protected String applyAmendment(String baseText, String amendment) { + @NotNull + protected String applyAmendment(@NotNull String baseText, @Nullable String amendment) { if (amendment == null) { return baseText; } else { diff --git a/paper-api/src/main/java/org/bukkit/help/HelpTopicComparator.java b/paper-api/src/main/java/org/bukkit/help/HelpTopicComparator.java index 3e62e91bdf..e586826d90 100644 --- a/paper-api/src/main/java/org/bukkit/help/HelpTopicComparator.java +++ b/paper-api/src/main/java/org/bukkit/help/HelpTopicComparator.java @@ -1,5 +1,7 @@ package org.bukkit.help; +import org.jetbrains.annotations.NotNull; + import java.util.Comparator; /** @@ -12,25 +14,27 @@ public class HelpTopicComparator implements Comparator { // Singleton implementations private static final TopicNameComparator tnc = new TopicNameComparator(); + @NotNull public static TopicNameComparator topicNameComparatorInstance() { return tnc; } private static final HelpTopicComparator htc = new HelpTopicComparator(); + @NotNull public static HelpTopicComparator helpTopicComparatorInstance() { return htc; } private HelpTopicComparator() {} - public int compare(HelpTopic lhs, HelpTopic rhs) { + public int compare(@NotNull HelpTopic lhs, @NotNull HelpTopic rhs) { return tnc.compare(lhs.getName(), rhs.getName()); } public static class TopicNameComparator implements Comparator { private TopicNameComparator(){} - public int compare(String lhs, String rhs) { + public int compare(@NotNull String lhs, @NotNull String rhs) { boolean lhsStartSlash = lhs.startsWith("/"); boolean rhsStartSlash = rhs.startsWith("/"); diff --git a/paper-api/src/main/java/org/bukkit/help/HelpTopicFactory.java b/paper-api/src/main/java/org/bukkit/help/HelpTopicFactory.java index 87d36977ba..b85da3f6dc 100644 --- a/paper-api/src/main/java/org/bukkit/help/HelpTopicFactory.java +++ b/paper-api/src/main/java/org/bukkit/help/HelpTopicFactory.java @@ -1,6 +1,8 @@ package org.bukkit.help; import org.bukkit.command.Command; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A HelpTopicFactory is used to create custom {@link HelpTopic} objects from @@ -38,5 +40,6 @@ public interface HelpTopicFactory { * @return A new custom help topic or {@code null} to intentionally NOT * create a topic. */ - public HelpTopic createTopic(TCommand command); + @Nullable + public HelpTopic createTopic(@NotNull TCommand command); } diff --git a/paper-api/src/main/java/org/bukkit/help/IndexHelpTopic.java b/paper-api/src/main/java/org/bukkit/help/IndexHelpTopic.java index c474031b54..2914c9f8a7 100644 --- a/paper-api/src/main/java/org/bukkit/help/IndexHelpTopic.java +++ b/paper-api/src/main/java/org/bukkit/help/IndexHelpTopic.java @@ -5,6 +5,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.util.ChatPaginator; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -22,15 +24,15 @@ public class IndexHelpTopic extends HelpTopic { protected String preamble; protected Collection allTopics; - public IndexHelpTopic(String name, String shortText, String permission, Collection topics) { + public IndexHelpTopic(@NotNull String name, @Nullable String shortText, @Nullable String permission, @NotNull Collection topics) { this(name, shortText, permission, topics, null); } - public IndexHelpTopic(String name, String shortText, String permission, Collection topics, String preamble) { + public IndexHelpTopic(@NotNull String name, @Nullable String shortText, @Nullable String permission, @NotNull Collection topics, @Nullable String preamble) { this.name = name; - this.shortText = shortText; + this.shortText = (shortText == null) ? "" : shortText; this.permission = permission; - this.preamble = preamble; + this.preamble = (preamble == null) ? "" : preamble; setTopicsCollection(topics); } @@ -39,11 +41,11 @@ public class IndexHelpTopic extends HelpTopic { * * @param topics The topics to set. */ - protected void setTopicsCollection(Collection topics) { + protected void setTopicsCollection(@NotNull Collection topics) { this.allTopics = topics; } - public boolean canSee(CommandSender sender) { + public boolean canSee(@NotNull CommandSender sender) { if (sender instanceof ConsoleCommandSender) { return true; } @@ -54,11 +56,12 @@ public class IndexHelpTopic extends HelpTopic { } @Override - public void amendCanSee(String amendedPermission) { + public void amendCanSee(@Nullable String amendedPermission) { permission = amendedPermission; } - public String getFullText(CommandSender sender) { + @NotNull + public String getFullText(@NotNull CommandSender sender) { StringBuilder sb = new StringBuilder(); if (preamble != null) { @@ -70,7 +73,7 @@ public class IndexHelpTopic extends HelpTopic { if (topic.canSee(sender)) { String lineStr = buildIndexLine(sender, topic).replace("\n", ". "); if (sender instanceof Player && lineStr.length() > ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH) { - sb.append(lineStr.substring(0, ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - 3)); + sb.append(lineStr, 0, ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - 3); sb.append("..."); } else { sb.append(lineStr); @@ -88,7 +91,8 @@ public class IndexHelpTopic extends HelpTopic { * @param sender The command sender requesting the preamble. * @return The topic preamble. */ - protected String buildPreamble(CommandSender sender) { + @NotNull + protected String buildPreamble(@NotNull CommandSender sender) { return ChatColor.GRAY + preamble; } @@ -100,7 +104,8 @@ public class IndexHelpTopic extends HelpTopic { * @param topic The topic to render into an index line. * @return The rendered index line. */ - protected String buildIndexLine(CommandSender sender, HelpTopic topic) { + @NotNull + protected String buildIndexLine(@NotNull CommandSender sender, @NotNull HelpTopic topic) { StringBuilder line = new StringBuilder(); line.append(ChatColor.GOLD); line.append(topic.getName()); diff --git a/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java b/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java index 4c16e34aa6..93c1158f8d 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java @@ -1,6 +1,7 @@ package org.bukkit.inventory; import org.bukkit.entity.AbstractHorse; +import org.jetbrains.annotations.Nullable; /** * An interface to the inventory of an {@link AbstractHorse}. @@ -12,6 +13,7 @@ public interface AbstractHorseInventory extends Inventory { * * @return the saddle item */ + @Nullable ItemStack getSaddle(); /** @@ -19,5 +21,5 @@ public interface AbstractHorseInventory extends Inventory { * * @param stack the new item */ - void setSaddle(ItemStack stack); + void setSaddle(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java b/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java index b2c6e2150b..4af562426a 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.Nullable; + /** * Interface to the inventory of an Anvil. */ @@ -11,6 +13,7 @@ public interface AnvilInventory extends Inventory { * * @return the rename text */ + @Nullable String getRenameText(); /** diff --git a/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java b/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java index 2f8769edc6..bd2289b18f 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.Nullable; + /** * Interface to the inventory of a Beacon. */ @@ -10,12 +12,13 @@ public interface BeaconInventory extends Inventory { * * @param item The new item */ - void setItem(ItemStack item); + void setItem(@Nullable ItemStack item); /** * Get the item powering the beacon. * * @return The current item. */ + @Nullable ItemStack getItem(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/BrewerInventory.java b/paper-api/src/main/java/org/bukkit/inventory/BrewerInventory.java index 3aaf17e1e7..df45423e66 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/BrewerInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/BrewerInventory.java @@ -2,6 +2,7 @@ package org.bukkit.inventory; import org.bukkit.Material; import org.bukkit.block.BrewingStand; +import org.jetbrains.annotations.Nullable; /** * Interface to the inventory of a Brewing Stand. @@ -13,6 +14,7 @@ public interface BrewerInventory extends Inventory { * * @return The ingredient. */ + @Nullable ItemStack getIngredient(); /** @@ -20,13 +22,14 @@ public interface BrewerInventory extends Inventory { * * @param ingredient The ingredient */ - void setIngredient(ItemStack ingredient); + void setIngredient(@Nullable ItemStack ingredient); /** * Get the current fuel for brewing. * * @return The fuel */ + @Nullable ItemStack getFuel(); /** @@ -35,7 +38,8 @@ public interface BrewerInventory extends Inventory { * * @param fuel The fuel */ - void setFuel(ItemStack fuel); + void setFuel(@Nullable ItemStack fuel); + @Nullable BrewingStand getHolder(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/CraftingInventory.java b/paper-api/src/main/java/org/bukkit/inventory/CraftingInventory.java index 106367e732..df81bac9ec 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/CraftingInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/CraftingInventory.java @@ -1,5 +1,8 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Interface to the crafting inventories */ @@ -10,13 +13,15 @@ public interface CraftingInventory extends Inventory { * * @return The result item. */ + @Nullable ItemStack getResult(); /** * Get the contents of the crafting matrix. * - * @return The contents. + * @return The contents. Individual entries may be null. */ + @NotNull ItemStack[] getMatrix(); /** @@ -24,16 +29,16 @@ public interface CraftingInventory extends Inventory { * * @param newResult The new result item. */ - void setResult(ItemStack newResult); + void setResult(@Nullable ItemStack newResult); /** * Replace the contents of the crafting matrix * - * @param contents The new contents. + * @param contents The new contents. Individual entries may be null. * @throws IllegalArgumentException if the length of contents is greater * than the size of the crafting matrix. */ - void setMatrix(ItemStack[] contents); + void setMatrix(@NotNull ItemStack[] contents); /** * Get the current recipe formed on the crafting inventory, if any. @@ -41,5 +46,6 @@ public interface CraftingInventory extends Inventory { * @return The recipe, or null if the current contents don't match any * recipe. */ + @Nullable Recipe getRecipe(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java b/paper-api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java index c03ad535c0..ca18cc8afb 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java @@ -1,6 +1,8 @@ package org.bukkit.inventory; import org.bukkit.block.DoubleChest; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Interface to the inventory of a Double Chest. @@ -12,6 +14,7 @@ public interface DoubleChestInventory extends Inventory { * * @return The left side inventory */ + @NotNull Inventory getLeftSide(); /** @@ -19,7 +22,9 @@ public interface DoubleChestInventory extends Inventory { * * @return The right side inventory */ + @NotNull Inventory getRightSide(); + @Nullable DoubleChest getHolder(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/EnchantingInventory.java b/paper-api/src/main/java/org/bukkit/inventory/EnchantingInventory.java index 6551a16aa2..ea47af00c0 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EnchantingInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EnchantingInventory.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.Nullable; + /** * Interface to the inventory of an Enchantment Table. */ @@ -10,13 +12,14 @@ public interface EnchantingInventory extends Inventory { * * @param item The new item */ - void setItem(ItemStack item); + void setItem(@Nullable ItemStack item); /** * Get the item being enchanted. * * @return The current item. */ + @Nullable ItemStack getItem(); /** @@ -24,12 +27,13 @@ public interface EnchantingInventory extends Inventory { * * @param item The new item */ - void setSecondary(ItemStack item); + void setSecondary(@Nullable ItemStack item); /** * Get the secondary item being used for the enchant. * * @return The second item */ + @Nullable ItemStack getSecondary(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/EntityEquipment.java b/paper-api/src/main/java/org/bukkit/inventory/EntityEquipment.java index aee8163cea..6875dbc725 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EntityEquipment.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EntityEquipment.java @@ -1,6 +1,8 @@ package org.bukkit.inventory; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An interface to a creatures inventory @@ -13,6 +15,7 @@ public interface EntityEquipment { * * @return the currently held item */ + @NotNull ItemStack getItemInMainHand(); /** @@ -20,7 +23,7 @@ public interface EntityEquipment { * * @param item The item to put into the entities hand */ - void setItemInMainHand(ItemStack item); + void setItemInMainHand(@Nullable ItemStack item); /** * Gets a copy of the item the entity is currently holding @@ -28,6 +31,7 @@ public interface EntityEquipment { * * @return the currently held item */ + @NotNull ItemStack getItemInOffHand(); /** @@ -35,7 +39,7 @@ public interface EntityEquipment { * * @param item The item to put into the entities hand */ - void setItemInOffHand(ItemStack item); + void setItemInOffHand(@Nullable ItemStack item); /** * Gets a copy of the item the entity is currently holding @@ -47,6 +51,7 @@ public interface EntityEquipment { * @return the currently held item */ @Deprecated + @NotNull ItemStack getItemInHand(); /** @@ -59,13 +64,14 @@ public interface EntityEquipment { * @param stack The item to put into the entities hand */ @Deprecated - void setItemInHand(ItemStack stack); + void setItemInHand(@Nullable ItemStack stack); /** * Gets a copy of the helmet currently being worn by the entity * * @return The helmet being worn */ + @Nullable ItemStack getHelmet(); /** @@ -73,13 +79,14 @@ public interface EntityEquipment { * * @param helmet The helmet to put on the entity */ - void setHelmet(ItemStack helmet); + void setHelmet(@Nullable ItemStack helmet); /** * Gets a copy of the chest plate currently being worn by the entity * * @return The chest plate being worn */ + @Nullable ItemStack getChestplate(); /** @@ -87,13 +94,14 @@ public interface EntityEquipment { * * @param chestplate The chest plate to put on the entity */ - void setChestplate(ItemStack chestplate); + void setChestplate(@Nullable ItemStack chestplate); /** * Gets a copy of the leggings currently being worn by the entity * * @return The leggings being worn */ + @Nullable ItemStack getLeggings(); /** @@ -101,13 +109,14 @@ public interface EntityEquipment { * * @param leggings The leggings to put on the entity */ - void setLeggings(ItemStack leggings); + void setLeggings(@Nullable ItemStack leggings); /** * Gets a copy of the boots currently being worn by the entity * * @return The boots being worn */ + @Nullable ItemStack getBoots(); /** @@ -115,21 +124,22 @@ public interface EntityEquipment { * * @param boots The boots to put on the entity */ - void setBoots(ItemStack boots); + void setBoots(@Nullable ItemStack boots); /** * Gets a copy of all worn armor * - * @return The array of worn armor + * @return The array of worn armor. Individual items may be null. */ + @NotNull ItemStack[] getArmorContents(); /** * Sets the entities armor to the provided array of ItemStacks * - * @param items The items to set the armor as + * @param items The items to set the armor as. Individual items may be null. */ - void setArmorContents(ItemStack[] items); + void setArmorContents(@NotNull ItemStack[] items); /** * Clears the entity of all armor and held items @@ -319,5 +329,6 @@ public interface EntityEquipment { * * @return the entity this EntityEquipment belongs to */ + @Nullable Entity getHolder(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/FurnaceInventory.java b/paper-api/src/main/java/org/bukkit/inventory/FurnaceInventory.java index 93b41d3681..65d8fa437f 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/FurnaceInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/FurnaceInventory.java @@ -1,6 +1,7 @@ package org.bukkit.inventory; import org.bukkit.block.Furnace; +import org.jetbrains.annotations.Nullable; /** * Interface to the inventory of a Furnace. @@ -12,6 +13,7 @@ public interface FurnaceInventory extends Inventory { * * @return The item */ + @Nullable ItemStack getResult(); /** @@ -19,6 +21,7 @@ public interface FurnaceInventory extends Inventory { * * @return The item */ + @Nullable ItemStack getFuel(); /** @@ -26,6 +29,7 @@ public interface FurnaceInventory extends Inventory { * * @return The item */ + @Nullable ItemStack getSmelting(); /** @@ -33,21 +37,22 @@ public interface FurnaceInventory extends Inventory { * * @param stack The item */ - void setFuel(ItemStack stack); + void setFuel(@Nullable ItemStack stack); /** * Set the current item in the result slot. * * @param stack The item */ - void setResult(ItemStack stack); + void setResult(@Nullable ItemStack stack); /** * Set the item currently smelting. * * @param stack The item */ - void setSmelting(ItemStack stack); + void setSmelting(@Nullable ItemStack stack); + @Nullable Furnace getHolder(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java index b3dcef520e..d40ffbe794 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java @@ -6,6 +6,7 @@ import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; /** * Represents a smelting recipe. @@ -19,22 +20,22 @@ public class FurnaceRecipe implements Recipe, Keyed { private String group = ""; @Deprecated - public FurnaceRecipe(ItemStack result, Material source) { + public FurnaceRecipe(@NotNull ItemStack result, @NotNull Material source) { this(NamespacedKey.randomKey(), result, source, 0, 0, 200); } @Deprecated - public FurnaceRecipe(ItemStack result, MaterialData source) { + public FurnaceRecipe(@NotNull ItemStack result, @NotNull MaterialData source) { this(NamespacedKey.randomKey(), result, source.getItemType(), source.getData(), 0, 200); } @Deprecated - public FurnaceRecipe(ItemStack result, MaterialData source, float experience) { + public FurnaceRecipe(@NotNull ItemStack result, @NotNull MaterialData source, float experience) { this(NamespacedKey.randomKey(), result, source.getItemType(), source.getData(), experience, 200); } @Deprecated - public FurnaceRecipe(ItemStack result, Material source, int data) { + public FurnaceRecipe(@NotNull ItemStack result, @NotNull Material source, int data) { this(NamespacedKey.randomKey(), result, source, data, 0, 200); } @@ -47,12 +48,12 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param experience The experience given by this recipe * @param cookingTime The cooking time (in ticks) */ - public FurnaceRecipe(NamespacedKey key, ItemStack result, Material source, float experience, int cookingTime) { + public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) { this(key, result, source, 0, experience, cookingTime); } @Deprecated - public FurnaceRecipe(NamespacedKey key, ItemStack result, Material source, int data, float experience, int cookingTime) { + public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, int data, float experience, int cookingTime) { this(key, result, new RecipeChoice.MaterialChoice(Collections.singletonList(source)), experience, cookingTime); } @@ -65,7 +66,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param experience The experience given by this recipe * @param cookingTime The cooking time (in ticks) */ - public FurnaceRecipe(NamespacedKey key, ItemStack result, RecipeChoice input, float experience, int cookingTime) { + public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) { this.key = key; this.output = new ItemStack(result); this.ingredient = input; @@ -79,7 +80,8 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param input The input material. * @return The changed recipe, so you can chain calls. */ - public FurnaceRecipe setInput(MaterialData input) { + @NotNull + public FurnaceRecipe setInput(@NotNull MaterialData input) { return setInput(input.getItemType(), input.getData()); } @@ -89,7 +91,8 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param input The input material. * @return The changed recipe, so you can chain calls. */ - public FurnaceRecipe setInput(Material input) { + @NotNull + public FurnaceRecipe setInput(@NotNull Material input) { return setInput(input, 0); } @@ -103,7 +106,8 @@ public class FurnaceRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - public FurnaceRecipe setInput(Material input, int data) { + @NotNull + public FurnaceRecipe setInput(@NotNull Material input, int data) { this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input)); return this; } @@ -113,6 +117,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * * @return The input material. */ + @NotNull public ItemStack getInput() { return this.ingredient.getItemStack(); } @@ -123,7 +128,8 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param input The input choice. * @return The changed recipe, so you can chain calls. */ - public FurnaceRecipe setInputChoice(RecipeChoice input) { + @NotNull + public FurnaceRecipe setInputChoice(@NotNull RecipeChoice input) { this.ingredient = input; return this; } @@ -133,6 +139,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * * @return The input choice. */ + @NotNull public RecipeChoice getInputChoice() { return this.ingredient.clone(); } @@ -142,6 +149,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * * @return The resulting stack. */ + @NotNull public ItemStack getResult() { return output.clone(); } @@ -183,6 +191,7 @@ public class FurnaceRecipe implements Recipe, Keyed { return cookingTime; } + @NotNull @Override public NamespacedKey getKey() { return key; @@ -194,6 +203,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * * @return recipe group. An empty string denotes no group. May not be null. */ + @NotNull public String getGroup() { return group; } @@ -205,7 +215,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param group recipe group. An empty string denotes no group. May not be * null. */ - public void setGroup(String group) { + public void setGroup(@NotNull String group) { Preconditions.checkArgument(group != null, "group"); this.group = group; } diff --git a/paper-api/src/main/java/org/bukkit/inventory/HorseInventory.java b/paper-api/src/main/java/org/bukkit/inventory/HorseInventory.java index a73c985020..608e99c420 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/HorseInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/HorseInventory.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.Nullable; + /** * An interface to the inventory of a Horse. */ @@ -10,6 +12,7 @@ public interface HorseInventory extends AbstractHorseInventory { * * @return the armor item */ + @Nullable ItemStack getArmor(); /** @@ -17,5 +20,5 @@ public interface HorseInventory extends AbstractHorseInventory { * * @param stack the new item */ - void setArmor(ItemStack stack); + void setArmor(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/Inventory.java b/paper-api/src/main/java/org/bukkit/inventory/Inventory.java index bab561dc42..36e3529172 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/Inventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/Inventory.java @@ -8,6 +8,9 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryType; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Interface to the various inventories. Behavior relating to {@link @@ -66,6 +69,7 @@ public interface Inventory extends Iterable { * @see InventoryView#getTitle() */ @Deprecated + @NotNull public String getName(); /** @@ -74,6 +78,7 @@ public interface Inventory extends Iterable { * @param index The index of the Slot's ItemStack to return * @return The ItemStack in the slot */ + @Nullable public ItemStack getItem(int index); /** @@ -82,7 +87,7 @@ public interface Inventory extends Iterable { * @param index The index where to put the ItemStack * @param item The ItemStack to set */ - public void setItem(int index, ItemStack item); + public void setItem(int index, @Nullable ItemStack item); /** * Stores the given ItemStacks in the inventory. This will try to fill @@ -108,7 +113,8 @@ public interface Inventory extends Iterable { * @return A HashMap containing items that didn't fit. * @throws IllegalArgumentException if items or any element in it is null */ - public HashMap addItem(ItemStack... items) throws IllegalArgumentException; + @NotNull + public HashMap addItem(@NotNull ItemStack... items) throws IllegalArgumentException; /** * Removes the given ItemStacks from the inventory. @@ -129,13 +135,15 @@ public interface Inventory extends Iterable { * @return A HashMap containing items that couldn't be removed. * @throws IllegalArgumentException if items is null */ - public HashMap removeItem(ItemStack... items) throws IllegalArgumentException; + @NotNull + public HashMap removeItem(@NotNull ItemStack... items) throws IllegalArgumentException; /** * Returns all ItemStacks from the inventory * - * @return An array of ItemStacks from the inventory. + * @return An array of ItemStacks from the inventory. Individual items may be null. */ + @NotNull public ItemStack[] getContents(); /** @@ -147,7 +155,7 @@ public interface Inventory extends Iterable { * @throws IllegalArgumentException If the array has more items than the * inventory. */ - public void setContents(ItemStack[] items) throws IllegalArgumentException; + public void setContents(@NotNull ItemStack[] items) throws IllegalArgumentException; /** * Return the contents from the section of the inventory where items can @@ -158,8 +166,9 @@ public interface Inventory extends Iterable { * It is these contents which will be used for add / contains / remove * methods which look for a specific stack. * - * @return inventory storage contents + * @return inventory storage contents. Individual items may be null. */ + @NotNull public ItemStack[] getStorageContents(); /** @@ -169,7 +178,7 @@ public interface Inventory extends Iterable { * @throws IllegalArgumentException If the array has more items than the * inventory. */ - public void setStorageContents(ItemStack[] items) throws IllegalArgumentException; + public void setStorageContents(@NotNull ItemStack[] items) throws IllegalArgumentException; /** * Checks if the inventory contains any ItemStacks with the given @@ -179,7 +188,7 @@ public interface Inventory extends Iterable { * @return true if an ItemStack is found with the given Material * @throws IllegalArgumentException if material is null */ - public boolean contains(Material material) throws IllegalArgumentException; + public boolean contains(@NotNull Material material) throws IllegalArgumentException; /** * Checks if the inventory contains any ItemStacks matching the given @@ -192,7 +201,8 @@ public interface Inventory extends Iterable { * @return false if item is null, true if any exactly matching ItemStacks * were found */ - public boolean contains(ItemStack item); + @Contract("null -> false") + public boolean contains(@Nullable ItemStack item); /** * Checks if the inventory contains any ItemStacks with the given @@ -204,7 +214,7 @@ public interface Inventory extends Iterable { * found to add to the given amount * @throws IllegalArgumentException if material is null */ - public boolean contains(Material material, int amount) throws IllegalArgumentException; + public boolean contains(@NotNull Material material, int amount) throws IllegalArgumentException; /** * Checks if the inventory contains at least the minimum amount specified @@ -219,7 +229,8 @@ public interface Inventory extends Iterable { * amount of exactly matching ItemStacks were found * @see #containsAtLeast(ItemStack, int) */ - public boolean contains(ItemStack item, int amount); + @Contract("null, _ -> false") + public boolean contains(@Nullable ItemStack item, int amount); /** * Checks if the inventory contains ItemStacks matching the given @@ -230,7 +241,8 @@ public interface Inventory extends Iterable { * @return false if item is null, true if amount less than 1, true if * enough ItemStacks were found to add to the given amount */ - public boolean containsAtLeast(ItemStack item, int amount); + @Contract("null, _ -> false") + public boolean containsAtLeast(@Nullable ItemStack item, int amount); /** * Returns a HashMap with all slots and ItemStacks in the inventory with @@ -244,7 +256,8 @@ public interface Inventory extends Iterable { * @return A HashMap containing the slot index, ItemStack pairs * @throws IllegalArgumentException if material is null */ - public HashMap all(Material material) throws IllegalArgumentException; + @NotNull + public HashMap all(@NotNull Material material) throws IllegalArgumentException; /** * Finds all slots in the inventory containing any ItemStacks with the @@ -258,7 +271,8 @@ public interface Inventory extends Iterable { * @param item The ItemStack to match against * @return A map from slot indexes to item at index */ - public HashMap all(ItemStack item); + @NotNull + public HashMap all(@Nullable ItemStack item); /** * Finds the first slot in the inventory containing an ItemStack with the @@ -268,7 +282,7 @@ public interface Inventory extends Iterable { * @return The slot index of the given Material or -1 if not found * @throws IllegalArgumentException if material is null */ - public int first(Material material) throws IllegalArgumentException; + public int first(@NotNull Material material) throws IllegalArgumentException; /** * Returns the first slot in the inventory containing an ItemStack with @@ -278,7 +292,7 @@ public interface Inventory extends Iterable { * @param item The ItemStack to match against * @return The slot index of the given ItemStack or -1 if not found */ - public int first(ItemStack item); + public int first(@NotNull ItemStack item); /** * Returns the first empty Slot. @@ -293,7 +307,7 @@ public interface Inventory extends Iterable { * @param material The material to remove * @throws IllegalArgumentException if material is null */ - public void remove(Material material) throws IllegalArgumentException; + public void remove(@NotNull Material material) throws IllegalArgumentException; /** * Removes all stacks in the inventory matching the given stack. @@ -303,7 +317,7 @@ public interface Inventory extends Iterable { * * @param item The ItemStack to match against */ - public void remove(ItemStack item); + public void remove(@NotNull ItemStack item); /** * Clears out a particular slot in the index. @@ -328,6 +342,7 @@ public interface Inventory extends Iterable { * * @return A list of HumanEntities who are viewing this Inventory. */ + @NotNull public List getViewers(); /** @@ -338,6 +353,7 @@ public interface Inventory extends Iterable { * @see InventoryView#getTitle() */ @Deprecated + @NotNull public String getTitle(); /** @@ -345,6 +361,7 @@ public interface Inventory extends Iterable { * * @return The InventoryType representing the type of inventory. */ + @NotNull public InventoryType getType(); /** @@ -352,8 +369,10 @@ public interface Inventory extends Iterable { * * @return The holder of the inventory; null if it has no holder. */ + @Nullable public InventoryHolder getHolder(); + @NotNull @Override public ListIterator iterator(); @@ -366,6 +385,7 @@ public interface Inventory extends Iterable { * @param index The index. * @return An iterator. */ + @NotNull public ListIterator iterator(int index); /** @@ -374,5 +394,6 @@ public interface Inventory extends Iterable { * * @return location or null if not applicable. */ + @Nullable public Location getLocation(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/InventoryHolder.java b/paper-api/src/main/java/org/bukkit/inventory/InventoryHolder.java index 9c06a3d791..c7b17eabf0 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/InventoryHolder.java +++ b/paper-api/src/main/java/org/bukkit/inventory/InventoryHolder.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.NotNull; + public interface InventoryHolder { /** @@ -7,5 +9,6 @@ public interface InventoryHolder { * * @return The inventory. */ + @NotNull public Inventory getInventory(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/InventoryView.java b/paper-api/src/main/java/org/bukkit/inventory/InventoryView.java index e13e3e3385..bc2b4da34e 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/InventoryView.java +++ b/paper-api/src/main/java/org/bukkit/inventory/InventoryView.java @@ -3,6 +3,8 @@ package org.bukkit.inventory; import com.google.common.base.Preconditions; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a view linking two inventories and a single player (whose @@ -99,11 +101,12 @@ public abstract class InventoryView { REPAIR_COST(0, InventoryType.ANVIL); int id; InventoryType style; - private Property(int id, InventoryType appliesTo) { + private Property(int id, @NotNull InventoryType appliesTo) { this.id = id; style = appliesTo; } + @NotNull public InventoryType getType() { return style; } @@ -123,6 +126,7 @@ public abstract class InventoryView { * * @return the inventory */ + @NotNull public abstract Inventory getTopInventory(); /** @@ -130,6 +134,7 @@ public abstract class InventoryView { * * @return the inventory */ + @NotNull public abstract Inventory getBottomInventory(); /** @@ -137,6 +142,7 @@ public abstract class InventoryView { * * @return the player */ + @NotNull public abstract HumanEntity getPlayer(); /** @@ -146,6 +152,7 @@ public abstract class InventoryView { * * @return the inventory type */ + @NotNull public abstract InventoryType getType(); /** @@ -157,11 +164,11 @@ public abstract class InventoryView { * @param slot The ID as returned by InventoryClickEvent.getRawSlot() * @param item The new item to put in the slot, or null to clear it. */ - public void setItem(int slot, ItemStack item) { + public void setItem(int slot, @Nullable ItemStack item) { Inventory inventory = getInventory(slot); if (inventory != null) { inventory.setItem(convertSlot(slot), item); - } else { + } else if (item != null) { getPlayer().getWorld().dropItemNaturally(getPlayer().getLocation(), item); } } @@ -172,6 +179,7 @@ public abstract class InventoryView { * @param slot The ID as returned by InventoryClickEvent.getRawSlot() * @return The item currently in the slot. */ + @Nullable public ItemStack getItem(int slot) { Inventory inventory = getInventory(slot); return (inventory == null) ? null : inventory.getItem(convertSlot(slot)); @@ -183,7 +191,7 @@ public abstract class InventoryView { * @param item The item to put on the cursor, or null to remove the item * on their cursor. */ - public final void setCursor(ItemStack item) { + public final void setCursor(@Nullable ItemStack item) { getPlayer().setItemOnCursor(item); } @@ -193,6 +201,7 @@ public abstract class InventoryView { * @return The item on the player's cursor, or null if they aren't holding * one. */ + @Nullable public final ItemStack getCursor() { return getPlayer().getItemOnCursor(); } @@ -209,6 +218,7 @@ public abstract class InventoryView { * @param rawSlot The raw slot ID. * @return corresponding inventory, or null */ + @Nullable public final Inventory getInventory(int rawSlot) { // Slot may be -1 if not properly detected due to client bug // e.g. dropping an item into part of the enchantment list section of an enchanting table @@ -310,6 +320,7 @@ public abstract class InventoryView { * @param slot The raw slot ID * @return the slot type */ + @NotNull public final InventoryType.SlotType getSlotType(int slot) { InventoryType.SlotType type = InventoryType.SlotType.CONTAINER; if (slot >= 0 && slot < this.getTopInventory().getSize()) { @@ -406,7 +417,7 @@ public abstract class InventoryView { * @return true if the property was updated successfully, false if the * property is not supported by that inventory */ - public final boolean setProperty(Property prop, int value) { + public final boolean setProperty(@NotNull Property prop, int value) { return getPlayer().setWindowProperty(prop, value); } @@ -415,6 +426,7 @@ public abstract class InventoryView { * * @return The title. */ + @NotNull public final String getTitle() { return getTopInventory().getTitle(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java b/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java index 762c43d695..07d2b4cfe4 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -6,6 +6,8 @@ import org.bukkit.Server; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An instance of the ItemFactory can be obtained with {@link @@ -23,7 +25,8 @@ public interface ItemFactory { * @return a new ItemMeta that could be applied to an item stack of the * specified material */ - ItemMeta getItemMeta(final Material material); + @Nullable + ItemMeta getItemMeta(@NotNull final Material material); /** * This method checks the item meta to confirm that it is applicable (no @@ -39,7 +42,7 @@ public interface ItemFactory { * @throws IllegalArgumentException if the meta was not created by this * factory */ - boolean isApplicable(final ItemMeta meta, final ItemStack stack) throws IllegalArgumentException; + boolean isApplicable(@Nullable final ItemMeta meta, @Nullable final ItemStack stack) throws IllegalArgumentException; /** * This method checks the item meta to confirm that it is applicable (no @@ -55,7 +58,7 @@ public interface ItemFactory { * @throws IllegalArgumentException if the meta was not created by this * factory */ - boolean isApplicable(final ItemMeta meta, final Material material) throws IllegalArgumentException; + boolean isApplicable(@Nullable final ItemMeta meta, @Nullable final Material material) throws IllegalArgumentException; /** * This method is used to compare two item meta data objects. @@ -68,7 +71,7 @@ public interface ItemFactory { * @throws IllegalArgumentException if either meta was not created by this * factory */ - boolean equals(final ItemMeta meta1, final ItemMeta meta2) throws IllegalArgumentException; + boolean equals(@Nullable final ItemMeta meta1, @Nullable final ItemMeta meta2) throws IllegalArgumentException; /** * Returns an appropriate item meta for the specified stack. @@ -91,7 +94,8 @@ public interface ItemFactory { * @throws IllegalArgumentException if the specified meta was not created * by this factory */ - ItemMeta asMetaFor(final ItemMeta meta, final ItemStack stack) throws IllegalArgumentException; + @Nullable + ItemMeta asMetaFor(@NotNull final ItemMeta meta, @NotNull final ItemStack stack) throws IllegalArgumentException; /** * Returns an appropriate item meta for the specified material. @@ -113,13 +117,15 @@ public interface ItemFactory { * @throws IllegalArgumentException if the specified meta was not created * by this factory */ - ItemMeta asMetaFor(final ItemMeta meta, final Material material) throws IllegalArgumentException; + @Nullable + ItemMeta asMetaFor(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException; /** * Returns the default color for all leather armor. * * @return the default color for leather armor */ + @NotNull Color getDefaultLeatherColor(); /** @@ -133,5 +139,6 @@ public interface ItemFactory { * @deprecated for internal use only */ @Deprecated - Material updateMaterial(final ItemMeta meta, final Material material) throws IllegalArgumentException; + @NotNull + Material updateMaterial(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException; } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java index c744799f64..7b709457f1 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java @@ -13,6 +13,8 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a stack of items @@ -31,7 +33,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * * @param type item material */ - public ItemStack(final Material type) { + public ItemStack(@NotNull final Material type) { this(type, 1); } @@ -41,7 +43,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param type item material * @param amount stack size */ - public ItemStack(final Material type, final int amount) { + public ItemStack(@NotNull final Material type, final int amount) { this(type, amount, (short) 0); } @@ -53,7 +55,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param damage durability / damage * @deprecated see {@link #setDurability(short)} */ - public ItemStack(final Material type, final int amount, final short damage) { + public ItemStack(@NotNull final Material type, final int amount, final short damage) { this(type, amount, damage, null); } @@ -65,7 +67,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @deprecated this method uses an ambiguous data byte object */ @Deprecated - public ItemStack(final Material type, final int amount, final short damage, final Byte data) { + public ItemStack(@NotNull final Material type, final int amount, final short damage, @Nullable final Byte data) { Validate.notNull(type, "Material cannot be null"); this.type = type; this.amount = amount; @@ -84,7 +86,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @throws IllegalArgumentException if the specified stack is null or * returns an item meta not created by the item factory */ - public ItemStack(final ItemStack stack) throws IllegalArgumentException { + public ItemStack(@NotNull final ItemStack stack) throws IllegalArgumentException { Validate.notNull(stack, "Cannot copy null stack"); this.type = stack.getType(); this.amount = stack.getAmount(); @@ -100,6 +102,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @return Type of the items in this stack */ @Utility + @NotNull public Material getType() { return type; } @@ -112,7 +115,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param type New type to set the items in this stack to */ @Utility - public void setType(Material type) { + public void setType(@NotNull Material type) { Validate.notNull(type, "Material cannot be null"); this.type = type; if (this.meta != null) { @@ -148,6 +151,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * * @return MaterialData for this item */ + @Nullable public MaterialData getData() { Material mat = Bukkit.getUnsafe().toLegacy(getType()); if (data == null && mat != null && mat.getData() != null) { @@ -162,7 +166,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * * @param data New MaterialData for this item */ - public void setData(MaterialData data) { + public void setData(@Nullable MaterialData data) { Material mat = Bukkit.getUnsafe().toLegacy(getType()); if (data == null || mat == null || mat.getData() == null) { @@ -258,7 +262,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @return true if the two stacks are equal, ignoring the amount */ @Utility - public boolean isSimilar(ItemStack stack) { + public boolean isSimilar(@Nullable ItemStack stack) { if (stack == null) { return false; } @@ -269,6 +273,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { return comparisonType == stack.getType() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true); } + @NotNull @Override public ItemStack clone() { try { @@ -307,7 +312,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param ench Enchantment to test * @return True if this has the given enchantment */ - public boolean containsEnchantment(Enchantment ench) { + public boolean containsEnchantment(@NotNull Enchantment ench) { return meta == null ? false : meta.hasEnchant(ench); } @@ -317,7 +322,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param ench Enchantment to check * @return Level of the enchantment, or 0 */ - public int getEnchantmentLevel(Enchantment ench) { + public int getEnchantmentLevel(@NotNull Enchantment ench) { return meta == null ? 0 : meta.getEnchantLevel(ench); } @@ -326,6 +331,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * * @return Map of enchantments. */ + @NotNull public Map getEnchantments() { return meta == null ? ImmutableMap.of() : meta.getEnchants(); } @@ -344,7 +350,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * exception is thrown. */ @Utility - public void addEnchantments(Map enchantments) { + public void addEnchantments(@NotNull Map enchantments) { Validate.notNull(enchantments, "Enchantments cannot be null"); for (Map.Entry entry : enchantments.entrySet()) { addEnchantment(entry.getKey(), entry.getValue()); @@ -363,7 +369,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * not applicable */ @Utility - public void addEnchantment(Enchantment ench, int level) { + public void addEnchantment(@NotNull Enchantment ench, int level) { Validate.notNull(ench, "Enchantment cannot be null"); if ((level < ench.getStartLevel()) || (level > ench.getMaxLevel())) { throw new IllegalArgumentException("Enchantment level is either too low or too high (given " + level + ", bounds are " + ench.getStartLevel() + " to " + ench.getMaxLevel() + ")"); @@ -384,7 +390,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param enchantments Enchantments to add */ @Utility - public void addUnsafeEnchantments(Map enchantments) { + public void addUnsafeEnchantments(@NotNull Map enchantments) { for (Map.Entry entry : enchantments.entrySet()) { addUnsafeEnchantment(entry.getKey(), entry.getValue()); } @@ -402,8 +408,11 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param ench Enchantment to add * @param level Level of the enchantment */ - public void addUnsafeEnchantment(Enchantment ench, int level) { - (meta == null ? meta = Bukkit.getItemFactory().getItemMeta(type) : meta).addEnchant(ench, level, true); + public void addUnsafeEnchantment(@NotNull Enchantment ench, int level) { + ItemMeta itemMeta = (meta == null ? meta = Bukkit.getItemFactory().getItemMeta(type) : meta); + if (itemMeta != null) { + itemMeta.addEnchant(ench, level, true); + } } /** @@ -413,7 +422,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @param ench Enchantment to remove * @return Previous level, or 0 */ - public int removeEnchantment(Enchantment ench) { + public int removeEnchantment(@NotNull Enchantment ench) { int level = getEnchantmentLevel(ench); if (level == 0 || meta == null) { return level; @@ -422,6 +431,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { return level; } + @NotNull @Utility public Map serialize() { Map result = new LinkedHashMap(); @@ -448,7 +458,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @return deserialized item stack * @see ConfigurationSerializable */ - public static ItemStack deserialize(Map args) { + @NotNull + public static ItemStack deserialize(@NotNull Map args) { int version = (args.containsKey("v")) ? ((Number) args.get("v")).intValue() : -1; short damage = 0; int amount = 1; @@ -461,7 +472,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { if (version < 0) { type = Material.getMaterial(Material.LEGACY_PREFIX + (String) args.get("type")); - byte dataVal = (type.getMaxDurability() == 0) ? (byte) damage : 0; // Actually durable items get a 0 passed into conversion + byte dataVal = (type != null && type.getMaxDurability() == 0) ? (byte) damage : 0; // Actually durable items get a 0 passed into conversion type = Bukkit.getUnsafe().fromLegacy(new MaterialData(type, dataVal), true); // We've converted now so the data val isn't a thing and can be reset @@ -514,6 +525,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * * @return a copy of the current ItemStack's ItemData */ + @Nullable public ItemMeta getItemMeta() { return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone(); } @@ -536,14 +548,14 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { * @throws IllegalArgumentException if the item meta was not created by * the {@link ItemFactory} */ - public boolean setItemMeta(ItemMeta itemMeta) { + public boolean setItemMeta(@Nullable ItemMeta itemMeta) { return setItemMeta0(itemMeta, type); } /* * Cannot be overridden, so it's safe for constructor call */ - private boolean setItemMeta0(ItemMeta itemMeta, Material material) { + private boolean setItemMeta0(@Nullable ItemMeta itemMeta, @NotNull Material material) { if (itemMeta == null) { this.meta = null; return true; diff --git a/paper-api/src/main/java/org/bukkit/inventory/LlamaInventory.java b/paper-api/src/main/java/org/bukkit/inventory/LlamaInventory.java index 9b3dcf3faa..2fa2c9d07e 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/LlamaInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/LlamaInventory.java @@ -1,17 +1,19 @@ package org.bukkit.inventory; import org.bukkit.entity.Llama; +import org.jetbrains.annotations.Nullable; /** * An interface to the inventory of a {@link Llama}. */ public interface LlamaInventory extends AbstractHorseInventory { - /* + /** * Gets the item in the llama's decor slot. * * @return the decor item */ + @Nullable ItemStack getDecor(); /** @@ -19,5 +21,5 @@ public interface LlamaInventory extends AbstractHorseInventory { * * @param stack the new item */ - void setDecor(ItemStack stack); + void setDecor(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/Merchant.java b/paper-api/src/main/java/org/bukkit/inventory/Merchant.java index c8e68570f5..668e919584 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/Merchant.java +++ b/paper-api/src/main/java/org/bukkit/inventory/Merchant.java @@ -3,6 +3,8 @@ package org.bukkit.inventory; import java.util.List; import org.bukkit.entity.HumanEntity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a merchant. A merchant is a special type of inventory which can @@ -15,6 +17,7 @@ public interface Merchant { * * @return an immutable list of trades */ + @NotNull List getRecipes(); /** @@ -25,7 +28,7 @@ public interface Merchant { * * @param recipes a list of recipes */ - void setRecipes(List recipes); + void setRecipes(@NotNull List recipes); /** * Get the recipe at a certain index of this merchant's trade list. @@ -34,6 +37,7 @@ public interface Merchant { * @return the recipe * @throws IndexOutOfBoundsException */ + @NotNull MerchantRecipe getRecipe(int i) throws IndexOutOfBoundsException; /** @@ -43,7 +47,7 @@ public interface Merchant { * @param recipe the recipe * @throws IndexOutOfBoundsException */ - void setRecipe(int i, MerchantRecipe recipe) throws IndexOutOfBoundsException; + void setRecipe(int i, @NotNull MerchantRecipe recipe) throws IndexOutOfBoundsException; /** * Get the number of trades this merchant currently has available. @@ -65,5 +69,6 @@ public interface Merchant { * * @return the trader, or null */ + @Nullable HumanEntity getTrader(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/MerchantInventory.java b/paper-api/src/main/java/org/bukkit/inventory/MerchantInventory.java index 8162476324..edc67fecc2 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/MerchantInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/MerchantInventory.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.Nullable; + /** * Represents a trading inventory between a player and a merchant. *
@@ -26,5 +28,6 @@ public interface MerchantInventory extends Inventory { * * @return the currently active recipe */ + @Nullable MerchantRecipe getSelectedRecipe(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java index 54e29d545d..dabbdf252a 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java @@ -1,6 +1,8 @@ package org.bukkit.inventory; import com.google.common.base.Preconditions; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.List; @@ -8,7 +10,7 @@ import java.util.List; * Represents a merchant's trade. * * Trades can take one or two ingredients, and provide one result. The - * ingredients' Itemstack amounts are respected in the trade. + * ingredients' ItemStack amounts are respected in the trade. *
* A trade has a limited number of uses, after which the trade can no longer be * used, unless the player uses a different trade, which will cause its maximum @@ -26,23 +28,24 @@ public class MerchantRecipe implements Recipe { private int maxUses; private boolean experienceReward; - public MerchantRecipe(ItemStack result, int maxUses) { + public MerchantRecipe(@NotNull ItemStack result, int maxUses) { this(result, 0, maxUses, false); } - public MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward) { + public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward) { this.result = result; this.uses = uses; this.maxUses = maxUses; this.experienceReward = experienceReward; } + @NotNull @Override public ItemStack getResult() { return result; } - public void addIngredient(ItemStack item) { + public void addIngredient(@NotNull ItemStack item) { Preconditions.checkState(ingredients.size() < 2, "MerchantRecipe can only have maximum 2 ingredients"); ingredients.add(item.clone()); } @@ -51,7 +54,7 @@ public class MerchantRecipe implements Recipe { ingredients.remove(index); } - public void setIngredients(List ingredients) { + public void setIngredients(@NotNull List ingredients) { Preconditions.checkState(ingredients.size() <= 2, "MerchantRecipe can only have maximum 2 ingredients"); this.ingredients = new ArrayList(); for (ItemStack item : ingredients) { @@ -59,6 +62,7 @@ public class MerchantRecipe implements Recipe { } } + @NotNull public List getIngredients() { List copy = new ArrayList(); for (ItemStack item : ingredients) { diff --git a/paper-api/src/main/java/org/bukkit/inventory/PlayerInventory.java b/paper-api/src/main/java/org/bukkit/inventory/PlayerInventory.java index fc5772e850..ef55b14637 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/PlayerInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/PlayerInventory.java @@ -1,6 +1,8 @@ package org.bukkit.inventory; import org.bukkit.entity.HumanEntity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Interface to the inventory of a Player, including the four armor slots and any extra slots. @@ -10,8 +12,9 @@ public interface PlayerInventory extends Inventory { /** * Get all ItemStacks from the armor slots * - * @return All the ItemStacks from the armor slots + * @return All the ItemStacks from the armor slots. Individual items can be null. */ + @NotNull public ItemStack[] getArmorContents(); /** @@ -21,8 +24,9 @@ public interface PlayerInventory extends Inventory { * will not be contained within {@link #getStorageContents()} or * {@link #getArmorContents()} * - * @return All additional ItemStacks + * @return All additional ItemStacks. Individual items can be null. */ + @NotNull public ItemStack[] getExtraContents(); /** @@ -30,6 +34,7 @@ public interface PlayerInventory extends Inventory { * * @return The ItemStack in the helmet slot */ + @Nullable public ItemStack getHelmet(); /** @@ -37,6 +42,7 @@ public interface PlayerInventory extends Inventory { * * @return The ItemStack in the chestplate slot */ + @Nullable public ItemStack getChestplate(); /** @@ -44,6 +50,7 @@ public interface PlayerInventory extends Inventory { * * @return The ItemStack in the leg slot */ + @Nullable public ItemStack getLeggings(); /** @@ -51,6 +58,7 @@ public interface PlayerInventory extends Inventory { * * @return The ItemStack in the boots slot */ + @Nullable public ItemStack getBoots(); /** @@ -79,14 +87,14 @@ public interface PlayerInventory extends Inventory { * @see #setItemInOffHand(ItemStack) */ @Override - public void setItem(int index, ItemStack item); + public void setItem(int index, @Nullable ItemStack item); /** * Put the given ItemStacks into the armor slots * * @param items The ItemStacks to use as armour */ - public void setArmorContents(ItemStack[] items); + public void setArmorContents(@Nullable ItemStack[] items); /** * Put the given ItemStacks into the extra slots @@ -95,7 +103,7 @@ public interface PlayerInventory extends Inventory { * * @param items The ItemStacks to use as extra */ - public void setExtraContents(ItemStack[] items); + public void setExtraContents(@Nullable ItemStack[] items); /** * Put the given ItemStack into the helmet slot. This does not check if @@ -103,7 +111,7 @@ public interface PlayerInventory extends Inventory { * * @param helmet The ItemStack to use as helmet */ - public void setHelmet(ItemStack helmet); + public void setHelmet(@Nullable ItemStack helmet); /** * Put the given ItemStack into the chestplate slot. This does not check @@ -111,7 +119,7 @@ public interface PlayerInventory extends Inventory { * * @param chestplate The ItemStack to use as chestplate */ - public void setChestplate(ItemStack chestplate); + public void setChestplate(@Nullable ItemStack chestplate); /** * Put the given ItemStack into the leg slot. This does not check if the @@ -119,7 +127,7 @@ public interface PlayerInventory extends Inventory { * * @param leggings The ItemStack to use as leggings */ - public void setLeggings(ItemStack leggings); + public void setLeggings(@Nullable ItemStack leggings); /** * Put the given ItemStack into the boots slot. This does not check if the @@ -127,7 +135,7 @@ public interface PlayerInventory extends Inventory { * * @param boots The ItemStack to use as boots */ - public void setBoots(ItemStack boots); + public void setBoots(@Nullable ItemStack boots); /** * Gets a copy of the item the player is currently holding @@ -135,6 +143,7 @@ public interface PlayerInventory extends Inventory { * * @return the currently held item */ + @NotNull ItemStack getItemInMainHand(); /** @@ -142,7 +151,7 @@ public interface PlayerInventory extends Inventory { * * @param item The item to put into the player's hand */ - void setItemInMainHand(ItemStack item); + void setItemInMainHand(@Nullable ItemStack item); /** * Gets a copy of the item the player is currently holding @@ -150,6 +159,7 @@ public interface PlayerInventory extends Inventory { * * @return the currently held item */ + @NotNull ItemStack getItemInOffHand(); /** @@ -157,7 +167,7 @@ public interface PlayerInventory extends Inventory { * * @param item The item to put into the player's hand */ - void setItemInOffHand(ItemStack item); + void setItemInOffHand(@Nullable ItemStack item); /** * Gets a copy of the item the player is currently holding @@ -169,6 +179,7 @@ public interface PlayerInventory extends Inventory { * @return the currently held item */ @Deprecated + @NotNull public ItemStack getItemInHand(); /** @@ -181,7 +192,7 @@ public interface PlayerInventory extends Inventory { * @param stack The item to put into the player's hand */ @Deprecated - public void setItemInHand(ItemStack stack); + public void setItemInHand(@Nullable ItemStack stack); /** * Get the slot number of the currently held item @@ -201,5 +212,6 @@ public interface PlayerInventory extends Inventory { */ public void setHeldItemSlot(int slot); + @Nullable public HumanEntity getHolder(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/Recipe.java b/paper-api/src/main/java/org/bukkit/inventory/Recipe.java index 7977ce2d79..4927a7ddca 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/Recipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/Recipe.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.NotNull; + /** * Represents some type of crafting recipe. */ @@ -10,5 +12,6 @@ public interface Recipe { * * @return The result stack */ + @NotNull ItemStack getResult(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java b/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java index 16c7f8e4ec..3d2c2b83a2 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java +++ b/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Objects; import java.util.function.Predicate; import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; /** * Represents a potential item match within a recipe. All choices within a @@ -24,10 +25,15 @@ public interface RecipeChoice extends Predicate, Cloneable { * @deprecated for compatability only */ @Deprecated + @NotNull ItemStack getItemStack(); + @NotNull RecipeChoice clone(); + @Override + boolean test(@NotNull ItemStack itemStack); + /** * Represents a choice of multiple matching Materials. */ @@ -35,15 +41,15 @@ public interface RecipeChoice extends Predicate, Cloneable { private List choices; - public MaterialChoice(Material choice) { + public MaterialChoice(@NotNull Material choice) { this(Arrays.asList(choice)); } - public MaterialChoice(Material... choices) { + public MaterialChoice(@NotNull Material... choices) { this(Arrays.asList(choices)); } - public MaterialChoice(List choices) { + public MaterialChoice(@NotNull List choices) { Preconditions.checkArgument(choices != null, "choices"); Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice"); for (Material choice : choices) { @@ -54,7 +60,7 @@ public interface RecipeChoice extends Predicate, Cloneable { } @Override - public boolean test(ItemStack t) { + public boolean test(@NotNull ItemStack t) { for (Material match : choices) { if (t.getType() == match) { return true; @@ -64,6 +70,7 @@ public interface RecipeChoice extends Predicate, Cloneable { return false; } + @NotNull @Override public ItemStack getItemStack() { ItemStack stack = new ItemStack(choices.get(0)); @@ -76,10 +83,12 @@ public interface RecipeChoice extends Predicate, Cloneable { return stack; } + @NotNull public List getChoices() { return Collections.unmodifiableList(choices); } + @NotNull @Override public MaterialChoice clone() { try { @@ -135,15 +144,15 @@ public interface RecipeChoice extends Predicate, Cloneable { private List choices; - public ExactChoice(ItemStack stack) { + public ExactChoice(@NotNull ItemStack stack) { this(Arrays.asList(stack)); } - public ExactChoice(ItemStack... stacks) { + public ExactChoice(@NotNull ItemStack... stacks) { this(Arrays.asList(stacks)); } - public ExactChoice(List choices) { + public ExactChoice(@NotNull List choices) { Preconditions.checkArgument(choices != null, "choices"); Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice"); for (ItemStack choice : choices) { @@ -153,15 +162,18 @@ public interface RecipeChoice extends Predicate, Cloneable { this.choices = new ArrayList<>(choices); } + @NotNull @Override public ItemStack getItemStack() { return choices.get(0).clone(); } + @NotNull public List getChoices() { return Collections.unmodifiableList(choices); } + @NotNull @Override public ExactChoice clone() { try { @@ -174,7 +186,7 @@ public interface RecipeChoice extends Predicate, Cloneable { } @Override - public boolean test(ItemStack t) { + public boolean test(@NotNull ItemStack t) { for (ItemStack match : choices) { if (t.isSimilar(match)) { return true; diff --git a/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java index 90d6d50cd1..77e6ccf5ea 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -11,6 +11,7 @@ import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; /** * Represents a shaped (ie normal) crafting recipe. @@ -23,7 +24,7 @@ public class ShapedRecipe implements Recipe, Keyed { private String group = ""; @Deprecated - public ShapedRecipe(ItemStack result) { + public ShapedRecipe(@NotNull ItemStack result) { this.key = NamespacedKey.randomKey(); this.output = new ItemStack(result); } @@ -40,7 +41,7 @@ public class ShapedRecipe implements Recipe, Keyed { * @see ShapedRecipe#setIngredient(char, Material, int) * @see ShapedRecipe#setIngredient(char, MaterialData) */ - public ShapedRecipe(NamespacedKey key, ItemStack result) { + public ShapedRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) { Preconditions.checkArgument(key != null, "key"); this.key = key; @@ -58,9 +59,10 @@ public class ShapedRecipe implements Recipe, Keyed { * @param shape The rows of the recipe (up to 3 rows). * @return The changed recipe, so you can chain calls. */ - public ShapedRecipe shape(final String... shape) { + @NotNull + public ShapedRecipe shape(@NotNull final String... shape) { Validate.notNull(shape, "Must provide a shape"); - Validate.isTrue(shape.length > 0 && shape.length < 4, "Crafting recipes should be 1, 2, 3 rows, not ", shape.length); + Validate.isTrue(shape.length > 0 && shape.length < 4, "Crafting recipes should be 1, 2 or 3 rows, not ", shape.length); int lastLen = -1; for (String row : shape) { @@ -94,7 +96,8 @@ public class ShapedRecipe implements Recipe, Keyed { * @param ingredient The ingredient. * @return The changed recipe, so you can chain calls. */ - public ShapedRecipe setIngredient(char key, MaterialData ingredient) { + @NotNull + public ShapedRecipe setIngredient(char key, @NotNull MaterialData ingredient) { return setIngredient(key, ingredient.getItemType(), ingredient.getData()); } @@ -105,7 +108,8 @@ public class ShapedRecipe implements Recipe, Keyed { * @param ingredient The ingredient. * @return The changed recipe, so you can chain calls. */ - public ShapedRecipe setIngredient(char key, Material ingredient) { + @NotNull + public ShapedRecipe setIngredient(char key, @NotNull Material ingredient) { return setIngredient(key, ingredient, 0); } @@ -119,7 +123,8 @@ public class ShapedRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - public ShapedRecipe setIngredient(char key, Material ingredient, int raw) { + @NotNull + public ShapedRecipe setIngredient(char key, @NotNull Material ingredient, int raw) { Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key); // -1 is the old wildcard, map to Short.MAX_VALUE as the new one @@ -131,7 +136,8 @@ public class ShapedRecipe implements Recipe, Keyed { return this; } - public ShapedRecipe setIngredient(char key, RecipeChoice ingredient) { + @NotNull + public ShapedRecipe setIngredient(char key, @NotNull RecipeChoice ingredient) { Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key); ingredients.put(key, ingredient); @@ -143,6 +149,7 @@ public class ShapedRecipe implements Recipe, Keyed { * * @return The mapping of character to ingredients. */ + @NotNull public Map getIngredientMap() { HashMap result = new HashMap(); for (Map.Entry ingredient : ingredients.entrySet()) { @@ -155,6 +162,7 @@ public class ShapedRecipe implements Recipe, Keyed { return result; } + @NotNull public Map getChoiceMap() { Map result = new HashMap<>(); for (Map.Entry ingredient : ingredients.entrySet()) { @@ -171,7 +179,9 @@ public class ShapedRecipe implements Recipe, Keyed { * Get the shape. * * @return The recipe's shape. + * @throws NullPointerException when not set yet */ + @NotNull public String[] getShape() { return rows.clone(); } @@ -181,10 +191,12 @@ public class ShapedRecipe implements Recipe, Keyed { * * @return The result stack. */ + @NotNull public ItemStack getResult() { return output.clone(); } + @NotNull @Override public NamespacedKey getKey() { return key; @@ -196,6 +208,7 @@ public class ShapedRecipe implements Recipe, Keyed { * * @return recipe group. An empty string denotes no group. May not be null. */ + @NotNull public String getGroup() { return group; } @@ -207,7 +220,7 @@ public class ShapedRecipe implements Recipe, Keyed { * @param group recipe group. An empty string denotes no group. May not be * null. */ - public void setGroup(String group) { + public void setGroup(@NotNull String group) { Preconditions.checkArgument(group != null, "group"); this.group = group; } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java index ea359c5406..a8d5f330bd 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java @@ -12,6 +12,7 @@ import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; /** * Represents a shapeless recipe, where the arrangement of the ingredients on @@ -24,7 +25,7 @@ public class ShapelessRecipe implements Recipe, Keyed { private String group = ""; @Deprecated - public ShapelessRecipe(ItemStack result) { + public ShapelessRecipe(@NotNull ItemStack result) { this.key = NamespacedKey.randomKey(); this.output = new ItemStack(result); } @@ -43,7 +44,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * @see ShapelessRecipe#addIngredient(int,MaterialData) * @see ShapelessRecipe#addIngredient(int,Material,int) */ - public ShapelessRecipe(NamespacedKey key, ItemStack result) { + public ShapelessRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) { this.key = key; this.output = new ItemStack(result); } @@ -54,7 +55,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ - public ShapelessRecipe addIngredient(MaterialData ingredient) { + @NotNull + public ShapelessRecipe addIngredient(@NotNull MaterialData ingredient) { return addIngredient(1, ingredient); } @@ -64,7 +66,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ - public ShapelessRecipe addIngredient(Material ingredient) { + @NotNull + public ShapelessRecipe addIngredient(@NotNull Material ingredient) { return addIngredient(1, ingredient, 0); } @@ -77,7 +80,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - public ShapelessRecipe addIngredient(Material ingredient, int rawdata) { + @NotNull + public ShapelessRecipe addIngredient(@NotNull Material ingredient, int rawdata) { return addIngredient(1, ingredient, rawdata); } @@ -88,7 +92,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ - public ShapelessRecipe addIngredient(int count, MaterialData ingredient) { + @NotNull + public ShapelessRecipe addIngredient(int count, @NotNull MaterialData ingredient) { return addIngredient(count, ingredient.getItemType(), ingredient.getData()); } @@ -99,7 +104,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ - public ShapelessRecipe addIngredient(int count, Material ingredient) { + @NotNull + public ShapelessRecipe addIngredient(int count, @NotNull Material ingredient) { return addIngredient(count, ingredient, 0); } @@ -113,7 +119,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - public ShapelessRecipe addIngredient(int count, Material ingredient, int rawdata) { + @NotNull + public ShapelessRecipe addIngredient(int count, @NotNull Material ingredient, int rawdata) { Validate.isTrue(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients"); // -1 is the old wildcard, map to Short.MAX_VALUE as the new one @@ -127,7 +134,8 @@ public class ShapelessRecipe implements Recipe, Keyed { return this; } - public ShapelessRecipe addIngredient(RecipeChoice ingredient) { + @NotNull + public ShapelessRecipe addIngredient(@NotNull RecipeChoice ingredient) { Validate.isTrue(ingredients.size() + 1 <= 9, "Shapeless recipes cannot have more than 9 ingredients"); ingredients.add(ingredient); @@ -140,7 +148,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to remove * @return The changed recipe. */ - public ShapelessRecipe removeIngredient(RecipeChoice ingredient) { + @NotNull + public ShapelessRecipe removeIngredient(@NotNull RecipeChoice ingredient) { ingredients.remove(ingredient); return this; @@ -154,7 +163,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to remove * @return The changed recipe. */ - public ShapelessRecipe removeIngredient(Material ingredient) { + @NotNull + public ShapelessRecipe removeIngredient(@NotNull Material ingredient) { return removeIngredient(ingredient, 0); } @@ -166,7 +176,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to remove * @return The changed recipe. */ - public ShapelessRecipe removeIngredient(MaterialData ingredient) { + @NotNull + public ShapelessRecipe removeIngredient(@NotNull MaterialData ingredient) { return removeIngredient(ingredient.getItemType(), ingredient.getData()); } @@ -179,7 +190,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to remove * @return The changed recipe. */ - public ShapelessRecipe removeIngredient(int count, Material ingredient) { + @NotNull + public ShapelessRecipe removeIngredient(int count, @NotNull Material ingredient) { return removeIngredient(count, ingredient, 0); } @@ -192,7 +204,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param ingredient The ingredient to remove. * @return The changed recipe. */ - public ShapelessRecipe removeIngredient(int count, MaterialData ingredient) { + @NotNull + public ShapelessRecipe removeIngredient(int count, @NotNull MaterialData ingredient) { return removeIngredient(count, ingredient.getItemType(), ingredient.getData()); } @@ -207,7 +220,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - public ShapelessRecipe removeIngredient(Material ingredient, int rawdata) { + @NotNull + public ShapelessRecipe removeIngredient(@NotNull Material ingredient, int rawdata) { return removeIngredient(1, ingredient, rawdata); } @@ -223,7 +237,8 @@ public class ShapelessRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - public ShapelessRecipe removeIngredient(int count, Material ingredient, int rawdata) { + @NotNull + public ShapelessRecipe removeIngredient(int count, @NotNull Material ingredient, int rawdata) { Iterator iterator = ingredients.iterator(); while (count > 0 && iterator.hasNext()) { ItemStack stack = iterator.next().getItemStack(); @@ -240,6 +255,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * * @return The result stack. */ + @NotNull public ItemStack getResult() { return output.clone(); } @@ -249,6 +265,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * * @return The input list */ + @NotNull public List getIngredientList() { ArrayList result = new ArrayList(ingredients.size()); for (RecipeChoice ingredient : ingredients) { @@ -257,6 +274,7 @@ public class ShapelessRecipe implements Recipe, Keyed { return result; } + @NotNull public List getChoiceList() { List result = new ArrayList<>(ingredients.size()); for (RecipeChoice ingredient : ingredients) { @@ -265,6 +283,7 @@ public class ShapelessRecipe implements Recipe, Keyed { return result; } + @NotNull @Override public NamespacedKey getKey() { return key; @@ -276,6 +295,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * * @return recipe group. An empty string denotes no group. May not be null. */ + @NotNull public String getGroup() { return group; } @@ -287,7 +307,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * @param group recipe group. An empty string denotes no group. May not be * null. */ - public void setGroup(String group) { + public void setGroup(@NotNull String group) { Preconditions.checkArgument(group != null, "group"); this.group = group; } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/BannerMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/BannerMeta.java index 54bf937234..4739d2ecc2 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/BannerMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/BannerMeta.java @@ -3,6 +3,8 @@ package org.bukkit.inventory.meta; import java.util.List; import org.bukkit.DyeColor; import org.bukkit.block.banner.Pattern; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface BannerMeta extends ItemMeta { @@ -13,6 +15,7 @@ public interface BannerMeta extends ItemMeta { * @deprecated banner color is now stored as the data value, not meta. */ @Deprecated + @Nullable DyeColor getBaseColor(); /** @@ -22,13 +25,14 @@ public interface BannerMeta extends ItemMeta { * @deprecated banner color is now stored as the data value, not meta. */ @Deprecated - void setBaseColor(DyeColor color); + void setBaseColor(@Nullable DyeColor color); /** * Returns a list of patterns on this banner * * @return the patterns */ + @NotNull List getPatterns(); /** @@ -36,7 +40,7 @@ public interface BannerMeta extends ItemMeta { * * @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 @@ -44,14 +48,16 @@ public interface BannerMeta extends ItemMeta { * * @param pattern the new pattern to add */ - void addPattern(Pattern pattern); + void addPattern(@NotNull Pattern pattern); /** * Returns the pattern at the specified index * * @param i the index * @return the pattern + * @throws IndexOutOfBoundsException when index is not in [0, numberOfPatterns()) range */ + @NotNull Pattern getPattern(int i); /** @@ -59,7 +65,9 @@ public interface BannerMeta extends ItemMeta { * * @param i the index * @return the removed pattern + * @throws IndexOutOfBoundsException when index is not in [0, numberOfPatterns()) range */ + @NotNull Pattern removePattern(int i); /** @@ -67,8 +75,9 @@ public interface BannerMeta extends ItemMeta { * * @param i the index * @param pattern the new pattern + * @throws IndexOutOfBoundsException when index is not in [0, numberOfPatterns()) range */ - 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/inventory/meta/BlockStateMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java index 4c2a746729..d71a4eaf12 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java @@ -2,6 +2,7 @@ package org.bukkit.inventory.meta; import org.bukkit.block.BlockState; +import org.jetbrains.annotations.NotNull; public interface BlockStateMeta extends ItemMeta { @@ -22,6 +23,7 @@ public interface BlockStateMeta extends ItemMeta { * * @return the attached state or a new state */ + @NotNull BlockState getBlockState(); /** @@ -31,5 +33,5 @@ public interface BlockStateMeta extends ItemMeta { * @throws IllegalArgumentException if the blockState is null * or invalid for this item. */ - void setBlockState(BlockState blockState); + void setBlockState(@NotNull BlockState blockState); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java index b28512098a..cb655ae856 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java @@ -3,6 +3,8 @@ package org.bukkit.inventory.meta; import java.util.List; import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a book ({@link Material#WRITABLE_BOOK} or {@link @@ -47,6 +49,7 @@ public interface BookMeta extends ItemMeta { * * @return the title of the book */ + @Nullable String getTitle(); /** @@ -57,7 +60,7 @@ public interface BookMeta extends ItemMeta { * @param title the title to set * @return true if the title was successfully set */ - boolean setTitle(String title); + boolean setTitle(@Nullable String title); /** * Checks for the existence of an author in the book. @@ -74,6 +77,7 @@ public interface BookMeta extends ItemMeta { * * @return the author of the book */ + @Nullable String getAuthor(); /** @@ -81,7 +85,7 @@ public interface BookMeta extends ItemMeta { * * @param author the author to set */ - void setAuthor(String author); + void setAuthor(@Nullable String author); /** * Checks for the existence of generation level in the book. @@ -98,6 +102,7 @@ public interface BookMeta extends ItemMeta { * * @return the generation of the book */ + @Nullable Generation getGeneration(); /** @@ -105,7 +110,7 @@ public interface BookMeta extends ItemMeta { * * @param generation the generation to set */ - void setGeneration(Generation generation); + void setGeneration(@Nullable Generation generation); /** * Checks for the existence of pages in the book. @@ -116,10 +121,13 @@ public interface BookMeta extends ItemMeta { /** * Gets the specified page in the book. The given page must exist. + *

+ * Pages are 1-indexed. * - * @param page the page number to get + * @param page the page number to get, in range [1, getPageCount()] * @return the page from the book */ + @NotNull String getPage(int page); /** @@ -128,17 +136,20 @@ public interface BookMeta extends ItemMeta { *

* The data can be up to 256 characters in length, additional characters * are truncated. + *

+ * Pages are 1-indexed. * - * @param page the page number to set + * @param page the page number to set, in range [1, getPageCount()] * @param data the data to set for that page */ - void setPage(int page, String data); + void setPage(int page, @NotNull String data); /** * Gets all the pages in the book. * * @return list of all the pages in the book */ + @NotNull List getPages(); /** @@ -147,7 +158,7 @@ public interface BookMeta extends ItemMeta { * * @param pages A list of pages to set the book to use */ - void setPages(List pages); + void setPages(@NotNull List pages); /** * Clears the existing book pages, and sets the book to use the provided @@ -155,7 +166,7 @@ public interface BookMeta extends ItemMeta { * * @param pages A list of strings, each being a page */ - void setPages(String... pages); + void setPages(@NotNull String... pages); /** * Adds new pages to the end of the book. Up to a maximum of 50 pages with @@ -163,7 +174,7 @@ public interface BookMeta extends ItemMeta { * * @param pages A list of strings, each being a page */ - void addPage(String... pages); + void addPage(@NotNull String... pages); /** * Gets the number of pages in the book. @@ -172,5 +183,6 @@ public interface BookMeta extends ItemMeta { */ int getPageCount(); + @NotNull BookMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/Damageable.java b/paper-api/src/main/java/org/bukkit/inventory/meta/Damageable.java index b3c4dc4345..6392362b98 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/Damageable.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/Damageable.java @@ -1,5 +1,7 @@ package org.bukkit.inventory.meta; +import org.jetbrains.annotations.NotNull; + /** * Represents an item that has durability and can take damage. */ @@ -26,5 +28,6 @@ public interface Damageable { */ void setDamage(int damage); + @NotNull Damageable clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java index fb93d03035..c44a227e02 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java @@ -4,6 +4,7 @@ import java.util.Map; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; /** * EnchantmentMeta is specific to items that can store enchantments, as @@ -25,7 +26,7 @@ public interface EnchantmentStorageMeta extends ItemMeta { * @param ench enchantment to check * @return true if this enchantment is stored in this meta */ - boolean hasStoredEnchant(Enchantment ench); + boolean hasStoredEnchant(@NotNull Enchantment ench); /** * Checks for the level of the stored enchantment. @@ -34,13 +35,14 @@ public interface EnchantmentStorageMeta extends ItemMeta { * @return The level that the specified stored enchantment has, or 0 if * none */ - int getStoredEnchantLevel(Enchantment ench); + int getStoredEnchantLevel(@NotNull Enchantment ench); /** * Gets a copy the stored enchantments in this ItemMeta. * * @return An immutable copy of the stored enchantments */ + @NotNull Map getStoredEnchants(); /** @@ -54,7 +56,7 @@ public interface EnchantmentStorageMeta extends ItemMeta { * otherwise * @throws IllegalArgumentException if enchantment is null */ - boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction); + boolean addStoredEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction); /** * Remove the specified stored enchantment from this item meta. @@ -64,7 +66,7 @@ public interface EnchantmentStorageMeta extends ItemMeta { * otherwise * @throws IllegalArgumentException if enchantment is null */ - boolean removeStoredEnchant(Enchantment ench) throws IllegalArgumentException; + boolean removeStoredEnchant(@NotNull Enchantment ench) throws IllegalArgumentException; /** * Checks if the specified enchantment conflicts with any enchantments in @@ -73,7 +75,8 @@ public interface EnchantmentStorageMeta extends ItemMeta { * @param ench enchantment to test * @return true if the enchantment conflicts, false otherwise */ - boolean hasConflictingStoredEnchant(Enchantment ench); + boolean hasConflictingStoredEnchant(@NotNull Enchantment ench); + @NotNull EnchantmentStorageMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java index f3af4bcc50..e50a029df3 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java @@ -2,6 +2,8 @@ package org.bukkit.inventory.meta; import org.bukkit.FireworkEffect; import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a meta that can store a single FireworkEffect. An example @@ -14,7 +16,7 @@ public interface FireworkEffectMeta extends ItemMeta { * * @param effect the effect to set, or null to indicate none. */ - void setEffect(FireworkEffect effect); + void setEffect(@Nullable FireworkEffect effect); /** * Checks if this meta has an effect. @@ -28,7 +30,9 @@ public interface FireworkEffectMeta extends ItemMeta { * * @return the current effect, or null if none */ + @Nullable FireworkEffect getEffect(); + @NotNull FireworkEffectMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java index 02486c1f2f..f1fe2b0747 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java @@ -4,6 +4,7 @@ import java.util.List; import org.bukkit.FireworkEffect; import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; /** * Represents a {@link Material#FIREWORK_ROCKET} and its effects. @@ -16,7 +17,7 @@ public interface FireworkMeta extends ItemMeta { * @param effect The firework effect to add * @throws IllegalArgumentException If effect is null */ - void addEffect(FireworkEffect effect) throws IllegalArgumentException; + void addEffect(@NotNull FireworkEffect effect) throws IllegalArgumentException; /** * Add several effects to this firework. @@ -26,7 +27,7 @@ public interface FireworkMeta extends ItemMeta { * @throws IllegalArgumentException If any effect is null (may be thrown * after changes have occurred) */ - void addEffects(FireworkEffect... effects) throws IllegalArgumentException; + void addEffects(@NotNull FireworkEffect... effects) throws IllegalArgumentException; /** * Add several firework effects to this firework. @@ -37,13 +38,14 @@ public interface FireworkMeta extends ItemMeta { * @throws IllegalArgumentException If any effect is null (may be thrown * after changes have occurred) */ - void addEffects(Iterable effects) throws IllegalArgumentException; + void addEffects(@NotNull Iterable effects) throws IllegalArgumentException; /** * Get the effects in this firework. * * @return An immutable list of the firework effects */ + @NotNull List getEffects(); /** @@ -90,5 +92,6 @@ public interface FireworkMeta extends ItemMeta { */ void setPower(int power) throws IllegalArgumentException; + @NotNull FireworkMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index cf7a17303a..f7008a78cc 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -13,6 +13,8 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.tags.CustomItemTagContainer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This type represents the storage mechanism for auxiliary item data. @@ -37,6 +39,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @return the display name that is set */ + @NotNull String getDisplayName(); /** @@ -44,7 +47,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @param name the name to set */ - void setDisplayName(String name); + void setDisplayName(@Nullable String name); /** * Checks for existence of a localized name. @@ -61,6 +64,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @return the localized name that is set */ + @NotNull String getLocalizedName(); /** @@ -68,7 +72,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @param name the name to set */ - void setLocalizedName(String name); + void setLocalizedName(@Nullable String name); /** * Checks for existence of lore. @@ -85,6 +89,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @return a list of lore that is set */ + @Nullable List getLore(); /** @@ -93,7 +98,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @param lore the lore that will be set */ - void setLore(List lore); + void setLore(@Nullable List lore); /** * Checks for the existence of any enchantments. @@ -108,7 +113,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @param ench enchantment to check * @return true if this enchantment exists for this meta */ - boolean hasEnchant(Enchantment ench); + boolean hasEnchant(@NotNull Enchantment ench); /** * Checks for the level of the specified enchantment. @@ -116,7 +121,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @param ench enchantment to check * @return The level that the specified enchantment has, or 0 if none */ - int getEnchantLevel(Enchantment ench); + int getEnchantLevel(@NotNull Enchantment ench); /** * Returns a copy the enchantments in this ItemMeta.
@@ -124,6 +129,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @return An immutable copy of the enchantments */ + @NotNull Map getEnchants(); /** @@ -136,7 +142,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @return true if the item meta changed as a result of this call, false * otherwise */ - boolean addEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction); + boolean addEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction); /** * Removes the specified enchantment from this item meta. @@ -145,7 +151,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @return true if the item meta changed as a result of this call, false * otherwise */ - boolean removeEnchant(Enchantment ench); + boolean removeEnchant(@NotNull Enchantment ench); /** * Checks if the specified enchantment conflicts with any enchantments in @@ -154,27 +160,28 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @param ench enchantment to test * @return true if the enchantment conflicts, false otherwise */ - boolean hasConflictingEnchant(Enchantment ench); + boolean hasConflictingEnchant(@NotNull Enchantment ench); /** * Set itemflags which should be ignored when rendering a ItemStack in the Client. This Method does silently ignore double set itemFlags. * * @param itemFlags The hideflags which shouldn't be rendered */ - void addItemFlags(ItemFlag... itemFlags); + void addItemFlags(@NotNull ItemFlag... itemFlags); /** * Remove specific set of itemFlags. This tells the Client it should render it again. This Method does silently ignore double removed itemFlags. * * @param itemFlags Hideflags which should be removed */ - void removeItemFlags(ItemFlag... itemFlags); + void removeItemFlags(@NotNull ItemFlag... itemFlags); /** * Get current set itemFlags. The collection returned is unmodifiable. * * @return A set of all itemFlags set */ + @NotNull Set getItemFlags(); /** @@ -183,7 +190,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @param flag the flag to check * @return if it is present */ - boolean hasItemFlag(ItemFlag flag); + boolean hasItemFlag(@NotNull ItemFlag flag); /** * Return if the unbreakable tag is true. An unbreakable item will not lose @@ -215,6 +222,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @return an immutable {@link Multimap} of Attributes * and their AttributeModifiers, or null if none exist */ + @Nullable Multimap getAttributeModifiers(); /** @@ -231,7 +239,8 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * respective Attributes and modifiers, or an empty map * if no attributes are set. */ - Multimap getAttributeModifiers(EquipmentSlot slot); + @NotNull + Multimap getAttributeModifiers(@NotNull EquipmentSlot slot); /** * Return an immutable copy of all {@link AttributeModifier}s @@ -242,7 +251,8 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * or null if no AttributeModifiers exist for the Attribute. * @throws NullPointerException if Attribute is null */ - Collection getAttributeModifiers(Attribute attribute); + @Nullable + Collection getAttributeModifiers(@NotNull Attribute attribute); /** * Add an Attribute and it's Modifier. @@ -260,7 +270,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @throws NullPointerException if AttributeModifier is null * @throws IllegalArgumentException if AttributeModifier already exists */ - boolean addAttributeModifier(Attribute attribute, AttributeModifier modifier); + boolean addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier); /** * Set all {@link Attribute}s and their {@link AttributeModifier}s. @@ -272,7 +282,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @param attributeModifiers the new Multimap containing the Attributes * and their AttributeModifiers */ - void setAttributeModifiers(Multimap attributeModifiers); + void setAttributeModifiers(@Nullable Multimap attributeModifiers); /** * Remove all {@link AttributeModifier}s associated with the given @@ -285,7 +295,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * removed. * @throws NullPointerException if Attribute is null */ - boolean removeAttributeModifier(Attribute attribute); + boolean removeAttributeModifier(@NotNull Attribute attribute); /** * Remove all {@link Attribute}s and {@link AttributeModifier}s for a @@ -298,7 +308,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @return true if all modifiers were removed that match the given * EquipmentSlot. */ - boolean removeAttributeModifier(EquipmentSlot slot); + boolean removeAttributeModifier(@NotNull EquipmentSlot slot); /** * Remove a specific {@link Attribute} and {@link AttributeModifier}. @@ -313,7 +323,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * @throws NullPointerException if the Attribute is null * @throws NullPointerException if the AttributeModifier is null */ - boolean removeAttributeModifier(Attribute attribute, AttributeModifier modifier); + boolean removeAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier); /** * Returns a public custom tag container capable of storing tags on the @@ -327,8 +337,10 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * * @return the custom tag container */ + @NotNull CustomItemTagContainer getCustomTagContainer(); @SuppressWarnings("javadoc") + @NotNull ItemMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/KnowledgeBookMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/KnowledgeBookMeta.java index 5cf201d625..736c60c71d 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/KnowledgeBookMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/KnowledgeBookMeta.java @@ -2,6 +2,7 @@ package org.bukkit.inventory.meta; import java.util.List; import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; public interface KnowledgeBookMeta extends ItemMeta { @@ -17,6 +18,7 @@ public interface KnowledgeBookMeta extends ItemMeta { * * @return list of all the recipes in the book */ + @NotNull List getRecipes(); /** @@ -25,15 +27,16 @@ public interface KnowledgeBookMeta extends ItemMeta { * * @param recipes A list of recipes to set the book to use */ - void setRecipes(List recipes); + void setRecipes(@NotNull List recipes); /** * Adds new recipe to the end of the book. * * @param recipes A list of recipe keys */ - void addRecipe(NamespacedKey... recipes); + void addRecipe(@NotNull NamespacedKey... recipes); + @NotNull @Override KnowledgeBookMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java index 2dc2420441..0b6779c6d5 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java @@ -3,6 +3,8 @@ package org.bukkit.inventory.meta; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.inventory.ItemFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents leather armor ({@link Material#LEATHER_BOOTS}, {@link @@ -17,6 +19,7 @@ public interface LeatherArmorMeta extends ItemMeta { * * @return the color of the armor, never null */ + @NotNull Color getColor(); /** @@ -25,7 +28,8 @@ public interface LeatherArmorMeta extends ItemMeta { * @param color the color to set. Setting it to null is equivalent to * setting it to {@link ItemFactory#getDefaultLeatherColor()}. */ - void setColor(Color color); + void setColor(@Nullable Color color); + @NotNull LeatherArmorMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/MapMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/MapMeta.java index 84c3f9f7e1..c90ad23791 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/MapMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/MapMeta.java @@ -1,7 +1,10 @@ package org.bukkit.inventory.meta; import org.bukkit.Color; +import org.bukkit.UndefinedNullability; import org.bukkit.map.MapView; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a map that can be scalable. @@ -71,6 +74,7 @@ public interface MapMeta extends ItemMeta { * @return the map view, or null if the item hasMapView(), but this map does * not exist on the server */ + @Nullable MapView getMapView(); /** @@ -83,7 +87,7 @@ public interface MapMeta extends ItemMeta { * * @param map the map to set */ - void setMapView(MapView map); + void setMapView(@UndefinedNullability("implementation defined") MapView map); /** * Checks to see if this map is scaling. @@ -114,6 +118,7 @@ public interface MapMeta extends ItemMeta { * * @return the location name that is set */ + @Nullable String getLocationName(); /** @@ -122,7 +127,7 @@ public interface MapMeta extends ItemMeta { * * @param name the name to set */ - void setLocationName(String name); + void setLocationName(@Nullable String name); /** * Checks for existence of a map color. @@ -140,6 +145,7 @@ public interface MapMeta extends ItemMeta { * * @return the map color that is set */ + @Nullable Color getColor(); /** @@ -148,7 +154,8 @@ public interface MapMeta extends ItemMeta { * * @param color the color to set */ - void setColor(Color color); + void setColor(@Nullable Color color); + @NotNull MapMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java index e98650544a..f26ec165f6 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java @@ -4,6 +4,8 @@ import org.bukkit.Color; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -17,13 +19,14 @@ public interface PotionMeta extends ItemMeta { * * @param data PotionData to set the base potion state to */ - void setBasePotionData(PotionData data); + void setBasePotionData(@NotNull PotionData data); /** * Returns the potion data about the base potion * * @return a PotionData object */ + @NotNull PotionData getBasePotionData(); /** @@ -42,6 +45,7 @@ public interface PotionMeta extends ItemMeta { * * @return the immutable list of custom potion effects */ + @NotNull List getCustomEffects(); /** @@ -52,7 +56,7 @@ public interface PotionMeta extends ItemMeta { * overwritten * @return true if the potion meta changed as a result of this call */ - boolean addCustomEffect(PotionEffect effect, boolean overwrite); + boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite); /** * Removes a custom potion effect from this potion. @@ -60,7 +64,7 @@ public interface PotionMeta extends ItemMeta { * @param type the potion effect type to remove * @return true if the potion meta changed as a result of this call */ - boolean removeCustomEffect(PotionEffectType type); + boolean removeCustomEffect(@NotNull PotionEffectType type); /** * Checks for a specific custom potion effect type on this potion. @@ -68,7 +72,7 @@ public interface PotionMeta extends ItemMeta { * @param type the potion effect type to check for * @return true if the potion has this effect */ - boolean hasCustomEffect(PotionEffectType type); + boolean hasCustomEffect(@NotNull PotionEffectType type); /** * Moves a potion effect to the top of the potion effect list. @@ -80,7 +84,7 @@ public interface PotionMeta extends ItemMeta { * @deprecated use {@link org.bukkit.potion.PotionType#PotionType} */ @Deprecated - boolean setMainEffect(PotionEffectType type); + boolean setMainEffect(@NotNull PotionEffectType type); /** * Removes all custom potion effects from this potion. @@ -105,6 +109,7 @@ public interface PotionMeta extends ItemMeta { * * @return the potion color that is set */ + @Nullable Color getColor(); /** @@ -113,7 +118,7 @@ public interface PotionMeta extends ItemMeta { * * @param color the color to set */ - void setColor(Color color); + void setColor(@Nullable Color color); @Override PotionMeta clone(); diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/Repairable.java b/paper-api/src/main/java/org/bukkit/inventory/meta/Repairable.java index c49844ed23..0a1d543db3 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/Repairable.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/Repairable.java @@ -1,5 +1,7 @@ package org.bukkit.inventory.meta; +import org.jetbrains.annotations.NotNull; + /** * Represents an item that can be repaired at an anvil. */ @@ -27,5 +29,6 @@ public interface Repairable { void setRepairCost(int cost); @SuppressWarnings("javadoc") + @NotNull Repairable clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java index 15c1dfd9e2..1583764b42 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java @@ -1,6 +1,8 @@ package org.bukkit.inventory.meta; import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a skull that can have an owner. @@ -14,6 +16,7 @@ public interface SkullMeta extends ItemMeta { * @deprecated see {@link #setOwningPlayer(org.bukkit.OfflinePlayer)}. */ @Deprecated + @Nullable String getOwner(); /** @@ -25,22 +28,20 @@ public interface SkullMeta extends ItemMeta { /** * Sets the owner of the skull. - *

- * Plugins should check that hasOwner() returns true before calling this - * plugin. * * @param owner the new owner of the skull * @return true if the owner was successfully set * @deprecated see {@link #setOwningPlayer(org.bukkit.OfflinePlayer)}. */ @Deprecated - boolean setOwner(String owner); + boolean setOwner(@Nullable String owner); /** * Gets the owner of the skull. * * @return the owner if the skull */ + @Nullable OfflinePlayer getOwningPlayer(); /** @@ -52,7 +53,8 @@ public interface SkullMeta extends ItemMeta { * @param owner the new owner of the skull * @return true if the owner was successfully set */ - boolean setOwningPlayer(OfflinePlayer owner); + boolean setOwningPlayer(@Nullable OfflinePlayer owner); + @NotNull SkullMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java index 39358e22e3..9ae84de430 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java @@ -1,6 +1,8 @@ package org.bukkit.inventory.meta; import org.bukkit.entity.EntityType; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; /** * Represents a spawn egg and it's spawned type. @@ -14,6 +16,7 @@ public interface SpawnEggMeta extends ItemMeta { * @deprecated different types are different items */ @Deprecated + @Contract("-> fail") EntityType getSpawnedType(); /** @@ -24,8 +27,10 @@ public interface SpawnEggMeta extends ItemMeta { * @deprecated different types are different items */ @Deprecated + @Contract("_ -> fail") void setSpawnedType(EntityType type); + @NotNull @Override SpawnEggMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java index f8a1139397..86db7cfa28 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java @@ -2,6 +2,7 @@ package org.bukkit.inventory.meta; import org.bukkit.DyeColor; import org.bukkit.entity.TropicalFish; +import org.jetbrains.annotations.NotNull; /** * Represents a bucket of tropical fish. @@ -16,6 +17,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { * * @return pattern color */ + @NotNull DyeColor getPatternColor(); /** @@ -26,7 +28,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { * * @param color pattern color */ - void setPatternColor(DyeColor color); + void setPatternColor(@NotNull DyeColor color); /** * Gets the color of the fish's body. @@ -36,6 +38,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { * * @return pattern color */ + @NotNull DyeColor getBodyColor(); /** @@ -46,7 +49,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { * * @param color body color */ - void setBodyColor(DyeColor color); + void setBodyColor(@NotNull DyeColor color); /** * Gets the fish's pattern. @@ -56,6 +59,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { * * @return pattern */ + @NotNull TropicalFish.Pattern getPattern(); /** @@ -66,7 +70,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { * * @param pattern new pattern */ - void setPattern(TropicalFish.Pattern pattern); + void setPattern(@NotNull TropicalFish.Pattern pattern); /** * Checks for existence of a variant tag indicating a specific fish will be @@ -76,5 +80,6 @@ public interface TropicalFishBucketMeta extends ItemMeta { */ boolean hasVariant(); + @NotNull TropicalFishBucketMeta clone(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java b/paper-api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java index f80dd85dd5..e3b77998f3 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java @@ -2,6 +2,8 @@ package org.bukkit.inventory.meta.tags; import org.bukkit.NamespacedKey; import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This interface represents a map like object, capable of storing custom tags @@ -28,7 +30,7 @@ public interface CustomItemTagContainer { * @throws IllegalArgumentException if no suitable adapter will be found for * the {@link ItemTagType#getPrimitiveType()} */ - void setCustomTag(NamespacedKey key, ItemTagType type, Z value); + void setCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType type, @NotNull Z value); /** * Returns if the item meta has a custom tag registered matching the @@ -56,7 +58,7 @@ public interface CustomItemTagContainer { * @throws NullPointerException if the type to cast the found object to is * null */ - boolean hasCustomTag(NamespacedKey key, ItemTagType type); + boolean hasCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType type); /** * Returns the custom tag's value that is stored on the item. @@ -75,7 +77,8 @@ public interface CustomItemTagContainer { * @throws IllegalArgumentException if no suitable adapter will be found for * the {@link ItemTagType#getPrimitiveType()} */ - Z getCustomTag(NamespacedKey key, ItemTagType type); + @Nullable + Z getCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType type); /** * Removes a custom key from the item meta. @@ -83,7 +86,7 @@ public interface CustomItemTagContainer { * @param key the key * @throws NullPointerException if the provided key is null */ - void removeCustomTag(NamespacedKey key); + void removeCustomTag(@NotNull NamespacedKey key); /** * Returns if the container instance is empty, therefore has no entries @@ -98,5 +101,6 @@ public interface CustomItemTagContainer { * * @return the tag context */ + @NotNull ItemTagAdapterContext getAdapterContext(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java b/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java index 348fa65f7e..9de37daa32 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java @@ -1,5 +1,7 @@ package org.bukkit.inventory.meta.tags; +import org.jetbrains.annotations.NotNull; + /** * This interface represents the context in which the {@link ItemTagType} can * serialize and deserialize the passed values. @@ -11,5 +13,6 @@ public interface ItemTagAdapterContext { * * @return the fresh container instance */ + @NotNull CustomItemTagContainer newTagContainer(); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java b/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java index f8a090104a..eab84fe863 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java @@ -1,5 +1,7 @@ package org.bukkit.inventory.meta.tags; +import org.jetbrains.annotations.NotNull; + /** * This class represents an enum with a generic content type. It defines the * types a custom item tag can have. @@ -75,6 +77,7 @@ public interface ItemTagType { * * @return the class */ + @NotNull Class getPrimitiveType(); /** @@ -82,6 +85,7 @@ public interface ItemTagType { * * @return the class type */ + @NotNull Class getComplexType(); /** @@ -92,7 +96,8 @@ public interface ItemTagType { * @param context the context this operation is running in * @return the primitive value */ - T toPrimitive(Z complex, ItemTagAdapterContext context); + @NotNull + T toPrimitive(@NotNull Z complex, @NotNull ItemTagAdapterContext context); /** * Creates a complex object based of the passed primitive value @@ -101,7 +106,8 @@ public interface ItemTagType { * @param context the context this operation is running in * @return the complex object instance */ - Z fromPrimitive(T primitive, ItemTagAdapterContext context); + @NotNull + Z fromPrimitive(@NotNull T primitive, @NotNull ItemTagAdapterContext context); /** * A default implementation that simply exists to pass on the retrieved or @@ -116,27 +122,31 @@ public interface ItemTagType { private final Class primitiveType; - PrimitiveTagType(Class primitiveType) { + PrimitiveTagType(@NotNull Class primitiveType) { this.primitiveType = primitiveType; } + @NotNull @Override public Class getPrimitiveType() { return primitiveType; } + @NotNull @Override public Class getComplexType() { return primitiveType; } + @NotNull @Override - public T toPrimitive(T complex, ItemTagAdapterContext context) { + public T toPrimitive(@NotNull T complex, @NotNull ItemTagAdapterContext context) { return complex; } + @NotNull @Override - public T fromPrimitive(T primitive, ItemTagAdapterContext context) { + public T fromPrimitive(@NotNull T primitive, @NotNull ItemTagAdapterContext context) { return primitive; } } diff --git a/paper-api/src/main/java/org/bukkit/loot/LootContext.java b/paper-api/src/main/java/org/bukkit/loot/LootContext.java index a2c83e58af..e307f9fc45 100644 --- a/paper-api/src/main/java/org/bukkit/loot/LootContext.java +++ b/paper-api/src/main/java/org/bukkit/loot/LootContext.java @@ -4,6 +4,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.HumanEntity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents additional information a {@link LootTable} can use to modify it's @@ -19,7 +21,7 @@ public final class LootContext { private final Entity lootedEntity; private final HumanEntity killer; - private LootContext(Location location, float luck, int lootingModifier, Entity lootedEntity, HumanEntity killer) { + private LootContext(@NotNull Location location, float luck, int lootingModifier, @Nullable Entity lootedEntity, @Nullable HumanEntity killer) { Validate.notNull(location, "LootContext location cannot be null"); Validate.notNull(location.getWorld(), "LootContext World cannot be null"); this.location = location; @@ -34,6 +36,7 @@ public final class LootContext { * * @return the Location of where the loot will be generated */ + @NotNull public Location getLocation() { return location; } @@ -69,6 +72,7 @@ public final class LootContext { * * @return the looted entity or null */ + @Nullable public Entity getLootedEntity() { return lootedEntity; } @@ -79,6 +83,7 @@ public final class LootContext { * * @return the killer entity, or null. */ + @Nullable public HumanEntity getKiller() { return killer; } @@ -102,7 +107,7 @@ public final class LootContext { * * @param location the location the LootContext should use */ - public Builder(Location location) { + public Builder(@NotNull Location location) { this.location = location; } @@ -112,6 +117,7 @@ public final class LootContext { * @param luck the luck level * @return the Builder */ + @NotNull public Builder luck(float luck) { this.luck = luck; return this; @@ -126,6 +132,7 @@ public final class LootContext { * @param modifier the looting level modifier * @return the Builder */ + @NotNull public Builder lootingModifier(int modifier) { this.lootingModifier = modifier; return this; @@ -137,7 +144,8 @@ public final class LootContext { * @param lootedEntity the looted entity * @return the Builder */ - public Builder lootedEntity(Entity lootedEntity) { + @NotNull + public Builder lootedEntity(@Nullable Entity lootedEntity) { this.lootedEntity = lootedEntity; return this; } @@ -150,7 +158,8 @@ public final class LootContext { * @param killer the killer entity * @return the Builder */ - public Builder killer(HumanEntity killer) { + @NotNull + public Builder killer(@Nullable HumanEntity killer) { this.killer = killer; return this; } @@ -161,6 +170,7 @@ public final class LootContext { * * @return a new {@link LootContext} instance */ + @NotNull public LootContext build() { return new LootContext(location, luck, lootingModifier, lootedEntity, killer); } diff --git a/paper-api/src/main/java/org/bukkit/loot/LootTable.java b/paper-api/src/main/java/org/bukkit/loot/LootTable.java index 30b1620088..b391b55de8 100644 --- a/paper-api/src/main/java/org/bukkit/loot/LootTable.java +++ b/paper-api/src/main/java/org/bukkit/loot/LootTable.java @@ -3,6 +3,7 @@ package org.bukkit.loot; import org.bukkit.Keyed; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.Random; @@ -24,7 +25,8 @@ public interface LootTable extends Keyed { * @param context context within to populate loot * @return a list of ItemStacks */ - Collection populateLoot(Random random, LootContext context); + @NotNull + Collection populateLoot(@NotNull Random random, @NotNull LootContext context); /** * Attempt to fill an inventory with this LootTable's loot. @@ -33,5 +35,5 @@ public interface LootTable extends Keyed { * @param random the random instance to use to generate loot * @param context context within to populate loot */ - void fillInventory(Inventory inventory, Random random, LootContext context); + void fillInventory(@NotNull Inventory inventory, @NotNull Random random, @NotNull LootContext context); } diff --git a/paper-api/src/main/java/org/bukkit/loot/LootTables.java b/paper-api/src/main/java/org/bukkit/loot/LootTables.java index 6e5e4d8ee9..f2591d3c08 100644 --- a/paper-api/src/main/java/org/bukkit/loot/LootTables.java +++ b/paper-api/src/main/java/org/bukkit/loot/LootTables.java @@ -3,6 +3,7 @@ package org.bukkit.loot; import org.bukkit.Bukkit; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; /** * This enum holds a list of all known {@link LootTable}s offered by Mojang. @@ -118,10 +119,11 @@ public enum LootTables implements Keyed { private final String location; - private LootTables(String location) { + private LootTables(@NotNull String location) { this.location = location; } + @NotNull @Override public NamespacedKey getKey() { return NamespacedKey.minecraft(location); @@ -133,6 +135,7 @@ public enum LootTables implements Keyed { * * @return the associated LootTable */ + @NotNull public LootTable getLootTable() { return Bukkit.getLootTable(getKey()); } diff --git a/paper-api/src/main/java/org/bukkit/loot/Lootable.java b/paper-api/src/main/java/org/bukkit/loot/Lootable.java index f4b3d02159..24a3d989db 100644 --- a/paper-api/src/main/java/org/bukkit/loot/Lootable.java +++ b/paper-api/src/main/java/org/bukkit/loot/Lootable.java @@ -1,5 +1,7 @@ package org.bukkit.loot; +import org.jetbrains.annotations.Nullable; + /** * Represents a {@link org.bukkit.block.Container} or a * {@link org.bukkit.entity.Mob} that can have a loot table. @@ -20,7 +22,7 @@ public interface Lootable { * @param table the Loot Table this {@link org.bukkit.block.Container} or * {@link org.bukkit.entity.Mob} will have. */ - void setLootTable(LootTable table); + void setLootTable(@Nullable LootTable table); /** * Gets the Loot Table attached to this block or entity. @@ -31,6 +33,7 @@ public interface Lootable { * * @return the Loot Table attached to this block or entity. */ + @Nullable LootTable getLootTable(); /** diff --git a/paper-api/src/main/java/org/bukkit/map/MapCanvas.java b/paper-api/src/main/java/org/bukkit/map/MapCanvas.java index d68bb179ea..f04b01088e 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapCanvas.java +++ b/paper-api/src/main/java/org/bukkit/map/MapCanvas.java @@ -1,5 +1,7 @@ package org.bukkit.map; +import org.jetbrains.annotations.NotNull; + import java.awt.Image; /** @@ -14,6 +16,7 @@ public interface MapCanvas { * * @return The MapView this canvas is attached to. */ + @NotNull public MapView getMapView(); /** @@ -21,6 +24,7 @@ public interface MapCanvas { * * @return The MapCursorCollection associated with this canvas. */ + @NotNull public MapCursorCollection getCursors(); /** @@ -30,7 +34,7 @@ public interface MapCanvas { * * @param cursors The MapCursorCollection to associate with this canvas. */ - public void setCursors(MapCursorCollection cursors); + public void setCursors(@NotNull MapCursorCollection cursors); /** * Draw a pixel to the canvas. @@ -66,7 +70,7 @@ public interface MapCanvas { * @param y The y coordinate of the image. * @param image The Image to draw. */ - public void drawImage(int x, int y, Image image); + public void drawImage(int x, int y, @NotNull Image image); /** * Render text to the map using fancy formatting. Newline (\n) characters @@ -79,6 +83,6 @@ public interface MapCanvas { * @param font The font to use. * @param text The formatted text to render. */ - public void drawText(int x, int y, MapFont font, String text); + public void drawText(int x, int y, @NotNull MapFont font, @NotNull String text); } diff --git a/paper-api/src/main/java/org/bukkit/map/MapCursor.java b/paper-api/src/main/java/org/bukkit/map/MapCursor.java index 3205c92d25..264c17820e 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapCursor.java +++ b/paper-api/src/main/java/org/bukkit/map/MapCursor.java @@ -1,5 +1,8 @@ package org.bukkit.map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Represents a cursor on a map. */ @@ -33,7 +36,7 @@ public final class MapCursor { * @param type The type (color/style) of the map cursor. * @param visible Whether the cursor is visible by default. */ - public MapCursor(byte x, byte y, byte direction, Type type, boolean visible) { + public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible) { this(x, y, direction, type, visible, null); } @@ -49,7 +52,7 @@ public final class MapCursor { * @deprecated Magic value */ @Deprecated - public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, String caption) { + public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable String caption) { this.x = x; this.y = y; setDirection(direction); @@ -68,7 +71,7 @@ public final class MapCursor { * @param visible Whether the cursor is visible by default. * @param caption cursor caption */ - public MapCursor(byte x, byte y, byte direction, Type type, boolean visible, String caption) { + public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible, @Nullable String caption) { this.x = x; this.y = y; setDirection(direction); @@ -109,7 +112,9 @@ public final class MapCursor { * * @return The type (color/style) of the map cursor. */ + @NotNull public Type getType() { + // It should be impossible to set type to something without appropriate Type, so this shouldn't return null return Type.byValue(type); } @@ -168,7 +173,7 @@ public final class MapCursor { * * @param type The type (color/style) of the map cursor. */ - public void setType(Type type) { + public void setType(@NotNull Type type) { setRawType(type.value); } @@ -200,6 +205,7 @@ public final class MapCursor { * * @return caption */ + @Nullable public String getCaption() { return caption; } @@ -209,7 +215,7 @@ public final class MapCursor { * * @param caption new caption */ - public void setCaption(String caption) { + public void setCaption(@Nullable String caption) { this.caption = caption; } @@ -271,6 +277,7 @@ public final class MapCursor { * @deprecated Magic value */ @Deprecated + @Nullable public static Type byValue(byte value) { for (Type t : values()) { if (t.value == value) return t; diff --git a/paper-api/src/main/java/org/bukkit/map/MapCursorCollection.java b/paper-api/src/main/java/org/bukkit/map/MapCursorCollection.java index 802d736d90..be0683ba61 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapCursorCollection.java +++ b/paper-api/src/main/java/org/bukkit/map/MapCursorCollection.java @@ -1,5 +1,8 @@ package org.bukkit.map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.ArrayList; import java.util.List; @@ -25,6 +28,7 @@ public final class MapCursorCollection { * @param index The index of the cursor. * @return The MapCursor. */ + @NotNull public MapCursor getCursor(int index) { return cursors.get(index); } @@ -35,7 +39,7 @@ public final class MapCursorCollection { * @param cursor The MapCursor to remove. * @return Whether the cursor was removed successfully. */ - public boolean removeCursor(MapCursor cursor) { + public boolean removeCursor(@NotNull MapCursor cursor) { return cursors.remove(cursor); } @@ -45,7 +49,8 @@ public final class MapCursorCollection { * @param cursor The MapCursor to add. * @return The MapCursor that was passed. */ - public MapCursor addCursor(MapCursor cursor) { + @NotNull + public MapCursor addCursor(@NotNull MapCursor cursor) { cursors.add(cursor); return cursor; } @@ -58,6 +63,7 @@ public final class MapCursorCollection { * @param direction The facing of the cursor, from 0 to 15. * @return The newly added MapCursor. */ + @NotNull public MapCursor addCursor(int x, int y, byte direction) { return addCursor(x, y, direction, (byte) 0, true); } @@ -73,6 +79,7 @@ public final class MapCursorCollection { * @deprecated Magic value */ @Deprecated + @NotNull public MapCursor addCursor(int x, int y, byte direction, byte type) { return addCursor(x, y, direction, type, true); } @@ -89,6 +96,7 @@ public final class MapCursorCollection { * @deprecated Magic value */ @Deprecated + @NotNull public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible) { return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible)); } @@ -106,7 +114,8 @@ public final class MapCursorCollection { * @deprecated Magic value */ @Deprecated - public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, String caption) { + @NotNull + public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, @Nullable String caption) { return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible, caption)); } } diff --git a/paper-api/src/main/java/org/bukkit/map/MapFont.java b/paper-api/src/main/java/org/bukkit/map/MapFont.java index 2d3b2da210..2d599c8f3e 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapFont.java +++ b/paper-api/src/main/java/org/bukkit/map/MapFont.java @@ -2,6 +2,8 @@ package org.bukkit.map; import java.util.HashMap; import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a bitmap font drawable to a map. @@ -19,7 +21,7 @@ public class MapFont { * @param sprite The CharacterSprite to set. * @throws IllegalStateException if this font is static. */ - public void setChar(char ch, CharacterSprite sprite) { + public void setChar(char ch, @NotNull CharacterSprite sprite) { if (!malleable) { throw new IllegalStateException("this font is not malleable"); } @@ -37,6 +39,7 @@ public class MapFont { * @return The CharacterSprite associated with the character, or null if * there is none. */ + @Nullable public CharacterSprite getChar(char ch) { return chars.get(ch); } @@ -48,7 +51,7 @@ public class MapFont { * @param text The text. * @return The width in pixels. */ - public int getWidth(String text) { + public int getWidth(@NotNull String text) { if (!isValid(text)) { throw new IllegalArgumentException("text contains invalid characters"); } @@ -84,7 +87,7 @@ public class MapFont { * @return True if the string contains only defined characters, false * otherwise. */ - public boolean isValid(String text) { + public boolean isValid(@NotNull String text) { for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch == ChatColor.COLOR_CHAR || ch == '\n') continue; @@ -102,7 +105,7 @@ public class MapFont { private final int height; private final boolean[] data; - public CharacterSprite(int width, int height, boolean[] data) { + public CharacterSprite(int width, int height, @NotNull boolean[] data) { this.width = width; this.height = height; this.data = data; diff --git a/paper-api/src/main/java/org/bukkit/map/MapPalette.java b/paper-api/src/main/java/org/bukkit/map/MapPalette.java index 2c27d0c93b..afe727e24e 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapPalette.java +++ b/paper-api/src/main/java/org/bukkit/map/MapPalette.java @@ -1,5 +1,8 @@ package org.bukkit.map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; @@ -15,11 +18,12 @@ public final class MapPalette { // Internal mechanisms private MapPalette() {} + @NotNull private static Color c(int r, int g, int b) { return new Color(r, g, b); } - private static double getDistance(Color c1, Color c2) { + private static double getDistance(@NotNull Color c1, @NotNull Color c2) { double rmean = (c1.getRed() + c2.getRed()) / 2.0; double r = c1.getRed() - c2.getRed(); double g = c1.getGreen() - c2.getGreen(); @@ -30,6 +34,7 @@ public final class MapPalette { return weightR * r * r + weightG * g * g + weightB * b * b; } + @NotNull static final Color[] colors = { c(0, 0, 0), c(0, 0, 0), c(0, 0, 0), c(0, 0, 0), c(89, 125, 39), c(109, 153, 48), c(127, 178, 56), c(67, 94, 29), @@ -163,7 +168,8 @@ public final class MapPalette { * @param image The image to resize. * @return The resized image. */ - public static BufferedImage resizeImage(Image image) { + @NotNull + public static BufferedImage resizeImage(@Nullable Image image) { BufferedImage result = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = result.createGraphics(); graphics.drawImage(image, 0, 0, 128, 128, null); @@ -179,7 +185,8 @@ public final class MapPalette { * @deprecated Magic value */ @Deprecated - public static byte[] imageToBytes(Image image) { + @NotNull + public static byte[] imageToBytes(@NotNull Image image) { BufferedImage temp = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = temp.createGraphics(); graphics.drawImage(image, 0, 0, null); @@ -219,7 +226,7 @@ public final class MapPalette { * @deprecated Magic value */ @Deprecated - public static byte matchColor(Color color) { + public static byte matchColor(@NotNull Color color) { if (color.getAlpha() < 128) return 0; int index = 0; @@ -245,6 +252,7 @@ public final class MapPalette { * @deprecated Magic value */ @Deprecated + @NotNull public static Color getColor(byte index) { if ((index > -49 && index < 0) || index > 127) { throw new IndexOutOfBoundsException(); diff --git a/paper-api/src/main/java/org/bukkit/map/MapRenderer.java b/paper-api/src/main/java/org/bukkit/map/MapRenderer.java index 322d0ce39e..93aeaf7e59 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapRenderer.java +++ b/paper-api/src/main/java/org/bukkit/map/MapRenderer.java @@ -1,6 +1,7 @@ package org.bukkit.map; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; /** * Represents a renderer for a map. @@ -42,7 +43,7 @@ public abstract class MapRenderer { * * @param map The MapView being initialized. */ - public void initialize(MapView map) {} + public void initialize(@NotNull MapView map) {} /** * Render to the given map. @@ -51,6 +52,6 @@ public abstract class MapRenderer { * @param canvas The canvas to use for rendering. * @param player The player who triggered the rendering. */ - abstract public void render(MapView map, MapCanvas canvas, Player player); + abstract public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player); } diff --git a/paper-api/src/main/java/org/bukkit/map/MapView.java b/paper-api/src/main/java/org/bukkit/map/MapView.java index e152d0768d..29dd573acc 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapView.java +++ b/paper-api/src/main/java/org/bukkit/map/MapView.java @@ -3,6 +3,8 @@ package org.bukkit.map; import java.util.List; import org.bukkit.World; import org.bukkit.inventory.meta.MapMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a map item. @@ -33,6 +35,7 @@ public interface MapView { * @deprecated Magic value */ @Deprecated + @Nullable public static Scale valueOf(byte value) { switch (value) { case 0: return CLOSEST; @@ -76,6 +79,7 @@ public interface MapView { * * @return The scale of the map. */ + @NotNull public Scale getScale(); /** @@ -83,7 +87,7 @@ public interface MapView { * * @param scale The scale to set. */ - public void setScale(Scale scale); + public void setScale(@NotNull Scale scale); /** * Get the center X position of this map. @@ -120,6 +124,7 @@ public interface MapView { * * @return The World this map is associated with. */ + @Nullable public World getWorld(); /** @@ -128,13 +133,14 @@ public interface MapView { * * @param world The World to associate this map with. */ - public void setWorld(World world); + public void setWorld(@NotNull World world); /** * Get a list of MapRenderers currently in effect. * * @return A {@code List} containing each map renderer. */ + @NotNull public List getRenderers(); /** @@ -142,7 +148,7 @@ public interface MapView { * * @param renderer The MapRenderer to add. */ - public void addRenderer(MapRenderer renderer); + public void addRenderer(@NotNull MapRenderer renderer); /** * Remove a renderer from this map. @@ -150,7 +156,7 @@ public interface MapView { * @param renderer The MapRenderer to remove. * @return True if the renderer was successfully removed. */ - public boolean removeRenderer(MapRenderer renderer); + public boolean removeRenderer(@Nullable MapRenderer renderer); /** * Whether the map will show a smaller position cursor (true), or no diff --git a/paper-api/src/main/java/org/bukkit/map/MinecraftFont.java b/paper-api/src/main/java/org/bukkit/map/MinecraftFont.java index 9ec8d10fef..e1c8acc772 100644 --- a/paper-api/src/main/java/org/bukkit/map/MinecraftFont.java +++ b/paper-api/src/main/java/org/bukkit/map/MinecraftFont.java @@ -1,5 +1,7 @@ package org.bukkit.map; +import org.jetbrains.annotations.NotNull; + /** * Represents the built-in Minecraft font. */ @@ -280,6 +282,7 @@ public class MinecraftFont extends MapFont { /** * A static non-malleable MinecraftFont. */ + @NotNull public static final MinecraftFont Font = new MinecraftFont(false); /** diff --git a/paper-api/src/main/java/org/bukkit/material/Attachable.java b/paper-api/src/main/java/org/bukkit/material/Attachable.java index 1d3f1076dc..16abdbf923 100644 --- a/paper-api/src/main/java/org/bukkit/material/Attachable.java +++ b/paper-api/src/main/java/org/bukkit/material/Attachable.java @@ -1,6 +1,7 @@ package org.bukkit.material; import org.bukkit.block.BlockFace; +import org.jetbrains.annotations.NotNull; /** * Indicates that a block can be attached to another block @@ -12,5 +13,6 @@ public interface Attachable extends Directional { * * @return BlockFace attached to */ + @NotNull public BlockFace getAttachedFace(); } diff --git a/paper-api/src/main/java/org/bukkit/material/Colorable.java b/paper-api/src/main/java/org/bukkit/material/Colorable.java index f34ebc674e..7f495e0522 100644 --- a/paper-api/src/main/java/org/bukkit/material/Colorable.java +++ b/paper-api/src/main/java/org/bukkit/material/Colorable.java @@ -1,6 +1,8 @@ package org.bukkit.material; import org.bukkit.DyeColor; +import org.bukkit.UndefinedNullability; +import org.jetbrains.annotations.Nullable; /** * An object that can be colored. @@ -15,6 +17,7 @@ public interface Colorable { * * @return The DyeColor of this object. */ + @Nullable public DyeColor getColor(); /** @@ -24,7 +27,8 @@ public interface Colorable { * object has a special default color (e.g Shulkers). * * @param color The color of the object, as a DyeColor. + * @throws NullPointerException if argument is null and this implementation does not support null */ - public void setColor(DyeColor color); + public void setColor(@UndefinedNullability("defined by subclass") DyeColor color); } diff --git a/paper-api/src/main/java/org/bukkit/material/Directional.java b/paper-api/src/main/java/org/bukkit/material/Directional.java index 25624d26e9..8c1c7b0a25 100644 --- a/paper-api/src/main/java/org/bukkit/material/Directional.java +++ b/paper-api/src/main/java/org/bukkit/material/Directional.java @@ -1,6 +1,7 @@ package org.bukkit.material; import org.bukkit.block.BlockFace; +import org.jetbrains.annotations.NotNull; public interface Directional { @@ -9,12 +10,13 @@ public interface Directional { * * @param face The facing direction */ - public void setFacingDirection(BlockFace face); + public void setFacingDirection(@NotNull BlockFace face); /** * Gets the direction this block is facing * * @return the direction this block is facing */ + @NotNull public BlockFace getFacing(); } diff --git a/paper-api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java b/paper-api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java index 6525ab4545..55ccca92ae 100644 --- a/paper-api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java +++ b/paper-api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java @@ -5,6 +5,8 @@ import java.util.Map; import org.bukkit.block.BlockFace; import com.google.common.collect.Maps; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents the different textured blocks of mushroom. @@ -70,7 +72,7 @@ public enum MushroomBlockTexture { private final Byte data; private final BlockFace capFace; - private MushroomBlockTexture(final int data, final BlockFace capFace) { + private MushroomBlockTexture(final int data, @Nullable final BlockFace capFace) { this.data = (byte) data; this.capFace = capFace; } @@ -91,6 +93,7 @@ public enum MushroomBlockTexture { * * @return The cap face */ + @Nullable public BlockFace getCapFace() { return capFace; } @@ -104,6 +107,7 @@ public enum MushroomBlockTexture { * @deprecated Magic value */ @Deprecated + @Nullable public static MushroomBlockTexture getByData(final byte data) { return BY_DATA.get(data); } @@ -117,7 +121,8 @@ public enum MushroomBlockTexture { * * @see BlockFace */ - public static MushroomBlockTexture getCapByFace(final BlockFace face) { + @Nullable + public static MushroomBlockTexture getCapByFace(@Nullable final BlockFace face) { return BY_BLOCKFACE.get(face); } diff --git a/paper-api/src/main/java/org/bukkit/metadata/FixedMetadataValue.java b/paper-api/src/main/java/org/bukkit/metadata/FixedMetadataValue.java index 5f4857399a..4ded655310 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/FixedMetadataValue.java +++ b/paper-api/src/main/java/org/bukkit/metadata/FixedMetadataValue.java @@ -1,6 +1,8 @@ package org.bukkit.metadata; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A FixedMetadataValue is a special case metadata item that contains the same @@ -24,7 +26,7 @@ public class FixedMetadataValue extends LazyMetadataValue { * @param owningPlugin the {@link Plugin} that created this metadata value * @param value the value assigned to this metadata value */ - public FixedMetadataValue(Plugin owningPlugin, final Object value) { + public FixedMetadataValue(@NotNull Plugin owningPlugin, @Nullable final Object value) { super(owningPlugin); this.internalValue = value; } @@ -34,6 +36,7 @@ public class FixedMetadataValue extends LazyMetadataValue { } + @Nullable @Override public Object value() { return internalValue; diff --git a/paper-api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java b/paper-api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java index da5e9f3a51..820b22ca9f 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java +++ b/paper-api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java @@ -5,6 +5,8 @@ import java.util.concurrent.Callable; import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The LazyMetadataValue class implements a type of metadata that is not @@ -31,7 +33,7 @@ public class LazyMetadataValue extends MetadataValueAdapter { * value. * @param lazyValue the lazy value assigned to this metadata value. */ - public LazyMetadataValue(Plugin owningPlugin, Callable lazyValue) { + public LazyMetadataValue(@NotNull Plugin owningPlugin, @NotNull Callable lazyValue) { this(owningPlugin, CacheStrategy.CACHE_AFTER_FIRST_EVAL, lazyValue); } @@ -44,7 +46,7 @@ public class LazyMetadataValue extends MetadataValueAdapter { * value. * @param lazyValue the lazy value assigned to this metadata value. */ - public LazyMetadataValue(Plugin owningPlugin, CacheStrategy cacheStrategy, Callable lazyValue) { + public LazyMetadataValue(@NotNull Plugin owningPlugin, @NotNull CacheStrategy cacheStrategy, @NotNull Callable lazyValue) { super(owningPlugin); Validate.notNull(cacheStrategy, "cacheStrategy cannot be null"); Validate.notNull(lazyValue, "lazyValue cannot be null"); @@ -59,10 +61,11 @@ public class LazyMetadataValue extends MetadataValueAdapter { * * @param owningPlugin the owning plugin */ - protected LazyMetadataValue(Plugin owningPlugin) { + protected LazyMetadataValue(@NotNull Plugin owningPlugin) { super(owningPlugin); } + @Nullable public Object value() { eval(); Object value = internalValue.get(); diff --git a/paper-api/src/main/java/org/bukkit/metadata/MetadataStore.java b/paper-api/src/main/java/org/bukkit/metadata/MetadataStore.java index 700d0bfb78..1ebba41f4a 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/MetadataStore.java +++ b/paper-api/src/main/java/org/bukkit/metadata/MetadataStore.java @@ -1,6 +1,7 @@ package org.bukkit.metadata; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -14,7 +15,7 @@ public interface MetadataStore { * @throws IllegalArgumentException If value is null, or the owning plugin * is null */ - public void setMetadata(T subject, String metadataKey, MetadataValue newMetadataValue); + public void setMetadata(@NotNull T subject, @NotNull String metadataKey, @NotNull MetadataValue newMetadataValue); /** * Returns all metadata values attached to an object. If multiple plugins @@ -25,7 +26,8 @@ public interface MetadataStore { * @return A list of values, one for each plugin that has set the * requested value. */ - public List getMetadata(T subject, String metadataKey); + @NotNull + public List getMetadata(@NotNull T subject, @NotNull String metadataKey); /** * Tests to see if a metadata attribute has been set on an object. @@ -35,7 +37,7 @@ public interface MetadataStore { * @param metadataKey the unique metadata key being queried. * @return the existence of the metadataKey within subject. */ - public boolean hasMetadata(T subject, String metadataKey); + public boolean hasMetadata(@NotNull T subject, @NotNull String metadataKey); /** * Removes a metadata item owned by a plugin from a subject. @@ -46,7 +48,7 @@ public interface MetadataStore { * @param owningPlugin the plugin attempting to remove a metadata item. * @throws IllegalArgumentException If plugin is null */ - public void removeMetadata(T subject, String metadataKey, Plugin owningPlugin); + public void removeMetadata(@NotNull T subject, @NotNull String metadataKey, @NotNull Plugin owningPlugin); /** * Invalidates all metadata in the metadata store that originates from the @@ -56,5 +58,5 @@ public interface MetadataStore { * @param owningPlugin the plugin requesting the invalidation. * @throws IllegalArgumentException If plugin is null */ - public void invalidateAll(Plugin owningPlugin); + public void invalidateAll(@NotNull Plugin owningPlugin); } diff --git a/paper-api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java b/paper-api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java index 093c144527..9dbc32d866 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java +++ b/paper-api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java @@ -2,6 +2,7 @@ package org.bukkit.metadata; import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; import java.util.*; @@ -30,7 +31,7 @@ public abstract class MetadataStoreBase { * @throws IllegalArgumentException If value is null, or the owning plugin * is null */ - public synchronized void setMetadata(T subject, String metadataKey, MetadataValue newMetadataValue) { + public synchronized void setMetadata(@NotNull T subject, @NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) { Validate.notNull(newMetadataValue, "Value cannot be null"); Plugin owningPlugin = newMetadataValue.getOwningPlugin(); Validate.notNull(owningPlugin, "Plugin cannot be null"); @@ -53,7 +54,8 @@ public abstract class MetadataStoreBase { * requested value. * @see MetadataStore#getMetadata(Object, String) */ - public synchronized List getMetadata(T subject, String metadataKey) { + @NotNull + public synchronized List getMetadata(@NotNull T subject, @NotNull String metadataKey) { String key = disambiguate(subject, metadataKey); if (metadataMap.containsKey(key)) { Collection values = metadataMap.get(key).values(); @@ -71,7 +73,7 @@ public abstract class MetadataStoreBase { * @param metadataKey the unique metadata key being queried. * @return the existence of the metadataKey within subject. */ - public synchronized boolean hasMetadata(T subject, String metadataKey) { + public synchronized boolean hasMetadata(@NotNull T subject, @NotNull String metadataKey) { String key = disambiguate(subject, metadataKey); return metadataMap.containsKey(key); } @@ -87,7 +89,7 @@ public abstract class MetadataStoreBase { * org.bukkit.plugin.Plugin) * @throws IllegalArgumentException If plugin is null */ - public synchronized void removeMetadata(T subject, String metadataKey, Plugin owningPlugin) { + public synchronized void removeMetadata(@NotNull T subject, @NotNull String metadataKey, @NotNull Plugin owningPlugin) { Validate.notNull(owningPlugin, "Plugin cannot be null"); String key = disambiguate(subject, metadataKey); Map entry = metadataMap.get(key); @@ -110,7 +112,7 @@ public abstract class MetadataStoreBase { * @see MetadataStore#invalidateAll(org.bukkit.plugin.Plugin) * @throws IllegalArgumentException If plugin is null */ - public synchronized void invalidateAll(Plugin owningPlugin) { + public synchronized void invalidateAll(@NotNull Plugin owningPlugin) { Validate.notNull(owningPlugin, "Plugin cannot be null"); for (Map values : metadataMap.values()) { if (values.containsKey(owningPlugin)) { @@ -132,5 +134,6 @@ public abstract class MetadataStoreBase { * @param metadataKey The name identifying the metadata value. * @return a unique metadata key for the given subject. */ - protected abstract String disambiguate(T subject, String metadataKey); + @NotNull + protected abstract String disambiguate(@NotNull T subject, @NotNull String metadataKey); } diff --git a/paper-api/src/main/java/org/bukkit/metadata/MetadataValue.java b/paper-api/src/main/java/org/bukkit/metadata/MetadataValue.java index eded8c0432..4b4d57924b 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/MetadataValue.java +++ b/paper-api/src/main/java/org/bukkit/metadata/MetadataValue.java @@ -1,6 +1,8 @@ package org.bukkit.metadata; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface MetadataValue { @@ -9,6 +11,7 @@ public interface MetadataValue { * * @return the metadata value. */ + @Nullable public Object value(); /** @@ -65,14 +68,15 @@ public interface MetadataValue { * * @return the value as a string. */ + @NotNull public String asString(); /** * Returns the {@link Plugin} that created this metadata item. * - * @return the plugin that owns this metadata value. This should never be - * null. + * @return the plugin that owns this metadata value. Could be null if the plugin was already unloaded. */ + @Nullable public Plugin getOwningPlugin(); /** diff --git a/paper-api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java b/paper-api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java index bbc3da86bf..f88299103b 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java +++ b/paper-api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java @@ -5,6 +5,8 @@ import java.lang.ref.WeakReference; import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; import org.bukkit.util.NumberConversions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Optional base class for facilitating MetadataValue implementations. @@ -16,11 +18,12 @@ import org.bukkit.util.NumberConversions; public abstract class MetadataValueAdapter implements MetadataValue { protected final WeakReference owningPlugin; - protected MetadataValueAdapter(Plugin owningPlugin) { + protected MetadataValueAdapter(@NotNull Plugin owningPlugin) { Validate.notNull(owningPlugin, "owningPlugin cannot be null"); this.owningPlugin = new WeakReference(owningPlugin); } + @Nullable public Plugin getOwningPlugin() { return owningPlugin.get(); } @@ -66,6 +69,7 @@ public abstract class MetadataValueAdapter implements MetadataValue { return value != null; } + @NotNull public String asString() { Object value = value(); diff --git a/paper-api/src/main/java/org/bukkit/metadata/Metadatable.java b/paper-api/src/main/java/org/bukkit/metadata/Metadatable.java index b47cf2b004..891e516083 100644 --- a/paper-api/src/main/java/org/bukkit/metadata/Metadatable.java +++ b/paper-api/src/main/java/org/bukkit/metadata/Metadatable.java @@ -1,6 +1,7 @@ package org.bukkit.metadata; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -17,7 +18,7 @@ public interface Metadatable { * @throws IllegalArgumentException If value is null, or the owning plugin * is null */ - public void setMetadata(String metadataKey, MetadataValue newMetadataValue); + public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue); /** * Returns a list of previously set metadata values from the implementing @@ -27,7 +28,8 @@ public interface Metadatable { * @return A list of values, one for each plugin that has set the * requested value. */ - public List getMetadata(String metadataKey); + @NotNull + public List getMetadata(@NotNull String metadataKey); /** * Tests to see whether the implementing object contains the given @@ -36,7 +38,7 @@ public interface Metadatable { * @param metadataKey the unique metadata key being queried. * @return the existence of the metadataKey within subject. */ - public boolean hasMetadata(String metadataKey); + public boolean hasMetadata(@NotNull String metadataKey); /** * Removes the given metadata value from the implementing object's @@ -48,5 +50,5 @@ public interface Metadatable { * other values will be left untouched. * @throws IllegalArgumentException If plugin is null */ - public void removeMetadata(String metadataKey, Plugin owningPlugin); + public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin); } diff --git a/paper-api/src/main/java/org/bukkit/permissions/Permissible.java b/paper-api/src/main/java/org/bukkit/permissions/Permissible.java index 5cd3cff023..2284211549 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/Permissible.java +++ b/paper-api/src/main/java/org/bukkit/permissions/Permissible.java @@ -2,6 +2,8 @@ package org.bukkit.permissions; import java.util.Set; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an object that may be assigned permissions @@ -15,7 +17,7 @@ public interface Permissible extends ServerOperator { * @param name Name of the permission * @return true if the permission is set, otherwise false */ - public boolean isPermissionSet(String name); + public boolean isPermissionSet(@NotNull String name); /** * Checks if this object contains an override for the specified {@link @@ -24,7 +26,7 @@ public interface Permissible extends ServerOperator { * @param perm Permission to check * @return true if the permission is set, otherwise false */ - public boolean isPermissionSet(Permission perm); + public boolean isPermissionSet(@NotNull Permission perm); /** * Gets the value of the specified permission, if set. @@ -35,7 +37,7 @@ public interface Permissible extends ServerOperator { * @param name Name of the permission * @return Value of the permission */ - public boolean hasPermission(String name); + public boolean hasPermission(@NotNull String name); /** * Gets the value of the specified permission, if set. @@ -46,7 +48,7 @@ public interface Permissible extends ServerOperator { * @param perm Permission to get * @return Value of the permission */ - public boolean hasPermission(Permission perm); + public boolean hasPermission(@NotNull Permission perm); /** * Adds a new {@link PermissionAttachment} with a single permission by @@ -58,7 +60,8 @@ public interface Permissible extends ServerOperator { * @param value Value of the permission * @return The PermissionAttachment that was just created */ - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value); + @NotNull + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value); /** * Adds a new empty {@link PermissionAttachment} to this object @@ -67,7 +70,8 @@ public interface Permissible extends ServerOperator { * or disabled * @return The PermissionAttachment that was just created */ - public PermissionAttachment addAttachment(Plugin plugin); + @NotNull + public PermissionAttachment addAttachment(@NotNull Plugin plugin); /** * Temporarily adds a new {@link PermissionAttachment} with a single @@ -81,7 +85,8 @@ public interface Permissible extends ServerOperator { * after * @return The PermissionAttachment that was just created */ - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks); + @Nullable + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks); /** * Temporarily adds a new empty {@link PermissionAttachment} to this @@ -93,7 +98,8 @@ public interface Permissible extends ServerOperator { * after * @return The PermissionAttachment that was just created */ - public PermissionAttachment addAttachment(Plugin plugin, int ticks); + @Nullable + public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks); /** * Removes the given {@link PermissionAttachment} from this object @@ -102,7 +108,7 @@ public interface Permissible extends ServerOperator { * @throws IllegalArgumentException Thrown when the specified attachment * isn't part of this object */ - public void removeAttachment(PermissionAttachment attachment); + public void removeAttachment(@NotNull PermissionAttachment attachment); /** * Recalculates the permissions for this object, if the attachments have @@ -118,5 +124,6 @@ public interface Permissible extends ServerOperator { * * @return Set of currently effective permissions */ + @NotNull public Set getEffectivePermissions(); } diff --git a/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java b/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java index d4cb00a821..27c14c0f54 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java @@ -9,17 +9,19 @@ import java.util.Set; import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Base Permissible for use in any Permissible object via proxy or extension */ public class PermissibleBase implements Permissible { - private ServerOperator opable = null; + private ServerOperator opable; private Permissible parent = this; private final List attachments = new LinkedList(); private final Map permissions = new HashMap(); - public PermissibleBase(ServerOperator opable) { + public PermissibleBase(@Nullable ServerOperator opable) { this.opable = opable; if (opable instanceof Permissible) { @@ -45,7 +47,7 @@ public class PermissibleBase implements Permissible { } } - public boolean isPermissionSet(String name) { + public boolean isPermissionSet(@NotNull String name) { if (name == null) { throw new IllegalArgumentException("Permission name cannot be null"); } @@ -53,7 +55,7 @@ public class PermissibleBase implements Permissible { return permissions.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)); } - public boolean isPermissionSet(Permission perm) { + public boolean isPermissionSet(@NotNull Permission perm) { if (perm == null) { throw new IllegalArgumentException("Permission cannot be null"); } @@ -61,7 +63,7 @@ public class PermissibleBase implements Permissible { return isPermissionSet(perm.getName()); } - public boolean hasPermission(String inName) { + public boolean hasPermission(@NotNull String inName) { if (inName == null) { throw new IllegalArgumentException("Permission name cannot be null"); } @@ -81,7 +83,7 @@ public class PermissibleBase implements Permissible { } } - public boolean hasPermission(Permission perm) { + public boolean hasPermission(@NotNull Permission perm) { if (perm == null) { throw new IllegalArgumentException("Permission cannot be null"); } @@ -94,7 +96,8 @@ public class PermissibleBase implements Permissible { return perm.getDefault().getValue(isOp()); } - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { + @NotNull + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { if (name == null) { throw new IllegalArgumentException("Permission name cannot be null"); } else if (plugin == null) { @@ -111,7 +114,8 @@ public class PermissibleBase implements Permissible { return result; } - public PermissionAttachment addAttachment(Plugin plugin) { + @NotNull + public PermissionAttachment addAttachment(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { @@ -126,7 +130,7 @@ public class PermissibleBase implements Permissible { return result; } - public void removeAttachment(PermissionAttachment attachment) { + public void removeAttachment(@NotNull PermissionAttachment attachment) { if (attachment == null) { throw new IllegalArgumentException("Attachment cannot be null"); } @@ -175,7 +179,7 @@ public class PermissibleBase implements Permissible { permissions.clear(); } - private void calculateChildPermissions(Map children, boolean invert, PermissionAttachment attachment) { + private void calculateChildPermissions(@NotNull Map children, boolean invert, @Nullable PermissionAttachment attachment) { for (Map.Entry entry : children.entrySet()) { String name = entry.getKey(); @@ -192,7 +196,8 @@ public class PermissibleBase implements Permissible { } } - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { + @Nullable + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { if (name == null) { throw new IllegalArgumentException("Permission name cannot be null"); } else if (plugin == null) { @@ -210,7 +215,8 @@ public class PermissibleBase implements Permissible { return result; } - public PermissionAttachment addAttachment(Plugin plugin, int ticks) { + @Nullable + public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { @@ -228,6 +234,7 @@ public class PermissibleBase implements Permissible { } } + @NotNull public Set getEffectivePermissions() { return new HashSet(permissions.values()); } @@ -235,7 +242,7 @@ public class PermissibleBase implements Permissible { private static class RemoveAttachmentRunnable implements Runnable { private PermissionAttachment attachment; - public RemoveAttachmentRunnable(PermissionAttachment attachment) { + public RemoveAttachmentRunnable(@NotNull PermissionAttachment attachment) { this.attachment = attachment; } diff --git a/paper-api/src/main/java/org/bukkit/permissions/Permission.java b/paper-api/src/main/java/org/bukkit/permissions/Permission.java index c5237bbcc7..09eb28cceb 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/Permission.java +++ b/paper-api/src/main/java/org/bukkit/permissions/Permission.java @@ -10,6 +10,8 @@ import java.util.logging.Level; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a unique permission that may be attached to a {@link @@ -23,35 +25,35 @@ public class Permission { private PermissionDefault defaultValue = DEFAULT_PERMISSION; private String description; - public Permission(String name) { + public Permission(@NotNull String name) { this(name, null, null, null); } - public Permission(String name, String description) { + public Permission(@NotNull String name, @Nullable String description) { this(name, description, null, null); } - public Permission(String name, PermissionDefault defaultValue) { + public Permission(@NotNull String name, @Nullable PermissionDefault defaultValue) { this(name, null, defaultValue, null); } - public Permission(String name, String description, PermissionDefault defaultValue) { + public Permission(@NotNull String name, @Nullable String description, @Nullable PermissionDefault defaultValue) { this(name, description, defaultValue, null); } - public Permission(String name, Map children) { + public Permission(@NotNull String name, @Nullable Map children) { this(name, null, null, children); } - public Permission(String name, String description, Map children) { + public Permission(@NotNull String name, @Nullable String description, @Nullable Map children) { this(name, description, null, children); } - public Permission(String name, PermissionDefault defaultValue, Map children) { + public Permission(@NotNull String name, @Nullable PermissionDefault defaultValue, @Nullable Map children) { this(name, null, defaultValue, children); } - public Permission(String name, String description, PermissionDefault defaultValue, Map children) { + public Permission(@NotNull String name, @Nullable String description, @Nullable PermissionDefault defaultValue, @Nullable Map children) { Validate.notNull(name, "Name cannot be null"); this.name = name; this.description = (description == null) ? "" : description; @@ -72,6 +74,7 @@ public class Permission { * * @return Fully qualified name */ + @NotNull public String getName() { return name; } @@ -84,6 +87,7 @@ public class Permission { * * @return Permission children */ + @NotNull public Map getChildren() { return children; } @@ -93,6 +97,7 @@ public class Permission { * * @return Default value of this permission. */ + @NotNull public PermissionDefault getDefault() { return defaultValue; } @@ -107,7 +112,7 @@ public class Permission { * * @param value The new default to set */ - public void setDefault(PermissionDefault value) { + public void setDefault(@NotNull PermissionDefault value) { if (defaultValue == null) { throw new IllegalArgumentException("Default value cannot be null"); } @@ -117,10 +122,11 @@ public class Permission { } /** - * Gets a brief description of this permission, if set + * Gets a brief description of this permission, may be empty * * @return Brief description of this permission */ + @NotNull public String getDescription() { return description; } @@ -133,7 +139,7 @@ public class Permission { * * @param value The new description to set */ - public void setDescription(String value) { + public void setDescription(@Nullable String value) { if (value == null) { description = ""; } else { @@ -149,6 +155,7 @@ public class Permission { * * @return Set containing permissibles with this permission */ + @NotNull public Set getPermissibles() { return Bukkit.getServer().getPluginManager().getPermissionSubscriptions(name); } @@ -179,7 +186,8 @@ public class Permission { * @param value The value to set this permission to * @return Parent permission it created or loaded */ - public Permission addParent(String name, boolean value) { + @NotNull + public Permission addParent(@NotNull String name, boolean value) { PluginManager pm = Bukkit.getServer().getPluginManager(); String lname = name.toLowerCase(java.util.Locale.ENGLISH); @@ -201,7 +209,7 @@ public class Permission { * @param perm Parent permission to register with * @param value The value to set this permission to */ - public void addParent(Permission perm, boolean value) { + public void addParent(@NotNull Permission perm, boolean value) { perm.getChildren().put(getName(), value); perm.recalculatePermissibles(); } @@ -221,11 +229,12 @@ public class Permission { * * * @param data Map of permissions - * @param error An error message to show if a permission is invalid. + * @param error An error message to show if a permission is invalid. May contain "%s" format tag, which will be replaced with the name of invalid permission. * @param def Default permission value to use if missing * @return Permission object */ - public static List loadPermissions(Map data, String error, PermissionDefault def) { + @NotNull + public static List loadPermissions(@NotNull Map data, @NotNull String error, @Nullable PermissionDefault def) { List result = new ArrayList(); for (Map.Entry entry : data.entrySet()) { @@ -256,7 +265,8 @@ public class Permission { * @param data Map of keys * @return Permission object */ - public static Permission loadPermission(String name, Map data) { + @NotNull + public static Permission loadPermission(@NotNull String name, @NotNull Map data) { return loadPermission(name, data, DEFAULT_PERMISSION, null); } @@ -279,7 +289,8 @@ public class Permission { * @param output A list to append any created child-Permissions to, may be null * @return Permission object */ - public static Permission loadPermission(String name, Map data, PermissionDefault def, List output) { + @NotNull + public static Permission loadPermission(@NotNull String name, @NotNull Map data, @Nullable PermissionDefault def, @Nullable List output) { Validate.notNull(name, "Name cannot be null"); Validate.notNull(data, "Data cannot be null"); @@ -318,7 +329,8 @@ public class Permission { return new Permission(name, desc, def, children); } - private static Map extractChildren(Map input, String name, PermissionDefault def, List output) { + @NotNull + private static Map extractChildren(@NotNull Map input, @NotNull String name, @Nullable PermissionDefault def, @Nullable List output) { Map children = new LinkedHashMap(); for (Map.Entry entry : input.entrySet()) { diff --git a/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachment.java b/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachment.java index 9849261d8c..cd8ac371a1 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachment.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachment.java @@ -3,6 +3,8 @@ package org.bukkit.permissions; import java.util.LinkedHashMap; import java.util.Map; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Holds information about a permission attachment on a {@link Permissible} @@ -14,14 +16,14 @@ public class PermissionAttachment { private final Permissible permissible; private final Plugin plugin; - public PermissionAttachment(Plugin plugin, Permissible Permissible) { + public PermissionAttachment(@NotNull Plugin plugin, @NotNull Permissible permissible) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is disabled"); } - this.permissible = Permissible; + this.permissible = permissible; this.plugin = plugin; } @@ -30,6 +32,7 @@ public class PermissionAttachment { * * @return Plugin responsible for this permission attachment */ + @NotNull public Plugin getPlugin() { return plugin; } @@ -40,7 +43,7 @@ public class PermissionAttachment { * * @param ex Object to be called when this is removed */ - public void setRemovalCallback(PermissionRemovedExecutor ex) { + public void setRemovalCallback(@Nullable PermissionRemovedExecutor ex) { removed = ex; } @@ -50,6 +53,7 @@ public class PermissionAttachment { * * @return Object to be called when this is removed */ + @Nullable public PermissionRemovedExecutor getRemovalCallback() { return removed; } @@ -59,6 +63,7 @@ public class PermissionAttachment { * * @return Permissible containing this attachment */ + @NotNull public Permissible getPermissible() { return permissible; } @@ -72,6 +77,7 @@ public class PermissionAttachment { * * @return Copy of all permissions and values expressed by this attachment */ + @NotNull public Map getPermissions() { return new LinkedHashMap(permissions); } @@ -82,7 +88,7 @@ public class PermissionAttachment { * @param name Name of the permission * @param value New value of the permission */ - public void setPermission(String name, boolean value) { + public void setPermission(@NotNull String name, boolean value) { permissions.put(name.toLowerCase(java.util.Locale.ENGLISH), value); permissible.recalculatePermissions(); } @@ -93,7 +99,7 @@ public class PermissionAttachment { * @param perm Permission to set * @param value New value of the permission */ - public void setPermission(Permission perm, boolean value) { + public void setPermission(@NotNull Permission perm, boolean value) { setPermission(perm.getName(), value); } @@ -105,7 +111,7 @@ public class PermissionAttachment { * * @param name Name of the permission to remove */ - public void unsetPermission(String name) { + public void unsetPermission(@NotNull String name) { permissions.remove(name.toLowerCase(java.util.Locale.ENGLISH)); permissible.recalculatePermissions(); } @@ -118,7 +124,7 @@ public class PermissionAttachment { * * @param perm Permission to remove */ - public void unsetPermission(Permission perm) { + public void unsetPermission(@NotNull Permission perm) { unsetPermission(perm.getName()); } diff --git a/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachmentInfo.java b/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachmentInfo.java index 8e8e33550f..a7f4cd37cf 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachmentInfo.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissionAttachmentInfo.java @@ -1,5 +1,8 @@ package org.bukkit.permissions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Holds information on a permission and which {@link PermissionAttachment} * provides it @@ -10,11 +13,11 @@ public class PermissionAttachmentInfo { private final PermissionAttachment attachment; private final boolean value; - public PermissionAttachmentInfo(Permissible permissible, String permission, PermissionAttachment attachment, boolean value) { + public PermissionAttachmentInfo(@NotNull Permissible permissible, @NotNull String permission, @Nullable PermissionAttachment attachment, boolean value) { if (permissible == null) { throw new IllegalArgumentException("Permissible may not be null"); } else if (permission == null) { - throw new IllegalArgumentException("Permissions may not be null"); + throw new IllegalArgumentException("Permission may not be null"); } this.permissible = permissible; @@ -28,6 +31,7 @@ public class PermissionAttachmentInfo { * * @return Permissible this permission is for */ + @NotNull public Permissible getPermissible() { return permissible; } @@ -37,6 +41,7 @@ public class PermissionAttachmentInfo { * * @return Name of the permission */ + @NotNull public String getPermission() { return permission; } @@ -47,6 +52,7 @@ public class PermissionAttachmentInfo { * * @return Attachment */ + @Nullable public PermissionAttachment getAttachment() { return attachment; } diff --git a/paper-api/src/main/java/org/bukkit/permissions/PermissionDefault.java b/paper-api/src/main/java/org/bukkit/permissions/PermissionDefault.java index 00f08b3b9e..dfd7a12c41 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissionDefault.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissionDefault.java @@ -1,5 +1,8 @@ package org.bukkit.permissions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.HashMap; import java.util.Map; @@ -15,7 +18,7 @@ public enum PermissionDefault { private final String[] names; private final static Map lookup = new HashMap(); - private PermissionDefault(String... names) { + private PermissionDefault(@NotNull String... names) { this.names = names; } @@ -47,7 +50,8 @@ public enum PermissionDefault { * @param name Name of the default * @return Specified value, or null if not found */ - public static PermissionDefault getByName(String name) { + @Nullable + public static PermissionDefault getByName(@NotNull String name) { return lookup.get(name.toLowerCase(java.util.Locale.ENGLISH).replaceAll("[^a-z!]", "")); } diff --git a/paper-api/src/main/java/org/bukkit/permissions/PermissionRemovedExecutor.java b/paper-api/src/main/java/org/bukkit/permissions/PermissionRemovedExecutor.java index b13d008278..4cc9e64718 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissionRemovedExecutor.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissionRemovedExecutor.java @@ -1,5 +1,7 @@ package org.bukkit.permissions; +import org.jetbrains.annotations.NotNull; + /** * Represents a class which is to be notified when a {@link * PermissionAttachment} is removed from a {@link Permissible} @@ -12,5 +14,5 @@ public interface PermissionRemovedExecutor { * * @param attachment Attachment which was removed */ - public void attachmentRemoved(PermissionAttachment attachment); + public void attachmentRemoved(@NotNull PermissionAttachment attachment); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java b/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java index 3b2c99ea7b..a850f0780d 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java +++ b/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java @@ -3,10 +3,11 @@ package org.bukkit.plugin; import org.bukkit.event.Event; import org.bukkit.event.EventException; import org.bukkit.event.Listener; +import org.jetbrains.annotations.NotNull; /** * Interface which defines the class for event call backs to plugins */ public interface EventExecutor { - public void execute(Listener listener, Event event) throws EventException; + public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException; } diff --git a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java index 55debf5d5a..076ec041f8 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java @@ -8,6 +8,8 @@ import org.bukkit.Server; import org.bukkit.command.TabExecutor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.generator.ChunkGenerator; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a Plugin @@ -21,6 +23,7 @@ public interface Plugin extends TabExecutor { * * @return The folder */ + @NotNull public File getDataFolder(); /** @@ -28,6 +31,7 @@ public interface Plugin extends TabExecutor { * * @return Contents of the plugin.yaml file */ + @NotNull public PluginDescriptionFile getDescription(); /** @@ -39,6 +43,7 @@ public interface Plugin extends TabExecutor { * * @return Plugin configuration */ + @NotNull public FileConfiguration getConfig(); /** @@ -47,7 +52,8 @@ public interface Plugin extends TabExecutor { * @param filename Filename of the resource * @return File if found, otherwise null */ - public InputStream getResource(String filename); + @Nullable + public InputStream getResource(@NotNull String filename); /** * Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}. @@ -76,7 +82,7 @@ public interface Plugin extends TabExecutor { * @throws IllegalArgumentException if the resource path is null, empty, * or points to a nonexistent resource. */ - public void saveResource(String resourcePath, boolean replace); + public void saveResource(@NotNull String resourcePath, boolean replace); /** * Discards any data in {@link #getConfig()} and reloads from disk. @@ -88,6 +94,7 @@ public interface Plugin extends TabExecutor { * * @return PluginLoader that controls this plugin */ + @NotNull public PluginLoader getPluginLoader(); /** @@ -95,6 +102,7 @@ public interface Plugin extends TabExecutor { * * @return Server running this plugin */ + @NotNull public Server getServer(); /** @@ -146,7 +154,8 @@ public interface Plugin extends TabExecutor { * generator was requested * @return ChunkGenerator for use in the default world generation */ - public ChunkGenerator getDefaultWorldGenerator(String worldName, String id); + @Nullable + public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id); /** * Returns the plugin logger associated with this server's logger. The @@ -155,6 +164,7 @@ public interface Plugin extends TabExecutor { * * @return Logger associated with this plugin */ + @NotNull public Logger getLogger(); /** @@ -165,5 +175,6 @@ public interface Plugin extends TabExecutor { * * @return name of the plugin */ + @NotNull public String getName(); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginBase.java b/paper-api/src/main/java/org/bukkit/plugin/PluginBase.java index 6031af11fa..70c53a24dc 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginBase.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginBase.java @@ -1,5 +1,7 @@ package org.bukkit.plugin; +import org.jetbrains.annotations.NotNull; + /** * Represents a base {@link Plugin} *

@@ -26,6 +28,7 @@ public abstract class PluginBase implements Plugin { return getName().equals(((Plugin) obj).getName()); } + @NotNull public final String getName() { return getDescription().getName(); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index c29ede7739..4574a965ee 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -10,12 +10,17 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; +import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; +import org.bukkit.command.TabCompleter; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.AbstractConstruct; import org.yaml.snakeyaml.constructor.SafeConstructor; @@ -179,12 +184,14 @@ public final class PluginDescriptionFile { private static final Pattern VALID_NAME = Pattern.compile("^[A-Za-z0-9 _.-]+$"); private static final ThreadLocal YAML = new ThreadLocal() { @Override + @NotNull protected Yaml initialValue() { return new Yaml(new SafeConstructor() { { yamlConstructors.put(null, new AbstractConstruct() { + @NotNull @Override - public Object construct(final Node node) { + public Object construct(@NotNull final Node node) { if (!node.getTag().startsWith("!@")) { // Unknown tag - will fail return SafeConstructor.undefinedConstructor.construct(node); @@ -200,8 +207,9 @@ public final class PluginDescriptionFile { }); for (final PluginAwareness.Flags flag : PluginAwareness.Flags.values()) { yamlConstructors.put(new Tag("!@" + flag.name()), new AbstractConstruct() { + @NotNull @Override - public PluginAwareness.Flags construct(final Node node) { + public PluginAwareness.Flags construct(@NotNull final Node node) { return flag; } }); @@ -218,7 +226,7 @@ public final class PluginDescriptionFile { private List softDepend = ImmutableList.of(); private List loadBefore = ImmutableList.of(); private String version = null; - private Map> commands = null; + private Map> commands = ImmutableMap.of(); private String description = null; private List authors = null; private String website = null; @@ -230,7 +238,7 @@ public final class PluginDescriptionFile { private Set awareness = ImmutableSet.of(); private String apiVersion = null; - public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException { + public PluginDescriptionFile(@NotNull final InputStream stream) throws InvalidDescriptionException { loadMap(asMap(YAML.get().load(stream))); } @@ -241,7 +249,7 @@ public final class PluginDescriptionFile { * @throws InvalidDescriptionException If the PluginDescriptionFile is * invalid */ - public PluginDescriptionFile(final Reader reader) throws InvalidDescriptionException { + public PluginDescriptionFile(@NotNull final Reader reader) throws InvalidDescriptionException { loadMap(asMap(YAML.get().load(reader))); } @@ -252,7 +260,7 @@ public final class PluginDescriptionFile { * @param pluginVersion Version of this plugin * @param mainClass Full location of the main class of this plugin */ - public PluginDescriptionFile(final String pluginName, final String pluginVersion, final String mainClass) { + public PluginDescriptionFile(@NotNull final String pluginName, @NotNull final String pluginVersion, @NotNull final String mainClass) { name = rawName = pluginName; if (!VALID_NAME.matcher(name).matches()) { @@ -288,6 +296,7 @@ public final class PluginDescriptionFile { * * @return the name of the plugin */ + @NotNull public String getName() { return name; } @@ -308,6 +317,7 @@ public final class PluginDescriptionFile { * * @return the version of the plugin */ + @NotNull public String getVersion() { return version; } @@ -334,6 +344,7 @@ public final class PluginDescriptionFile { * * @return the fully qualified main class for the plugin */ + @NotNull public String getMain() { return main; } @@ -353,6 +364,7 @@ public final class PluginDescriptionFile { * * @return description of this plugin, or null if not specified */ + @Nullable public String getDescription() { return description; } @@ -376,6 +388,7 @@ public final class PluginDescriptionFile { * * @return the phase when the plugin should be loaded */ + @NotNull public PluginLoadOrder getLoad() { return order; } @@ -411,6 +424,7 @@ public final class PluginDescriptionFile { * * @return an immutable list of the plugin's authors */ + @NotNull public List getAuthors() { return authors; } @@ -430,6 +444,7 @@ public final class PluginDescriptionFile { * * @return description of this plugin, or null if not specified */ + @Nullable public String getWebsite() { return website; } @@ -460,6 +475,7 @@ public final class PluginDescriptionFile { * * @return immutable list of the plugin's dependencies */ + @NotNull public List getDepend() { return depend; } @@ -489,6 +505,7 @@ public final class PluginDescriptionFile { * * @return immutable list of the plugin's preferred dependencies */ + @NotNull public List getSoftDepend() { return softDepend; } @@ -518,6 +535,7 @@ public final class PluginDescriptionFile { * @return immutable list of plugins that should consider this plugin a * soft-dependency */ + @NotNull public List getLoadBefore() { return loadBefore; } @@ -537,6 +555,7 @@ public final class PluginDescriptionFile { * * @return the prefixed logging token, or null if not specified */ + @Nullable public String getPrefix() { return prefix; } @@ -589,8 +608,7 @@ public final class PluginDescriptionFile { * standard one if no specific message is defined. Without the * permission node, no {@link * PluginCommand#setExecutor(CommandExecutor) CommandExecutor} or - * {@link PluginCommand#setTabCompleter(TabCompleter) - * TabCompleter} will be called. + * {@link PluginCommand#setTabCompleter(TabCompleter)} will be called. *

permission: inferno.flagrate
* * permission-message @@ -612,9 +630,8 @@ public final class PluginDescriptionFile { * String * This message is displayed to a player when the {@link * PluginCommand#setExecutor(CommandExecutor)} {@linkplain - * CommandExecutor#onCommand(CommandSender,Command,String,String[]) - * returns false}. <command> is a macro that is replaced - * the command issued. + * CommandExecutor#onCommand(CommandSender, Command, String, String[]) returns false}. + * <command> is a macro that is replaced the command issued. *
usage: Syntax error! Perhaps you meant /<command> PlayerName?
* It is worth noting that to use a colon in a yaml, like * `usage: Usage: /god [player]', you need to @@ -657,6 +674,7 @@ public final class PluginDescriptionFile { * * @return the commands this plugin will register */ + @NotNull public Map> getCommands() { return commands; } @@ -769,6 +787,7 @@ public final class PluginDescriptionFile { * * @return the permissions this plugin will register */ + @NotNull public List getPermissions() { if (permissions == null) { if (lazyPermissions == null) { @@ -798,6 +817,7 @@ public final class PluginDescriptionFile { * * @return the default value for the plugin's permissions */ + @NotNull public PermissionDefault getPermissionDefault() { return defaultPerm; } @@ -837,6 +857,7 @@ public final class PluginDescriptionFile { * * @return a set containing every awareness for the plugin */ + @NotNull public Set getAwareness() { return awareness; } @@ -848,6 +869,7 @@ public final class PluginDescriptionFile { * * @return a descriptive name of the plugin and respective version */ + @NotNull public String getFullName() { return name + " v" + version; } @@ -865,6 +887,7 @@ public final class PluginDescriptionFile { * * @return the version of the plugin */ + @Nullable public String getAPIVersion() { return apiVersion; } @@ -874,6 +897,7 @@ public final class PluginDescriptionFile { * @deprecated unused */ @Deprecated + @Nullable public String getClassLoaderOf() { return classLoaderOf; } @@ -883,11 +907,11 @@ public final class PluginDescriptionFile { * * @param writer Writer to output this file to */ - public void save(Writer writer) { + public void save(@NotNull Writer writer) { YAML.get().dump(saveMap(), writer); } - private void loadMap(Map map) throws InvalidDescriptionException { + private void loadMap(@NotNull Map map) throws InvalidDescriptionException { try { name = rawName = map.get("name").toString(); @@ -1033,7 +1057,8 @@ public final class PluginDescriptionFile { } } - private static List makePluginNameList(final Map map, final String key) throws InvalidDescriptionException { + @NotNull + private static List makePluginNameList(@NotNull final Map map, @NotNull final String key) throws InvalidDescriptionException { final Object value = map.get(key); if (value == null) { return ImmutableList.of(); @@ -1052,6 +1077,7 @@ public final class PluginDescriptionFile { return builder.build(); } + @NotNull private Map saveMap() { Map map = new HashMap(); @@ -1098,7 +1124,8 @@ public final class PluginDescriptionFile { return map; } - private Map asMap(Object object) throws InvalidDescriptionException { + @NotNull + private Map asMap(@NotNull Object object) throws InvalidDescriptionException { if (object instanceof Map) { return (Map) object; } @@ -1110,6 +1137,7 @@ public final class PluginDescriptionFile { * @deprecated Internal use */ @Deprecated + @NotNull public String getRawName() { return rawName; } diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java index e7981a1d94..da7839aa92 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java @@ -7,6 +7,7 @@ import java.util.regex.Pattern; import org.bukkit.event.Event; import org.bukkit.event.Listener; +import org.jetbrains.annotations.NotNull; /** * Represents a plugin loader, which handles direct access to specific types @@ -25,7 +26,8 @@ public interface PluginLoader { * @throws UnknownDependencyException If a required dependency could not * be found */ - public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException; + @NotNull + public Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException; /** * Loads a PluginDescriptionFile from the specified file @@ -36,13 +38,15 @@ public interface PluginLoader { * @throws InvalidDescriptionException If the plugin description file * could not be created */ - public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException; + @NotNull + public PluginDescriptionFile getPluginDescription(@NotNull File file) throws InvalidDescriptionException; /** * Returns a list of all filename filters expected by this PluginLoader * * @return The filters */ + @NotNull public Pattern[] getPluginFileFilters(); /** @@ -53,7 +57,8 @@ public interface PluginLoader { * @param plugin The plugin to use when creating registered listeners * @return The registered listeners. */ - public Map, Set> createRegisteredListeners(Listener listener, Plugin plugin); + @NotNull + public Map, Set> createRegisteredListeners(@NotNull Listener listener, @NotNull Plugin plugin); /** * Enables the specified plugin @@ -63,7 +68,7 @@ public interface PluginLoader { * * @param plugin Plugin to enable */ - public void enablePlugin(Plugin plugin); + public void enablePlugin(@NotNull Plugin plugin); /** * Disables the specified plugin @@ -72,5 +77,5 @@ public interface PluginLoader { * * @param plugin Plugin to disable */ - public void disablePlugin(Plugin plugin); + public void disablePlugin(@NotNull Plugin plugin); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginLogger.java b/paper-api/src/main/java/org/bukkit/plugin/PluginLogger.java index f43c10b01e..533f0b6f81 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginLogger.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginLogger.java @@ -1,5 +1,7 @@ package org.bukkit.plugin; +import org.jetbrains.annotations.NotNull; + import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; @@ -19,7 +21,7 @@ public class PluginLogger extends Logger { * * @param context A reference to the plugin */ - public PluginLogger(Plugin context) { + public PluginLogger(@NotNull Plugin context) { super(context.getClass().getCanonicalName(), null); String prefix = context.getDescription().getPrefix(); pluginName = prefix != null ? new StringBuilder().append("[").append(prefix).append("] ").toString() : "[" + context.getDescription().getName() + "] "; @@ -28,7 +30,7 @@ public class PluginLogger extends Logger { } @Override - public void log(LogRecord logRecord) { + public void log(@NotNull LogRecord logRecord) { logRecord.setMessage(pluginName + logRecord.getMessage()); super.log(logRecord); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java index e5638d5609..a468467b45 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java @@ -8,6 +8,9 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Handles all plugin management from the Server @@ -21,7 +24,7 @@ public interface PluginManager { * @throws IllegalArgumentException Thrown when the given Class is not a * valid PluginLoader */ - public void registerInterface(Class loader) throws IllegalArgumentException; + public void registerInterface(@NotNull Class loader) throws IllegalArgumentException; /** * Checks if the given plugin is loaded and returns it when applicable @@ -31,13 +34,15 @@ public interface PluginManager { * @param name Name of the plugin to check * @return Plugin if it exists, otherwise null */ - public Plugin getPlugin(String name); + @Nullable + public Plugin getPlugin(@NotNull String name); /** * Gets a list of all currently loaded plugins * * @return Array of Plugins */ + @NotNull public Plugin[] getPlugins(); /** @@ -48,7 +53,7 @@ public interface PluginManager { * @param name Name of the plugin to check * @return true if the plugin is enabled, otherwise false */ - public boolean isPluginEnabled(String name); + public boolean isPluginEnabled(@NotNull String name); /** * Checks if the given plugin is enabled or not @@ -56,7 +61,8 @@ public interface PluginManager { * @param plugin Plugin to check * @return true if the plugin is enabled, otherwise false */ - public boolean isPluginEnabled(Plugin plugin); + @Contract("null -> false") + public boolean isPluginEnabled(@Nullable Plugin plugin); /** * Loads the plugin in the specified file @@ -72,7 +78,8 @@ public interface PluginManager { * @throws UnknownDependencyException If a required dependency could not * be resolved */ - public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException; + @Nullable + public Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException; /** * Loads the plugins contained within the specified directory @@ -80,7 +87,8 @@ public interface PluginManager { * @param directory Directory to check for plugins * @return A list of all plugins loaded */ - public Plugin[] loadPlugins(File directory); + @NotNull + public Plugin[] loadPlugins(@NotNull File directory); /** * Disables all the loaded plugins @@ -102,7 +110,7 @@ public interface PluginManager { * Note: This is best-effort basis, and should not be used to test * synchronized state. This is an indicator for flawed flow logic. */ - public void callEvent(Event event) throws IllegalStateException; + public void callEvent(@NotNull Event event) throws IllegalStateException; /** * Registers all the events in the given listener class @@ -110,7 +118,7 @@ public interface PluginManager { * @param listener Listener to register * @param plugin Plugin to register */ - public void registerEvents(Listener listener, Plugin plugin); + public void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin); /** * Registers the specified executor to the given event class @@ -121,7 +129,7 @@ public interface PluginManager { * @param executor EventExecutor to register * @param plugin Plugin to register */ - public void registerEvent(Class event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin); + public void registerEvent(@NotNull Class event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin); /** * Registers the specified executor to the given event class @@ -133,7 +141,7 @@ public interface PluginManager { * @param plugin Plugin to register * @param ignoreCancelled Whether to pass cancelled events or not */ - public void registerEvent(Class event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled); + public void registerEvent(@NotNull Class event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled); /** * Enables the specified plugin @@ -143,7 +151,7 @@ public interface PluginManager { * * @param plugin Plugin to enable */ - public void enablePlugin(Plugin plugin); + public void enablePlugin(@NotNull Plugin plugin); /** * Disables the specified plugin @@ -152,7 +160,7 @@ public interface PluginManager { * * @param plugin Plugin to disable */ - public void disablePlugin(Plugin plugin); + public void disablePlugin(@NotNull Plugin plugin); /** * Gets a {@link Permission} from its fully qualified name @@ -160,7 +168,8 @@ public interface PluginManager { * @param name Name of the permission * @return Permission, or null if none */ - public Permission getPermission(String name); + @Nullable + public Permission getPermission(@NotNull String name); /** * Adds a {@link Permission} to this plugin manager. @@ -172,7 +181,7 @@ public interface PluginManager { * @throws IllegalArgumentException Thrown when a permission with the same * name already exists */ - public void addPermission(Permission perm); + public void addPermission(@NotNull Permission perm); /** * Removes a {@link Permission} registration from this plugin manager. @@ -185,7 +194,7 @@ public interface PluginManager { * * @param perm Permission to remove */ - public void removePermission(Permission perm); + public void removePermission(@NotNull Permission perm); /** * Removes a {@link Permission} registration from this plugin manager. @@ -198,7 +207,7 @@ public interface PluginManager { * * @param name Permission to remove */ - public void removePermission(String name); + public void removePermission(@NotNull String name); /** * Gets the default permissions for the given op status @@ -206,6 +215,7 @@ public interface PluginManager { * @param op Which set of default permissions to get * @return The default permissions */ + @NotNull public Set getDefaultPermissions(boolean op); /** @@ -216,7 +226,7 @@ public interface PluginManager { * * @param perm Permission to recalculate */ - public void recalculatePermissionDefaults(Permission perm); + public void recalculatePermissionDefaults(@NotNull Permission perm); /** * Subscribes the given Permissible for information about the requested @@ -228,7 +238,7 @@ public interface PluginManager { * @param permission Permission to subscribe to * @param permissible Permissible subscribing */ - public void subscribeToPermission(String permission, Permissible permissible); + public void subscribeToPermission(@NotNull String permission, @NotNull Permissible permissible); /** * Unsubscribes the given Permissible for information about the requested @@ -237,7 +247,7 @@ public interface PluginManager { * @param permission Permission to unsubscribe from * @param permissible Permissible subscribing */ - public void unsubscribeFromPermission(String permission, Permissible permissible); + public void unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible); /** * Gets a set containing all subscribed {@link Permissible}s to the given @@ -246,7 +256,8 @@ public interface PluginManager { * @param permission Permission to query for * @return Set containing all subscribed permissions */ - public Set getPermissionSubscriptions(String permission); + @NotNull + public Set getPermissionSubscriptions(@NotNull String permission); /** * Subscribes to the given Default permissions by operator status @@ -257,7 +268,7 @@ public interface PluginManager { * @param op Default list to subscribe to * @param permissible Permissible subscribing */ - public void subscribeToDefaultPerms(boolean op, Permissible permissible); + public void subscribeToDefaultPerms(boolean op, @NotNull Permissible permissible); /** * Unsubscribes from the given Default permissions by operator status @@ -265,7 +276,7 @@ public interface PluginManager { * @param op Default list to unsubscribe from * @param permissible Permissible subscribing */ - public void unsubscribeFromDefaultPerms(boolean op, Permissible permissible); + public void unsubscribeFromDefaultPerms(boolean op, @NotNull Permissible permissible); /** * Gets a set containing all subscribed {@link Permissible}s to the given @@ -274,6 +285,7 @@ public interface PluginManager { * @param op Default list to query for * @return Set containing all subscribed permissions */ + @NotNull public Set getDefaultPermSubscriptions(boolean op); /** @@ -283,6 +295,7 @@ public interface PluginManager { * * @return Set containing all current registered permissions */ + @NotNull public Set getPermissions(); /** diff --git a/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java b/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java index 944f908815..a3b3a056b9 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java +++ b/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java @@ -1,6 +1,7 @@ package org.bukkit.plugin; import org.bukkit.event.*; +import org.jetbrains.annotations.NotNull; /** * Stores relevant information for plugin listeners @@ -12,7 +13,7 @@ public class RegisteredListener { private final EventExecutor executor; private final boolean ignoreCancelled; - public RegisteredListener(final Listener listener, final EventExecutor executor, final EventPriority priority, final Plugin plugin, final boolean ignoreCancelled) { + public RegisteredListener(@NotNull final Listener listener, @NotNull final EventExecutor executor, @NotNull final EventPriority priority, @NotNull final Plugin plugin, final boolean ignoreCancelled) { this.listener = listener; this.priority = priority; this.plugin = plugin; @@ -25,6 +26,7 @@ public class RegisteredListener { * * @return Registered Listener */ + @NotNull public Listener getListener() { return listener; } @@ -34,6 +36,7 @@ public class RegisteredListener { * * @return Registered Plugin */ + @NotNull public Plugin getPlugin() { return plugin; } @@ -43,6 +46,7 @@ public class RegisteredListener { * * @return Registered Priority */ + @NotNull public EventPriority getPriority() { return priority; } @@ -53,7 +57,7 @@ public class RegisteredListener { * @param event The event * @throws EventException If an event handler throws an exception. */ - public void callEvent(final Event event) throws EventException { + public void callEvent(@NotNull final Event event) throws EventException { if (event instanceof Cancellable) { if (((Cancellable) event).isCancelled() && isIgnoringCancelled()) { return; diff --git a/paper-api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java b/paper-api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java index ba3ff15e91..cbcdadd490 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java +++ b/paper-api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java @@ -1,5 +1,7 @@ package org.bukkit.plugin; +import org.jetbrains.annotations.NotNull; + /** * A registered service provider. * @@ -12,31 +14,34 @@ public class RegisteredServiceProvider implements Comparable service, T provider, ServicePriority priority, Plugin plugin) { - + public RegisteredServiceProvider(@NotNull Class service, @NotNull T provider, @NotNull ServicePriority priority, @NotNull Plugin plugin) { this.service = service; this.plugin = plugin; this.provider = provider; this.priority = priority; } + @NotNull public Class getService() { return service; } + @NotNull public Plugin getPlugin() { return plugin; } + @NotNull public T getProvider() { return provider; } + @NotNull public ServicePriority getPriority() { return priority; } - public int compareTo(RegisteredServiceProvider other) { + public int compareTo(@NotNull RegisteredServiceProvider other) { if (priority.ordinal() == other.getPriority().ordinal()) { return 0; } else { diff --git a/paper-api/src/main/java/org/bukkit/plugin/ServicesManager.java b/paper-api/src/main/java/org/bukkit/plugin/ServicesManager.java index 5d45ffb24a..185b644b12 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/ServicesManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/ServicesManager.java @@ -1,5 +1,8 @@ package org.bukkit.plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Collection; import java.util.List; @@ -22,14 +25,14 @@ public interface ServicesManager { * @param plugin plugin with the provider * @param priority priority of the provider */ - public void register(Class service, T provider, Plugin plugin, ServicePriority priority); + public void register(@NotNull Class service, @NotNull T provider, @NotNull Plugin plugin, @NotNull ServicePriority priority); /** * Unregister all the providers registered by a particular plugin. * * @param plugin The plugin */ - public void unregisterAll(Plugin plugin); + public void unregisterAll(@NotNull Plugin plugin); /** * Unregister a particular provider for a particular service. @@ -37,14 +40,14 @@ public interface ServicesManager { * @param service The service interface * @param provider The service provider implementation */ - public void unregister(Class service, Object provider); + public void unregister(@NotNull Class service, @NotNull Object provider); /** * Unregister a particular provider. * * @param provider The service provider implementation */ - public void unregister(Object provider); + public void unregister(@NotNull Object provider); /** * Queries for a provider. This may return if no provider has been @@ -54,7 +57,8 @@ public interface ServicesManager { * @param service The service interface * @return provider or null */ - public T load(Class service); + @Nullable + public T load(@NotNull Class service); /** * Queries for a provider registration. This may return if no provider @@ -64,15 +68,17 @@ public interface ServicesManager { * @param service The service interface * @return provider registration or null */ - public RegisteredServiceProvider getRegistration(Class service); + @Nullable + public RegisteredServiceProvider getRegistration(@NotNull Class service); /** * Get registrations of providers for a plugin. * * @param plugin The plugin - * @return provider registration or null + * @return provider registrations */ - public List> getRegistrations(Plugin plugin); + @NotNull + public List> getRegistrations(@NotNull Plugin plugin); /** * Get registrations of providers for a service. The returned list is @@ -82,7 +88,8 @@ public interface ServicesManager { * @param service The service interface * @return list of registrations */ - public Collection> getRegistrations(Class service); + @NotNull + public Collection> getRegistrations(@NotNull Class service); /** * Get a list of known services. A service is known if it has registered @@ -90,6 +97,7 @@ public interface ServicesManager { * * @return list of known services */ + @NotNull public Collection> getKnownServices(); /** @@ -101,6 +109,6 @@ public interface ServicesManager { * @param service service to check * @return whether there has been a registered provider */ - public boolean isProvidedFor(Class service); + public boolean isProvidedFor(@NotNull Class service); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 2fcb56fd6d..08d890c1ce 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -34,6 +34,8 @@ import org.bukkit.permissions.PermissionDefault; import org.bukkit.util.FileUtil; import com.google.common.collect.ImmutableSet; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Handles all plugin management from the Server @@ -51,7 +53,7 @@ public final class SimplePluginManager implements PluginManager { private final Map> defSubs = new HashMap>(); private boolean useTimings = false; - public SimplePluginManager(Server instance, SimpleCommandMap commandMap) { + public SimplePluginManager(@NotNull Server instance, @NotNull SimpleCommandMap commandMap) { server = instance; this.commandMap = commandMap; @@ -66,7 +68,7 @@ public final class SimplePluginManager implements PluginManager { * @throws IllegalArgumentException Thrown when the given Class is not a * valid PluginLoader */ - public void registerInterface(Class loader) throws IllegalArgumentException { + public void registerInterface(@NotNull Class loader) throws IllegalArgumentException { PluginLoader instance; if (PluginLoader.class.isAssignableFrom(loader)) { @@ -101,7 +103,8 @@ public final class SimplePluginManager implements PluginManager { * @param directory Directory to check for plugins * @return A list of all plugins loaded */ - public Plugin[] loadPlugins(File directory) { + @NotNull + public Plugin[] loadPlugins(@NotNull File directory) { Validate.notNull(directory, "Directory cannot be null"); Validate.isTrue(directory.isDirectory(), "Directory must be a directory"); @@ -309,7 +312,8 @@ public final class SimplePluginManager implements PluginManager { * @throws UnknownDependencyException If a required dependency could not * be found */ - public synchronized Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException { + @Nullable + public synchronized Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException { Validate.notNull(file, "File cannot be null"); checkUpdate(file); @@ -336,7 +340,7 @@ public final class SimplePluginManager implements PluginManager { return result; } - private void checkUpdate(File file) { + private void checkUpdate(@NotNull File file) { if (updateDirectory == null || !updateDirectory.isDirectory()) { return; } @@ -355,10 +359,12 @@ public final class SimplePluginManager implements PluginManager { * @param name Name of the plugin to check * @return Plugin if it exists, otherwise null */ - public synchronized Plugin getPlugin(String name) { + @Nullable + public synchronized Plugin getPlugin(@NotNull String name) { return lookupNames.get(name.replace(' ', '_')); } + @NotNull public synchronized Plugin[] getPlugins() { return plugins.toArray(new Plugin[plugins.size()]); } @@ -371,7 +377,7 @@ public final class SimplePluginManager implements PluginManager { * @param name Name of the plugin to check * @return true if the plugin is enabled, otherwise false */ - public boolean isPluginEnabled(String name) { + public boolean isPluginEnabled(@NotNull String name) { Plugin plugin = getPlugin(name); return isPluginEnabled(plugin); @@ -383,7 +389,7 @@ public final class SimplePluginManager implements PluginManager { * @param plugin Plugin to check * @return true if the plugin is enabled, otherwise false */ - public boolean isPluginEnabled(Plugin plugin) { + public boolean isPluginEnabled(@Nullable Plugin plugin) { if ((plugin != null) && (plugins.contains(plugin))) { return plugin.isEnabled(); } else { @@ -391,7 +397,7 @@ public final class SimplePluginManager implements PluginManager { } } - public void enablePlugin(final Plugin plugin) { + public void enablePlugin(@NotNull final Plugin plugin) { if (!plugin.isEnabled()) { List pluginCommands = PluginCommandYamlParser.parse(plugin); @@ -416,7 +422,7 @@ public final class SimplePluginManager implements PluginManager { } } - public void disablePlugin(final Plugin plugin) { + public void disablePlugin(@NotNull final Plugin plugin) { if (plugin.isEnabled()) { try { plugin.getPluginLoader().disablePlugin(plugin); @@ -471,7 +477,7 @@ public final class SimplePluginManager implements PluginManager { * * @param event Event details */ - public void callEvent(Event event) { + public void callEvent(@NotNull Event event) { if (event.isAsynchronous()) { if (Thread.holdsLock(this)) { throw new IllegalStateException(event.getEventName() + " cannot be triggered asynchronously from inside synchronized code."); @@ -487,7 +493,7 @@ public final class SimplePluginManager implements PluginManager { } } - private void fireEvent(Event event) { + private void fireEvent(@NotNull Event event) { HandlerList handlers = event.getHandlers(); RegisteredListener[] listeners = handlers.getRegisteredListeners(); @@ -517,7 +523,7 @@ public final class SimplePluginManager implements PluginManager { } } - public void registerEvents(Listener listener, Plugin plugin) { + public void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin) { if (!plugin.isEnabled()) { throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled"); } @@ -528,7 +534,7 @@ public final class SimplePluginManager implements PluginManager { } - public void registerEvent(Class event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin) { + public void registerEvent(@NotNull Class event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin) { registerEvent(event, listener, priority, executor, plugin, false); } @@ -544,7 +550,7 @@ public final class SimplePluginManager implements PluginManager { * @param ignoreCancelled Do not call executor if event was already * cancelled */ - public void registerEvent(Class event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled) { + public void registerEvent(@NotNull Class event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled) { Validate.notNull(listener, "Listener cannot be null"); Validate.notNull(priority, "Priority cannot be null"); Validate.notNull(executor, "Executor cannot be null"); @@ -561,7 +567,8 @@ public final class SimplePluginManager implements PluginManager { } } - private HandlerList getEventListeners(Class type) { + @NotNull + private HandlerList getEventListeners(@NotNull Class type) { try { Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList"); method.setAccessible(true); @@ -571,7 +578,8 @@ public final class SimplePluginManager implements PluginManager { } } - private Class getRegistrationClass(Class clazz) { + @NotNull + private Class getRegistrationClass(@NotNull Class clazz) { try { clazz.getDeclaredMethod("getHandlerList"); return clazz; @@ -586,16 +594,17 @@ public final class SimplePluginManager implements PluginManager { } } - public Permission getPermission(String name) { + @Nullable + public Permission getPermission(@NotNull String name) { return permissions.get(name.toLowerCase(java.util.Locale.ENGLISH)); } - public void addPermission(Permission perm) { + public void addPermission(@NotNull Permission perm) { addPermission(perm, true); } @Deprecated - public void addPermission(Permission perm, boolean dirty) { + public void addPermission(@NotNull Permission perm, boolean dirty) { String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH); if (permissions.containsKey(name)) { @@ -606,19 +615,20 @@ public final class SimplePluginManager implements PluginManager { calculatePermissionDefault(perm, dirty); } + @NotNull public Set getDefaultPermissions(boolean op) { return ImmutableSet.copyOf(defaultPerms.get(op)); } - public void removePermission(Permission perm) { + public void removePermission(@NotNull Permission perm) { removePermission(perm.getName()); } - public void removePermission(String name) { + public void removePermission(@NotNull String name) { permissions.remove(name.toLowerCase(java.util.Locale.ENGLISH)); } - public void recalculatePermissionDefaults(Permission perm) { + public void recalculatePermissionDefaults(@NotNull Permission perm) { if (perm != null && permissions.containsKey(perm.getName().toLowerCase(java.util.Locale.ENGLISH))) { defaultPerms.get(true).remove(perm); defaultPerms.get(false).remove(perm); @@ -627,7 +637,7 @@ public final class SimplePluginManager implements PluginManager { } } - private void calculatePermissionDefault(Permission perm, boolean dirty) { + private void calculatePermissionDefault(@NotNull Permission perm, boolean dirty) { if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) { defaultPerms.get(true).add(perm); if (dirty) { @@ -656,7 +666,7 @@ public final class SimplePluginManager implements PluginManager { } } - public void subscribeToPermission(String permission, Permissible permissible) { + public void subscribeToPermission(@NotNull String permission, @NotNull Permissible permissible) { String name = permission.toLowerCase(java.util.Locale.ENGLISH); Map map = permSubs.get(name); @@ -668,7 +678,7 @@ public final class SimplePluginManager implements PluginManager { map.put(permissible, true); } - public void unsubscribeFromPermission(String permission, Permissible permissible) { + public void unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible) { String name = permission.toLowerCase(java.util.Locale.ENGLISH); Map map = permSubs.get(name); @@ -681,7 +691,8 @@ public final class SimplePluginManager implements PluginManager { } } - public Set getPermissionSubscriptions(String permission) { + @NotNull + public Set getPermissionSubscriptions(@NotNull String permission) { String name = permission.toLowerCase(java.util.Locale.ENGLISH); Map map = permSubs.get(name); @@ -692,7 +703,7 @@ public final class SimplePluginManager implements PluginManager { } } - public void subscribeToDefaultPerms(boolean op, Permissible permissible) { + public void subscribeToDefaultPerms(boolean op, @NotNull Permissible permissible) { Map map = defSubs.get(op); if (map == null) { @@ -703,7 +714,7 @@ public final class SimplePluginManager implements PluginManager { map.put(permissible, true); } - public void unsubscribeFromDefaultPerms(boolean op, Permissible permissible) { + public void unsubscribeFromDefaultPerms(boolean op, @NotNull Permissible permissible) { Map map = defSubs.get(op); if (map != null) { @@ -715,6 +726,7 @@ public final class SimplePluginManager implements PluginManager { } } + @NotNull public Set getDefaultPermSubscriptions(boolean op) { Map map = defSubs.get(op); @@ -725,6 +737,7 @@ public final class SimplePluginManager implements PluginManager { } } + @NotNull public Set getPermissions() { return new HashSet(permissions.values()); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java index 4e1771122b..6514d4ef1e 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java @@ -6,6 +6,8 @@ import org.bukkit.event.server.ServiceUnregisterEvent; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -35,7 +37,7 @@ public class SimpleServicesManager implements ServicesManager { * @param plugin plugin with the provider * @param priority priority of the provider */ - public void register(Class service, T provider, Plugin plugin, ServicePriority priority) { + public void register(@NotNull Class service, @NotNull T provider, @NotNull Plugin plugin, @NotNull ServicePriority priority) { RegisteredServiceProvider registeredProvider = null; synchronized (providers) { List> registered = providers.get(service); @@ -63,7 +65,7 @@ public class SimpleServicesManager implements ServicesManager { * * @param plugin The plugin */ - public void unregisterAll(Plugin plugin) { + public void unregisterAll(@NotNull Plugin plugin) { ArrayList unregisteredEvents = new ArrayList(); synchronized (providers) { Iterator, List>>> it = providers.entrySet().iterator(); @@ -105,7 +107,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @param provider The service provider implementation */ - public void unregister(Class service, Object provider) { + public void unregister(@NotNull Class service, @NotNull Object provider) { ArrayList unregisteredEvents = new ArrayList(); synchronized (providers) { Iterator, List>>> it = providers.entrySet().iterator(); @@ -152,7 +154,7 @@ public class SimpleServicesManager implements ServicesManager { * * @param provider The service provider implementation */ - public void unregister(Object provider) { + public void unregister(@NotNull Object provider) { ArrayList unregisteredEvents = new ArrayList(); synchronized (providers) { Iterator, List>>> it = providers.entrySet().iterator(); @@ -196,7 +198,8 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @return provider or null */ - public T load(Class service) { + @Nullable + public T load(@NotNull Class service) { synchronized (providers) { List> registered = providers.get(service); @@ -217,8 +220,9 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @return provider registration or null */ + @Nullable @SuppressWarnings("unchecked") - public RegisteredServiceProvider getRegistration(Class service) { + public RegisteredServiceProvider getRegistration(@NotNull Class service) { synchronized (providers) { List> registered = providers.get(service); @@ -235,9 +239,10 @@ public class SimpleServicesManager implements ServicesManager { * Get registrations of providers for a plugin. * * @param plugin The plugin - * @return provider registration or null + * @return provider registrations */ - public List> getRegistrations(Plugin plugin) { + @NotNull + public List> getRegistrations(@NotNull Plugin plugin) { ImmutableList.Builder> ret = ImmutableList.>builder(); synchronized (providers) { for (List> registered : providers.values()) { @@ -259,8 +264,9 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @return a copy of the list of registrations */ + @NotNull @SuppressWarnings("unchecked") - public List> getRegistrations(Class service) { + public List> getRegistrations(@NotNull Class service) { ImmutableList.Builder> ret; synchronized (providers) { List> registered = providers.get(service); @@ -285,6 +291,7 @@ public class SimpleServicesManager implements ServicesManager { * * @return a copy of the set of known services */ + @NotNull public Set> getKnownServices() { synchronized (providers) { return ImmutableSet.>copyOf(providers.keySet()); @@ -298,7 +305,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service service to check * @return true if and only if there are registered providers */ - public boolean isProvidedFor(Class service) { + public boolean isProvidedFor(@NotNull Class service) { synchronized (providers) { return providers.containsKey(service); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/TimedRegisteredListener.java b/paper-api/src/main/java/org/bukkit/plugin/TimedRegisteredListener.java index 164be937fd..1d76e30b82 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/TimedRegisteredListener.java +++ b/paper-api/src/main/java/org/bukkit/plugin/TimedRegisteredListener.java @@ -4,6 +4,8 @@ import org.bukkit.event.Event; import org.bukkit.event.EventException; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Extends RegisteredListener to include timing information @@ -14,12 +16,12 @@ public class TimedRegisteredListener extends RegisteredListener { private Class eventClass; private boolean multiple = false; - public TimedRegisteredListener(final Listener pluginListener, final EventExecutor eventExecutor, final EventPriority eventPriority, final Plugin registeredPlugin, final boolean listenCancelled) { + public TimedRegisteredListener(@NotNull final Listener pluginListener, @NotNull final EventExecutor eventExecutor, @NotNull final EventPriority eventPriority, @NotNull final Plugin registeredPlugin, final boolean listenCancelled) { super(pluginListener, eventExecutor, eventPriority, registeredPlugin, listenCancelled); } @Override - public void callEvent(Event event) throws EventException { + public void callEvent(@NotNull Event event) throws EventException { if (event.isAsynchronous()) { super.callEvent(event); return; @@ -37,7 +39,8 @@ public class TimedRegisteredListener extends RegisteredListener { totalTime += System.nanoTime() - start; } - private static Class getCommonSuperclass(Class class1, Class class2) { + @NotNull + private static Class getCommonSuperclass(@NotNull Class class1, @NotNull Class class2) { while (!class1.isAssignableFrom(class2)) { class1 = class1.getSuperclass(); } @@ -81,6 +84,7 @@ public class TimedRegisteredListener extends RegisteredListener { * * @return the event class handled by this RegisteredListener */ + @Nullable public Class getEventClass() { return eventClass; } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 6788780640..7c9348996c 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -27,6 +27,8 @@ import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLogger; import com.google.common.base.Charsets; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a Java plugin @@ -52,7 +54,7 @@ public abstract class JavaPlugin extends PluginBase { ((PluginClassLoader) classLoader).initialize(this); } - protected JavaPlugin(final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file) { + protected JavaPlugin(@NotNull final JavaPluginLoader loader, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file) { final ClassLoader classLoader = this.getClass().getClassLoader(); if (classLoader instanceof PluginClassLoader) { throw new IllegalStateException("Cannot use initialization constructor at runtime"); @@ -66,6 +68,7 @@ public abstract class JavaPlugin extends PluginBase { * * @return The folder. */ + @NotNull @Override public final File getDataFolder() { return dataFolder; @@ -76,6 +79,7 @@ public abstract class JavaPlugin extends PluginBase { * * @return PluginLoader that controls this plugin */ + @NotNull @Override public final PluginLoader getPluginLoader() { return loader; @@ -86,6 +90,7 @@ public abstract class JavaPlugin extends PluginBase { * * @return Server running this plugin */ + @NotNull @Override public final Server getServer() { return server; @@ -107,6 +112,7 @@ public abstract class JavaPlugin extends PluginBase { * * @return File containing this plugin */ + @NotNull protected File getFile() { return file; } @@ -116,11 +122,13 @@ public abstract class JavaPlugin extends PluginBase { * * @return Contents of the plugin.yaml file */ + @NotNull @Override public final PluginDescriptionFile getDescription() { return description; } + @NotNull @Override public FileConfiguration getConfig() { if (newConfig == null) { @@ -139,7 +147,8 @@ public abstract class JavaPlugin extends PluginBase { * @throws IllegalArgumentException if file is null * @see ClassLoader#getResourceAsStream(String) */ - protected final Reader getTextResource(String file) { + @Nullable + protected final Reader getTextResource(@NotNull String file) { final InputStream in = getResource(file); return in == null ? null : new InputStreamReader(in, Charsets.UTF_8); @@ -174,7 +183,7 @@ public abstract class JavaPlugin extends PluginBase { } @Override - public void saveResource(String resourcePath, boolean replace) { + public void saveResource(@NotNull String resourcePath, boolean replace) { if (resourcePath == null || resourcePath.equals("")) { throw new IllegalArgumentException("ResourcePath cannot be null or empty"); } @@ -211,8 +220,9 @@ public abstract class JavaPlugin extends PluginBase { } } + @Nullable @Override - public InputStream getResource(String filename) { + public InputStream getResource(@NotNull String filename) { if (filename == null) { throw new IllegalArgumentException("Filename cannot be null"); } @@ -237,6 +247,7 @@ public abstract class JavaPlugin extends PluginBase { * * @return ClassLoader holding this plugin */ + @NotNull protected final ClassLoader getClassLoader() { return classLoader; } @@ -259,7 +270,7 @@ public abstract class JavaPlugin extends PluginBase { } - final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) { + final void init(@NotNull PluginLoader loader, @NotNull Server server, @NotNull PluginDescriptionFile description, @NotNull File dataFolder, @NotNull File file, @NotNull ClassLoader classLoader) { this.loader = loader; this.server = server; this.file = file; @@ -274,7 +285,7 @@ public abstract class JavaPlugin extends PluginBase { * {@inheritDoc} */ @Override - 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) { return false; } @@ -282,7 +293,8 @@ public abstract class JavaPlugin extends PluginBase { * {@inheritDoc} */ @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + @Nullable + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { return null; } @@ -294,7 +306,8 @@ public abstract class JavaPlugin extends PluginBase { * @param name name or alias of the command * @return the plugin command if found, otherwise null */ - public PluginCommand getCommand(String name) { + @Nullable + public PluginCommand getCommand(@NotNull String name) { String alias = name.toLowerCase(java.util.Locale.ENGLISH); PluginCommand command = getServer().getPluginCommand(alias); @@ -318,8 +331,9 @@ public abstract class JavaPlugin extends PluginBase { @Override public void onEnable() {} + @Nullable @Override - public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { + public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) { return null; } @@ -333,11 +347,13 @@ public abstract class JavaPlugin extends PluginBase { this.naggable = canNag; } + @NotNull @Override public Logger getLogger() { return logger; } + @NotNull @Override public String toString() { return description.getFullName(); @@ -366,7 +382,8 @@ public abstract class JavaPlugin extends PluginBase { * @throws ClassCastException if plugin that provided the class does not * extend the class */ - public static T getPlugin(Class clazz) { + @NotNull + public static T getPlugin(@NotNull Class clazz) { Validate.notNull(clazz, "Null class cannot have a plugin"); if (!JavaPlugin.class.isAssignableFrom(clazz)) { throw new IllegalArgumentException(clazz + " does not extend " + JavaPlugin.class); @@ -394,7 +411,8 @@ public abstract class JavaPlugin extends PluginBase { * @throws IllegalStateException if called from the static initializer for * given JavaPlugin */ - public static JavaPlugin getProvidingPlugin(Class clazz) { + @NotNull + public static JavaPlugin getProvidingPlugin(@NotNull Class clazz) { Validate.notNull(clazz, "Null class cannot have a plugin"); final ClassLoader cl = clazz.getClassLoader(); if (!(cl instanceof PluginClassLoader)) { diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 9589014ab8..de68a03864 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -41,6 +41,8 @@ import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.TimedRegisteredListener; import org.bukkit.plugin.UnknownDependencyException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.yaml.snakeyaml.error.YAMLException; /** @@ -58,12 +60,13 @@ public final class JavaPluginLoader implements PluginLoader { * @param instance the server instance */ @Deprecated - public JavaPluginLoader(Server instance) { + public JavaPluginLoader(@NotNull Server instance) { Validate.notNull(instance, "Server cannot be null"); server = instance; } - public Plugin loadPlugin(final File file) throws InvalidPluginException { + @NotNull + public Plugin loadPlugin(@NotNull final File file) throws InvalidPluginException { Validate.notNull(file, "File cannot be null"); if (!file.exists()) { @@ -139,7 +142,8 @@ public final class JavaPluginLoader implements PluginLoader { return loader.plugin; } - public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException { + @NotNull + public PluginDescriptionFile getPluginDescription(@NotNull File file) throws InvalidDescriptionException { Validate.notNull(file, "File cannot be null"); JarFile jar = null; @@ -177,10 +181,12 @@ public final class JavaPluginLoader implements PluginLoader { } } + @NotNull public Pattern[] getPluginFileFilters() { return fileFilters.clone(); } + @Nullable Class getClassByName(final String name) { Class cachedClass = classes.get(name); @@ -199,7 +205,7 @@ public final class JavaPluginLoader implements PluginLoader { return null; } - void setClass(final String name, final Class clazz) { + void setClass(@NotNull final String name, @NotNull final Class clazz) { if (!classes.containsKey(name)) { classes.put(name, clazz); @@ -210,7 +216,7 @@ public final class JavaPluginLoader implements PluginLoader { } } - private void removeClass(String name) { + private void removeClass(@NotNull String name) { Class clazz = classes.remove(name); try { @@ -224,7 +230,8 @@ public final class JavaPluginLoader implements PluginLoader { } } - public Map, Set> createRegisteredListeners(Listener listener, final Plugin plugin) { + @NotNull + public Map, Set> createRegisteredListeners(@NotNull Listener listener, @NotNull final Plugin plugin) { Validate.notNull(plugin, "Plugin can not be null"); Validate.notNull(listener, "Listener can not be null"); @@ -291,7 +298,7 @@ public final class JavaPluginLoader implements PluginLoader { } EventExecutor executor = new EventExecutor() { - public void execute(Listener listener, Event event) throws EventException { + public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { try { if (!eventClass.isAssignableFrom(event.getClass())) { return; @@ -313,7 +320,7 @@ public final class JavaPluginLoader implements PluginLoader { return ret; } - public void enablePlugin(final Plugin plugin) { + public void enablePlugin(@NotNull final Plugin plugin) { Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader"); if (!plugin.isEnabled()) { @@ -340,7 +347,7 @@ public final class JavaPluginLoader implements PluginLoader { } } - public void disablePlugin(Plugin plugin) { + public void disablePlugin(@NotNull Plugin plugin) { Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader"); if (plugin.isEnabled()) { diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 7a8abe75ad..541d8ee6b5 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -19,6 +19,8 @@ import java.util.jar.Manifest; import org.apache.commons.lang.Validate; import org.bukkit.plugin.InvalidPluginException; import org.bukkit.plugin.PluginDescriptionFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A ClassLoader for plugins, to allow shared classes across multiple plugins @@ -40,7 +42,7 @@ final class PluginClassLoader extends URLClassLoader { ClassLoader.registerAsParallelCapable(); } - PluginClassLoader(final JavaPluginLoader loader, final ClassLoader parent, final PluginDescriptionFile description, final File dataFolder, final File file) throws IOException, InvalidPluginException, MalformedURLException { + PluginClassLoader(@NotNull final JavaPluginLoader loader, @Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file) throws IOException, InvalidPluginException, MalformedURLException { super(new URL[] {file.toURI().toURL()}, parent); Validate.notNull(loader, "Loader cannot be null"); @@ -80,7 +82,7 @@ final class PluginClassLoader extends URLClassLoader { return findClass(name, true); } - Class findClass(String name, boolean checkGlobal) throws ClassNotFoundException { + Class findClass(@NotNull String name, boolean checkGlobal) throws ClassNotFoundException { if (name.startsWith("org.bukkit.") || name.startsWith("net.minecraft.")) { throw new ClassNotFoundException(name); } @@ -154,11 +156,12 @@ final class PluginClassLoader extends URLClassLoader { } } + @NotNull Set getClasses() { return classes.keySet(); } - synchronized void initialize(JavaPlugin javaPlugin) { + synchronized void initialize(@NotNull JavaPlugin javaPlugin) { Validate.notNull(javaPlugin, "Initializing plugin cannot be null"); Validate.isTrue(javaPlugin.getClass().getClassLoader() == this, "Cannot initialize plugin outside of this class loader"); if (this.plugin != null || this.pluginInit != null) { diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java index 7aa1d81ba7..ea9b525ff6 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java @@ -4,6 +4,7 @@ import java.util.Set; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * A class responsible for managing the registrations of plugin channels and @@ -35,7 +36,7 @@ public interface Messenger { * @return True if the channel is reserved, otherwise false. * @throws IllegalArgumentException Thrown if channel is null. */ - public boolean isReservedChannel(String channel); + public boolean isReservedChannel(@NotNull String channel); /** * Registers the specific plugin to the requested outgoing plugin channel, @@ -45,7 +46,7 @@ public interface Messenger { * @param channel Channel to register. * @throws IllegalArgumentException Thrown if plugin or channel is null. */ - public void registerOutgoingPluginChannel(Plugin plugin, String channel); + public void registerOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel); /** * Unregisters the specific plugin from the requested outgoing plugin @@ -57,7 +58,7 @@ public interface Messenger { * @param channel Channel to unregister. * @throws IllegalArgumentException Thrown if plugin or channel is null. */ - public void unregisterOutgoingPluginChannel(Plugin plugin, String channel); + public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel); /** * Unregisters the specific plugin from all outgoing plugin channels, no @@ -66,7 +67,7 @@ public interface Messenger { * @param plugin Plugin that no longer wishes to send plugin messages. * @throws IllegalArgumentException Thrown if plugin is null. */ - public void unregisterOutgoingPluginChannel(Plugin plugin); + public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin); /** * Registers the specific plugin for listening on the requested incoming @@ -80,7 +81,8 @@ public interface Messenger { * @throws IllegalArgumentException Thrown if plugin, channel or listener * is null, or the listener is already registered for this channel. */ - public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener); + @NotNull + public PluginMessageListenerRegistration registerIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener); /** * Unregisters the specific plugin's listener from listening on the @@ -93,7 +95,7 @@ public interface Messenger { * @throws IllegalArgumentException Thrown if plugin, channel or listener * is null. */ - public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener); + public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener); /** * Unregisters the specific plugin from listening on the requested @@ -104,7 +106,7 @@ public interface Messenger { * @param channel Channel to unregister. * @throws IllegalArgumentException Thrown if plugin or channel is null. */ - public void unregisterIncomingPluginChannel(Plugin plugin, String channel); + public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel); /** * Unregisters the specific plugin from listening on all plugin channels @@ -113,13 +115,14 @@ public interface Messenger { * @param plugin Plugin that wishes to unregister from this channel. * @throws IllegalArgumentException Thrown if plugin is null. */ - public void unregisterIncomingPluginChannel(Plugin plugin); + public void unregisterIncomingPluginChannel(@NotNull Plugin plugin); /** * Gets a set containing all the outgoing plugin channels. * * @return List of all registered outgoing plugin channels. */ + @NotNull public Set getOutgoingChannels(); /** @@ -131,13 +134,15 @@ public interface Messenger { * is registered to. * @throws IllegalArgumentException Thrown if plugin is null. */ - public Set getOutgoingChannels(Plugin plugin); + @NotNull + public Set getOutgoingChannels(@NotNull Plugin plugin); /** * Gets a set containing all the incoming plugin channels. * * @return List of all registered incoming plugin channels. */ + @NotNull public Set getIncomingChannels(); /** @@ -149,7 +154,8 @@ public interface Messenger { * is registered for. * @throws IllegalArgumentException Thrown if plugin is null. */ - public Set getIncomingChannels(Plugin plugin); + @NotNull + public Set getIncomingChannels(@NotNull Plugin plugin); /** * Gets a set containing all the incoming plugin channel registrations @@ -159,7 +165,8 @@ public interface Messenger { * @return List of all registrations that the plugin has. * @throws IllegalArgumentException Thrown if plugin is null. */ - public Set getIncomingChannelRegistrations(Plugin plugin); + @NotNull + public Set getIncomingChannelRegistrations(@NotNull Plugin plugin); /** * Gets a set containing all the incoming plugin channel registrations @@ -169,7 +176,8 @@ public interface Messenger { * @return List of all registrations that are on the channel. * @throws IllegalArgumentException Thrown if channel is null. */ - public Set getIncomingChannelRegistrations(String channel); + @NotNull + public Set getIncomingChannelRegistrations(@NotNull String channel); /** * Gets a set containing all the incoming plugin channel registrations @@ -180,7 +188,8 @@ public interface Messenger { * @return List of all registrations that the plugin has. * @throws IllegalArgumentException Thrown if plugin or channel is null. */ - public Set getIncomingChannelRegistrations(Plugin plugin, String channel); + @NotNull + public Set getIncomingChannelRegistrations(@NotNull Plugin plugin, @NotNull String channel); /** * Checks if the specified plugin message listener registration is valid. @@ -191,7 +200,7 @@ public interface Messenger { * @param registration Registration to check. * @return True if the registration is valid, otherwise false. */ - public boolean isRegistrationValid(PluginMessageListenerRegistration registration); + public boolean isRegistrationValid(@NotNull PluginMessageListenerRegistration registration); /** * Checks if the specified plugin has registered to receive incoming @@ -201,7 +210,7 @@ public interface Messenger { * @param channel Channel to test for. * @return True if the channel is registered, else false. */ - public boolean isIncomingChannelRegistered(Plugin plugin, String channel); + public boolean isIncomingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel); /** * Checks if the specified plugin has registered to send outgoing messages @@ -211,7 +220,7 @@ public interface Messenger { * @param channel Channel to test for. * @return True if the channel is registered, else false. */ - public boolean isOutgoingChannelRegistered(Plugin plugin, String channel); + public boolean isOutgoingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel); /** * Dispatches the specified incoming message to any registered listeners. @@ -220,5 +229,5 @@ public interface Messenger { * @param channel Channel that the message was sent by. * @param message Raw payload of the message. */ - public void dispatchIncomingMessage(Player source, String channel, byte[] message); + public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @NotNull byte[] message); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListener.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListener.java index f1aa0806b2..eb962efd50 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListener.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListener.java @@ -1,6 +1,7 @@ package org.bukkit.plugin.messaging; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; /** * A listener for a specific Plugin Channel, which will receive notifications @@ -16,5 +17,5 @@ public interface PluginMessageListener { * @param player Source of the message. * @param message The raw message that was sent. */ - public void onPluginMessageReceived(String channel, Player player, byte[] message); + public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListenerRegistration.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListenerRegistration.java index 29929bf7ca..1d00296724 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListenerRegistration.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageListenerRegistration.java @@ -1,6 +1,7 @@ package org.bukkit.plugin.messaging; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Contains information about a {@link Plugin}s registration to a plugin @@ -12,7 +13,7 @@ public final class PluginMessageListenerRegistration { private final String channel; private final PluginMessageListener listener; - public PluginMessageListenerRegistration(Messenger messenger, Plugin plugin, String channel, PluginMessageListener listener) { + public PluginMessageListenerRegistration(@NotNull Messenger messenger, @NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) { if (messenger == null) { throw new IllegalArgumentException("Messenger cannot be null!"); } @@ -37,6 +38,7 @@ public final class PluginMessageListenerRegistration { * * @return Plugin channel. */ + @NotNull public String getChannel() { return channel; } @@ -46,6 +48,7 @@ public final class PluginMessageListenerRegistration { * * @return Registered listener. */ + @NotNull public PluginMessageListener getListener() { return listener; } @@ -55,6 +58,7 @@ public final class PluginMessageListenerRegistration { * * @return Registered plugin. */ + @NotNull public Plugin getPlugin() { return plugin; } @@ -77,16 +81,16 @@ public final class PluginMessageListenerRegistration { return false; } final PluginMessageListenerRegistration other = (PluginMessageListenerRegistration) obj; - if (this.messenger != other.messenger && (this.messenger == null || !this.messenger.equals(other.messenger))) { + if (this.messenger != other.messenger && !this.messenger.equals(other.messenger)) { return false; } - if (this.plugin != other.plugin && (this.plugin == null || !this.plugin.equals(other.plugin))) { + if (this.plugin != other.plugin && !this.plugin.equals(other.plugin)) { return false; } - if ((this.channel == null) ? (other.channel != null) : !this.channel.equals(other.channel)) { + if (!this.channel.equals(other.channel)) { return false; } - if (this.listener != other.listener && (this.listener == null || !this.listener.equals(other.listener))) { + if (this.listener != other.listener && !this.listener.equals(other.listener)) { return false; } return true; @@ -95,10 +99,10 @@ public final class PluginMessageListenerRegistration { @Override public int hashCode() { int hash = 7; - hash = 53 * hash + (this.messenger != null ? this.messenger.hashCode() : 0); - hash = 53 * hash + (this.plugin != null ? this.plugin.hashCode() : 0); - hash = 53 * hash + (this.channel != null ? this.channel.hashCode() : 0); - hash = 53 * hash + (this.listener != null ? this.listener.hashCode() : 0); + hash = 53 * hash + this.messenger.hashCode(); + hash = 53 * hash + this.plugin.hashCode(); + hash = 53 * hash + this.channel.hashCode(); + hash = 53 * hash + this.listener.hashCode(); return hash; } } diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageRecipient.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageRecipient.java index e5c591653d..b84b37fe27 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageRecipient.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/PluginMessageRecipient.java @@ -2,6 +2,7 @@ package org.bukkit.plugin.messaging; import java.util.Set; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Represents a possible recipient for a Plugin Message. @@ -26,7 +27,7 @@ public interface PluginMessageRecipient { * @throws ChannelNotRegisteredException Thrown if the channel is not * registered for this plugin. */ - public void sendPluginMessage(Plugin source, String channel, byte[] message); + public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message); /** * Gets a set containing all the Plugin Channels that this client is @@ -34,5 +35,6 @@ public interface PluginMessageRecipient { * * @return Set containing all the channels that this client may accept. */ + @NotNull public Set getListeningPluginChannels(); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java index f21cae7202..8227b375ee 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java @@ -10,6 +10,7 @@ import java.util.Set; import java.util.logging.Level; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Standard implementation to {@link Messenger} @@ -22,7 +23,7 @@ public class StandardMessenger implements Messenger { private final Object incomingLock = new Object(); private final Object outgoingLock = new Object(); - private void addToOutgoing(Plugin plugin, String channel) { + private void addToOutgoing(@NotNull Plugin plugin, @NotNull String channel) { synchronized (outgoingLock) { Set plugins = outgoingByChannel.get(channel); Set channels = outgoingByPlugin.get(plugin); @@ -42,7 +43,7 @@ public class StandardMessenger implements Messenger { } } - private void removeFromOutgoing(Plugin plugin, String channel) { + private void removeFromOutgoing(@NotNull Plugin plugin, @NotNull String channel) { synchronized (outgoingLock) { Set plugins = outgoingByChannel.get(channel); Set channels = outgoingByPlugin.get(plugin); @@ -65,7 +66,7 @@ public class StandardMessenger implements Messenger { } } - private void removeFromOutgoing(Plugin plugin) { + private void removeFromOutgoing(@NotNull Plugin plugin) { synchronized (outgoingLock) { Set channels = outgoingByPlugin.get(plugin); @@ -81,7 +82,7 @@ public class StandardMessenger implements Messenger { } } - private void addToIncoming(PluginMessageListenerRegistration registration) { + private void addToIncoming(@NotNull PluginMessageListenerRegistration registration) { synchronized (incomingLock) { Set registrations = incomingByChannel.get(registration.getChannel()); @@ -111,7 +112,7 @@ public class StandardMessenger implements Messenger { } } - private void removeFromIncoming(PluginMessageListenerRegistration registration) { + private void removeFromIncoming(@NotNull PluginMessageListenerRegistration registration) { synchronized (incomingLock) { Set registrations = incomingByChannel.get(registration.getChannel()); @@ -135,7 +136,7 @@ public class StandardMessenger implements Messenger { } } - private void removeFromIncoming(Plugin plugin, String channel) { + private void removeFromIncoming(@NotNull Plugin plugin, @NotNull String channel) { synchronized (incomingLock) { Set registrations = incomingByPlugin.get(plugin); @@ -151,7 +152,7 @@ public class StandardMessenger implements Messenger { } } - private void removeFromIncoming(Plugin plugin) { + private void removeFromIncoming(@NotNull Plugin plugin) { synchronized (incomingLock) { Set registrations = incomingByPlugin.get(plugin); @@ -167,13 +168,13 @@ public class StandardMessenger implements Messenger { } } - public boolean isReservedChannel(String channel) { + public boolean isReservedChannel(@NotNull String channel) { channel = validateAndCorrectChannel(channel); return channel.contains("minecraft") && !channel.equals("minecraft:brand"); } - public void registerOutgoingPluginChannel(Plugin plugin, String channel) { + public void registerOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -185,7 +186,7 @@ public class StandardMessenger implements Messenger { addToOutgoing(plugin, channel); } - public void unregisterOutgoingPluginChannel(Plugin plugin, String channel) { + public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -194,7 +195,7 @@ public class StandardMessenger implements Messenger { removeFromOutgoing(plugin, channel); } - public void unregisterOutgoingPluginChannel(Plugin plugin) { + public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -202,7 +203,8 @@ public class StandardMessenger implements Messenger { removeFromOutgoing(plugin); } - public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { + @NotNull + public PluginMessageListenerRegistration registerIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -221,7 +223,7 @@ public class StandardMessenger implements Messenger { return result; } - public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { + public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -233,7 +235,7 @@ public class StandardMessenger implements Messenger { removeFromIncoming(new PluginMessageListenerRegistration(this, plugin, channel, listener)); } - public void unregisterIncomingPluginChannel(Plugin plugin, String channel) { + public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -242,7 +244,7 @@ public class StandardMessenger implements Messenger { removeFromIncoming(plugin, channel); } - public void unregisterIncomingPluginChannel(Plugin plugin) { + public void unregisterIncomingPluginChannel(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -250,6 +252,7 @@ public class StandardMessenger implements Messenger { removeFromIncoming(plugin); } + @NotNull public Set getOutgoingChannels() { synchronized (outgoingLock) { Set keys = outgoingByChannel.keySet(); @@ -257,7 +260,8 @@ public class StandardMessenger implements Messenger { } } - public Set getOutgoingChannels(Plugin plugin) { + @NotNull + public Set getOutgoingChannels(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -273,6 +277,7 @@ public class StandardMessenger implements Messenger { } } + @NotNull public Set getIncomingChannels() { synchronized (incomingLock) { Set keys = incomingByChannel.keySet(); @@ -280,7 +285,8 @@ public class StandardMessenger implements Messenger { } } - public Set getIncomingChannels(Plugin plugin) { + @NotNull + public Set getIncomingChannels(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -302,7 +308,8 @@ public class StandardMessenger implements Messenger { } } - public Set getIncomingChannelRegistrations(Plugin plugin) { + @NotNull + public Set getIncomingChannelRegistrations(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -318,7 +325,8 @@ public class StandardMessenger implements Messenger { } } - public Set getIncomingChannelRegistrations(String channel) { + @NotNull + public Set getIncomingChannelRegistrations(@NotNull String channel) { channel = validateAndCorrectChannel(channel); synchronized (incomingLock) { @@ -332,7 +340,8 @@ public class StandardMessenger implements Messenger { } } - public Set getIncomingChannelRegistrations(Plugin plugin, String channel) { + @NotNull + public Set getIncomingChannelRegistrations(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -357,7 +366,7 @@ public class StandardMessenger implements Messenger { } } - public boolean isRegistrationValid(PluginMessageListenerRegistration registration) { + public boolean isRegistrationValid(@NotNull PluginMessageListenerRegistration registration) { if (registration == null) { throw new IllegalArgumentException("Registration cannot be null"); } @@ -373,7 +382,7 @@ public class StandardMessenger implements Messenger { } } - public boolean isIncomingChannelRegistered(Plugin plugin, String channel) { + public boolean isIncomingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -394,7 +403,7 @@ public class StandardMessenger implements Messenger { } } - public boolean isOutgoingChannelRegistered(Plugin plugin, String channel) { + public boolean isOutgoingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } @@ -411,7 +420,7 @@ public class StandardMessenger implements Messenger { } } - public void dispatchIncomingMessage(Player source, String channel, byte[] message) { + public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @NotNull byte[] message) { if (source == null) { throw new IllegalArgumentException("Player source cannot be null"); } @@ -441,7 +450,7 @@ public class StandardMessenger implements Messenger { * @deprecated not an API method */ @Deprecated - public static void validateChannel(String channel) { + public static void validateChannel(@NotNull String channel) { validateAndCorrectChannel(channel); } @@ -453,7 +462,8 @@ public class StandardMessenger implements Messenger { * @deprecated not an API method */ @Deprecated - public static String validateAndCorrectChannel(String channel) { + @NotNull + public static String validateAndCorrectChannel(@NotNull String channel) { if (channel == null) { throw new IllegalArgumentException("Channel cannot be null"); } @@ -498,7 +508,7 @@ public class StandardMessenger implements Messenger { * @throws ChannelNotRegisteredException Thrown if the channel is not * registered for this plugin. */ - public static void validatePluginMessage(Messenger messenger, Plugin source, String channel, byte[] message) { + public static void validatePluginMessage(@NotNull Messenger messenger, @NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) { if (messenger == null) { throw new IllegalArgumentException("Messenger cannot be null"); } diff --git a/paper-api/src/main/java/org/bukkit/potion/Potion.java b/paper-api/src/main/java/org/bukkit/potion/Potion.java index 1413b361b0..63b7c70cee 100644 --- a/paper-api/src/main/java/org/bukkit/potion/Potion.java +++ b/paper-api/src/main/java/org/bukkit/potion/Potion.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; +import org.jetbrains.annotations.NotNull; /** * Potion Adapter for pre-1.9 data values @@ -28,7 +29,7 @@ public class Potion { * @param type The potion type * @see #Potion(int) */ - public Potion(PotionType type) { + public Potion(@NotNull PotionType type) { Validate.notNull(type, "Null PotionType"); this.type = type; } @@ -39,7 +40,7 @@ public class Potion { * @param type The type of potion. * @param level The potion's level. */ - public Potion(PotionType type, int level) { + public Potion(@NotNull PotionType type, int level) { this(type); Validate.notNull(type, "Type cannot be null"); Validate.isTrue(level > 0 && level < 3, "Level must be 1 or 2"); @@ -56,7 +57,7 @@ public class Potion { * #splash()}. */ @Deprecated - public Potion(PotionType type, int level, boolean splash) { + public Potion(@NotNull PotionType type, int level, boolean splash) { this(type, level); this.splash = splash; } @@ -72,7 +73,7 @@ public class Potion { * #extend()} and possibly {@link #splash()}. */ @Deprecated - public Potion(PotionType type, int level, boolean splash, boolean extended) { + public Potion(@NotNull PotionType type, int level, boolean splash, boolean extended) { this(type, level, splash); this.extended = extended; } @@ -90,6 +91,7 @@ public class Potion { * * @return The potion. */ + @NotNull public Potion splash() { setSplash(true); return this; @@ -100,6 +102,7 @@ public class Potion { * * @return The potion. */ + @NotNull public Potion extend() { setHasExtendedDuration(true); return this; @@ -111,7 +114,7 @@ public class Potion { * * @param to The itemstack to apply to */ - public void apply(ItemStack to) { + public void apply(@NotNull ItemStack to) { Validate.notNull(to, "itemstack cannot be null"); Validate.isTrue(to.hasItemMeta(), "given itemstack is not a potion"); Validate.isTrue(to.getItemMeta() instanceof PotionMeta, "given itemstack is not a potion"); @@ -127,7 +130,7 @@ public class Potion { * @see LivingEntity#addPotionEffects(Collection) * @param to The entity to apply the effects to */ - public void apply(LivingEntity to) { + public void apply(@NotNull LivingEntity to) { Validate.notNull(to, "entity cannot be null"); to.addPotionEffects(getEffects()); } @@ -152,6 +155,7 @@ public class Potion { * @see Potion#toDamageValue() * @return The effects that this potion applies */ + @NotNull public Collection getEffects() { return getBrewer().getEffects(type, level == 2, extended); } @@ -170,6 +174,7 @@ public class Potion { * * @return The type of this potion */ + @NotNull public PotionType getType() { return type; } @@ -228,7 +233,7 @@ public class Potion { * * @param type The new type of this potion */ - public void setType(PotionType type) { + public void setType(@NotNull PotionType type) { this.type = type; } @@ -262,6 +267,7 @@ public class Potion { * @param amount The amount of the ItemStack * @return The created ItemStack */ + @NotNull public ItemStack toItemStack(int amount) { Material material; if (isSplash()) { @@ -289,6 +295,7 @@ public class Potion { * @param damage the damage value * @return the produced potion */ + @NotNull public static Potion fromDamage(int damage) { PotionType type; switch (damage & POTION_BIT) { @@ -354,7 +361,8 @@ public class Potion { return potion; } - public static Potion fromItemStack(ItemStack item) { + @NotNull + public static Potion fromItemStack(@NotNull ItemStack item) { Validate.notNull(item, "item cannot be null"); if (item.getType() != Material.POTION) throw new IllegalArgumentException("item is not a potion"); @@ -366,6 +374,7 @@ public class Potion { * * @return An instance of PotionBrewer */ + @NotNull public static PotionBrewer getBrewer() { return brewer; } @@ -376,7 +385,7 @@ public class Potion { * * @param other The new PotionBrewer */ - public static void setPotionBrewer(PotionBrewer other) { + public static void setPotionBrewer(@NotNull PotionBrewer other) { if (brewer != null) throw new IllegalArgumentException("brewer can only be set internally"); brewer = other; diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionBrewer.java b/paper-api/src/main/java/org/bukkit/potion/PotionBrewer.java index 40f8d12b9b..9f913e1ee3 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionBrewer.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionBrewer.java @@ -1,5 +1,7 @@ package org.bukkit.potion; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; /** @@ -16,7 +18,8 @@ public interface PotionBrewer { * @param amplifier The amplifier of the effect * @return The resulting potion effect */ - public PotionEffect createEffect(PotionEffectType potion, int duration, int amplifier); + @NotNull + public PotionEffect createEffect(@NotNull PotionEffectType potion, int duration, int amplifier); /** * Returns a collection of {@link PotionEffect} that would be applied from @@ -27,6 +30,7 @@ public interface PotionBrewer { * @deprecated Non-Functional */ @Deprecated + @NotNull public Collection getEffectsFromDamage(int damage); /** @@ -36,5 +40,6 @@ public interface PotionBrewer { * @param type The type of the potion * @return The list of effects */ - public Collection getEffects(PotionType type, boolean upgraded, boolean extended); + @NotNull + public Collection getEffects(@NotNull PotionType type, boolean upgraded, boolean extended); } diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionData.java b/paper-api/src/main/java/org/bukkit/potion/PotionData.java index 6e8139a9ed..ba0d671165 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionData.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionData.java @@ -1,6 +1,7 @@ package org.bukkit.potion; import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; public final class PotionData { @@ -18,7 +19,7 @@ public final class PotionData { * @param upgraded whether the potion is upgraded PotionType#isUpgradable() * must be true */ - public PotionData(PotionType type, boolean extended, boolean upgraded) { + public PotionData(@NotNull PotionType type, boolean extended, boolean upgraded) { Validate.notNull(type, "Potion Type must not be null"); Validate.isTrue(!upgraded || type.isUpgradeable(), "Potion Type is not upgradable"); Validate.isTrue(!extended || type.isExtendable(), "Potion Type is not extendable"); @@ -28,7 +29,7 @@ public final class PotionData { this.upgraded = upgraded; } - public PotionData(PotionType type) { + public PotionData(@NotNull PotionType type) { this(type, false, false); } @@ -38,6 +39,7 @@ public final class PotionData { * * @return the potion type */ + @NotNull public PotionType getType() { return type; } diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffect.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffect.java index 86616f1b85..d57450c95e 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffect.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffect.java @@ -10,6 +10,9 @@ import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.entity.LivingEntity; import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a potion effect, that can be added to a {@link LivingEntity}. A @@ -42,7 +45,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param particles the particle status, see {@link PotionEffect#hasParticles()} * @param icon the icon status, see {@link PotionEffect#hasIcon()} */ - public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon) { + public PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon) { Validate.notNull(type, "effect type cannot be null"); this.type = type; this.duration = duration; @@ -62,7 +65,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param ambient the ambient status, see {@link PotionEffect#isAmbient()} * @param particles the particle status, see {@link PotionEffect#hasParticles()} */ - public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles) { + public PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles) { this(type, duration, amplifier, ambient, particles, particles); } @@ -75,7 +78,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param amplifier the amplifier, see {@link PotionEffect#getAmplifier()} * @param ambient the ambient status, see {@link PotionEffect#isAmbient()} */ - public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient) { + public PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient) { this(type, duration, amplifier, ambient, true); } @@ -87,7 +90,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param amplifier the amplifier for the effect * @see PotionEffect#PotionEffect(PotionEffectType, int, int, boolean) */ - public PotionEffect(PotionEffectType type, int duration, int amplifier) { + public PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier) { this(type, duration, amplifier, true); } @@ -96,11 +99,12 @@ public class PotionEffect implements ConfigurationSerializable { * * @param map the map to deserialize from */ - public PotionEffect(Map map) { + public PotionEffect(@NotNull Map map) { this(getEffectType(map), getInt(map, DURATION), getInt(map, AMPLIFIER), getBool(map, AMBIENT, false), getBool(map, PARTICLES, true), getBool(map, ICON, getBool(map, PARTICLES, true))); } - private static PotionEffectType getEffectType(Map map) { + @NotNull + private static PotionEffectType getEffectType(@NotNull Map map) { int type = getInt(map, TYPE); PotionEffectType effect = PotionEffectType.getById(type); if (effect != null) { @@ -109,7 +113,7 @@ public class PotionEffect implements ConfigurationSerializable { throw new NoSuchElementException(map + " does not contain " + TYPE); } - private static int getInt(Map map, Object key) { + private static int getInt(@NotNull Map map, @NotNull Object key) { Object num = map.get(key); if (num instanceof Integer) { return (Integer) num; @@ -117,7 +121,7 @@ public class PotionEffect implements ConfigurationSerializable { throw new NoSuchElementException(map + " does not contain " + key); } - private static boolean getBool(Map map, Object key, boolean def) { + private static boolean getBool(@NotNull Map map, @NotNull Object key, boolean def) { Object bool = map.get(key); if (bool instanceof Boolean) { return (Boolean) bool; @@ -125,6 +129,7 @@ public class PotionEffect implements ConfigurationSerializable { return def; } + @NotNull public Map serialize() { return ImmutableMap.builder() .put(TYPE, type.getId()) @@ -144,7 +149,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param entity The entity to add this effect to * @return Whether the effect could be added */ - public boolean apply(LivingEntity entity) { + public boolean apply(@NotNull LivingEntity entity) { return entity.addPotionEffect(this); } @@ -186,6 +191,7 @@ public class PotionEffect implements ConfigurationSerializable { * * @return The potion type of this effect */ + @NotNull public PotionEffectType getType() { return type; } @@ -211,6 +217,8 @@ public class PotionEffect implements ConfigurationSerializable { * @deprecated color is not part of potion effects */ @Deprecated + @Nullable + @Contract("-> null") public Color getColor() { return null; } diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java index 962d36f8f7..059c77d3c5 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -6,6 +6,8 @@ import java.util.Map; import org.apache.commons.lang.Validate; import org.bukkit.Color; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a type of potion and its effect on an entity. @@ -178,6 +180,7 @@ public abstract class PotionEffectType { * @param amplifier the effect's amplifier * @return a resulting potion effect */ + @NotNull public PotionEffect createEffect(int duration, int amplifier) { return new PotionEffect(this, isInstant() ? 1 : (int) (duration * getDurationModifier()), amplifier); } @@ -205,6 +208,7 @@ public abstract class PotionEffectType { * * @return The name of this effect type */ + @NotNull public abstract String getName(); /** @@ -219,6 +223,7 @@ public abstract class PotionEffectType { * * @return the color */ + @NotNull public abstract Color getColor(); @Override @@ -259,6 +264,7 @@ public abstract class PotionEffectType { * @deprecated Magic value */ @Deprecated + @Nullable public static PotionEffectType getById(int id) { if (id >= byId.length || id < 0) return null; @@ -271,7 +277,8 @@ public abstract class PotionEffectType { * @param name Name of PotionEffectType to fetch * @return Resulting PotionEffectType, or null if not found. */ - public static PotionEffectType getByName(String name) { + @Nullable + public static PotionEffectType getByName(@NotNull String name) { Validate.notNull(name, "name cannot be null"); return byName.get(name.toLowerCase(java.util.Locale.ENGLISH)); } @@ -283,7 +290,7 @@ public abstract class PotionEffectType { * * @param type PotionType to register */ - public static void registerPotionEffectType(PotionEffectType type) { + public static void registerPotionEffectType(@NotNull PotionEffectType type) { if (byId[type.id] != null || byName.containsKey(type.getName().toLowerCase(java.util.Locale.ENGLISH))) { throw new IllegalArgumentException("Cannot set already-set type"); } else if (!acceptingNew) { @@ -308,6 +315,7 @@ public abstract class PotionEffectType { * * @return Array of types. */ + @NotNull public static PotionEffectType[] values() { return Arrays.copyOfRange(byId, 1, byId.length); } diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java index 356a866fec..47d46edc49 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java @@ -1,6 +1,7 @@ package org.bukkit.potion; import org.bukkit.Color; +import org.jetbrains.annotations.NotNull; public class PotionEffectTypeWrapper extends PotionEffectType { protected PotionEffectTypeWrapper(int id) { @@ -12,6 +13,7 @@ public class PotionEffectTypeWrapper extends PotionEffectType { return getType().getDurationModifier(); } + @NotNull @Override public String getName() { return getType().getName(); @@ -22,6 +24,7 @@ public class PotionEffectTypeWrapper extends PotionEffectType { * * @return The potion effect type */ + @NotNull public PotionEffectType getType() { return PotionEffectType.getById(getId()); } @@ -31,6 +34,7 @@ public class PotionEffectTypeWrapper extends PotionEffectType { return getType().isInstant(); } + @NotNull @Override public Color getColor() { return getType().getColor(); diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionType.java b/paper-api/src/main/java/org/bukkit/potion/PotionType.java index 034421a76e..1a82fe7cec 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionType.java @@ -1,5 +1,8 @@ package org.bukkit.potion; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; + /** * This enum reflects and matches each potion state that can be obtained from * the Creative mode inventory @@ -32,12 +35,13 @@ public enum PotionType { private final boolean upgradeable; private final boolean extendable; - PotionType(PotionEffectType effect, boolean upgradeable, boolean extendable) { + PotionType(@Nullable PotionEffectType effect, boolean upgradeable, boolean extendable) { this.effect = effect; this.upgradeable = upgradeable; this.extendable = extendable; } + @Nullable public PotionEffectType getEffectType() { return effect; } @@ -83,6 +87,8 @@ public enum PotionType { * @deprecated Non-functional */ @Deprecated + @Nullable + @Contract("_ -> null") public static PotionType getByDamageValue(int damage) { return null; } @@ -91,7 +97,8 @@ public enum PotionType { * @deprecated Misleading */ @Deprecated - public static PotionType getByEffect(PotionEffectType effectType) { + @Nullable + public static PotionType getByEffect(@Nullable PotionEffectType effectType) { if (effectType == null) return WATER; for (PotionType type : PotionType.values()) { diff --git a/paper-api/src/main/java/org/bukkit/projectiles/BlockProjectileSource.java b/paper-api/src/main/java/org/bukkit/projectiles/BlockProjectileSource.java index e713c0d81f..21a3d767ba 100644 --- a/paper-api/src/main/java/org/bukkit/projectiles/BlockProjectileSource.java +++ b/paper-api/src/main/java/org/bukkit/projectiles/BlockProjectileSource.java @@ -1,6 +1,7 @@ package org.bukkit.projectiles; import org.bukkit.block.Block; +import org.jetbrains.annotations.NotNull; public interface BlockProjectileSource extends ProjectileSource { @@ -9,5 +10,6 @@ public interface BlockProjectileSource extends ProjectileSource { * * @return Block for the projectile source */ + @NotNull public Block getBlock(); } diff --git a/paper-api/src/main/java/org/bukkit/projectiles/ProjectileSource.java b/paper-api/src/main/java/org/bukkit/projectiles/ProjectileSource.java index cf90946187..eabd8b926e 100644 --- a/paper-api/src/main/java/org/bukkit/projectiles/ProjectileSource.java +++ b/paper-api/src/main/java/org/bukkit/projectiles/ProjectileSource.java @@ -2,6 +2,8 @@ package org.bukkit.projectiles; import org.bukkit.entity.Projectile; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a valid source of a projectile. @@ -15,7 +17,8 @@ public interface ProjectileSource { * @param projectile class of the projectile to launch * @return the launched projectile */ - public T launchProjectile(Class projectile); + @NotNull + public T launchProjectile(@NotNull Class projectile); /** * Launches a {@link Projectile} from the ProjectileSource with an @@ -26,5 +29,6 @@ public interface ProjectileSource { * @param velocity the velocity with which to launch * @return the launched projectile */ - public T launchProjectile(Class projectile, Vector velocity); + @NotNull + public T launchProjectile(@NotNull Class projectile, @Nullable Vector velocity); } diff --git a/paper-api/src/main/java/org/bukkit/scheduler/BukkitRunnable.java b/paper-api/src/main/java/org/bukkit/scheduler/BukkitRunnable.java index d526f0f8dd..35a1e92fc0 100644 --- a/paper-api/src/main/java/org/bukkit/scheduler/BukkitRunnable.java +++ b/paper-api/src/main/java/org/bukkit/scheduler/BukkitRunnable.java @@ -2,6 +2,7 @@ package org.bukkit.scheduler; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * This class is provided as an easy way to handle scheduling tasks. @@ -38,7 +39,8 @@ public abstract class BukkitRunnable implements Runnable { * @throws IllegalStateException if this was already scheduled * @see BukkitScheduler#runTask(Plugin, Runnable) */ - public synchronized BukkitTask runTask(Plugin plugin) throws IllegalArgumentException, IllegalStateException { + @NotNull + public synchronized BukkitTask runTask(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException { checkNotYetScheduled(); return setupTask(Bukkit.getScheduler().runTask(plugin, (Runnable) this)); } @@ -55,7 +57,8 @@ public abstract class BukkitRunnable implements Runnable { * @throws IllegalStateException if this was already scheduled * @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable) */ - public synchronized BukkitTask runTaskAsynchronously(Plugin plugin) throws IllegalArgumentException, IllegalStateException { + @NotNull + public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException { checkNotYetScheduled(); return setupTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this)); } @@ -70,7 +73,8 @@ public abstract class BukkitRunnable implements Runnable { * @throws IllegalStateException if this was already scheduled * @see BukkitScheduler#runTaskLater(Plugin, Runnable, long) */ - public synchronized BukkitTask runTaskLater(Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { + @NotNull + public synchronized BukkitTask runTaskLater(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { checkNotYetScheduled(); return setupTask(Bukkit.getScheduler().runTaskLater(plugin, (Runnable) this, delay)); } @@ -89,7 +93,8 @@ public abstract class BukkitRunnable implements Runnable { * @throws IllegalStateException if this was already scheduled * @see BukkitScheduler#runTaskLaterAsynchronously(Plugin, Runnable, long) */ - public synchronized BukkitTask runTaskLaterAsynchronously(Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { + @NotNull + public synchronized BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { checkNotYetScheduled(); return setupTask(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, (Runnable) this, delay)); } @@ -106,7 +111,8 @@ public abstract class BukkitRunnable implements Runnable { * @throws IllegalStateException if this was already scheduled * @see BukkitScheduler#runTaskTimer(Plugin, Runnable, long, long) */ - public synchronized BukkitTask runTaskTimer(Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { + @NotNull + public synchronized BukkitTask runTaskTimer(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { checkNotYetScheduled(); return setupTask(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period)); } @@ -128,7 +134,8 @@ public abstract class BukkitRunnable implements Runnable { * @see BukkitScheduler#runTaskTimerAsynchronously(Plugin, Runnable, long, * long) */ - public synchronized BukkitTask runTaskTimerAsynchronously(Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { + @NotNull + public synchronized BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { checkNotYetScheduled(); return setupTask(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, (Runnable) this, delay, period)); } @@ -156,7 +163,8 @@ public abstract class BukkitRunnable implements Runnable { } } - private BukkitTask setupTask(final BukkitTask task) { + @NotNull + private BukkitTask setupTask(@NotNull final BukkitTask task) { this.task = task; return task; } diff --git a/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java index 073a737074..acbd23687d 100644 --- a/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java +++ b/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java @@ -1,6 +1,8 @@ package org.bukkit.scheduler; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.List; @@ -18,7 +20,7 @@ public interface BukkitScheduler { * @param delay Delay in server ticks before executing task * @return Task id number (-1 if scheduling failed) */ - public int scheduleSyncDelayedTask(Plugin plugin, Runnable task, long delay); + public int scheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay); /** * @deprecated Use {@link BukkitRunnable#runTaskLater(Plugin, long)} @@ -28,7 +30,7 @@ public interface BukkitScheduler { * @return Task id number (-1 if scheduling failed) */ @Deprecated - public int scheduleSyncDelayedTask(Plugin plugin, BukkitRunnable task, long delay); + public int scheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay); /** * Schedules a once off task to occur as soon as possible. @@ -39,7 +41,7 @@ public interface BukkitScheduler { * @param task Task to be executed * @return Task id number (-1 if scheduling failed) */ - public int scheduleSyncDelayedTask(Plugin plugin, Runnable task); + public int scheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task); /** * @deprecated Use {@link BukkitRunnable#runTask(Plugin)} @@ -48,7 +50,7 @@ public interface BukkitScheduler { * @return Task id number (-1 if scheduling failed) */ @Deprecated - public int scheduleSyncDelayedTask(Plugin plugin, BukkitRunnable task); + public int scheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task); /** * Schedules a repeating task. @@ -61,7 +63,7 @@ public interface BukkitScheduler { * @param period Period in server ticks of the task * @return Task id number (-1 if scheduling failed) */ - public int scheduleSyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period); + public int scheduleSyncRepeatingTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period); /** * @deprecated Use {@link BukkitRunnable#runTaskTimer(Plugin, long, long)} @@ -72,7 +74,7 @@ public interface BukkitScheduler { * @return Task id number (-1 if scheduling failed) */ @Deprecated - public int scheduleSyncRepeatingTask(Plugin plugin, BukkitRunnable task, long delay, long period); + public int scheduleSyncRepeatingTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period); /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -89,7 +91,7 @@ public interface BukkitScheduler { * task, but rather, "an async" task */ @Deprecated - public int scheduleAsyncDelayedTask(Plugin plugin, Runnable task, long delay); + public int scheduleAsyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay); /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -105,7 +107,7 @@ public interface BukkitScheduler { * task, but rather, "an async" task */ @Deprecated - public int scheduleAsyncDelayedTask(Plugin plugin, Runnable task); + public int scheduleAsyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task); /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -123,7 +125,7 @@ public interface BukkitScheduler { * task, but rather, "an async" task */ @Deprecated - public int scheduleAsyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period); + public int scheduleAsyncRepeatingTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period); /** * Calls a method on the main thread and returns a Future object. This @@ -139,7 +141,8 @@ public interface BukkitScheduler { * @param task Task to be executed * @return Future Future object related to the task */ - public Future callSyncMethod(Plugin plugin, Callable task); + @NotNull + public Future callSyncMethod(@NotNull Plugin plugin, @NotNull Callable task); /** * Removes task from scheduler. @@ -154,7 +157,7 @@ public interface BukkitScheduler { * * @param plugin Owner of tasks to be removed */ - public void cancelTasks(Plugin plugin); + public void cancelTasks(@NotNull Plugin plugin); /** * Check if the task currently running. @@ -193,6 +196,7 @@ public interface BukkitScheduler { * * @return Active workers */ + @NotNull public List getActiveWorkers(); /** @@ -201,6 +205,7 @@ public interface BukkitScheduler { * * @return Active workers */ + @NotNull public List getPendingTasks(); /** @@ -212,7 +217,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public BukkitTask runTask(Plugin plugin, Runnable task) throws IllegalArgumentException; + @NotNull + public BukkitTask runTask(@NotNull Plugin plugin, @NotNull Runnable task) throws IllegalArgumentException; /** * Returns a task that will run on the next server tick. @@ -222,7 +228,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTask(Plugin plugin, Consumer task) throws IllegalArgumentException; + public void runTask(@NotNull Plugin plugin, @NotNull Consumer task) throws IllegalArgumentException; /** * @deprecated Use {@link BukkitRunnable#runTask(Plugin)} @@ -234,7 +240,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if task is null */ @Deprecated - public BukkitTask runTask(Plugin plugin, BukkitRunnable task) throws IllegalArgumentException; + @NotNull + public BukkitTask runTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task) throws IllegalArgumentException; /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -248,7 +255,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public BukkitTask runTaskAsynchronously(Plugin plugin, Runnable task) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskAsynchronously(@NotNull Plugin plugin, @NotNull Runnable task) throws IllegalArgumentException; /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -261,7 +269,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTaskAsynchronously(Plugin plugin, Consumer task) throws IllegalArgumentException; + public void runTaskAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task) throws IllegalArgumentException; /** * @deprecated Use {@link BukkitRunnable#runTaskAsynchronously(Plugin)} @@ -272,7 +280,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if task is null */ @Deprecated - public BukkitTask runTaskAsynchronously(Plugin plugin, BukkitRunnable task) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task) throws IllegalArgumentException; /** * Returns a task that will run after the specified number of server @@ -285,7 +294,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public BukkitTask runTaskLater(Plugin plugin, Runnable task, long delay) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskLater(@NotNull Plugin plugin, @NotNull Runnable task, long delay) throws IllegalArgumentException; /** * Returns a task that will run after the specified number of server @@ -297,7 +307,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTaskLater(Plugin plugin, Consumer task, long delay) throws IllegalArgumentException; + public void runTaskLater(@NotNull Plugin plugin, @NotNull Consumer task, long delay) throws IllegalArgumentException; /** * @deprecated Use {@link BukkitRunnable#runTaskLater(Plugin, long)} @@ -309,7 +319,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if task is null */ @Deprecated - public BukkitTask runTaskLater(Plugin plugin, BukkitRunnable task, long delay) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskLater(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) throws IllegalArgumentException; /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -325,7 +336,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public BukkitTask runTaskLaterAsynchronously(Plugin plugin, Runnable task, long delay) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Runnable task, long delay) throws IllegalArgumentException; /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -340,7 +352,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTaskLaterAsynchronously(Plugin plugin, Consumer task, long delay) throws IllegalArgumentException; + public void runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task, long delay) throws IllegalArgumentException; /** * @deprecated Use {@link BukkitRunnable#runTaskLaterAsynchronously(Plugin, long)} @@ -352,7 +364,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if task is null */ @Deprecated - public BukkitTask runTaskLaterAsynchronously(Plugin plugin, BukkitRunnable task, long delay) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) throws IllegalArgumentException; /** * Returns a task that will repeatedly run until cancelled, starting after @@ -366,7 +379,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public BukkitTask runTaskTimer(Plugin plugin, Runnable task, long delay, long period) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskTimer(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) throws IllegalArgumentException; /** * Returns a task that will repeatedly run until cancelled, starting after @@ -379,7 +393,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTaskTimer(Plugin plugin, Consumer task, long delay, long period) throws IllegalArgumentException; + public void runTaskTimer(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period) throws IllegalArgumentException; /** * @deprecated Use {@link BukkitRunnable#runTaskTimer(Plugin, long, long)} @@ -392,7 +406,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if task is null */ @Deprecated - public BukkitTask runTaskTimer(Plugin plugin, BukkitRunnable task, long delay, long period) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskTimer(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException; /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -410,7 +425,8 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public BukkitTask runTaskTimerAsynchronously(Plugin plugin, Runnable task, long delay, long period) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) throws IllegalArgumentException; /** * Asynchronous tasks should never access any API in Bukkit. Great care @@ -427,7 +443,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTaskTimerAsynchronously(Plugin plugin, Consumer task, long delay, long period) throws IllegalArgumentException; + public void runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period) throws IllegalArgumentException; /** * @deprecated Use {@link BukkitRunnable#runTaskTimerAsynchronously(Plugin, long, long)} @@ -441,5 +457,6 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if task is null */ @Deprecated - public BukkitTask runTaskTimerAsynchronously(Plugin plugin, BukkitRunnable task, long delay, long period) throws IllegalArgumentException; + @NotNull + public BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException; } diff --git a/paper-api/src/main/java/org/bukkit/scheduler/BukkitTask.java b/paper-api/src/main/java/org/bukkit/scheduler/BukkitTask.java index 9c693f8386..5125158493 100644 --- a/paper-api/src/main/java/org/bukkit/scheduler/BukkitTask.java +++ b/paper-api/src/main/java/org/bukkit/scheduler/BukkitTask.java @@ -1,6 +1,7 @@ package org.bukkit.scheduler; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Represents a task being executed by the scheduler @@ -19,6 +20,7 @@ public interface BukkitTask { * * @return The Plugin that owns the task */ + @NotNull public Plugin getOwner(); /** diff --git a/paper-api/src/main/java/org/bukkit/scheduler/BukkitWorker.java b/paper-api/src/main/java/org/bukkit/scheduler/BukkitWorker.java index fe1afbd561..81bdc9ceaf 100644 --- a/paper-api/src/main/java/org/bukkit/scheduler/BukkitWorker.java +++ b/paper-api/src/main/java/org/bukkit/scheduler/BukkitWorker.java @@ -1,6 +1,7 @@ package org.bukkit.scheduler; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; /** * Represents a worker thread for the scheduler. This gives information about @@ -22,6 +23,7 @@ public interface BukkitWorker { * * @return The Plugin that owns the task */ + @NotNull public Plugin getOwner(); /** @@ -29,6 +31,7 @@ public interface BukkitWorker { * * @return The Thread object for the worker */ + @NotNull public Thread getThread(); } diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/Objective.java b/paper-api/src/main/java/org/bukkit/scoreboard/Objective.java index 9876debdfe..f5cbf6df32 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/Objective.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/Objective.java @@ -1,6 +1,8 @@ package org.bukkit.scoreboard; import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An objective on a scoreboard that can show scores specific to entries. This @@ -12,9 +14,10 @@ public interface Objective { /** * Gets the name of this Objective * - * @return this objective'ss name + * @return this objective's name * @throws IllegalStateException if this objective has been unregistered */ + @NotNull String getName() throws IllegalStateException; /** @@ -23,6 +26,7 @@ public interface Objective { * @return this objective's display name * @throws IllegalStateException if this objective has been unregistered */ + @NotNull String getDisplayName() throws IllegalStateException; /** @@ -34,7 +38,7 @@ public interface Objective { * @throws IllegalArgumentException if displayName is longer than 128 * characters. */ - void setDisplayName(String displayName) throws IllegalStateException, IllegalArgumentException; + void setDisplayName(@NotNull String displayName) throws IllegalStateException, IllegalArgumentException; /** * Gets the criteria this objective tracks. @@ -42,6 +46,7 @@ public interface Objective { * @return this objective's criteria * @throws IllegalStateException if this objective has been unregistered */ + @NotNull String getCriteria() throws IllegalStateException; /** @@ -59,6 +64,7 @@ public interface Objective { * @return Owning scoreboard, or null if it has been {@link #unregister() * unregistered} */ + @Nullable Scoreboard getScoreboard(); /** @@ -75,7 +81,7 @@ public interface Objective { * @param slot display slot to change, or null to not display * @throws IllegalStateException if this objective has been unregistered */ - void setDisplaySlot(DisplaySlot slot) throws IllegalStateException; + void setDisplaySlot(@Nullable DisplaySlot slot) throws IllegalStateException; /** * Gets the display slot this objective is displayed at. @@ -83,6 +89,7 @@ public interface Objective { * @return the display slot for this objective, or null if not displayed * @throws IllegalStateException if this objective has been unregistered */ + @Nullable DisplaySlot getDisplaySlot() throws IllegalStateException; /** @@ -91,7 +98,7 @@ public interface Objective { * @param renderType new render type * @throws IllegalStateException if this objective has been unregistered */ - void setRenderType(RenderType renderType) throws IllegalStateException; + void setRenderType(@NotNull RenderType renderType) throws IllegalStateException; /** * Sets manner in which this objective will be rendered. @@ -99,6 +106,7 @@ public interface Objective { * @return the render type * @throws IllegalStateException if this objective has been unregistered */ + @NotNull RenderType getRenderType() throws IllegalStateException; /** @@ -112,7 +120,8 @@ public interface Objective { * @see #getScore(String) */ @Deprecated - Score getScore(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; + @NotNull + Score getScore(@NotNull OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; /** * Gets an entry's Score for an Objective on this Scoreboard. @@ -123,5 +132,6 @@ public interface Objective { * @throws IllegalStateException if this objective has been unregistered * @throws IllegalArgumentException if entry is longer than 40 characters. */ - Score getScore(String entry) throws IllegalArgumentException, IllegalStateException; + @NotNull + Score getScore(@NotNull String entry) throws IllegalArgumentException, IllegalStateException; } diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/Score.java b/paper-api/src/main/java/org/bukkit/scoreboard/Score.java index f7b86b4030..f4e626f928 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/Score.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/Score.java @@ -1,6 +1,8 @@ package org.bukkit.scoreboard; import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A score entry for an {@link #getEntry() entry} on an {@link @@ -17,6 +19,7 @@ public interface Score { * @see #getEntry() */ @Deprecated + @NotNull OfflinePlayer getPlayer(); /** @@ -24,6 +27,7 @@ public interface Score { * * @return this Score's tracked entry */ + @NotNull String getEntry(); /** @@ -31,6 +35,7 @@ public interface Score { * * @return this Score's tracked objective */ + @NotNull Objective getObjective(); /** @@ -66,5 +71,6 @@ public interface Score { * @return the owning objective's scoreboard, or null if it has been * {@link Objective#unregister() unregistered} */ + @Nullable Scoreboard getScoreboard(); } diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java index 85471b3f9b..fa35d7d597 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java @@ -3,6 +3,8 @@ package org.bukkit.scoreboard; import java.util.Set; import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A scoreboard @@ -24,7 +26,8 @@ public interface Scoreboard { * @deprecated a displayName should be explicitly specified */ @Deprecated - Objective registerNewObjective(String name, String criteria) throws IllegalArgumentException; + @NotNull + Objective registerNewObjective(@NotNull String name, @NotNull String criteria) throws IllegalArgumentException; /** * Registers an Objective on this Scoreboard @@ -43,7 +46,8 @@ public interface Scoreboard { * @throws IllegalArgumentException if an objective by that name already * exists */ - Objective registerNewObjective(String name, String criteria, String displayName) throws IllegalArgumentException; + @NotNull + Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName) throws IllegalArgumentException; /** * Registers an Objective on this Scoreboard @@ -64,7 +68,8 @@ public interface Scoreboard { * @throws IllegalArgumentException if an objective by that name already * exists */ - Objective registerNewObjective(String name, String criteria, String displayName, RenderType renderType) throws IllegalArgumentException; + @NotNull + Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException; /** * Gets an Objective on this Scoreboard by name @@ -73,7 +78,8 @@ public interface Scoreboard { * @return the Objective or null if it does not exist * @throws IllegalArgumentException if name is null */ - Objective getObjective(String name) throws IllegalArgumentException; + @Nullable + Objective getObjective(@NotNull String name) throws IllegalArgumentException; /** * Gets all Objectives of a Criteria on the Scoreboard @@ -81,13 +87,15 @@ public interface Scoreboard { * @param criteria Criteria to search by * @return an immutable set of Objectives using the specified Criteria */ - Set getObjectivesByCriteria(String criteria) throws IllegalArgumentException; + @NotNull + Set getObjectivesByCriteria(@NotNull String criteria) throws IllegalArgumentException; /** * Gets all Objectives on this Scoreboard * * @return An immutable set of all Objectives on this Scoreboard */ + @NotNull Set getObjectives(); /** @@ -99,7 +107,8 @@ public interface Scoreboard { * displayed in that DisplaySlot * @throws IllegalArgumentException if slot is null */ - Objective getObjective(DisplaySlot slot) throws IllegalArgumentException; + @Nullable + Objective getObjective(@NotNull DisplaySlot slot) throws IllegalArgumentException; /** * Gets all scores for a player on this Scoreboard @@ -111,7 +120,8 @@ public interface Scoreboard { * @see #getScores(String) */ @Deprecated - Set getScores(OfflinePlayer player) throws IllegalArgumentException; + @NotNull + Set getScores(@NotNull OfflinePlayer player) throws IllegalArgumentException; /** * Gets all scores for an entry on this Scoreboard @@ -120,7 +130,8 @@ public interface Scoreboard { * @return immutable set of all scores tracked for the entry * @throws IllegalArgumentException if entry is null */ - Set getScores(String entry) throws IllegalArgumentException; + @NotNull + Set getScores(@NotNull String entry) throws IllegalArgumentException; /** * Removes all scores for a player on this Scoreboard @@ -131,7 +142,7 @@ public interface Scoreboard { * @see #resetScores(String) */ @Deprecated - void resetScores(OfflinePlayer player) throws IllegalArgumentException; + void resetScores(@NotNull OfflinePlayer player) throws IllegalArgumentException; /** * Removes all scores for an entry on this Scoreboard @@ -139,7 +150,7 @@ public interface Scoreboard { * @param entry the entry to drop all current scores for * @throws IllegalArgumentException if entry is null */ - void resetScores(String entry) throws IllegalArgumentException; + void resetScores(@NotNull String entry) throws IllegalArgumentException; /** * Gets a player's Team on this Scoreboard @@ -151,7 +162,8 @@ public interface Scoreboard { * @see #getEntryTeam(String) */ @Deprecated - Team getPlayerTeam(OfflinePlayer player) throws IllegalArgumentException; + @Nullable + Team getPlayerTeam(@NotNull OfflinePlayer player) throws IllegalArgumentException; /** * Gets a entries Team on this Scoreboard @@ -160,7 +172,8 @@ public interface Scoreboard { * @return the entries Team or null if the entry is not on a team * @throws IllegalArgumentException if entry is null */ - Team getEntryTeam(String entry) throws IllegalArgumentException; + @Nullable + Team getEntryTeam(@NotNull String entry) throws IllegalArgumentException; /** * Gets a Team by name on this Scoreboard @@ -169,13 +182,15 @@ public interface Scoreboard { * @return the matching Team or null if no matches * @throws IllegalArgumentException if teamName is null */ - Team getTeam(String teamName) throws IllegalArgumentException; + @Nullable + Team getTeam(@NotNull String teamName) throws IllegalArgumentException; /** * Gets all teams on this Scoreboard * * @return an immutable set of Teams */ + @NotNull Set getTeams(); /** @@ -186,7 +201,8 @@ public interface Scoreboard { * @throws IllegalArgumentException if name is null * @throws IllegalArgumentException if team by that name already exists */ - Team registerNewTeam(String name) throws IllegalArgumentException; + @NotNull + Team registerNewTeam(@NotNull String name) throws IllegalArgumentException; /** * Gets all players tracked by this Scoreboard @@ -196,6 +212,7 @@ public interface Scoreboard { * @see #getEntries() */ @Deprecated + @NotNull Set getPlayers(); /** @@ -203,6 +220,7 @@ public interface Scoreboard { * * @return immutable set of all tracked entries */ + @NotNull Set getEntries(); /** @@ -211,5 +229,5 @@ public interface Scoreboard { * @param slot the slot to remove objectives * @throws IllegalArgumentException if slot is null */ - void clearSlot(DisplaySlot slot) throws IllegalArgumentException; + void clearSlot(@NotNull DisplaySlot slot) throws IllegalArgumentException; } diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java b/paper-api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java index 00b67a18e9..255977c2fb 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java @@ -1,5 +1,7 @@ package org.bukkit.scoreboard; +import org.jetbrains.annotations.NotNull; + import java.lang.ref.WeakReference; /** @@ -15,6 +17,7 @@ public interface ScoreboardManager { * * @return the default sever scoreboard */ + @NotNull Scoreboard getMainScoreboard(); /** @@ -25,5 +28,6 @@ public interface ScoreboardManager { * @return the registered Scoreboard * @see WeakReference */ + @NotNull Scoreboard getNewScoreboard(); } diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/Team.java b/paper-api/src/main/java/org/bukkit/scoreboard/Team.java index ab71f3c312..f75dbe846b 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/Team.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/Team.java @@ -5,6 +5,8 @@ import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A team on a scoreboard that has a common display theme and other @@ -19,6 +21,7 @@ public interface Team { * @return Objective name * @throws IllegalStateException if this team has been unregistered */ + @NotNull String getName() throws IllegalStateException; /** @@ -27,6 +30,7 @@ public interface Team { * @return Team display name * @throws IllegalStateException if this team has been unregistered */ + @NotNull String getDisplayName() throws IllegalStateException; /** @@ -37,7 +41,7 @@ public interface Team { * characters. * @throws IllegalStateException if this team has been unregistered */ - void setDisplayName(String displayName) throws IllegalStateException, IllegalArgumentException; + void setDisplayName(@NotNull String displayName) throws IllegalStateException, IllegalArgumentException; /** * Gets the prefix prepended to the display of entries on this team. @@ -45,6 +49,7 @@ public interface Team { * @return Team prefix * @throws IllegalStateException if this team has been unregistered */ + @NotNull String getPrefix() throws IllegalStateException; /** @@ -56,7 +61,7 @@ public interface Team { * characters * @throws IllegalStateException if this team has been unregistered */ - void setPrefix(String prefix) throws IllegalStateException, IllegalArgumentException; + void setPrefix(@NotNull String prefix) throws IllegalStateException, IllegalArgumentException; /** * Gets the suffix appended to the display of entries on this team. @@ -64,6 +69,7 @@ public interface Team { * @return the team's current suffix * @throws IllegalStateException if this team has been unregistered */ + @NotNull String getSuffix() throws IllegalStateException; /** @@ -75,7 +81,7 @@ public interface Team { * characters * @throws IllegalStateException if this team has been unregistered */ - void setSuffix(String suffix) throws IllegalStateException, IllegalArgumentException; + void setSuffix(@NotNull String suffix) throws IllegalStateException, IllegalArgumentException; /** * Gets the color of the team. @@ -84,8 +90,9 @@ public interface Team { * names are handled by prefixes / suffixes. * * @return team color, defaults to {@link ChatColor#RESET} - * @throws IllegalStateException + * @throws IllegalStateException if this team has been unregistered */ + @NotNull ChatColor getColor() throws IllegalStateException; /** @@ -97,7 +104,7 @@ public interface Team { * @param color new color, must be non-null. Use {@link ChatColor#RESET} for * no color */ - void setColor(ChatColor color); + void setColor(@NotNull ChatColor color); /** * Gets the team friendly fire state @@ -141,18 +148,19 @@ public interface Team { * @deprecated see {@link #getOption(org.bukkit.scoreboard.Team.Option)} */ @Deprecated + @NotNull NameTagVisibility getNameTagVisibility() throws IllegalArgumentException; /** * Set's the team's ability to see name tags * - * @param visibility The nameTagVisibilty to set + * @param visibility The nameTagVisibility to set * @throws IllegalArgumentException if this team has been unregistered * @deprecated see * {@link #setOption(org.bukkit.scoreboard.Team.Option, org.bukkit.scoreboard.Team.OptionStatus)} */ @Deprecated - void setNameTagVisibility(NameTagVisibility visibility) throws IllegalArgumentException; + void setNameTagVisibility(@NotNull NameTagVisibility visibility) throws IllegalArgumentException; /** * Gets the Set of players on the team @@ -163,6 +171,7 @@ public interface Team { * @see #getEntries() */ @Deprecated + @NotNull Set getPlayers() throws IllegalStateException; /** @@ -171,6 +180,7 @@ public interface Team { * @return entries on the team * @throws IllegalStateException if this entries has been unregistered\ */ + @NotNull Set getEntries() throws IllegalStateException; /** @@ -187,6 +197,7 @@ public interface Team { * @return Owning scoreboard, or null if this team has been {@link * #unregister() unregistered} */ + @Nullable Scoreboard getScoreboard(); /** @@ -201,7 +212,7 @@ public interface Team { * @see #addEntry(String) */ @Deprecated - void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; + void addPlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; /** * This puts the specified entry onto this team for the scoreboard. @@ -212,7 +223,7 @@ public interface Team { * @throws IllegalArgumentException if entry is null * @throws IllegalStateException if this team has been unregistered */ - void addEntry(String entry) throws IllegalStateException, IllegalArgumentException; + void addEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException; /** * Removes the player from this team. @@ -225,7 +236,7 @@ public interface Team { * @see #removeEntry(String) */ @Deprecated - boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; + boolean removePlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; /** * Removes the entry from this team. @@ -235,7 +246,7 @@ public interface Team { * @throws IllegalStateException if this team has been unregistered * @return if the entry was a part of this team */ - boolean removeEntry(String entry) throws IllegalStateException, IllegalArgumentException; + boolean removeEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException; /** * Unregisters this team from the Scoreboard @@ -255,7 +266,7 @@ public interface Team { * @see #hasEntry(String) */ @Deprecated - boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; + boolean hasPlayer(@NotNull OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; /** * Checks to see if the specified entry is a member of this team. * @@ -264,7 +275,7 @@ public interface Team { * @throws IllegalArgumentException if entry is null * @throws IllegalStateException if this team has been unregistered */ - boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException; + boolean hasEntry(@NotNull String entry) throws IllegalArgumentException, IllegalStateException; /** * Get an option for this team @@ -273,7 +284,8 @@ public interface Team { * @return the option status * @throws IllegalStateException if this team has been unregistered */ - OptionStatus getOption(Option option) throws IllegalStateException; + @NotNull + OptionStatus getOption(@NotNull Option option) throws IllegalStateException; /** * Set an option for this team @@ -282,7 +294,7 @@ public interface Team { * @param status the new option status * @throws IllegalStateException if this team has been unregistered */ - void setOption(Option option, OptionStatus status) throws IllegalStateException; + void setOption(@NotNull Option option, @NotNull OptionStatus status) throws IllegalStateException; /** * Represents an option which may be applied to this team. diff --git a/paper-api/src/main/java/org/bukkit/util/BlockIterator.java b/paper-api/src/main/java/org/bukkit/util/BlockIterator.java index ec672e7f4f..8e6887ae7d 100644 --- a/paper-api/src/main/java/org/bukkit/util/BlockIterator.java +++ b/paper-api/src/main/java/org/bukkit/util/BlockIterator.java @@ -7,6 +7,7 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; import java.util.Iterator; import java.util.NoSuchElementException; @@ -53,7 +54,7 @@ public class BlockIterator implements Iterator { * unloaded chunks. A value of 0 indicates no limit * */ - public BlockIterator(World world, Vector start, Vector direction, double yOffset, int maxDistance) { + public BlockIterator(@NotNull World world, @NotNull Vector start, @NotNull Vector direction, double yOffset, int maxDistance) { this.world = world; this.maxDistance = maxDistance; @@ -177,31 +178,31 @@ public class BlockIterator implements Iterator { } - private boolean blockEquals(Block a, Block b) { + private boolean blockEquals(@NotNull Block a, @NotNull Block b) { return a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ(); } - private BlockFace getXFace(Vector direction) { + private BlockFace getXFace(@NotNull Vector direction) { return ((direction.getX() > 0) ? BlockFace.EAST : BlockFace.WEST); } - private BlockFace getYFace(Vector direction) { + private BlockFace getYFace(@NotNull Vector direction) { return ((direction.getY() > 0) ? BlockFace.UP : BlockFace.DOWN); } - private BlockFace getZFace(Vector direction) { + private BlockFace getZFace(@NotNull Vector direction) { return ((direction.getZ() > 0) ? BlockFace.SOUTH : BlockFace.NORTH); } - private double getXLength(Vector direction) { + private double getXLength(@NotNull Vector direction) { return Math.abs(direction.getX()); } - private double getYLength(Vector direction) { + private double getYLength(@NotNull Vector direction) { return Math.abs(direction.getY()); } - private double getZLength(Vector direction) { + private double getZLength(@NotNull Vector direction) { return Math.abs(direction.getZ()); } @@ -209,15 +210,15 @@ public class BlockIterator implements Iterator { return direction > 0 ? (position - blockPosition) : (blockPosition + 1 - position); } - private double getXPosition(Vector direction, Vector position, Block block) { + private double getXPosition(@NotNull Vector direction, @NotNull Vector position, @NotNull Block block) { return getPosition(direction.getX(), position.getX(), block.getX()); } - private double getYPosition(Vector direction, Vector position, Block block) { + private double getYPosition(@NotNull Vector direction, @NotNull Vector position, @NotNull Block block) { return getPosition(direction.getY(), position.getY(), block.getY()); } - private double getZPosition(Vector direction, Vector position, Block block) { + private double getZPosition(@NotNull Vector direction, @NotNull Vector position, @NotNull Block block) { return getPosition(direction.getZ(), position.getZ(), block.getZ()); } @@ -233,7 +234,7 @@ public class BlockIterator implements Iterator { * trace. Setting this value above 140 may lead to problems with * unloaded chunks. A value of 0 indicates no limit */ - public BlockIterator(Location loc, double yOffset, int maxDistance) { + public BlockIterator(@NotNull Location loc, double yOffset, int maxDistance) { this(loc.getWorld(), loc.toVector(), loc.getDirection(), yOffset, maxDistance); } @@ -247,7 +248,7 @@ public class BlockIterator implements Iterator { * by this value */ - public BlockIterator(Location loc, double yOffset) { + public BlockIterator(@NotNull Location loc, double yOffset) { this(loc.getWorld(), loc.toVector(), loc.getDirection(), yOffset, 0); } @@ -259,7 +260,7 @@ public class BlockIterator implements Iterator { * @param loc The location for the start of the ray trace */ - public BlockIterator(Location loc) { + public BlockIterator(@NotNull Location loc) { this(loc, 0D); } @@ -274,7 +275,7 @@ public class BlockIterator implements Iterator { * unloaded chunks. A value of 0 indicates no limit */ - public BlockIterator(LivingEntity entity, int maxDistance) { + public BlockIterator(@NotNull LivingEntity entity, int maxDistance) { this(entity.getLocation(), entity.getEyeHeight(), maxDistance); } @@ -286,7 +287,7 @@ public class BlockIterator implements Iterator { * @param entity Information from the entity is used to set up the trace */ - public BlockIterator(LivingEntity entity) { + public BlockIterator(@NotNull LivingEntity entity) { this(entity, 0); } @@ -304,8 +305,8 @@ public class BlockIterator implements Iterator { * * @return the next Block in the trace */ - - public Block next() { + @NotNull + public Block next() throws NoSuchElementException { scan(); if (currentBlock <= -1) { throw new NoSuchElementException(); diff --git a/paper-api/src/main/java/org/bukkit/util/BlockVector.java b/paper-api/src/main/java/org/bukkit/util/BlockVector.java index bdf8f6d5d6..eddc724890 100644 --- a/paper-api/src/main/java/org/bukkit/util/BlockVector.java +++ b/paper-api/src/main/java/org/bukkit/util/BlockVector.java @@ -2,6 +2,7 @@ package org.bukkit.util; import java.util.Map; import org.bukkit.configuration.serialization.SerializableAs; +import org.jetbrains.annotations.NotNull; /** * A vector with a hash function that floors the X, Y, Z components, a la @@ -26,7 +27,7 @@ public class BlockVector extends Vector { * * @param vec The other vector. */ - public BlockVector(Vector vec) { + public BlockVector(@NotNull Vector vec) { this.x = vec.getX(); this.y = vec.getY(); this.z = vec.getZ(); @@ -108,7 +109,8 @@ public class BlockVector extends Vector { return (BlockVector) super.clone(); } - public static BlockVector deserialize(Map args) { + @NotNull + public static BlockVector deserialize(@NotNull Map args) { double x = 0; double y = 0; double z = 0; diff --git a/paper-api/src/main/java/org/bukkit/util/BoundingBox.java b/paper-api/src/main/java/org/bukkit/util/BoundingBox.java index 67a3322f5d..e5c7826afe 100644 --- a/paper-api/src/main/java/org/bukkit/util/BoundingBox.java +++ b/paper-api/src/main/java/org/bukkit/util/BoundingBox.java @@ -9,6 +9,8 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A mutable axis aligned bounding box (AABB). @@ -35,7 +37,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param corner2 the second corner * @return the bounding box */ - public static BoundingBox of(Vector corner1, Vector corner2) { + @NotNull + public static BoundingBox of(@NotNull Vector corner1, @NotNull Vector corner2) { Validate.notNull(corner1, "Corner1 is null!"); Validate.notNull(corner2, "Corner2 is null!"); return new BoundingBox(corner1.getX(), corner1.getY(), corner1.getZ(), corner2.getX(), corner2.getY(), corner2.getZ()); @@ -49,7 +52,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param corner2 the second corner * @return the bounding box */ - public static BoundingBox of(Location corner1, Location corner2) { + @NotNull + public static BoundingBox of(@NotNull Location corner1, @NotNull Location corner2) { Validate.notNull(corner1, "Corner1 is null!"); Validate.notNull(corner2, "Corner2 is null!"); Validate.isTrue(Objects.equals(corner1.getWorld(), corner2.getWorld()), "Locations from different worlds!"); @@ -66,7 +70,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param corner2 the second corner block * @return the bounding box */ - public static BoundingBox of(Block corner1, Block corner2) { + @NotNull + public static BoundingBox of(@NotNull Block corner1, @NotNull Block corner2) { Validate.notNull(corner1, "Corner1 is null!"); Validate.notNull(corner2, "Corner2 is null!"); Validate.isTrue(Objects.equals(corner1.getWorld(), corner2.getWorld()), "Blocks from different worlds!"); @@ -94,7 +99,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param block the block * @return the bounding box */ - public static BoundingBox of(Block block) { + @NotNull + public static BoundingBox of(@NotNull Block block) { Validate.notNull(block, "Block is null!"); return new BoundingBox(block.getX(), block.getY(), block.getZ(), block.getX() + 1, block.getY() + 1, block.getZ() + 1); } @@ -108,7 +114,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param z 1/2 the size of the bounding box along the z axis * @return the bounding box */ - public static BoundingBox of(Vector center, double x, double y, double z) { + @NotNull + public static BoundingBox of(@NotNull Vector center, double x, double y, double z) { Validate.notNull(center, "Center is null!"); return new BoundingBox(center.getX() - x, center.getY() - y, center.getZ() - z, center.getX() + x, center.getY() + y, center.getZ() + z); } @@ -122,7 +129,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param z 1/2 the size of the bounding box along the z axis * @return the bounding box */ - public static BoundingBox of(Location center, double x, double y, double z) { + @NotNull + public static BoundingBox of(@NotNull Location center, double x, double y, double z) { Validate.notNull(center, "Center is null!"); return new BoundingBox(center.getX() - x, center.getY() - y, center.getZ() - z, center.getX() + x, center.getY() + y, center.getZ() + z); } @@ -167,6 +175,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param z2 the second corner's z value * @return this bounding box (resized) */ + @NotNull public BoundingBox resize(double x1, double y1, double z1, double x2, double y2, double z2) { NumberConversions.checkFinite(x1, "x1 not finite"); NumberConversions.checkFinite(y1, "y1 not finite"); @@ -216,6 +225,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * * @return the minimum corner as vector */ + @NotNull public Vector getMin() { return new Vector(minX, minY, minZ); } @@ -252,6 +262,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * * @return the maximum corner vector */ + @NotNull public Vector getMax() { return new Vector(maxX, maxY, maxZ); } @@ -324,6 +335,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * * @return the center */ + @NotNull public Vector getCenter() { return new Vector(this.getCenterX(), this.getCenterY(), this.getCenterZ()); } @@ -334,7 +346,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param other the other bounding box * @return this bounding box */ - public BoundingBox copy(BoundingBox other) { + @NotNull + public BoundingBox copy(@NotNull BoundingBox other) { Validate.notNull(other, "Other bounding box is null!"); return this.resize(other.getMinX(), other.getMinY(), other.getMinZ(), other.getMaxX(), other.getMaxY(), other.getMaxZ()); } @@ -355,6 +368,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param positiveZ the amount of expansion in the positive z direction * @return this bounding box (now expanded) */ + @NotNull public BoundingBox expand(double negativeX, double negativeY, double negativeZ, double positiveX, double positiveY, double positiveZ) { if (negativeX == 0.0D && negativeY == 0.0D && negativeZ == 0.0D && positiveX == 0.0D && positiveY == 0.0D && positiveZ == 0.0D) { return this; @@ -418,6 +432,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * direction * @return this bounding box (now expanded) */ + @NotNull public BoundingBox expand(double x, double y, double z) { return this.expand(x, y, z, x, y, z); } @@ -432,7 +447,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param expansion the expansion values * @return this bounding box (now expanded) */ - public BoundingBox expand(Vector expansion) { + @NotNull + public BoundingBox expand(@NotNull Vector expansion) { Validate.notNull(expansion, "Expansion is null!"); double x = expansion.getX(); double y = expansion.getY(); @@ -449,6 +465,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param expansion the amount of expansion * @return this bounding box (now expanded) */ + @NotNull public BoundingBox expand(double expansion) { return this.expand(expansion, expansion, expansion, expansion, expansion, expansion); } @@ -466,6 +483,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param expansion the amount of expansion * @return this bounding box (now expanded) */ + @NotNull public BoundingBox expand(double dirX, double dirY, double dirZ, double expansion) { if (expansion == 0.0D) return this; if (dirX == 0.0D && dirY == 0.0D && dirZ == 0.0D) return this; @@ -490,7 +508,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param expansion the amount of expansion * @return this bounding box (now expanded) */ - public BoundingBox expand(Vector direction, double expansion) { + @NotNull + public BoundingBox expand(@NotNull Vector direction, double expansion) { Validate.notNull(direction, "Direction is null!"); return this.expand(direction.getX(), direction.getY(), direction.getZ(), expansion); } @@ -506,7 +525,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param expansion the amount of expansion * @return this bounding box (now expanded) */ - public BoundingBox expand(BlockFace blockFace, double expansion) { + @NotNull + public BoundingBox expand(@NotNull BlockFace blockFace, double expansion) { Validate.notNull(blockFace, "Block face is null!"); if (blockFace == BlockFace.SELF) return this; @@ -526,6 +546,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param dirZ the z direction component * @return this bounding box (now expanded) */ + @NotNull public BoundingBox expandDirectional(double dirX, double dirY, double dirZ) { return this.expand(dirX, dirY, dirZ, 1.0D); } @@ -540,7 +561,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param direction the direction and magnitude of the expansion * @return this bounding box (now expanded) */ - public BoundingBox expandDirectional(Vector direction) { + @NotNull + public BoundingBox expandDirectional(@NotNull Vector direction) { Validate.notNull(direction, "Expansion is null!"); return this.expand(direction.getX(), direction.getY(), direction.getZ(), 1.0D); } @@ -554,6 +576,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @return this bounding box (now expanded) * @see #contains(double, double, double) */ + @NotNull public BoundingBox union(double posX, double posY, double posZ) { double newMinX = Math.min(this.minX, posX); double newMinY = Math.min(this.minY, posY); @@ -574,7 +597,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @return this bounding box (now expanded) * @see #contains(double, double, double) */ - public BoundingBox union(Vector position) { + @NotNull + public BoundingBox union(@NotNull Vector position) { Validate.notNull(position, "Position is null!"); return this.union(position.getX(), position.getY(), position.getZ()); } @@ -586,7 +610,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @return this bounding box (now expanded) * @see #contains(double, double, double) */ - public BoundingBox union(Location position) { + @NotNull + public BoundingBox union(@NotNull Location position) { Validate.notNull(position, "Position is null!"); return this.union(position.getX(), position.getY(), position.getZ()); } @@ -598,7 +623,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param other the other bounding box * @return this bounding box (now expanded) */ - public BoundingBox union(BoundingBox other) { + @NotNull + public BoundingBox union(@NotNull BoundingBox other) { Validate.notNull(other, "Other bounding box is null!"); if (this.contains(other)) return this; double newMinX = Math.min(this.minX, other.minX); @@ -618,7 +644,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @return this bounding box (now representing the intersection) * @throws IllegalArgumentException if the bounding boxes don't overlap */ - public BoundingBox intersection(BoundingBox other) { + @NotNull + public BoundingBox intersection(@NotNull BoundingBox other) { Validate.notNull(other, "Other bounding box is null!"); Validate.isTrue(this.overlaps(other), "The bounding boxes do not overlap!"); double newMinX = Math.max(this.minX, other.minX); @@ -638,6 +665,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param shiftZ the shift in z direction * @return this bounding box (now shifted) */ + @NotNull public BoundingBox shift(double shiftX, double shiftY, double shiftZ) { if (shiftX == 0.0D && shiftY == 0.0D && shiftZ == 0.0D) return this; return this.resize(this.minX + shiftX, this.minY + shiftY, this.minZ + shiftZ, @@ -650,7 +678,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param shift the shift * @return this bounding box (now shifted) */ - public BoundingBox shift(Vector shift) { + @NotNull + public BoundingBox shift(@NotNull Vector shift) { Validate.notNull(shift, "Shift is null!"); return this.shift(shift.getX(), shift.getY(), shift.getZ()); } @@ -661,7 +690,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param shift the shift * @return this bounding box (now shifted) */ - public BoundingBox shift(Location shift) { + @NotNull + public BoundingBox shift(@NotNull Location shift) { Validate.notNull(shift, "Shift is null!"); return this.shift(shift.getX(), shift.getY(), shift.getZ()); } @@ -681,7 +711,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param other the other bounding box * @return true if overlapping */ - public boolean overlaps(BoundingBox other) { + public boolean overlaps(@NotNull BoundingBox other) { Validate.notNull(other, "Other bounding box is null!"); return this.overlaps(other.minX, other.minY, other.minZ, other.maxX, other.maxY, other.maxZ); } @@ -697,7 +727,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param max the second corner * @return true if overlapping */ - public boolean overlaps(Vector min, Vector max) { + public boolean overlaps(@NotNull Vector min, @NotNull Vector max) { Validate.notNull(min, "Min is null!"); Validate.notNull(max, "Max is null!"); double x1 = min.getX(); @@ -742,7 +772,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param position the position * @return true if the bounding box contains the position */ - public boolean contains(Vector position) { + public boolean contains(@NotNull Vector position) { Validate.notNull(position, "Position is null!"); return this.contains(position.getX(), position.getY(), position.getZ()); } @@ -760,7 +790,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @return true if the bounding box contains the given bounding * box */ - public boolean contains(BoundingBox other) { + public boolean contains(@NotNull BoundingBox other) { Validate.notNull(other, "Other bounding box is null!"); return this.contains(other.minX, other.minY, other.minZ, other.maxX, other.maxY, other.maxZ); } @@ -774,7 +804,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @return true if the bounding box contains the specified * bounding box */ - public boolean contains(Vector min, Vector max) { + public boolean contains(@NotNull Vector min, @NotNull Vector max) { Validate.notNull(min, "Min is null!"); Validate.notNull(max, "Max is null!"); double x1 = min.getX(); @@ -799,7 +829,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * @param maxDistance the maximum distance * @return the ray trace hit result, or null if there is no hit */ - public RayTraceResult rayTrace(Vector start, Vector direction, double maxDistance) { + @Nullable + public RayTraceResult rayTrace(@NotNull Vector start, @NotNull Vector direction, double maxDistance) { Validate.notNull(start, "Start is null!"); start.checkFinite(); Validate.notNull(direction, "Direction is null!"); @@ -977,6 +1008,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { * * @return the cloned bounding box */ + @NotNull @Override public BoundingBox clone() { try { @@ -986,6 +1018,7 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { } } + @NotNull @Override public Map serialize() { Map result = new LinkedHashMap(); @@ -998,7 +1031,8 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable { return result; } - public static BoundingBox deserialize(Map args) { + @NotNull + public static BoundingBox deserialize(@NotNull Map args) { double minX = 0.0D; double minY = 0.0D; double minZ = 0.0D; diff --git a/paper-api/src/main/java/org/bukkit/util/ChatPaginator.java b/paper-api/src/main/java/org/bukkit/util/ChatPaginator.java index b0b91ad8c5..04358f17e9 100644 --- a/paper-api/src/main/java/org/bukkit/util/ChatPaginator.java +++ b/paper-api/src/main/java/org/bukkit/util/ChatPaginator.java @@ -1,6 +1,8 @@ package org.bukkit.util; import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.LinkedList; @@ -26,7 +28,8 @@ public class ChatPaginator { * @param pageNumber The page number to fetch. * @return A single chat page. */ - public static ChatPage paginate(String unpaginatedString, int pageNumber) { + @NotNull + public static ChatPage paginate(@Nullable String unpaginatedString, int pageNumber) { return paginate(unpaginatedString, pageNumber, GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH, CLOSED_CHAT_PAGE_HEIGHT); } @@ -39,7 +42,8 @@ public class ChatPaginator { * @param pageHeight The desired number of lines in a page. * @return A single chat page. */ - public static ChatPage paginate(String unpaginatedString, int pageNumber, int lineLength, int pageHeight) { + @NotNull + public static ChatPage paginate(@Nullable String unpaginatedString, int pageNumber, int lineLength, int pageHeight) { String[] lines = wordWrap(unpaginatedString, lineLength); int totalPages = lines.length / pageHeight + (lines.length % pageHeight == 0 ? 0 : 1); @@ -60,7 +64,8 @@ public class ChatPaginator { * @param lineLength The length of a line of text. * @return An array of word-wrapped lines. */ - public static String[] wordWrap(String rawString, int lineLength) { + @NotNull + public static String[] wordWrap(@Nullable String rawString, int lineLength) { // A null string is a single line if (rawString == null) { return new String[] {""}; @@ -151,7 +156,7 @@ public class ChatPaginator { private int pageNumber; private int totalPages; - public ChatPage(String[] lines, int pageNumber, int totalPages) { + public ChatPage(@NotNull String[] lines, int pageNumber, int totalPages) { this.lines = lines; this.pageNumber = pageNumber; this.totalPages = totalPages; @@ -165,8 +170,8 @@ public class ChatPaginator { return totalPages; } + @NotNull public String[] getLines() { - return lines; } } diff --git a/paper-api/src/main/java/org/bukkit/util/EulerAngle.java b/paper-api/src/main/java/org/bukkit/util/EulerAngle.java index f5c2773ebb..201cb4a8c7 100644 --- a/paper-api/src/main/java/org/bukkit/util/EulerAngle.java +++ b/paper-api/src/main/java/org/bukkit/util/EulerAngle.java @@ -1,5 +1,7 @@ package org.bukkit.util; +import org.jetbrains.annotations.NotNull; + /** * EulerAngle is used to represent 3 angles, one for each * axis (x, y, z). The angles are in radians @@ -63,6 +65,7 @@ public class EulerAngle { * @param x the angle in radians * @return the resultant EulerAngle */ + @NotNull public EulerAngle setX(double x) { return new EulerAngle(x, y, z); } @@ -74,6 +77,7 @@ public class EulerAngle { * @param y the angle in radians * @return the resultant EulerAngle */ + @NotNull public EulerAngle setY(double y) { return new EulerAngle(x, y, z); } @@ -85,6 +89,7 @@ public class EulerAngle { * @param z the angle in radians * @return the resultant EulerAngle */ + @NotNull public EulerAngle setZ(double z) { return new EulerAngle(x, y, z); } @@ -98,6 +103,7 @@ public class EulerAngle { * @param z the angle to add to the z axis in radians * @return the resultant EulerAngle */ + @NotNull public EulerAngle add(double x, double y, double z) { return new EulerAngle( this.x + x, @@ -115,6 +121,7 @@ public class EulerAngle { * @param z the angle to subtract to the z axis in radians * @return the resultant EulerAngle */ + @NotNull public EulerAngle subtract(double x, double y, double z) { return add(-x, -y, -z); } diff --git a/paper-api/src/main/java/org/bukkit/util/FileUtil.java b/paper-api/src/main/java/org/bukkit/util/FileUtil.java index 7cabf4c549..af75ce2e7c 100644 --- a/paper-api/src/main/java/org/bukkit/util/FileUtil.java +++ b/paper-api/src/main/java/org/bukkit/util/FileUtil.java @@ -1,5 +1,7 @@ package org.bukkit.util; +import org.jetbrains.annotations.NotNull; + import java.nio.channels.FileChannel; import java.io.File; import java.io.FileInputStream; @@ -18,7 +20,7 @@ public class FileUtil { * @param outFile the target filename * @return true on success */ - public static boolean copy(File inFile, File outFile) { + public static boolean copy(@NotNull File inFile, @NotNull File outFile) { if (!inFile.exists()) { return false; } diff --git a/paper-api/src/main/java/org/bukkit/util/NumberConversions.java b/paper-api/src/main/java/org/bukkit/util/NumberConversions.java index 440d2798fa..e10b9a4e53 100644 --- a/paper-api/src/main/java/org/bukkit/util/NumberConversions.java +++ b/paper-api/src/main/java/org/bukkit/util/NumberConversions.java @@ -1,5 +1,8 @@ package org.bukkit.util; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Utils for casting number types to other number types */ @@ -24,7 +27,7 @@ public final class NumberConversions { return num * num; } - public static int toInt(Object object) { + public static int toInt(@Nullable Object object) { if (object instanceof Number) { return ((Number) object).intValue(); } @@ -37,7 +40,7 @@ public final class NumberConversions { return 0; } - public static float toFloat(Object object) { + public static float toFloat(@Nullable Object object) { if (object instanceof Number) { return ((Number) object).floatValue(); } @@ -50,7 +53,7 @@ public final class NumberConversions { return 0; } - public static double toDouble(Object object) { + public static double toDouble(@Nullable Object object) { if (object instanceof Number) { return ((Number) object).doubleValue(); } @@ -63,7 +66,7 @@ public final class NumberConversions { return 0; } - public static long toLong(Object object) { + public static long toLong(@Nullable Object object) { if (object instanceof Number) { return ((Number) object).longValue(); } @@ -76,7 +79,7 @@ public final class NumberConversions { return 0; } - public static short toShort(Object object) { + public static short toShort(@Nullable Object object) { if (object instanceof Number) { return ((Number) object).shortValue(); } @@ -89,7 +92,7 @@ public final class NumberConversions { return 0; } - public static byte toByte(Object object) { + public static byte toByte(@Nullable Object object) { if (object instanceof Number) { return ((Number) object).byteValue(); } @@ -110,13 +113,13 @@ public final class NumberConversions { return Math.abs(f) <= Float.MAX_VALUE; } - public static void checkFinite(double d, String message) { + public static void checkFinite(double d, @NotNull String message) { if (!isFinite(d)) { throw new IllegalArgumentException(message); } } - public static void checkFinite(float d, String message) { + public static void checkFinite(float d, @NotNull String message) { if (!isFinite(d)) { throw new IllegalArgumentException(message); } diff --git a/paper-api/src/main/java/org/bukkit/util/RayTraceResult.java b/paper-api/src/main/java/org/bukkit/util/RayTraceResult.java index 5a3a05efcb..0546301917 100644 --- a/paper-api/src/main/java/org/bukkit/util/RayTraceResult.java +++ b/paper-api/src/main/java/org/bukkit/util/RayTraceResult.java @@ -6,6 +6,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The hit result of a ray trace. @@ -22,7 +24,7 @@ public class RayTraceResult { private final BlockFace hitBlockFace; private final Entity hitEntity; - private RayTraceResult(Vector hitPosition, Block hitBlock, BlockFace hitBlockFace, Entity hitEntity) { + private RayTraceResult(@NotNull Vector hitPosition, @Nullable Block hitBlock, @Nullable BlockFace hitBlockFace, @Nullable Entity hitEntity) { Validate.notNull(hitPosition, "Hit position is null!"); this.hitPosition = hitPosition.clone(); this.hitBlock = hitBlock; @@ -35,7 +37,7 @@ public class RayTraceResult { * * @param hitPosition the hit position */ - public RayTraceResult(Vector hitPosition) { + public RayTraceResult(@NotNull Vector hitPosition) { this(hitPosition, null, null, null); } @@ -45,7 +47,7 @@ public class RayTraceResult { * @param hitPosition the hit position * @param hitBlockFace the hit block face */ - public RayTraceResult(Vector hitPosition, BlockFace hitBlockFace) { + public RayTraceResult(@NotNull Vector hitPosition, @Nullable BlockFace hitBlockFace) { this(hitPosition, null, hitBlockFace, null); } @@ -56,7 +58,7 @@ public class RayTraceResult { * @param hitBlock the hit block * @param hitBlockFace the hit block face */ - public RayTraceResult(Vector hitPosition, Block hitBlock, BlockFace hitBlockFace) { + public RayTraceResult(@NotNull Vector hitPosition, @Nullable Block hitBlock, @Nullable BlockFace hitBlockFace) { this(hitPosition, hitBlock, hitBlockFace, null); } @@ -66,7 +68,7 @@ public class RayTraceResult { * @param hitPosition the hit position * @param hitEntity the hit entity */ - public RayTraceResult(Vector hitPosition, Entity hitEntity) { + public RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity) { this(hitPosition, null, null, hitEntity); } @@ -77,7 +79,7 @@ public class RayTraceResult { * @param hitEntity the hit entity * @param hitBlockFace the hit block face */ - public RayTraceResult(Vector hitPosition, Entity hitEntity, BlockFace hitBlockFace) { + public RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity, @Nullable BlockFace hitBlockFace) { this(hitPosition, null, hitBlockFace, hitEntity); } @@ -86,6 +88,7 @@ public class RayTraceResult { * * @return a copy of the exact hit position */ + @NotNull public Vector getHitPosition() { return hitPosition.clone(); } @@ -95,6 +98,7 @@ public class RayTraceResult { * * @return the hit block, or null if not available */ + @Nullable public Block getHitBlock() { return hitBlock; } @@ -104,6 +108,7 @@ public class RayTraceResult { * * @return the hit block face, or null if not available */ + @Nullable public BlockFace getHitBlockFace() { return hitBlockFace; } @@ -113,6 +118,7 @@ public class RayTraceResult { * * @return the hit entity, or null if not available */ + @Nullable public Entity getHitEntity() { return hitEntity; } diff --git a/paper-api/src/main/java/org/bukkit/util/StringUtil.java b/paper-api/src/main/java/org/bukkit/util/StringUtil.java index 7e7939306b..458d5ebdf6 100644 --- a/paper-api/src/main/java/org/bukkit/util/StringUtil.java +++ b/paper-api/src/main/java/org/bukkit/util/StringUtil.java @@ -2,6 +2,7 @@ package org.bukkit.util; import java.util.Collection; import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; public class StringUtil { @@ -22,7 +23,8 @@ public class StringUtil { * @throws IllegalArgumentException if originals contains a null element. * Note: the collection may be modified before this is thrown */ - public static > T copyPartialMatches(final String token, final Iterable originals, final T collection) throws UnsupportedOperationException, IllegalArgumentException { + @NotNull + public static > T copyPartialMatches(@NotNull final String token, @NotNull final Iterable originals, @NotNull final T collection) throws UnsupportedOperationException, IllegalArgumentException { Validate.notNull(token, "Search token cannot be null"); Validate.notNull(collection, "Collection cannot be null"); Validate.notNull(originals, "Originals cannot be null"); @@ -48,7 +50,7 @@ public class StringUtil { * @throws NullPointerException if prefix is null * @throws IllegalArgumentException if string is null */ - public static boolean startsWithIgnoreCase(final String string, final String prefix) throws IllegalArgumentException, NullPointerException { + public static boolean startsWithIgnoreCase(@NotNull final String string, @NotNull final String prefix) throws IllegalArgumentException, NullPointerException { Validate.notNull(string, "Cannot check a null string for a match"); if (string.length() < prefix.length()) { return false; diff --git a/paper-api/src/main/java/org/bukkit/util/Vector.java b/paper-api/src/main/java/org/bukkit/util/Vector.java index e1d8d2b340..b218a1dc8d 100644 --- a/paper-api/src/main/java/org/bukkit/util/Vector.java +++ b/paper-api/src/main/java/org/bukkit/util/Vector.java @@ -8,6 +8,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; +import org.jetbrains.annotations.NotNull; /** * Represents a mutable vector. Because the components of Vectors are mutable, @@ -84,7 +85,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param vec The other vector * @return the same vector */ - public Vector add(Vector vec) { + @NotNull + public Vector add(@NotNull Vector vec) { x += vec.x; y += vec.y; z += vec.z; @@ -97,7 +99,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param vec The other vector * @return the same vector */ - public Vector subtract(Vector vec) { + @NotNull + public Vector subtract(@NotNull Vector vec) { x -= vec.x; y -= vec.y; z -= vec.z; @@ -110,7 +113,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param vec The other vector * @return the same vector */ - public Vector multiply(Vector vec) { + @NotNull + public Vector multiply(@NotNull Vector vec) { x *= vec.x; y *= vec.y; z *= vec.z; @@ -123,7 +127,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param vec The other vector * @return the same vector */ - public Vector divide(Vector vec) { + @NotNull + public Vector divide(@NotNull Vector vec) { x /= vec.x; y /= vec.y; z /= vec.z; @@ -136,7 +141,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param vec The other vector * @return the same vector */ - public Vector copy(Vector vec) { + @NotNull + public Vector copy(@NotNull Vector vec) { x = vec.x; y = vec.y; z = vec.z; @@ -175,7 +181,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param o The other vector * @return the distance */ - public double distance(Vector o) { + public double distance(@NotNull Vector o) { return Math.sqrt(NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z)); } @@ -185,7 +191,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param o The other vector * @return the distance */ - public double distanceSquared(Vector o) { + public double distanceSquared(@NotNull Vector o) { return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z); } @@ -195,7 +201,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param other The other vector * @return angle in radians */ - public float angle(Vector other) { + public float angle(@NotNull Vector other) { double dot = dot(other) / (length() * other.length()); return (float) Math.acos(dot); @@ -207,7 +213,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param other The other vector * @return this same vector (now a midpoint) */ - public Vector midpoint(Vector other) { + @NotNull + public Vector midpoint(@NotNull Vector other) { x = (x + other.x) / 2; y = (y + other.y) / 2; z = (z + other.z) / 2; @@ -220,7 +227,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param other The other vector * @return a new midpoint vector */ - public Vector getMidpoint(Vector other) { + @NotNull + public Vector getMidpoint(@NotNull Vector other) { double x = (this.x + other.x) / 2; double y = (this.y + other.y) / 2; double z = (this.z + other.z) / 2; @@ -234,6 +242,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param m The factor * @return the same vector */ + @NotNull public Vector multiply(int m) { x *= m; y *= m; @@ -248,6 +257,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param m The factor * @return the same vector */ + @NotNull public Vector multiply(double m) { x *= m; y *= m; @@ -262,6 +272,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param m The factor * @return the same vector */ + @NotNull public Vector multiply(float m) { x *= m; y *= m; @@ -276,7 +287,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param other The other vector * @return dot product */ - public double dot(Vector other) { + public double dot(@NotNull Vector other) { return x * other.x + y * other.y + z * other.z; } @@ -292,7 +303,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param o The other vector * @return the same vector */ - public Vector crossProduct(Vector o) { + @NotNull + public Vector crossProduct(@NotNull Vector o) { double newX = y * o.z - o.y * z; double newY = z * o.x - o.z * x; double newZ = x * o.y - o.x * y; @@ -315,7 +327,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param o The other vector * @return a new vector */ - public Vector getCrossProduct(Vector o) { + @NotNull + public Vector getCrossProduct(@NotNull Vector o) { double x = this.y * o.z - o.y * this.z; double y = this.z * o.x - o.z * this.x; double z = this.x * o.y - o.x * this.y; @@ -327,6 +340,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * * @return the same vector */ + @NotNull public Vector normalize() { double length = length(); @@ -342,6 +356,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * * @return the same vector */ + @NotNull public Vector zero() { x = 0; y = 0; @@ -359,7 +374,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param max Maximum vector * @return whether this vector is in the AABB */ - public boolean isInAABB(Vector min, Vector max) { + public boolean isInAABB(@NotNull Vector min, @NotNull Vector max) { return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; } @@ -370,7 +385,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param radius Sphere radius * @return whether this vector is in the sphere */ - public boolean isInSphere(Vector origin, double radius) { + public boolean isInSphere(@NotNull Vector origin, double radius) { return (NumberConversions.square(origin.x - x) + NumberConversions.square(origin.y - y) + NumberConversions.square(origin.z - z)) <= NumberConversions.square(radius); } @@ -395,6 +410,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * in radians * @return the same vector */ + @NotNull public Vector rotateAroundX(double angle) { double angleCos = Math.cos(angle); double angleSin = Math.sin(angle); @@ -416,6 +432,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * in radians * @return the same vector */ + @NotNull public Vector rotateAroundY(double angle) { double angleCos = Math.cos(angle); double angleSin = Math.sin(angle); @@ -437,6 +454,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * in radians * @return the same vector */ + @NotNull public Vector rotateAroundZ(double angle) { double angleCos = Math.cos(angle); double angleSin = Math.sin(angle); @@ -467,7 +485,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @throws IllegalArgumentException if the provided axis vector instance is * null */ - public Vector rotateAroundAxis(Vector axis, double angle) throws IllegalArgumentException { + @NotNull + public Vector rotateAroundAxis(@NotNull Vector axis, double angle) throws IllegalArgumentException { Preconditions.checkArgument(axis != null, "The provided axis vector was null"); return rotateAroundNonUnitAxis(axis.isNormalized() ? axis : axis.clone().normalize(), angle); @@ -493,7 +512,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @throws IllegalArgumentException if the provided axis vector instance is * null */ - public Vector rotateAroundNonUnitAxis(Vector axis, double angle) throws IllegalArgumentException { + @NotNull + public Vector rotateAroundNonUnitAxis(@NotNull Vector axis, double angle) throws IllegalArgumentException { Preconditions.checkArgument(axis != null, "The provided axis vector was null"); double x = getX(), y = getY(), z = getZ(); @@ -579,6 +599,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param x The new X component. * @return This vector. */ + @NotNull public Vector setX(int x) { this.x = x; return this; @@ -590,6 +611,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param x The new X component. * @return This vector. */ + @NotNull public Vector setX(double x) { this.x = x; return this; @@ -601,6 +623,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param x The new X component. * @return This vector. */ + @NotNull public Vector setX(float x) { this.x = x; return this; @@ -612,6 +635,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param y The new Y component. * @return This vector. */ + @NotNull public Vector setY(int y) { this.y = y; return this; @@ -623,6 +647,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param y The new Y component. * @return This vector. */ + @NotNull public Vector setY(double y) { this.y = y; return this; @@ -634,6 +659,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param y The new Y component. * @return This vector. */ + @NotNull public Vector setY(float y) { this.y = y; return this; @@ -645,6 +671,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param z The new Z component. * @return This vector. */ + @NotNull public Vector setZ(int z) { this.z = z; return this; @@ -656,6 +683,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param z The new Z component. * @return This vector. */ + @NotNull public Vector setZ(double z) { this.z = z; return this; @@ -667,6 +695,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param z The new Z component. * @return This vector. */ + @NotNull public Vector setZ(float z) { this.z = z; return this; @@ -710,6 +739,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * * @return vector */ + @NotNull @Override public Vector clone() { try { @@ -733,7 +763,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param world The world to link the location to. * @return the location */ - public Location toLocation(World world) { + @NotNull + public Location toLocation(@NotNull World world) { return new Location(world, x, y, z); } @@ -745,7 +776,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param pitch The desired pitch. * @return the location */ - public Location toLocation(World world, float yaw, float pitch) { + @NotNull + public Location toLocation(@NotNull World world, float yaw, float pitch) { return new Location(world, x, y, z, yaw, pitch); } @@ -754,6 +786,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * * @return A block vector. */ + @NotNull public BlockVector toBlockVector() { return new BlockVector(x, y, z); } @@ -785,7 +818,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param v2 The second vector. * @return minimum */ - public static Vector getMinimum(Vector v1, Vector v2) { + @NotNull + public static Vector getMinimum(@NotNull Vector v1, @NotNull Vector v2) { return new Vector(Math.min(v1.x, v2.x), Math.min(v1.y, v2.y), Math.min(v1.z, v2.z)); } @@ -796,7 +830,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @param v2 The second vector. * @return maximum */ - public static Vector getMaximum(Vector v1, Vector v2) { + @NotNull + public static Vector getMaximum(@NotNull Vector v1, @NotNull Vector v2) { return new Vector(Math.max(v1.x, v2.x), Math.max(v1.y, v2.y), Math.max(v1.z, v2.z)); } @@ -806,10 +841,12 @@ public class Vector implements Cloneable, ConfigurationSerializable { * * @return A random vector. */ + @NotNull public static Vector getRandom() { return new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()); } + @NotNull public Map serialize() { Map result = new LinkedHashMap(); @@ -820,7 +857,8 @@ public class Vector implements Cloneable, ConfigurationSerializable { return result; } - public static Vector deserialize(Map args) { + @NotNull + public static Vector deserialize(@NotNull Map args) { double x = 0; double y = 0; double z = 0; diff --git a/paper-api/src/main/java/org/bukkit/util/io/Wrapper.java b/paper-api/src/main/java/org/bukkit/util/io/Wrapper.java index e45605b327..51dd951b07 100644 --- a/paper-api/src/main/java/org/bukkit/util/io/Wrapper.java +++ b/paper-api/src/main/java/org/bukkit/util/io/Wrapper.java @@ -7,17 +7,18 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.NotNull; class Wrapper & Serializable> implements Serializable { private static final long serialVersionUID = -986209235411767547L; final T map; - static Wrapper> newWrapper(ConfigurationSerializable obj) { + static Wrapper> newWrapper(@NotNull ConfigurationSerializable obj) { return new Wrapper>(ImmutableMap.builder().put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(obj.getClass())).putAll(obj.serialize()).build()); } - private Wrapper(T map) { + private Wrapper(@NotNull T map) { this.map = map; } } diff --git a/paper-api/src/main/java/org/bukkit/util/noise/OctaveGenerator.java b/paper-api/src/main/java/org/bukkit/util/noise/OctaveGenerator.java index a87304ba6a..618ed706e2 100644 --- a/paper-api/src/main/java/org/bukkit/util/noise/OctaveGenerator.java +++ b/paper-api/src/main/java/org/bukkit/util/noise/OctaveGenerator.java @@ -1,15 +1,18 @@ package org.bukkit.util.noise; +import org.jetbrains.annotations.NotNull; + /** * Creates noise using unbiased octaves */ public abstract class OctaveGenerator { + @NotNull protected final NoiseGenerator[] octaves; protected double xScale = 1; protected double yScale = 1; protected double zScale = 1; - protected OctaveGenerator(NoiseGenerator[] octaves) { + protected OctaveGenerator(@NotNull NoiseGenerator[] octaves) { this.octaves = octaves; } @@ -86,6 +89,7 @@ public abstract class OctaveGenerator { * * @return Clone of the individual octaves */ + @NotNull public NoiseGenerator[] getOctaves() { return octaves.clone(); } diff --git a/paper-api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java b/paper-api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java index 858c3f13ad..f481286b85 100644 --- a/paper-api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java +++ b/paper-api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java @@ -2,6 +2,7 @@ package org.bukkit.util.noise; import java.util.Random; import org.bukkit.World; +import org.jetbrains.annotations.NotNull; /** * Generates noise using the "classic" perlin generator @@ -45,7 +46,7 @@ public class PerlinNoiseGenerator extends NoiseGenerator { * * @param world World to construct this generator for */ - public PerlinNoiseGenerator(World world) { + public PerlinNoiseGenerator(@NotNull World world) { this(new Random(world.getSeed())); } @@ -63,7 +64,7 @@ public class PerlinNoiseGenerator extends NoiseGenerator { * * @param rand Random to construct with */ - public PerlinNoiseGenerator(Random rand) { + public PerlinNoiseGenerator(@NotNull Random rand) { offsetX = rand.nextDouble() * 256; offsetY = rand.nextDouble() * 256; offsetZ = rand.nextDouble() * 256; @@ -123,6 +124,7 @@ public class PerlinNoiseGenerator extends NoiseGenerator { * * @return Singleton */ + @NotNull public static PerlinNoiseGenerator getInstance() { return instance; } diff --git a/paper-api/src/main/java/org/bukkit/util/noise/PerlinOctaveGenerator.java b/paper-api/src/main/java/org/bukkit/util/noise/PerlinOctaveGenerator.java index 55b7ad7e47..af7e01188e 100644 --- a/paper-api/src/main/java/org/bukkit/util/noise/PerlinOctaveGenerator.java +++ b/paper-api/src/main/java/org/bukkit/util/noise/PerlinOctaveGenerator.java @@ -2,6 +2,7 @@ package org.bukkit.util.noise; import java.util.Random; import org.bukkit.World; +import org.jetbrains.annotations.NotNull; /** * Creates perlin noise through unbiased octaves @@ -14,7 +15,7 @@ public class PerlinOctaveGenerator extends OctaveGenerator { * @param world World to construct this generator for * @param octaves Amount of octaves to create */ - public PerlinOctaveGenerator(World world, int octaves) { + public PerlinOctaveGenerator(@NotNull World world, int octaves) { this(new Random(world.getSeed()), octaves); } @@ -34,11 +35,12 @@ public class PerlinOctaveGenerator extends OctaveGenerator { * @param rand Random object to construct this generator for * @param octaves Amount of octaves to create */ - public PerlinOctaveGenerator(Random rand, int octaves) { + public PerlinOctaveGenerator(@NotNull Random rand, int octaves) { super(createOctaves(rand, octaves)); } - private static NoiseGenerator[] createOctaves(Random rand, int octaves) { + @NotNull + private static NoiseGenerator[] createOctaves(@NotNull Random rand, int octaves) { NoiseGenerator[] result = new NoiseGenerator[octaves]; for (int i = 0; i < octaves; i++) { diff --git a/paper-api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java b/paper-api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java index 7dac89b065..850604a4de 100644 --- a/paper-api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java +++ b/paper-api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java @@ -2,6 +2,7 @@ package org.bukkit.util.noise; import java.util.Random; import org.bukkit.World; +import org.jetbrains.annotations.NotNull; /** * Generates simplex-based noise. @@ -53,7 +54,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator { * * @param world World to construct this generator for */ - public SimplexNoiseGenerator(World world) { + public SimplexNoiseGenerator(@NotNull World world) { this(new Random(world.getSeed())); } @@ -71,20 +72,20 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator { * * @param rand Random to construct with */ - public SimplexNoiseGenerator(Random rand) { + public SimplexNoiseGenerator(@NotNull Random rand) { super(rand); offsetW = rand.nextDouble() * 256; } - protected static double dot(int g[], double x, double y) { + protected static double dot(@NotNull int[] g, double x, double y) { return g[0] * x + g[1] * y; } - protected static double dot(int g[], double x, double y, double z) { + protected static double dot(@NotNull int[] g, double x, double y, double z) { return g[0] * x + g[1] * y + g[2] * z; } - protected static double dot(int g[], double x, double y, double z, double w) { + protected static double dot(@NotNull int[] g, double x, double y, double z, double w) { return g[0] * x + g[1] * y + g[2] * z + g[3] * w; } @@ -514,6 +515,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator { * * @return Singleton */ + @NotNull public static SimplexNoiseGenerator getInstance() { return instance; } diff --git a/paper-api/src/main/java/org/bukkit/util/noise/SimplexOctaveGenerator.java b/paper-api/src/main/java/org/bukkit/util/noise/SimplexOctaveGenerator.java index 61e66aa222..6cc15431e1 100644 --- a/paper-api/src/main/java/org/bukkit/util/noise/SimplexOctaveGenerator.java +++ b/paper-api/src/main/java/org/bukkit/util/noise/SimplexOctaveGenerator.java @@ -2,6 +2,7 @@ package org.bukkit.util.noise; import java.util.Random; import org.bukkit.World; +import org.jetbrains.annotations.NotNull; /** * Creates simplex noise through unbiased octaves @@ -15,7 +16,7 @@ public class SimplexOctaveGenerator extends OctaveGenerator { * @param world World to construct this generator for * @param octaves Amount of octaves to create */ - public SimplexOctaveGenerator(World world, int octaves) { + public SimplexOctaveGenerator(@NotNull World world, int octaves) { this(new Random(world.getSeed()), octaves); } @@ -35,7 +36,7 @@ public class SimplexOctaveGenerator extends OctaveGenerator { * @param rand Random object to construct this generator for * @param octaves Amount of octaves to create */ - public SimplexOctaveGenerator(Random rand, int octaves) { + public SimplexOctaveGenerator(@NotNull Random rand, int octaves) { super(createOctaves(rand, octaves)); } @@ -117,7 +118,8 @@ public class SimplexOctaveGenerator extends OctaveGenerator { return result; } - private static NoiseGenerator[] createOctaves(Random rand, int octaves) { + @NotNull + private static NoiseGenerator[] createOctaves(@NotNull Random rand, int octaves) { NoiseGenerator[] result = new NoiseGenerator[octaves]; for (int i = 0; i < octaves; i++) { diff --git a/paper-api/src/main/java/org/bukkit/util/permissions/BroadcastPermissions.java b/paper-api/src/main/java/org/bukkit/util/permissions/BroadcastPermissions.java index 092370e98a..54bc413700 100644 --- a/paper-api/src/main/java/org/bukkit/util/permissions/BroadcastPermissions.java +++ b/paper-api/src/main/java/org/bukkit/util/permissions/BroadcastPermissions.java @@ -2,6 +2,7 @@ package org.bukkit.util.permissions; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.jetbrains.annotations.NotNull; public final class BroadcastPermissions { private static final String ROOT = "bukkit.broadcast"; @@ -9,7 +10,8 @@ public final class BroadcastPermissions { private BroadcastPermissions() {} - public static Permission registerPermissions(Permission parent) { + @NotNull + public static Permission registerPermissions(@NotNull Permission parent) { Permission broadcasts = DefaultPermissions.registerPermission(ROOT, "Allows the user to receive all broadcast messages", parent); DefaultPermissions.registerPermission(PREFIX + "admin", "Allows the user to receive administrative broadcasts", PermissionDefault.OP, broadcasts); diff --git a/paper-api/src/main/java/org/bukkit/util/permissions/CommandPermissions.java b/paper-api/src/main/java/org/bukkit/util/permissions/CommandPermissions.java index 619646eedd..7763d6101a 100644 --- a/paper-api/src/main/java/org/bukkit/util/permissions/CommandPermissions.java +++ b/paper-api/src/main/java/org/bukkit/util/permissions/CommandPermissions.java @@ -2,6 +2,7 @@ package org.bukkit.util.permissions; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.jetbrains.annotations.NotNull; public final class CommandPermissions { private static final String ROOT = "bukkit.command"; @@ -9,7 +10,8 @@ public final class CommandPermissions { private CommandPermissions() {} - public static Permission registerPermissions(Permission parent) { + @NotNull + public static Permission registerPermissions(@NotNull Permission parent) { Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all CraftBukkit commands", parent); DefaultPermissions.registerPermission(PREFIX + "help", "Allows the user to view the vanilla help menu", PermissionDefault.TRUE, commands); diff --git a/paper-api/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java b/paper-api/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java index 8c0df8e42c..e1a4ddf2c0 100644 --- a/paper-api/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java +++ b/paper-api/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java @@ -4,6 +4,8 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public final class DefaultPermissions { private static final String ROOT = "craftbukkit"; @@ -11,17 +13,20 @@ public final class DefaultPermissions { private DefaultPermissions() {} - public static Permission registerPermission(Permission perm) { + @NotNull + public static Permission registerPermission(@NotNull Permission perm) { return registerPermission(perm, true); } - public static Permission registerPermission(Permission perm, boolean withLegacy) { + @NotNull + public static Permission registerPermission(@NotNull Permission perm, boolean withLegacy) { Permission result = perm; try { Bukkit.getPluginManager().addPermission(perm); } catch (IllegalArgumentException ex) { result = Bukkit.getPluginManager().getPermission(perm.getName()); + assert result != null; } if (withLegacy) { @@ -33,39 +38,46 @@ public final class DefaultPermissions { return result; } - public static Permission registerPermission(Permission perm, Permission parent) { + @NotNull + public static Permission registerPermission(@NotNull Permission perm, @NotNull Permission parent) { parent.getChildren().put(perm.getName(), true); return registerPermission(perm); } - public static Permission registerPermission(String name, String desc) { + @NotNull + public static Permission registerPermission(@NotNull String name, @Nullable String desc) { Permission perm = registerPermission(new Permission(name, desc)); return perm; } - public static Permission registerPermission(String name, String desc, Permission parent) { + @NotNull + public static Permission registerPermission(@NotNull String name, @Nullable String desc, @NotNull Permission parent) { Permission perm = registerPermission(name, desc); parent.getChildren().put(perm.getName(), true); return perm; } - public static Permission registerPermission(String name, String desc, PermissionDefault def) { + @NotNull + public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def) { Permission perm = registerPermission(new Permission(name, desc, def)); return perm; } - public static Permission registerPermission(String name, String desc, PermissionDefault def, Permission parent) { + @NotNull + public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @NotNull Permission parent) { Permission perm = registerPermission(name, desc, def); parent.getChildren().put(perm.getName(), true); return perm; } - public static Permission registerPermission(String name, String desc, PermissionDefault def, Map children) { + @NotNull + public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map children) { Permission perm = registerPermission(new Permission(name, desc, def, children)); return perm; } - public static Permission registerPermission(String name, String desc, PermissionDefault def, Map children, Permission parent) { + @NotNull + public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map children, @NotNull Permission parent) { Permission perm = registerPermission(name, desc, def, children); parent.getChildren().put(perm.getName(), true); return perm; diff --git a/paper-api/src/test/java/org/bukkit/AnnotationTest.java b/paper-api/src/test/java/org/bukkit/AnnotationTest.java new file mode 100644 index 0000000000..dfd6e137c9 --- /dev/null +++ b/paper-api/src/test/java/org/bukkit/AnnotationTest.java @@ -0,0 +1,247 @@ +package org.bukkit; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; +import org.junit.Test; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.AnnotationNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.ParameterNode; + +public class AnnotationTest { + + private static final String[] ACCEPTED_ANNOTATIONS = { + "Lorg/jetbrains/annotations/Nullable;", + "Lorg/jetbrains/annotations/NotNull;", + "Lorg/jetbrains/annotations/Contract;", + "Lorg/bukkit/UndefinedNullability;" + }; + + private static final String[] EXCLUDED_CLASSES = { + // Internal technical classes + "org/bukkit/plugin/java/JavaPluginLoader", + "org/bukkit/util/io/BukkitObjectInputStream", + "org/bukkit/util/io/BukkitObjectOutputStream", + "org/bukkit/util/io/Wrapper", + "org/bukkit/plugin/java/PluginClassLoader", + // Generic functional interface + "org/bukkit/util/Consumer" + }; + + @Test + public void testAll() throws IOException, URISyntaxException { + URL loc = Bukkit.class.getProtectionDomain().getCodeSource().getLocation(); + File file = new File(loc.toURI()); + + // Running from jar is not supported yet + Assert.assertTrue("code must be in a directory", file.isDirectory()); + + final HashMap foundClasses = new HashMap<>(); + collectClasses(file, foundClasses); + + final ArrayList errors = new ArrayList<>(); + + for (ClassNode clazz : foundClasses.values()) { + if (!isClassIncluded(clazz, foundClasses)) { + continue; + } + + for (MethodNode method : clazz.methods) { + if (!isMethodIncluded(clazz, method, foundClasses)) { + continue; + } + + if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) { + warn(errors, clazz, method, "return value"); + } + + Type[] paramTypes = Type.getArgumentTypes(method.desc); + List parameters = method.parameters; + + for (int i = 0; i < paramTypes.length; i++) { + if (mustBeAnnotated(paramTypes[i]) && !isWellAnnotated(method.invisibleParameterAnnotations == null ? null : method.invisibleParameterAnnotations[i])) { + ParameterNode paramNode = parameters == null ? null : parameters.get(i); + String paramName = paramNode == null ? null : paramNode.name; + + warn(errors, clazz, method, "parameter " + i + (paramName == null ? "" : ": " + paramName)); + } + } + } + } + + if (errors.isEmpty()) { + // Success + return; + } + + Collections.sort(errors); + + System.out.println(errors.size() + " missing annotation(s):"); + for (String message : errors) { + System.out.print("\t"); + System.out.println(message); + } + + Assert.fail("There " + errors.size() + " are missing annotation(s)"); + } + + private static void collectClasses(@NotNull File from, @NotNull Map to) throws IOException { + if (from.isDirectory()) { + final File[] files = from.listFiles(); + assert files != null; + + for (File file : files) { + collectClasses(file, to); + } + return; + } + + if (!from.getName().endsWith(".class")) { + return; + } + + try (FileInputStream in = new FileInputStream(from)) { + final ClassReader cr = new ClassReader(in); + + final ClassNode node = new ClassNode(); + cr.accept(node, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + + to.put(node.name, node); + } + } + + private static boolean isClassIncluded(@NotNull ClassNode clazz, @NotNull Map allClasses) { + // Exclude private, synthetic or deprecated classes and annotations, since their members can't be null + if ((clazz.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_DEPRECATED | Opcodes.ACC_ANNOTATION)) != 0) { + return false; + } + + if (isSubclassOf(clazz, "org/bukkit/material/MaterialData", allClasses)) { + // MaterialData is deprecated and all of its subclasses are excluded + return false; + } + + if (isSubclassOf(clazz, "java/lang/Exception", allClasses) + || isSubclassOf(clazz, "java/lang/RuntimeException", allClasses)) { + // Exceptions are excluded + return false; + } + + for (String excludedClass : EXCLUDED_CLASSES) { + if (excludedClass.equals(clazz.name)) { + return false; + } + } + + return true; + } + + private static boolean isMethodIncluded(@NotNull ClassNode clazz, @NotNull MethodNode method, @NotNull Map allClasses) { + // Exclude private, synthetic and deprecated methods + if ((method.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_DEPRECATED)) != 0) { + return false; + } + + // Exclude Java methods + if (is(method, "toString", 0) || is(method, "clone", 0) || is(method, "equals", 1)) { + return false; + } + + // Exclude generated Enum methods + if (isSubclassOf(clazz, "java/lang/Enum", allClasses) && (is(method, "values", 0) || is(method, "valueOf", 1))) { + return false; + } + + // Anonymous classes have generated constructors, which can't be annotated nor invoked + if ("".equals(method.name) && isAnonymous(clazz)) { + return false; + } + + return true; + } + + private static boolean isWellAnnotated(@Nullable List annotations) { + if (annotations == null) { + return false; + } + + for (AnnotationNode node : annotations) { + for (String acceptedAnnotation : ACCEPTED_ANNOTATIONS) { + if (acceptedAnnotation.equals(node.desc)) { + return true; + } + } + } + + return false; + } + + private static boolean mustBeAnnotated(@NotNull Type type) { + return type.getSort() == Type.ARRAY || type.getSort() == Type.OBJECT; + } + + private static boolean is(@NotNull MethodNode method, @NotNull String name, int parameters) { + final List params = method.parameters; + return method.name.equals(name) && (params == null || params.size() == parameters); + } + + /** + * @return true if given class is anonymous + */ + private static boolean isAnonymous(@NotNull ClassNode clazz) { + final String name = clazz.name; + if (name == null) { + return false; + } + final int nestedSeparator = name.lastIndexOf('$'); + if (nestedSeparator == -1 || nestedSeparator + 1 == name.length()) { + return false; + } + + // Nested classes have purely numeric names. Java classes can't begin with a number, + // so if first character is a number, the class must be anonymous + final char c = name.charAt(nestedSeparator + 1); + return c >= '0' && c <= '9'; + } + + private static boolean isSubclassOf(@NotNull ClassNode what, @NotNull String ofWhat, @NotNull Map allClasses) { + if (ofWhat.equals(what.name) + // Not only optimization: Super class may not be present in allClasses, so it is checked here + || ofWhat.equals(what.superName)) { + return true; + } + + final ClassNode parent = allClasses.get(what.superName); + if (parent != null && isSubclassOf(parent, ofWhat, allClasses)) { + return true; + } + + for (String superInterface : what.interfaces) { + final ClassNode interfaceParent = allClasses.get(superInterface); + if (interfaceParent != null && isSubclassOf(interfaceParent, ofWhat, allClasses)) { + return true; + } + } + + return false; + } + + private static void warn(@NotNull Collection out, @NotNull ClassNode clazz, @NotNull MethodNode method, @NotNull String description) { + out.add(clazz.name + " \t" + method.name + " \t" + description); + } +}