Fix more incorrect array nullability annotations (#11836)

This commit is contained in:
Jake Potrebic
2024-12-27 13:24:16 -08:00
committed by GitHub
parent 13c94e40ad
commit ca8709b30f
27 changed files with 61 additions and 77 deletions

View File

@ -304,8 +304,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
return new PlayerIterator();
}
@NotNull
protected Object[] getOnlinePlayers() {
protected @NotNull Object @NotNull [] getOnlinePlayers() {
return Bukkit.getOnlinePlayers().toArray();
}

View File

@ -1184,7 +1184,7 @@ public final class Bukkit {
* @return the {@link Recipe} resulting from the given crafting matrix.
*/
@Nullable
public static Recipe getCraftingRecipe(@NotNull ItemStack[] craftingMatrix, @NotNull World world) {
public static Recipe getCraftingRecipe(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world) {
return server.getCraftingRecipe(craftingMatrix, world);
}
@ -1213,7 +1213,7 @@ public final class Bukkit {
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public static ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player) {
public static ItemCraftResult craftItemResult(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world, @NotNull Player player) {
return server.craftItemResult(craftingMatrix, world, player);
}
@ -1235,7 +1235,7 @@ public final class Bukkit {
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public static ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world) {
public static ItemCraftResult craftItemResult(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world) {
return server.craftItemResult(craftingMatrix, world);
}
@ -1266,7 +1266,7 @@ public final class Bukkit {
* an ItemStack of {@link Material#AIR} is returned.
*/
@NotNull
public static ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player) {
public static ItemStack craftItem(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world, @NotNull Player player) {
return server.craftItem(craftingMatrix, world, player);
}
@ -1289,7 +1289,7 @@ public final class Bukkit {
* an ItemStack of {@link Material#AIR} is returned.
*/
@NotNull
public static ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world) {
public static ItemStack craftItem(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world) {
return server.craftItem(craftingMatrix, world);
}
@ -1756,8 +1756,7 @@ public final class Bukkit {
*
* @return an array containing all previous players
*/
@NotNull
public static OfflinePlayer[] getOfflinePlayers() {
public static @NotNull OfflinePlayer @NotNull [] getOfflinePlayers() {
return server.getOfflinePlayers();
}
@ -2404,8 +2403,7 @@ public final class Bukkit {
* Gets the current server TPS
* @return current server TPS (1m, 5m, 15m in Paper-Server)
*/
@NotNull
public static double[] getTPS() {
public static double @NotNull [] getTPS() {
return server.getTPS();
}
@ -2414,8 +2412,7 @@ public final class Bukkit {
*
* @return A sample of the servers last tick times (in nanos)
*/
@NotNull
public static long[] getTickTimes() {
public static long @NotNull [] getTickTimes() {
return server.getTickTimes();
}

View File

@ -133,8 +133,7 @@ public interface Chunk extends PersistentDataHolder {
*
* @return The entities.
*/
@NotNull
Entity[] getEntities();
@NotNull Entity @NotNull [] getEntities();
/**
* Get a list of all tile entities in the chunk.
@ -143,7 +142,7 @@ public interface Chunk extends PersistentDataHolder {
*/
@NotNull
// Paper start
default BlockState[] getTileEntities() {
default BlockState @NotNull [] getTileEntities() {
return getTileEntities(true);
}
@ -154,7 +153,7 @@ public interface Chunk extends PersistentDataHolder {
* @return The tile entities.
*/
@NotNull
BlockState[] getTileEntities(boolean useSnapshot);
BlockState @NotNull [] getTileEntities(boolean useSnapshot);
/**
* Get a list of all tile entities that match a given predicate in the chunk.

View File

@ -1018,7 +1018,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return the {@link Recipe} resulting from the given crafting matrix.
*/
@Nullable
public Recipe getCraftingRecipe(@NotNull ItemStack[] craftingMatrix, @NotNull World world);
public Recipe getCraftingRecipe(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
@ -1046,7 +1046,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* an ItemStack of {@link Material#AIR} is returned.
*/
@NotNull
public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player);
public ItemStack craftItem(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world, @NotNull Player player);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
@ -1067,7 +1067,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* an ItemStack of {@link Material#AIR} is returned.
*/
@NotNull
public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world);
public ItemStack craftItem(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
@ -1094,7 +1094,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player);
public ItemCraftResult craftItemResult(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world, @NotNull Player player);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
@ -1114,7 +1114,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world);
public ItemCraftResult craftItemResult(@NotNull ItemStack @NotNull [] craftingMatrix, @NotNull World world);
/**
* Get an iterator through the list of crafting recipes.
@ -1503,8 +1503,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*
* @return an array containing all previous players
*/
@NotNull
public OfflinePlayer[] getOfflinePlayers();
public @NotNull OfflinePlayer @NotNull [] getOfflinePlayers();
/**
* Gets the {@link Messenger} responsible for this server.
@ -2057,16 +2056,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*
* @return current server TPS (1m, 5m, 15m in Paper-Server)
*/
@NotNull
public double[] getTPS();
public double @NotNull [] getTPS();
/**
* Get a sample of the servers last tick times (in nanos)
*
* @return A sample of the servers last tick times (in nanos)
*/
@NotNull
long[] getTickTimes();
long @NotNull [] getTickTimes();
/**
* Get the average tick time (in millis)

View File

@ -346,8 +346,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*
* @return Chunk[] containing all loaded chunks
*/
@NotNull
public Chunk[] getLoadedChunks();
public @NotNull Chunk @NotNull [] getLoadedChunks();
/**
* Loads the specified {@link Chunk}.
@ -3563,8 +3562,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*
* @return An array of {@link GameRule} names.
*/
@NotNull
public String[] getGameRules();
public @NotNull String @NotNull [] getGameRules();
/**
* Gets the current state of the specified rule

View File

@ -66,7 +66,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(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args);
public abstract boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String @NotNull [] args);
/**
* Executed on tab completion for this command, returning a list of
@ -80,7 +80,7 @@ public abstract class Command {
* @throws IllegalArgumentException if sender, alias, or args is null
*/
@NotNull
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String @NotNull [] args) throws IllegalArgumentException {
return tabComplete0(sender, alias, args, null);
}
@ -97,7 +97,7 @@ public abstract class Command {
* @throws IllegalArgumentException if sender, alias, or args is null
*/
@NotNull
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String @NotNull [] args, @Nullable Location location) throws IllegalArgumentException {
return tabComplete(sender, alias, args);
}

View File

@ -19,5 +19,5 @@ public interface CommandExecutor {
* @param args Passed command arguments
* @return true if a valid command, otherwise false
*/
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args);
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args);
}

View File

@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
public interface MessageCommandSender extends CommandSender {
@Override
default void sendMessage(@NotNull String[] messages) {
default void sendMessage(@NotNull String @NotNull [] messages) {
for (String message : messages) {
sendMessage(message);
}
@ -34,7 +34,7 @@ public interface MessageCommandSender extends CommandSender {
}
@Override
default void sendMessage(@Nullable UUID sender, @NotNull String[] messages) {
default void sendMessage(@Nullable UUID sender, @NotNull String @NotNull [] messages) {
for (String message : messages) {
sendMessage(message);
}

View File

@ -18,8 +18,7 @@ public class MultipleCommandAlias extends Command {
*
* @return commands associated with alias
*/
@NotNull
public Command[] getCommands() {
public @NotNull Command @NotNull [] getCommands() {
return commands;
}

View File

@ -23,5 +23,5 @@ public interface TabCompleter {
* to default to the command executor
*/
@Nullable
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args);
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args);
}

View File

@ -2308,7 +2308,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* long.
*/
@Deprecated // Paper - adventure
public void setResourcePack(@NotNull String url, @Nullable byte[] hash);
public void setResourcePack(@NotNull String url, byte @Nullable [] hash);
/**
* Request that the player's client download and switch resource packs.
@ -2353,7 +2353,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* long.
*/
@Deprecated // Paper - adventure
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt);
public void setResourcePack(@NotNull String url, byte @Nullable [] hash, @Nullable String prompt);
// Paper start
/**
@ -2447,7 +2447,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @deprecated in favour of {@link #sendResourcePacks(net.kyori.adventure.resource.ResourcePackRequest)}
*/
@Deprecated // Paper - adventure
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, boolean force);
public void setResourcePack(@NotNull String url, byte @Nullable [] hash, boolean force);
/**
* Request that the player's client download and switch resource packs.
@ -2494,7 +2494,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @deprecated in favour of {@link #sendResourcePacks(net.kyori.adventure.resource.ResourcePackRequest)}
*/
@Deprecated // Paper
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force);
public void setResourcePack(@NotNull String url, byte @Nullable [] hash, @Nullable String prompt, boolean force);
// Paper start
/**
@ -2592,7 +2592,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @deprecated in favour of {@link #sendResourcePacks(net.kyori.adventure.resource.ResourcePackRequest)}
*/
@Deprecated // Paper - adventure
public void setResourcePack(@NotNull UUID id, @NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force);
public void setResourcePack(@NotNull UUID id, @NotNull String url, byte @Nullable [] hash, @Nullable String prompt, boolean force);
// Paper start
/**

View File

@ -203,8 +203,7 @@ public class HandlerList {
*
* @return the array of registered listeners
*/
@NotNull
public RegisteredListener[] getRegisteredListeners() {
public @NotNull RegisteredListener @NotNull [] getRegisteredListeners() {
RegisteredListener[] handlers;
while ((handlers = this.handlers) == null) bake(); // This prevents fringe cases of returning null
return handlers;

View File

@ -329,7 +329,7 @@ public interface EntityEquipment {
*
* @param items The items to set the armor as. Individual items may be null.
*/
void setArmorContents(@NotNull ItemStack[] items);
void setArmorContents(@NotNull ItemStack @NotNull [] items);
/**
* Clears the entity of all armor and held items

View File

@ -24,8 +24,7 @@ public interface ItemCraftResult {
*
* @return resulting matrix
*/
@NotNull
public ItemStack[] getResultingMatrix();
public @NotNull ItemStack @NotNull [] getResultingMatrix();
/**
* Gets the overflowed items for items that don't fit back into the crafting

View File

@ -744,8 +744,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
* @param bytes bytes representing an item in NBT
* @return ItemStack migrated to this version of Minecraft if needed.
*/
@NotNull
public static ItemStack deserializeBytes(@NotNull byte[] bytes) {
public static @NotNull ItemStack deserializeBytes(final byte @NotNull [] bytes) {
return org.bukkit.Bukkit.getUnsafe().deserializeItem(bytes);
}
@ -754,8 +753,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
* use the built in data converter instead of bukkits dangerous serialization system.
* @return bytes representing this item in NBT.
*/
@NotNull
public byte[] serializeAsBytes() {
public byte @NotNull [] serializeAsBytes() {
return org.bukkit.Bukkit.getUnsafe().serializeItem(this);
}

View File

@ -118,7 +118,7 @@ public interface PlayerInventory extends Inventory {
*
* @param items The ItemStacks to use as armour
*/
public void setArmorContents(@Nullable ItemStack[] items);
public void setArmorContents(@Nullable ItemStack @NotNull [] items);
/**
* Put the given ItemStacks into the extra slots
@ -127,7 +127,7 @@ public interface PlayerInventory extends Inventory {
*
* @param items The ItemStacks to use as extra
*/
public void setExtraContents(@Nullable ItemStack[] items);
public void setExtraContents(@Nullable ItemStack @NotNull [] items);
/**
* Put the given ItemStack into the helmet slot. This does not check if

View File

@ -234,8 +234,7 @@ public class ShapedRecipe extends CraftingRecipe {
* @return The recipe's shape.
* @throws NullPointerException when not set yet
*/
@NotNull
public String[] getShape() {
public @NotNull String @NotNull [] getShape() {
return rows.clone();
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.enchantments.EnchantmentOffer;
import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
/**
* An instance of {@link InventoryView} which provides extra methods related to
@ -36,8 +37,7 @@ public interface EnchantmentView extends InventoryView {
*
* @return The enchantment offers that are provided
*/
@NotNull
EnchantmentOffer[] getOffers();
@Nullable EnchantmentOffer @NotNull [] getOffers();
/**
* Sets the offers to provide to the player.
@ -45,5 +45,5 @@ public interface EnchantmentView extends InventoryView {
* @param offers The offers to provide
* @throws IllegalArgumentException if the array length isn't 3
*/
void setOffers(@NotNull EnchantmentOffer[] offers) throws IllegalArgumentException;
void setOffers(@Nullable EnchantmentOffer @NotNull [] offers) throws IllegalArgumentException;
}

View File

@ -112,7 +112,7 @@ public class MapFont {
private final int height;
private final boolean[] data;
public CharacterSprite(int width, int height, @NotNull boolean[] data) {
public CharacterSprite(int width, int height, boolean @NotNull [] data) {
this.width = width;
this.height = height;
this.data = data;

View File

@ -319,7 +319,7 @@ public abstract class JavaPlugin extends PluginBase {
* {@inheritDoc}
*/
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
return false;
}
@ -328,7 +328,7 @@ public abstract class JavaPlugin extends PluginBase {
*/
@Override
@Nullable
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String @NotNull [] args) {
return null;
}

View File

@ -229,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(@NotNull Player source, @NotNull String channel, @NotNull byte[] message);
public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, byte @NotNull [] message);
}

View File

@ -17,5 +17,5 @@ public interface PluginMessageListener {
* @param player Source of the message.
* @param message The raw message that was sent.
*/
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message);
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte @NotNull [] message);
}

View File

@ -27,7 +27,7 @@ public interface PluginMessageRecipient {
* @throws ChannelNotRegisteredException Thrown if the channel is not
* registered for this plugin.
*/
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message);
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, byte @NotNull [] message);
/**
* Gets a set containing all the Plugin Channels that this client is

View File

@ -439,7 +439,7 @@ public class StandardMessenger implements Messenger {
}
@Override
public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @NotNull byte[] message) {
public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, byte @NotNull [] message) {
if (source == null) {
throw new IllegalArgumentException("Player source cannot be null");
}
@ -534,7 +534,7 @@ public class StandardMessenger implements Messenger {
* @throws ChannelNotRegisteredException Thrown if the channel is not
* registered for this plugin.
*/
public static void validatePluginMessage(@NotNull Messenger messenger, @NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) {
public static void validatePluginMessage(@NotNull Messenger messenger, @NotNull Plugin source, @NotNull String channel, byte @NotNull [] message) {
if (messenger == null) {
throw new IllegalArgumentException("Messenger cannot be null");
}

View File

@ -150,7 +150,7 @@ public class ChatPaginator {
private int pageNumber;
private int totalPages;
public ChatPage(@NotNull String[] lines, int pageNumber, int totalPages) {
public ChatPage(@NotNull String @NotNull [] lines, int pageNumber, int totalPages) {
this.lines = lines;
this.pageNumber = pageNumber;
this.totalPages = totalPages;
@ -165,7 +165,7 @@ public class ChatPaginator {
}
@NotNull
public String[] getLines() {
public String @NotNull [] getLines() {
return lines;
}
}

View File

@ -12,7 +12,7 @@ public abstract class OctaveGenerator {
protected double yScale = 1;
protected double zScale = 1;
protected OctaveGenerator(@NotNull NoiseGenerator[] octaves) {
protected OctaveGenerator(@NotNull NoiseGenerator @NotNull [] octaves) {
this.octaves = octaves;
}
@ -90,7 +90,7 @@ public abstract class OctaveGenerator {
* @return Clone of the individual octaves
*/
@NotNull
public NoiseGenerator[] getOctaves() {
public NoiseGenerator @NotNull [] getOctaves() {
return octaves.clone();
}

View File

@ -78,15 +78,15 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator {
offsetW = rand.nextDouble() * 256;
}
protected static double dot(@NotNull int[] g, double x, double y) {
protected static double dot(int @NotNull [] g, double x, double y) {
return g[0] * x + g[1] * y;
}
protected static double dot(@NotNull int[] g, double x, double y, double z) {
protected static double dot(int @NotNull [] g, double x, double y, double z) {
return g[0] * x + g[1] * y + g[2] * z;
}
protected static double dot(@NotNull int[] g, double x, double y, double z, double w) {
protected static double dot(int @NotNull [] g, double x, double y, double z, double w) {
return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
}