From 0adf5876db692abb00caca9036c093df7fcd84a8 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 30 Sep 2024 11:44:36 -0700 Subject: [PATCH] Finish converting most of the undeprecated api to jspecify --- ...eEvent-and-CollarColorable-interface.patch | 7 +- patches/api/Add-FeatureFlag-API.patch | 20 +- patches/api/Add-FluidState-API.patch | 11 +- patches/api/Add-Lifecycle-Event-system.patch | 54 +++-- patches/api/Add-Moving-Piston-API.patch | 5 +- patches/api/Add-Position.patch | 50 ++-- ...gistryAccess-for-managing-registries.patch | 15 +- patches/api/Add-Shearable-API.patch | 5 +- patches/api/Add-Tick-TemporalUnit.patch | 28 ++- patches/api/Add-UnknownCommandEvent.patch | 23 +- patches/api/Add-basic-Datapack-API.patch | 34 +-- patches/api/Add-moon-phase-API.patch | 11 +- patches/api/Add-more-advancement-API.patch | 18 +- patches/api/Add-villager-reputation-API.patch | 10 +- patches/api/Adventure.patch | 53 ++-- patches/api/AsyncTabCompleteEvent.patch | 49 ++-- patches/api/Basic-PlayerProfile-API.patch | 94 ++++---- patches/api/Brigadier-based-command-API.patch | 179 +++++++------- patches/api/Bucketable-API.patch | 5 +- patches/api/Code-Generation.patch | 23 +- patches/api/Custom-Potion-Mixes.patch | 27 +-- patches/api/Expand-ArmorStand-API.patch | 34 +-- .../api/Expose-server-build-information.patch | 32 +-- patches/api/Fix-issues-with-recipe-API.patch | 5 +- patches/api/Friction-API.patch | 6 +- .../Improve-the-Saddle-API-for-Horses.patch | 13 +- ...ntroduce-registry-entry-and-builders.patch | 52 ++-- patches/api/ItemStack-Tooltip-API.patch | 18 +- patches/api/Leashable-API.patch | 7 +- patches/api/LootTable-API.patch | 7 +- ...w-accessible-directly-from-ItemStack.patch | 40 ++- patches/api/Misc-Utils.patch | 23 +- patches/api/Missing-Entity-API.patch | 10 +- patches/api/More-CommandBlock-API.patch | 7 +- patches/api/Paper-Plugins.patch | 228 ++++++++---------- .../api/PlayerAttemptPickupItemEvent.patch | 12 +- patches/api/Registry-Modification-API.patch | 126 +++++----- patches/api/Suspicious-Effect-Entry-API.patch | 14 +- patches/api/Tag-Lifecycle-Events.patch | 54 +++-- patches/api/add-number-format-api.patch | 37 +-- .../api/create-TileStateInventoryHolder.patch | 7 +- patches/api/improve-BanList-types.patch | 10 +- .../server/Brigadier-based-command-API.patch | 14 +- patches/server/More-CommandBlock-API.patch | 19 +- .../testplugin/brigtests/Registration.java | 4 +- 45 files changed, 782 insertions(+), 718 deletions(-) diff --git a/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch b/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch index 82546010c5d..9afb9edb7e0 100644 --- a/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch +++ b/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch @@ -14,11 +14,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.DyeColor; +import org.bukkit.entity.LivingEntity; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * Entities that can have their collars colored. + */ ++@NullMarked +public interface CollarColorable extends LivingEntity { + + /** @@ -26,14 +27,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the color of the collar + */ -+ @NotNull DyeColor getCollarColor(); ++ DyeColor getCollarColor(); + + /** + * Set the collar color of this entity + * + * @param color the color to apply + */ -+ void setCollarColor(@NotNull DyeColor color); ++ void setCollarColor(DyeColor color); +} diff --git a/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java new file mode 100644 diff --git a/patches/api/Add-FeatureFlag-API.patch b/patches/api/Add-FeatureFlag-API.patch index f051f260c4a..b32579330cb 100644 --- a/patches/api/Add-FeatureFlag-API.patch +++ b/patches/api/Add-FeatureFlag-API.patch @@ -14,9 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import java.util.Set; +import org.bukkit.FeatureFlag; -+import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Unmodifiable; ++import org.jspecify.annotations.NullMarked; + +/** + * Implemented by types in built-in registries that are controlled by {@link FeatureFlag FeatureFlags}. @@ -24,6 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @apiNote When a type that currently implements this interface transitions to being data-drive, this + * interface will be removed from that type in the following major version. + */ ++@NullMarked +@ApiStatus.NonExtendable +public interface FeatureDependant { + @@ -33,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the immutable set of feature flags + */ -+ default @Unmodifiable @NonNull Set requiredFeatures() { ++ default @Unmodifiable Set requiredFeatures() { + return FeatureFlagProvider.provider().requiredFeatures(this); + } +} @@ -50,7 +51,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Set; +import org.bukkit.FeatureFlag; +import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + ++@NullMarked +@ApiStatus.Internal +interface FeatureFlagProvider { + @@ -72,14 +75,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import java.util.Set; +import org.bukkit.FeatureFlag; -+import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Unmodifiable; ++import org.jspecify.annotations.NullMarked; + +/** + * Implemented by types that hold {@link FeatureFlag FeatureFlags} like + * {@link org.bukkit.generator.WorldInfo} and {@link org.bukkit.RegionAccessor}. + */ ++@NullMarked +@ApiStatus.NonExtendable +public interface FeatureFlagSetHolder { + @@ -88,7 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return true if enabled + */ -+ default boolean isEnabled(final @NonNull FeatureDependant featureDependant) { ++ default boolean isEnabled(final FeatureDependant featureDependant) { + return this.getFeatureFlags().containsAll(featureDependant.requiredFeatures()); + } + @@ -97,7 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return all enabled {@link FeatureFlag FeatureFlags} + */ -+ @Unmodifiable @NonNull Set getFeatureFlags(); ++ @Unmodifiable Set getFeatureFlags(); +} diff --git a/src/main/java/org/bukkit/FeatureFlag.java b/src/main/java/org/bukkit/FeatureFlag.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -189,12 +193,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import java.util.HashSet; +import java.util.Set; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; +import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + +@ApiStatus.Internal -+@DefaultQualifier(NonNull.class) ++@NullMarked +record FeatureFlagImpl(NamespacedKey key) implements FeatureFlag { + + static final Set ALL_FLAGS = new HashSet<>(); @@ -205,7 +208,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @ApiStatus.Internal -+ @DefaultQualifier(NonNull.class) + record Deprecated(NamespacedKey key) implements FeatureFlag { + + @Override diff --git a/patches/api/Add-FluidState-API.patch b/patches/api/Add-FluidState-API.patch index 59f43a51aeb..e7b096f77c7 100644 --- a/patches/api/Add-FluidState-API.patch +++ b/patches/api/Add-FluidState-API.patch @@ -15,13 +15,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.Fluid; +import org.bukkit.Location; +import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Range; ++import org.jspecify.annotations.NullMarked; + +/** + * A representation of a fluid in a specific state of data. + * This type is not linked to a specific location and hence mostly resembles a {@link org.bukkit.block.data.BlockData}. + */ ++@NullMarked +public interface FluidData extends Cloneable { + + /** @@ -29,14 +30,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the fluid type + */ -+ @NotNull Fluid getFluidType(); ++ Fluid getFluidType(); + + /** + * Returns a copy of this FluidData. + * + * @return a copy of the fluid data + */ -+ @NotNull FluidData clone(); ++ FluidData clone(); + + /** + * Computes the direction of the flow of the liquid at the given location as a vector. @@ -48,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param location - the location to check the liquid flow + * @return the flow direction vector at the given location + */ -+ @NotNull Vector computeFlowDirection(@NotNull Location location); ++ Vector computeFlowDirection(Location location); + + /** + * Returns the level of liquid this fluid data holds. @@ -69,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the height as a float value + */ + @Range(from = 0, to = 1) -+ float computeHeight(@NotNull Location location); ++ float computeHeight(Location location); + + /** + * Returns whether this fluid is a source block diff --git a/patches/api/Add-Lifecycle-Event-system.patch b/patches/api/Add-Lifecycle-Event-system.patch index a2163839ff8..f5a27f571c7 100644 --- a/patches/api/Add-Lifecycle-Event-system.patch +++ b/patches/api/Add-Lifecycle-Event-system.patch @@ -17,13 +17,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner; import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; + import org.jspecify.annotations.NullMarked; - /** - * Represents the context provided to a {@link PluginBootstrap} during both the bootstrapping and plugin -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.ApiStatus; - */ +@@ -0,0 +0,0 @@ import org.jspecify.annotations.NullMarked; @ApiStatus.Experimental + @NullMarked @ApiStatus.NonExtendable -public interface BootstrapContext extends PluginProviderContext { +public interface BootstrapContext extends PluginProviderContext, LifecycleEventOwner { @@ -34,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the lifecycle event manager + */ -+ @NotNull LifecycleEventManager getLifecycleManager(); ++ LifecycleEventManager getLifecycleManager(); } diff --git a/src/main/java/io/papermc/paper/plugin/lifecycle/event/LifecycleEvent.java b/src/main/java/io/papermc/paper/plugin/lifecycle/event/LifecycleEvent.java new file mode 100644 @@ -71,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.handler.configuration.LifecycleEventHandlerConfiguration; +import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEventType; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * Manages a plugin's lifecycle events. Can be obtained @@ -80,6 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param the owning type, {@link org.bukkit.plugin.Plugin} or {@link io.papermc.paper.plugin.bootstrap.BootstrapContext} + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface LifecycleEventManager { + @@ -102,7 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param eventHandler the handler for that event + * @param the type of the event object + */ -+ default void registerEventHandler(final @NotNull LifecycleEventType eventType, final @NotNull LifecycleEventHandler eventHandler) { ++ default void registerEventHandler(final LifecycleEventType eventType, final LifecycleEventHandler eventHandler) { + this.registerEventHandler(eventType.newHandler(eventHandler)); + } + @@ -115,7 +114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param handlerConfiguration the handler configuration to register + */ -+ void registerEventHandler(@NotNull LifecycleEventHandlerConfiguration handlerConfiguration); ++ void registerEventHandler(LifecycleEventHandlerConfiguration handlerConfiguration); +} diff --git a/src/main/java/io/papermc/paper/plugin/lifecycle/event/LifecycleEventOwner.java b/src/main/java/io/papermc/paper/plugin/lifecycle/event/LifecycleEventOwner.java new file mode 100644 @@ -127,7 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import io.papermc.paper.plugin.configuration.PluginMeta; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * Implemented by types that are considered owners @@ -137,6 +136,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * event handlers. + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface LifecycleEventOwner { + @@ -145,7 +145,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the plugin meta + */ -+ @NotNull PluginMeta getPluginMeta(); ++ PluginMeta getPluginMeta(); +} diff --git a/src/main/java/io/papermc/paper/plugin/lifecycle/event/handler/LifecycleEventHandler.java b/src/main/java/io/papermc/paper/plugin/lifecycle/event/handler/LifecycleEventHandler.java new file mode 100644 @@ -157,7 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import io.papermc.paper.plugin.lifecycle.event.LifecycleEvent; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A handler for a specific event. Can be implemented @@ -166,10 +166,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param the event + */ +@ApiStatus.Experimental ++@NullMarked +@FunctionalInterface +public interface LifecycleEventHandler { + -+ void run(@NotNull E event); ++ void run(E event); +} diff --git a/src/main/java/io/papermc/paper/plugin/lifecycle/event/handler/configuration/LifecycleEventHandlerConfiguration.java b/src/main/java/io/papermc/paper/plugin/lifecycle/event/handler/configuration/LifecycleEventHandlerConfiguration.java new file mode 100644 @@ -182,6 +183,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner; +import io.papermc.paper.plugin.lifecycle.event.handler.LifecycleEventHandler; +import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + +/** + * Base type for constructing configured event handlers for @@ -192,6 +194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@SuppressWarnings("unused") +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface LifecycleEventHandlerConfiguration { +} @@ -206,6 +209,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; ++import org.jspecify.annotations.NullMarked; + +/** + * Handler configuration for event types that allow "monitor" handlers. @@ -213,6 +217,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param the required owner type + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface MonitorLifecycleEventHandlerConfiguration extends LifecycleEventHandlerConfiguration { + @@ -237,6 +242,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; ++import org.jspecify.annotations.NullMarked; + +/** + * Handler configuration that allows both "monitor" and prioritized handlers. @@ -245,6 +251,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param the required owner type + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface PrioritizedLifecycleEventHandlerConfiguration extends LifecycleEventHandlerConfiguration { + @@ -300,7 +307,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.LifecycleEvent; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A lifecycle event that exposes a {@link Registrar} of some kind @@ -311,6 +318,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see ReloadableRegistrarEvent + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface RegistrarEvent extends LifecycleEvent { + @@ -320,7 +328,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the registrar + */ + @Contract(pure = true) -+ @NotNull R registrar(); ++ R registrar(); +} diff --git a/src/main/java/io/papermc/paper/plugin/lifecycle/event/registrar/ReloadableRegistrarEvent.java b/src/main/java/io/papermc/paper/plugin/lifecycle/event/registrar/ReloadableRegistrarEvent.java new file mode 100644 @@ -332,7 +340,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A lifecycle event that exposes a {@link Registrar} that is @@ -342,6 +350,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see RegistrarEvent + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface ReloadableRegistrarEvent extends RegistrarEvent { + @@ -351,7 +360,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the cause + */ + @Contract(pure = true) -+ @NotNull Cause cause(); ++ Cause cause(); + + @ApiStatus.Experimental + enum Cause { @@ -383,7 +392,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.handler.configuration.PrioritizedLifecycleEventHandlerConfiguration; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * Base type for all types of lifecycle events. Differs from @@ -397,6 +406,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param the configuration type + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface LifecycleEventType> { + @@ -406,7 +416,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the name + */ + @Contract(pure = true) -+ @NotNull String name(); ++ String name(); + + /** + * Create a configuration for this event with the specified @@ -417,7 +427,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see LifecycleEventManager#registerEventHandler(LifecycleEventHandlerConfiguration) + */ + @Contract("_ -> new") -+ @NotNull C newHandler(@NotNull LifecycleEventHandler handler); ++ C newHandler(LifecycleEventHandler handler); + + /** + * Lifecycle event type that supports separate registration @@ -458,8 +468,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Optional; +import java.util.ServiceLoader; +import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + +@ApiStatus.Internal ++@NullMarked +interface LifecycleEventTypeProvider { + + Optional INSTANCE = ServiceLoader.load(LifecycleEventTypeProvider.class) @@ -487,6 +499,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + +/** + * Holds various types of lifecycle events for @@ -494,6 +507,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * in {@link LifecycleEventManager}. + */ +@ApiStatus.Experimental ++@NullMarked +public final class LifecycleEvents { + + // diff --git a/patches/api/Add-Moving-Piston-API.patch b/patches/api/Add-Moving-Piston-API.patch index 1273d15b672..a60304ac9b0 100644 --- a/patches/api/Add-Moving-Piston-API.patch +++ b/patches/api/Add-Moving-Piston-API.patch @@ -15,8 +15,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.BlockFace; +import org.bukkit.block.TileState; +import org.bukkit.block.data.BlockData; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + ++@NullMarked +public interface MovingPiston extends TileState { + + /** @@ -24,7 +25,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the pushed block + */ -+ @NotNull + BlockData getMovingBlock(); + + /** @@ -33,7 +33,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the direction + */ -+ @NotNull + BlockFace getDirection(); + + /** diff --git a/patches/api/Add-Position.patch b/patches/api/Add-Position.patch index 648c1c1bf52..38facc6f829 100644 --- a/patches/api/Add-Position.patch +++ b/patches/api/Add-Position.patch @@ -16,15 +16,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.BlockFace; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A position represented with integers. + *

+ * May see breaking changes until Experimental annotation is removed. ++ * + * @see FinePosition + */ +@ApiStatus.Experimental ++@NullMarked +public interface BlockPosition extends Position { + + @Override @@ -53,17 +55,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ default @NotNull BlockPosition toBlock() { ++ default BlockPosition toBlock() { + return this; + } + + @Override -+ default @NotNull BlockPosition offset(int x, int y, int z) { ++ default BlockPosition offset(final int x, final int y, final int z) { + return x == 0 && y == 0 && z == 0 ? this : new BlockPositionImpl(this.blockX() + x, this.blockY() + y, this.blockZ() + z); + } + + @Override -+ default @NotNull FinePosition offset(double x, double y, double z) { ++ default FinePosition offset(final double x, final double y, final double z) { + return new FinePositionImpl(this.blockX() + x, this.blockY() + y, this.blockZ() + z); + } + @@ -74,7 +76,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the offset block position + */ + @Contract(value = "_ -> new", pure = true) -+ default @NotNull BlockPosition offset(@NotNull BlockFace blockFace) { ++ default BlockPosition offset(final BlockFace blockFace) { + return this.offset(blockFace, 1); + } + @@ -87,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the offset block position + */ + @Contract(pure = true) -+ default @NotNull BlockPosition offset(@NotNull BlockFace blockFace, int amount) { ++ default BlockPosition offset(final BlockFace blockFace, final int amount) { + return amount == 0 ? this : new BlockPositionImpl(this.blockX() + (blockFace.getModX() * amount), this.blockY() + (blockFace.getModY() * amount), this.blockZ() + (blockFace.getModZ() * amount)); + } + @@ -100,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the offset block position + */ + @Contract(pure = true) -+ default @NotNull BlockPosition offset(@NotNull Axis axis, int amount) { ++ default BlockPosition offset(final Axis axis, final int amount) { + return amount == 0 ? this : switch (axis) { + case X -> new BlockPositionImpl(this.blockX() + amount, this.blockY(), this.blockZ()); + case Y -> new BlockPositionImpl(this.blockX(), this.blockY() + amount, this.blockZ()); @@ -127,17 +129,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.math; + +import org.bukkit.util.NumberConversions; -+import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A position represented with doubles. + *

+ * May see breaking changes until Experimental annotation is removed. ++ * + * @see BlockPosition + */ +@ApiStatus.Experimental ++@NullMarked +public interface FinePosition extends Position { + + @Override @@ -166,17 +169,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ default @NotNull BlockPosition toBlock() { ++ default BlockPosition toBlock() { + return new BlockPositionImpl(this.blockX(), this.blockY(), this.blockZ()); + } + + @Override -+ default @NotNull FinePosition offset(int x, int y, int z) { ++ default FinePosition offset(final int x, final int y, final int z) { + return this.offset((double) x, y, z); + } + + @Override -+ default @NotNull FinePosition offset(double x, double y, double z) { ++ default FinePosition offset(final double x, final double y, final double z) { + return x == 0.0 && y == 0.0 && z == 0.0 ? this : new FinePositionImpl(this.x() + x, this.y() + y, this.z() + z); + } +} @@ -203,7 +206,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * Common interface for {@link FinePosition} and {@link BlockPosition}. @@ -211,6 +214,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * May see breaking changes until Experimental annotation is removed. + */ +@ApiStatus.Experimental ++@NullMarked +public interface Position { + + FinePosition FINE_ZERO = new FinePositionImpl(0, 0, 0); @@ -287,7 +291,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param z z value to offset + * @return the offset position + */ -+ @NotNull Position offset(int x, int y, int z); ++ Position offset(int x, int y, int z); + + /** + * Returns a position offset by the specified amounts. @@ -297,7 +301,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param z z value to offset + * @return the offset position + */ -+ @NotNull FinePosition offset(double x, double y, double z); ++ FinePosition offset(double x, double y, double z); + + /** + * Returns a new position at the center of the block position this represents @@ -305,7 +309,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a new center position + */ + @Contract(value = "-> new", pure = true) -+ default @NotNull FinePosition toCenter() { ++ default FinePosition toCenter() { + return new FinePositionImpl(this.blockX() + 0.5, this.blockY() + 0.5, this.blockZ() + 0.5); + } + @@ -316,7 +320,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the block position + */ + @Contract(pure = true) -+ @NotNull BlockPosition toBlock(); ++ BlockPosition toBlock(); + + /** + * Converts this position to a vector @@ -324,7 +328,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a new vector + */ + @Contract(value = "-> new", pure = true) -+ default @NotNull Vector toVector() { ++ default Vector toVector() { + return new Vector(this.x(), this.y(), this.z()); + } + @@ -335,7 +339,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a new location + */ + @Contract(value = "_ -> new", pure = true) -+ default @NotNull Location toLocation(@NotNull World world) { ++ default Location toLocation(final World world) { + return new Location(world, this.x(), this.y(), this.z()); + } + @@ -348,7 +352,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a position with those coords + */ + @Contract(value = "_, _, _ -> new", pure = true) -+ static @NotNull BlockPosition block(int x, int y, int z) { ++ static BlockPosition block(final int x, final int y, final int z) { + return new BlockPositionImpl(x, y, z); + } + @@ -359,7 +363,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a new position at that location + */ + @Contract(value = "_ -> new", pure = true) -+ static @NotNull BlockPosition block(@NotNull Location location) { ++ static BlockPosition block(final Location location) { + return new BlockPositionImpl(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + @@ -372,7 +376,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a position with those coords + */ + @Contract(value = "_, _, _ -> new", pure = true) -+ static @NotNull FinePosition fine(double x, double y, double z) { ++ static FinePosition fine(final double x, final double y, final double z) { + return new FinePositionImpl(x, y, z); + } + @@ -383,7 +387,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a new position at that location + */ + @Contract(value = "_ -> new", pure = true) -+ static @NotNull FinePosition fine(@NotNull Location location) { ++ static FinePosition fine(final Location location) { + return new FinePositionImpl(location.getX(), location.getY(), location.getZ()); + } +} diff --git a/patches/api/Add-RegistryAccess-for-managing-registries.patch b/patches/api/Add-RegistryAccess-for-managing-registries.patch index 47c7e4fb6c7..1913738ee3e 100644 --- a/patches/api/Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/Add-RegistryAccess-for-managing-registries.patch @@ -105,14 +105,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.Keyed; +import org.bukkit.Registry; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Used for accessing different {@link Registry} instances + * by a {@link RegistryKey}. Get the main instance of {@link RegistryAccess} + * with {@link RegistryAccess#registryAccess()}. + */ ++@NullMarked +@ApiStatus.NonExtendable +public interface RegistryAccess { + @@ -121,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the RegistryAccess instance + */ -+ static @NotNull RegistryAccess registryAccess() { ++ static RegistryAccess registryAccess() { + return RegistryAccessHolder.INSTANCE.orElseThrow(() -> new IllegalStateException("No RegistryAccess implementation found")); + } + @@ -134,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link #getRegistry(RegistryKey)} with keys from {@link RegistryKey} + */ + @Deprecated(since = "1.20.6", forRemoval = true) -+ @Nullable Registry getRegistry(@NotNull Class type); ++ @Nullable Registry getRegistry(Class type); + + /** + * Gets the registry with the specified key. @@ -147,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + // Future note: We should have no trouble removing this generic qualifier when + // registry types no longer have to be "keyed" as it shouldn't break ABI or API. -+ @NotNull Registry getRegistry(@NotNull RegistryKey registryKey); ++ Registry getRegistry(RegistryKey registryKey); +} diff --git a/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java b/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java new file mode 100644 @@ -171,13 +172,13 @@ diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java +++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java -@@ -0,0 +0,0 @@ record RegistryKeyImpl(@NotNull Key key) implements RegistryKey { +@@ -0,0 +0,0 @@ record RegistryKeyImpl(Key key) implements RegistryKey { static final Set> REGISTRY_KEYS = Sets.newIdentityHashSet(); + // override equals and hashCode to this can be used to simulate an "identity" hashmap + @Override -+ public boolean equals(final Object obj) { ++ public boolean equals(final @Nullable Object obj) { + return obj == this; + } + diff --git a/patches/api/Add-Shearable-API.patch b/patches/api/Add-Shearable-API.patch index 91020594727..e0594680bc1 100644 --- a/patches/api/Add-Shearable-API.patch +++ b/patches/api/Add-Shearable-API.patch @@ -14,11 +14,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import net.kyori.adventure.sound.Sound; +import org.bukkit.entity.Entity; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * Represents an entity that can be sheared. + */ ++@NullMarked +public interface Shearable extends Entity { + + /** @@ -44,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param source Sound source to play any sound effects on + */ -+ void shear(@NotNull Sound.Source source); ++ void shear(Sound.Source source); + + /** + * Gets if the entity would be able to be sheared or not naturally using shears. diff --git a/patches/api/Add-Tick-TemporalUnit.patch b/patches/api/Add-Tick-TemporalUnit.patch index 026a2bd8f0a..94ddd3e0516 100644 --- a/patches/api/Add-Tick-TemporalUnit.patch +++ b/patches/api/Add-Tick-TemporalUnit.patch @@ -12,40 +12,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.util; + -+import net.kyori.adventure.util.Ticks; -+import org.jetbrains.annotations.NotNull; -+ +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalUnit; +import java.util.Objects; ++import net.kyori.adventure.util.Ticks; ++import org.jspecify.annotations.NullMarked; + +/** + * A TemporalUnit that represents the target length of one server tick. This is defined + * as 50 milliseconds. Note that this class is not for measuring the length that a tick + * took, rather it is used for simple conversion between times and ticks. ++ * + * @see #tick() + */ ++@NullMarked +public final class Tick implements TemporalUnit { ++ + private static final Tick INSTANCE = new Tick(Ticks.SINGLE_TICK_DURATION_MS); + + private final long milliseconds; + + /** + * Gets the instance of the tick temporal unit. ++ * + * @return the tick instance + */ -+ public static @NotNull Tick tick() { ++ public static Tick tick() { + return INSTANCE; + } + + /** + * Creates a new tick. ++ * + * @param length the length of the tick in milliseconds + * @see #tick() + */ -+ private Tick(long length) { ++ private Tick(final long length) { + this.milliseconds = length; + } + @@ -53,27 +57,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Creates a duration from an amount of ticks. This is shorthand for + * {@link Duration#of(long, TemporalUnit)} called with the amount of ticks and + * {@link #tick()}. ++ * + * @param ticks the amount of ticks + * @return the duration + */ -+ public static @NotNull Duration of(long ticks) { ++ public static Duration of(final long ticks) { + return Duration.of(ticks, INSTANCE); + } + + /** + * Gets the number of whole ticks that occur in the provided duration. Note that this + * method returns an {@code int} as this is the unit that Minecraft stores ticks in. ++ * + * @param duration the duration + * @return the number of whole ticks in this duration + * @throws ArithmeticException if the duration is zero or an overflow occurs + */ -+ public int fromDuration(@NotNull Duration duration) { ++ public int fromDuration(final Duration duration) { + Objects.requireNonNull(duration, "duration cannot be null"); + return Math.toIntExact(Math.floorDiv(duration.toMillis(), this.milliseconds)); + } + + @Override -+ public @NotNull Duration getDuration() { ++ public Duration getDuration() { + return Duration.ofMillis(this.milliseconds); + } + @@ -96,12 +102,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @SuppressWarnings("unchecked") // following ChronoUnit#addTo + @Override -+ public @NotNull R addTo(@NotNull R temporal, long amount) { -+ return (R) temporal.plus(getDuration().multipliedBy(amount)); ++ public R addTo(final R temporal, final long amount) { ++ return (R) temporal.plus(this.getDuration().multipliedBy(amount)); + } + + @Override -+ public long between(@NotNull Temporal start, @NotNull Temporal end) { ++ public long between(final Temporal start, final Temporal end) { + return start.until(end, ChronoUnit.MILLIS) / this.milliseconds; + } +} diff --git a/patches/api/Add-UnknownCommandEvent.patch b/patches/api/Add-UnknownCommandEvent.patch index 79d8f5023bb..39daf8e00b4 100644 --- a/patches/api/Add-UnknownCommandEvent.patch +++ b/patches/api/Add-UnknownCommandEvent.patch @@ -19,22 +19,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Thrown when a player executes a command that is not defined + */ ++@NullMarked +public class UnknownCommandEvent extends Event { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ @NotNull private final CommandSender sender; -+ @NotNull private final String commandLine; -+ @Nullable private Component message; ++ private final CommandSender sender; ++ private final String commandLine; ++ private @Nullable Component message; + + @ApiStatus.Internal -+ public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) { ++ public UnknownCommandEvent(final CommandSender sender, final String commandLine, final @Nullable Component message) { + super(false); + this.sender = sender; + this.commandLine = commandLine; @@ -46,7 +47,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return Sender of the command + */ -+ @NotNull + public CommandSender getSender() { + return this.sender; + } @@ -56,7 +56,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return Command sent + */ -+ @NotNull + public String getCommandLine() { + return this.commandLine; + } @@ -67,9 +66,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return Unknown command message + * @deprecated use {@link #message()} + */ -+ @Nullable + @Deprecated -+ public String getMessage() { ++ public @Nullable String getMessage() { + return this.message == null ? null : LegacyComponentSerializer.legacySection().serialize(this.message); + } + @@ -91,9 +89,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return Unknown command message + */ -+ @Nullable + @Contract(pure = true) -+ public Component message() { ++ public @Nullable Component message() { + return this.message; + } + @@ -108,13 +105,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.message = message; + } + -+ @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + -+ @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } diff --git a/patches/api/Add-basic-Datapack-API.patch b/patches/api/Add-basic-Datapack-API.patch index 23589eb9f8a..644cf10d9d9 100644 --- a/patches/api/Add-basic-Datapack-API.patch +++ b/patches/api/Add-basic-Datapack-API.patch @@ -16,14 +16,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Set; +import net.kyori.adventure.text.Component; +import org.bukkit.FeatureFlag; -+import org.checkerframework.checker.nullness.qual.NonNull; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; ++import org.jspecify.annotations.NullMarked; + +/** + * This is a snapshot of a datapack on the server. It + * won't be updated as datapacks are updated. + */ ++@NullMarked +public interface Datapack { + + /** @@ -32,21 +33,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the name of the pack + */ + @Contract(pure = true) -+ @NonNull String getName(); ++ String getName(); + + /** + * Gets the title component of this datapack. + * + * @return the title + */ -+ @NonNull Component getTitle(); ++ Component getTitle(); + + /** + * Gets the description component of this datapack. + * + * @return the description + */ -+ @NonNull Component getDescription(); ++ Component getDescription(); + + /** + * Gets if this datapack is required to be enabled. @@ -60,14 +61,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the compatibility of the pack + */ -+ @NonNull Compatibility getCompatibility(); ++ Compatibility getCompatibility(); + + /** + * Gets the set of required features for this datapack. + * + * @return the set of required features + */ -+ @NonNull @Unmodifiable Set getRequiredFeatures(); ++ @Unmodifiable Set getRequiredFeatures(); + + /** + * Gets the enabled state of this pack. @@ -91,7 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the pack source + */ -+ @NonNull DatapackSource getSource(); ++ DatapackSource getSource(); + + /** + * Computes the component vanilla Minecraft uses @@ -101,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a new component + */ + @Contract(pure = true, value = "-> new") -+ @NonNull Component computeDisplayName(); ++ Component computeDisplayName(); + + enum Compatibility { + TOO_OLD, @@ -117,12 +118,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.datapack; + -+import org.checkerframework.checker.nullness.qual.NonNull; -+ +import java.util.Collection; -+import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.Unmodifiable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + ++@NullMarked +public interface DatapackManager { + + /** @@ -140,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param name the name/id of the datapack + * @return the datapack, or null if not found + */ -+ @Nullable Datapack getPack(@NonNull String name); ++ @Nullable Datapack getPack(String name); + + /** + * Gets the available datapacks. May require calling {@link #refreshPacks()} before @@ -148,7 +149,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return all the packs known to the server + */ -+ @NonNull @Unmodifiable Collection getPacks(); ++ @Unmodifiable Collection getPacks(); + + /** + * Gets the enabled datapacks. May require calling {@link #refreshPacks()} before @@ -156,7 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return all the packs which are currently enabled + */ -+ @NonNull @Unmodifiable Collection getEnabledPacks(); ++ @Unmodifiable Collection getEnabledPacks(); +} diff --git a/src/main/java/io/papermc/paper/datapack/DatapackSource.java b/src/main/java/io/papermc/paper/datapack/DatapackSource.java new file mode 100644 @@ -166,9 +167,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.datapack; + ++import org.jspecify.annotations.NullMarked; ++ +/** + * Source of a datapack. + */ ++@NullMarked +public sealed interface DatapackSource permits DatapackSourceImpl { + + DatapackSource DEFAULT = create("default"); @@ -190,8 +194,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.datapack; + +import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + +@ApiStatus.Internal ++@NullMarked +record DatapackSourceImpl(String name) implements DatapackSource { + + @Override diff --git a/patches/api/Add-moon-phase-API.patch b/patches/api/Add-moon-phase-API.patch index bf5721b736f..a4d9c603be2 100644 --- a/patches/api/Add-moon-phase-API.patch +++ b/patches/api/Add-moon-phase-API.patch @@ -12,11 +12,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.world; + -+import org.jetbrains.annotations.NotNull; -+ +import java.util.HashMap; +import java.util.Map; ++import org.jspecify.annotations.NullMarked; + ++@NullMarked +public enum MoonPhase { + FULL_MOON(0L), + WANING_GIBBOUS(1L), @@ -29,20 +29,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final long day; + -+ MoonPhase(long day) { ++ MoonPhase(final long day) { + this.day = day; + } + + private static final Map BY_DAY = new HashMap<>(); + + static { -+ for (MoonPhase phase : values()) { ++ for (final MoonPhase phase : values()) { + BY_DAY.put(phase.day, phase); + } + } + -+ @NotNull -+ public static MoonPhase getPhase(long day) { ++ public static MoonPhase getPhase(final long day) { + return BY_DAY.get(day % 8L); + } +} diff --git a/patches/api/Add-more-advancement-API.patch b/patches/api/Add-more-advancement-API.patch index 7de1fbedb77..8287fb183c5 100644 --- a/patches/api/Add-more-advancement-API.patch +++ b/patches/api/Add-more-advancement-API.patch @@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.util.Index; +import org.bukkit.NamespacedKey; +import org.bukkit.inventory.ItemStack; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Describes the display of an advancement. @@ -29,6 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * The display is used in the chat, in the toast messages and the advancements + * screen. + */ ++@NullMarked +public interface AdvancementDisplay { + + /** @@ -39,7 +40,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the frame type + */ -+ @NotNull + Frame frame(); + + /** @@ -47,7 +47,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the title + */ -+ @NotNull + Component title(); + + /** @@ -55,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the description + */ -+ @NotNull + Component description(); + + /** @@ -63,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return a copy of the icon + */ -+ @NotNull + ItemStack icon(); + + /** @@ -104,8 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the background texture path + */ -+ @Nullable -+ NamespacedKey backgroundPath(); ++ @Nullable NamespacedKey backgroundPath(); + + /** + * Gets the formatted display name for this display. This @@ -115,7 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the display name + * @see org.bukkit.advancement.Advancement#displayName() + */ -+ @NotNull Component displayName(); ++ Component displayName(); + + /** + * Defines how the {@link #icon()} appears in the advancements screen and @@ -148,7 +144,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final String name; + private final TextColor color; + -+ Frame(String name, TextColor color) { ++ Frame(final String name, final TextColor color) { + this.name = name; + this.color = color; + } @@ -158,7 +154,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the text color + */ -+ @NotNull + public TextColor color() { + return this.color; + } @@ -171,7 +166,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the toast message key + */ + @Override -+ @NotNull + public String translationKey() { + return "advancements.toast." + this.name; + } diff --git a/patches/api/Add-villager-reputation-API.patch b/patches/api/Add-villager-reputation-API.patch index 7f2096ac3c0..08d7e988638 100644 --- a/patches/api/Add-villager-reputation-API.patch +++ b/patches/api/Add-villager-reputation-API.patch @@ -13,10 +13,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.entity.villager; + +import com.google.common.base.Preconditions; -+ +import java.util.EnumMap; +import java.util.Map; -+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; + +/** @@ -31,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this(new EnumMap<>(ReputationType.class)); + } + -+ public Reputation(Map reputation) { ++ public Reputation(final Map reputation) { + Preconditions.checkNotNull(reputation, "reputation cannot be null"); + this.reputation = reputation; + } @@ -42,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param type The {@link ReputationType type} of reputation to get. + * @return The value of the {@link ReputationType type}. + */ -+ public int getReputation(ReputationType type) { ++ public int getReputation(final ReputationType type) { + Preconditions.checkNotNull(type, "the reputation type cannot be null"); + return this.reputation.getOrDefault(type, 0); + } @@ -53,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param type The {@link ReputationType type} of reputation to set. + * @param value The value of the {@link ReputationType type}. + */ -+ public void setReputation(ReputationType type, int value) { ++ public void setReputation(final ReputationType type, final int value) { + Preconditions.checkNotNull(type, "the reputation type cannot be null"); + this.reputation.put(type, value); + } @@ -64,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param type The {@link ReputationType type} to check + * @return If there is a value for this {@link ReputationType type} set. + */ -+ public boolean hasReputationSet(ReputationType type) { ++ public boolean hasReputationSet(final ReputationType type) { + return this.reputation.containsKey(type); + } +} diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 3065b13863a..4530381b06f 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -101,13 +101,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.Component; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A chat renderer is responsible for rendering chat messages sent by {@link Player}s to the server. + */ ++@NullMarked +@FunctionalInterface +public interface ChatRenderer { ++ + /** + * Renders a chat message. This will be called once for each receiving {@link Audience}. + * @@ -118,15 +120,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a rendered chat message + */ + @ApiStatus.OverrideOnly -+ @NotNull -+ Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer); ++ Component render(Player source, Component sourceDisplayName, Component message, Audience viewer); + + /** + * Create a new instance of the default {@link ChatRenderer}. + * + * @return a new {@link ChatRenderer} + */ -+ @NotNull + static ChatRenderer defaultRenderer() { + return new ViewerUnawareImpl.Default((source, sourceDisplayName, message) -> Component.translatable("chat.type.text", sourceDisplayName, message)); + } @@ -142,8 +142,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param renderer the viewer unaware renderer + * @return a new {@link ChatRenderer} + */ -+ @NotNull -+ static ChatRenderer viewerUnaware(final @NotNull ViewerUnaware renderer) { ++ static ChatRenderer viewerUnaware(final ViewerUnaware renderer) { + return new ViewerUnawareImpl(renderer); + } + @@ -153,6 +152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see ChatRenderer#viewerUnaware(ViewerUnaware) + */ + interface ViewerUnaware { ++ + /** + * Renders a chat message. + * @@ -162,8 +162,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a rendered chat message + */ + @ApiStatus.OverrideOnly -+ @NotNull -+ Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message); ++ Component render(Player source, Component sourceDisplayName, Component message); + } +} diff --git a/src/main/java/io/papermc/paper/chat/ViewerUnawareImpl.java b/src/main/java/io/papermc/paper/chat/ViewerUnawareImpl.java @@ -177,9 +176,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.text.Component; +import org.bukkit.entity.Player; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + ++@ApiStatus.Internal ++@NullMarked +sealed class ViewerUnawareImpl implements ChatRenderer, ChatRenderer.ViewerUnaware permits ViewerUnawareImpl.Default { + private final ViewerUnaware unaware; + private @Nullable Component message; @@ -189,12 +191,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public @NotNull Component render(final @NotNull Player source, final @NotNull Component sourceDisplayName, final @NotNull Component message, final @NotNull Audience viewer) { ++ public Component render(final Player source, final Component sourceDisplayName, final Component message, final Audience viewer) { + return this.render(source, sourceDisplayName, message); + } + + @Override -+ public @NotNull Component render(final @NotNull Player source, final @NotNull Component sourceDisplayName, final @NotNull Component message) { ++ public Component render(final Player source, final Component sourceDisplayName, final Component message) { + if (this.message == null) { + this.message = this.unaware.render(source, sourceDisplayName, message); + } @@ -585,6 +587,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.text; + ++import java.io.IOException; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.flattener.ComponentFlattener; +import net.kyori.adventure.text.format.NamedTextColor; @@ -595,15 +598,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.io.IOException; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Paper API-specific methods for working with {@link Component}s and related. + */ ++@NullMarked +public final class PaperComponents { ++ + private PaperComponents() { + throw new RuntimeException("PaperComponents is not to be instantiated!"); + } @@ -633,7 +636,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the resolved component + * @throws IOException if a syntax error tripped during resolving + */ -+ public static @NotNull Component resolveWithContext(@NotNull Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject) throws IOException { ++ public static Component resolveWithContext(final Component input, final @Nullable CommandSender context, final @Nullable Entity scoreboardSubject) throws IOException { + return resolveWithContext(input, context, scoreboardSubject, true); + } + @@ -664,7 +667,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the resolved component + * @throws IOException if a syntax error tripped during resolving + */ -+ public static @NotNull Component resolveWithContext(@NotNull Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject, boolean bypassPermissions) throws IOException { ++ @SuppressWarnings("deprecation") // using unsafe as a bridge ++ public static Component resolveWithContext(final Component input, final @Nullable CommandSender context, final @Nullable Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { + return Bukkit.getUnsafe().resolveWithContext(input, context, scoreboardSubject, bypassPermissions); + } + @@ -673,7 +677,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return a component flattener + */ -+ public static @NotNull ComponentFlattener flattener() { ++ @SuppressWarnings("deprecation") // using unsafe as a bridge ++ public static ComponentFlattener flattener() { + return Bukkit.getUnsafe().componentFlattener(); + } + @@ -688,7 +693,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated will be removed in adventure 5.0.0, use {@link PlainTextComponentSerializer#plainText()} + */ + @Deprecated(forRemoval = true, since = "1.18.1") -+ public static @NotNull PlainComponentSerializer plainSerializer() { ++ public static PlainComponentSerializer plainSerializer() { + return Bukkit.getUnsafe().plainComponentSerializer(); + } + @@ -703,7 +708,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link PlainTextComponentSerializer#plainText()} + */ + @Deprecated(forRemoval = true, since = "1.18.2") -+ public static @NotNull PlainTextComponentSerializer plainTextSerializer() { ++ public static PlainTextComponentSerializer plainTextSerializer() { + return Bukkit.getUnsafe().plainTextSerializer(); + } + @@ -719,7 +724,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link GsonComponentSerializer#gson()} + */ + @Deprecated(forRemoval = true, since = "1.18.2") -+ public static @NotNull GsonComponentSerializer gsonSerializer() { ++ public static GsonComponentSerializer gsonSerializer() { + return Bukkit.getUnsafe().gsonComponentSerializer(); + } + @@ -736,7 +741,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link GsonComponentSerializer#colorDownsamplingGson()} + */ + @Deprecated(forRemoval = true, since = "1.18.2") -+ public static @NotNull GsonComponentSerializer colorDownsamplingGsonSerializer() { ++ public static GsonComponentSerializer colorDownsamplingGsonSerializer() { + return Bukkit.getUnsafe().colorDownsamplingGsonComponentSerializer(); + } + @@ -756,7 +761,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated use {@link LegacyComponentSerializer#legacySection()} + */ + @Deprecated(forRemoval = true, since = "1.18.2") -+ public static @NotNull LegacyComponentSerializer legacySectionSerializer() { ++ public static LegacyComponentSerializer legacySectionSerializer() { + return Bukkit.getUnsafe().legacyComponentSerializer(); + } +} diff --git a/patches/api/AsyncTabCompleteEvent.patch b/patches/api/AsyncTabCompleteEvent.patch index 8067d1efe0a..ed97b4609f0 100644 --- a/patches/api/AsyncTabCompleteEvent.patch +++ b/patches/api/AsyncTabCompleteEvent.patch @@ -362,9 +362,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.util; + -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.jetbrains.annotations.NotNull; -+ +import java.util.AbstractList; +import java.util.Iterator; +import java.util.List; @@ -372,6 +369,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.RandomAccess; +import java.util.function.Function; +import java.util.function.Predicate; ++import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; + +import static com.google.common.base.Preconditions.checkNotNull; + @@ -381,7 +380,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param backing list element type + * @param transformed list element type + */ ++@NullMarked ++@ApiStatus.Internal +public final class TransformingRandomAccessList extends AbstractList implements RandomAccess { ++ + final List fromList; + final Function toFunction; + final Function fromFunction; @@ -389,14 +391,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Create a new {@link TransformingRandomAccessList}. + * -+ * @param fromList backing list -+ * @param toFunction function mapping backing list element type to transformed list element type ++ * @param fromList backing list ++ * @param toFunction function mapping backing list element type to transformed list element type + * @param fromFunction function mapping transformed list element type to backing list element type + */ + public TransformingRandomAccessList( -+ final @NonNull List fromList, -+ final @NonNull Function toFunction, -+ final @NonNull Function fromFunction ++ final List fromList, ++ final Function toFunction, ++ final Function fromFunction + ) { + this.fromList = checkNotNull(fromList); + this.toFunction = checkNotNull(toFunction); @@ -409,25 +411,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public T get(int index) { ++ public T get(final int index) { + return this.toFunction.apply(this.fromList.get(index)); + } + + @Override -+ public @NotNull Iterator iterator() { ++ public Iterator iterator() { + return this.listIterator(); + } + + @Override -+ public @NotNull ListIterator listIterator(int index) { -+ return new TransformedListIterator(this.fromList.listIterator(index)) { ++ public ListIterator listIterator(final int index) { ++ return new TransformedListIterator<>(this.fromList.listIterator(index)) { + @Override -+ T transform(F from) { ++ T transform(final F from) { + return TransformingRandomAccessList.this.toFunction.apply(from); + } + + @Override -+ F transformBack(T from) { ++ F transformBack(final T from) { + return TransformingRandomAccessList.this.fromFunction.apply(from); + } + }; @@ -439,13 +441,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public boolean removeIf(Predicate filter) { ++ public boolean removeIf(final Predicate filter) { + checkNotNull(filter); + return this.fromList.removeIf(element -> filter.test(this.toFunction.apply(element))); + } + + @Override -+ public T remove(int index) { ++ public T remove(final int index) { + return this.toFunction.apply(this.fromList.remove(index)); + } + @@ -455,19 +457,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public T set(int i, T t) { ++ public T set(final int i, final T t) { + return this.toFunction.apply(this.fromList.set(i, this.fromFunction.apply(t))); + } + + @Override -+ public void add(int i, T t) { ++ public void add(final int i, final T t) { + this.fromList.add(i, this.fromFunction.apply(t)); + } + -+ static abstract class TransformedListIterator implements ListIterator, Iterator { ++ abstract static class TransformedListIterator implements ListIterator, Iterator { ++ + final Iterator backingIterator; + -+ TransformedListIterator(ListIterator backingIterator) { ++ TransformedListIterator(final ListIterator backingIterator) { + this.backingIterator = checkNotNull((Iterator) backingIterator); + } + @@ -475,7 +478,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return cast(this.backingIterator); + } + -+ static ListIterator cast(Iterator iterator) { ++ static ListIterator cast(final Iterator iterator) { + return (ListIterator) iterator; + } + @@ -500,12 +503,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public void set(T element) { ++ public void set(final T element) { + this.backingIterator().set(this.transformBack(element)); + } + + @Override -+ public void add(T element) { ++ public void add(final T element) { + this.backingIterator().add(this.transformBack(element)); + } + diff --git a/patches/api/Basic-PlayerProfile-API.patch b/patches/api/Basic-PlayerProfile-API.patch index 4831c91b5b6..fb11d9abb80 100644 --- a/patches/api/Basic-PlayerProfile-API.patch +++ b/patches/api/Basic-PlayerProfile-API.patch @@ -16,20 +16,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Collection; +import java.util.Set; +import java.util.UUID; -+ +import java.util.concurrent.CompletableFuture; +import org.bukkit.profile.PlayerTextures; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Represents a players profile for the game, such as UUID, Name, and textures. + */ ++@NullMarked +public interface PlayerProfile extends org.bukkit.profile.PlayerProfile { + + /** + * @return The players name, if set + */ ++ @Override + @Nullable + String getName(); + @@ -39,14 +40,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param name The new Name + * @return The previous Name + */ -+ @NotNull + @Deprecated(forRemoval = true, since = "1.18.1") + String setName(@Nullable String name); + + /** + * @return The players unique identifier, if set + */ -+ @Nullable UUID getId(); ++ @Nullable ++ UUID getId(); + + /** + * Sets this profiles UUID @@ -54,8 +55,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param uuid The new UUID + * @return The previous UUID + */ -+ @Nullable + @Deprecated(forRemoval = true, since = "1.18.1") ++ @Nullable + UUID setId(@Nullable UUID uuid); + + /** @@ -65,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the textures, not null + */ -+ @NotNull ++ @Override + PlayerTextures getTextures(); + + /** @@ -74,16 +75,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param textures the textures to copy, or null to clear the + * textures + */ ++ @Override + void setTextures(@Nullable PlayerTextures textures); + + /** + * @return A Mutable set of this players properties, such as textures. + * Values specified here are subject to implementation details. + */ -+ @NotNull Set getProperties(); ++ Set getProperties(); + + /** + * Check if the Profile has the specified property ++ * + * @param property Property name to check + * @return If the property is set + */ @@ -95,17 +98,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param property Property to set. + * @throws IllegalArgumentException if setting the property results in more than 16 properties + */ -+ void setProperty(@NotNull ProfileProperty property); ++ void setProperty(ProfileProperty property); + + /** + * Sets multiple properties. If any of the set properties already exist, it will be replaced ++ * + * @param properties The properties to set + * @throws IllegalArgumentException if the number of properties exceeds 16 + */ -+ void setProperties(@NotNull Collection properties); ++ void setProperties(Collection properties); + + /** + * Removes a specific property from this profile ++ * + * @param property The property to remove + * @return If a property was removed + */ @@ -113,22 +118,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Removes a specific property from this profile ++ * + * @param property The property to remove + * @return If a property was removed + */ -+ default boolean removeProperty(@NotNull ProfileProperty property) { -+ return removeProperty(property.getName()); ++ default boolean removeProperty(final ProfileProperty property) { ++ return this.removeProperty(property.getName()); + } + + /** + * Removes all properties in the collection ++ * + * @param properties The properties to remove + * @return If any property was removed + */ -+ default boolean removeProperties(@NotNull Collection properties) { ++ default boolean removeProperties(final Collection properties) { + boolean removed = false; -+ for (ProfileProperty property : properties) { -+ if (removeProperty(property)) { ++ for (final ProfileProperty property : properties) { ++ if (this.removeProperty(property)) { + removed = true; + } + } @@ -143,6 +150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * @return If the profile is now complete (has UUID and Name) + */ ++ @Override + boolean isComplete(); + + /** @@ -175,21 +183,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * If this profile is not complete, then make the API call to complete it. + * This is a blocking operation and should be done asynchronously. -+ * ++ *

+ * This will also complete textures. If you do not want to load textures, use {{@link #complete(boolean)}} ++ * + * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail) + */ + default boolean complete() { -+ return complete(true); ++ return this.complete(true); + } + + /** + * If this profile is not complete, then make the API call to complete it. + * This is a blocking operation and should be done asynchronously. -+ * ++ *

+ * Optionally will also fill textures. -+ * ++ *

+ * Online mode will be automatically determined ++ * + * @param textures controls if we should fill the profile with texture properties + * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail) + */ @@ -198,8 +208,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * If this profile is not complete, then make the API call to complete it. + * This is a blocking operation and should be done asynchronously. -+ * ++ *

+ * Optionally will also fill textures. ++ * + * @param textures controls if we should fill the profile with texture properties + * @param onlineMode Treat this server as online mode or not + * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail) @@ -235,14 +246,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + */ + @Override -+ @NotNull CompletableFuture update(); ++ CompletableFuture update(); + + /** + * Whether this Profile has textures associated to it ++ * + * @return If it has a textures property + */ + default boolean hasTextures() { -+ return hasProperty("textures"); ++ return this.hasProperty("textures"); + } +} diff --git a/src/main/java/com/destroystokyo/paper/profile/ProfileProperty.java b/src/main/java/com/destroystokyo/paper/profile/ProfileProperty.java @@ -254,24 +266,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.profile; + +import com.google.common.base.Preconditions; -+ +import java.util.Objects; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Represents a property on a {@link PlayerProfile} + */ ++@NullMarked +public final class ProfileProperty { ++ + private final String name; + private final String value; -+ private final String signature; ++ private final @Nullable String signature; + -+ public ProfileProperty(@NotNull String name, @NotNull String value) { ++ public ProfileProperty(final String name, final String value) { + this(name, value, null); + } + -+ public ProfileProperty(@NotNull String name, @NotNull String value, @Nullable String signature) { ++ public ProfileProperty(final String name, final String value, final @Nullable String signature) { + this.name = Preconditions.checkNotNull(name, "ProfileProperty name can not be null"); + this.value = Preconditions.checkNotNull(value, "ProfileProperty value can not be null"); + this.signature = signature; @@ -283,25 +296,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * @return The property name, ie "textures" + */ -+ @NotNull + public String getName() { -+ return name; ++ return this.name; + } + + /** + * @return The property value, likely to be base64 encoded + */ -+ @NotNull + public String getValue() { -+ return value; ++ return this.value; + } + + /** + * @return A signature from Mojang for signed properties + */ -+ @Nullable -+ public String getSignature() { -+ return signature; ++ public @Nullable String getSignature() { ++ return this.signature; + } + + /** @@ -312,18 +322,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public boolean equals(Object o) { ++ public boolean equals(final @Nullable Object o) { + if (this == o) return true; -+ if (o == null || getClass() != o.getClass()) return false; -+ ProfileProperty that = (ProfileProperty) o; -+ return Objects.equals(name, that.name) && -+ Objects.equals(value, that.value) && -+ Objects.equals(signature, that.signature); ++ if (o == null || this.getClass() != o.getClass()) return false; ++ final ProfileProperty that = (ProfileProperty) o; ++ return Objects.equals(this.name, that.name) && ++ Objects.equals(this.value, that.value) && ++ Objects.equals(this.signature, that.signature); + } + + @Override + public int hashCode() { -+ return Objects.hash(name); ++ return Objects.hash(this.name); + } +} diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/patches/api/Brigadier-based-command-API.patch b/patches/api/Brigadier-based-command-API.patch index f3978be8ead..c9f4c678691 100644 --- a/patches/api/Brigadier-based-command-API.patch +++ b/patches/api/Brigadier-based-command-API.patch @@ -512,14 +512,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Collections; +import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * Implementing this interface allows for easily creating "Bukkit-style" {@code String[] args} commands. + * The implementation handles converting the command to a representation compatible with Brigadier on registration, usually in the form of {@literal /commandlabel }. + */ +@ApiStatus.Experimental ++@NullMarked +@FunctionalInterface +public interface BasicCommand { + @@ -530,7 +531,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param args the arguments of the command ignoring repeated spaces + */ + @ApiStatus.OverrideOnly -+ void execute(@NotNull CommandSourceStack commandSourceStack, @NotNull String[] args); ++ void execute(CommandSourceStack commandSourceStack, String[] args); + + /** + * Suggests possible completions for the given command {@link CommandSourceStack} and arguments. @@ -540,7 +541,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return a collection of suggestions + */ + @ApiStatus.OverrideOnly -+ default @NotNull Collection suggest(final @NotNull CommandSourceStack commandSourceStack, final @NotNull String[] args) { ++ default Collection suggest(final CommandSourceStack commandSourceStack, final String[] args) { + return Collections.emptyList(); + } + @@ -552,8 +553,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see #permission() + */ + @ApiStatus.OverrideOnly -+ default boolean canUse(final @NotNull CommandSender sender) { -+ return this.permission() == null || sender.hasPermission(this.permission()); ++ default boolean canUse(final CommandSender sender) { ++ final String permission = this.permission(); ++ return permission == null || sender.hasPermission(permission); + } + + /** @@ -598,8 +600,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * The command source type for Brigadier commands registered using Paper API. @@ -613,8 +615,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * exist yet, or no specific sender is available. Methods on such a {@link CommandSender} + * will either have no effect or throw an {@link UnsupportedOperationException}.

+ */ -+@ApiStatus.NonExtendable +@ApiStatus.Experimental ++@NullMarked ++@ApiStatus.NonExtendable +public interface CommandSourceStack { + + /** @@ -622,7 +625,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return a cloned location instance. + */ -+ @NotNull Location getLocation(); ++ Location getLocation(); + + /** + * Gets the command sender that executed this command. @@ -631,7 +634,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return the command sender instance + */ -+ @NotNull CommandSender getSender(); ++ CommandSender getSender(); + + /** + * Gets the entity that executes this command. @@ -664,9 +667,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.Collections; +import java.util.Set; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; + +/** + * The registrar for custom commands. Supports Brigadier commands and {@link BasicCommand}. @@ -709,6 +712,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents#COMMANDS + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface Commands extends Registrar { + @@ -718,7 +722,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param literal literal name + * @return a new builder instance + */ -+ static @NotNull LiteralArgumentBuilder literal(final @NotNull String literal) { ++ static LiteralArgumentBuilder literal(final String literal) { + return LiteralArgumentBuilder.literal(literal); + } + @@ -730,7 +734,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param the generic type of the argument value + * @return a new required argument builder + */ -+ static @NotNull RequiredArgumentBuilder argument(final @NotNull String name, final @NotNull ArgumentType argumentType) { ++ static RequiredArgumentBuilder argument(final String name, final ArgumentType argumentType) { + return RequiredArgumentBuilder.argument(name, argumentType); + } + @@ -754,7 +758,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the dispatcher instance + */ + @ApiStatus.Experimental -+ @NotNull CommandDispatcher getDispatcher(); ++ CommandDispatcher getDispatcher(); + + /** + * Registers a command for the current plugin context. @@ -768,7 +772,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param node the built literal command node + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ default @Unmodifiable @NotNull Set register(final @NotNull LiteralCommandNode node) { ++ default @Unmodifiable Set register(final LiteralCommandNode node) { + return this.register(node, null, Collections.emptyList()); + } + @@ -785,7 +789,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param description the help description for the root literal node + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ default @Unmodifiable @NotNull Set register(final @NotNull LiteralCommandNode node, final @Nullable String description) { ++ default @Unmodifiable Set register(final LiteralCommandNode node, final @Nullable String description) { + return this.register(node, description, Collections.emptyList()); + } + @@ -802,7 +806,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param aliases a collection of aliases to register the literal node's command to + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ default @Unmodifiable @NotNull Set register(final @NotNull LiteralCommandNode node, final @NotNull Collection aliases) { ++ default @Unmodifiable Set register(final LiteralCommandNode node, final Collection aliases) { + return this.register(node, null, aliases); + } + @@ -820,7 +824,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param aliases a collection of aliases to register the literal node's command to + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ @Unmodifiable @NotNull Set register(@NotNull LiteralCommandNode node, @Nullable String description, @NotNull Collection aliases); ++ @Unmodifiable Set register(LiteralCommandNode node, @Nullable String description, Collection aliases); + + /** + * Registers a command for a plugin. @@ -837,7 +841,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param aliases a collection of aliases to register the literal node's command to + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ @Unmodifiable @NotNull Set register(@NotNull PluginMeta pluginMeta, @NotNull LiteralCommandNode node, @Nullable String description, @NotNull Collection aliases); ++ @Unmodifiable Set register(PluginMeta pluginMeta, LiteralCommandNode node, @Nullable String description, Collection aliases); + + /** + * This allows configuring the registration of your command, which is not intended for public use. @@ -854,7 +858,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * See {@link CommandRegistrationFlag} for a more indepth explanation of this method's use-case. + */ + @ApiStatus.Internal -+ @Unmodifiable @NotNull Set registerWithFlags(@NotNull PluginMeta pluginMeta, @NotNull LiteralCommandNode node, @Nullable String description, @NotNull Collection aliases, @NotNull Set flags); ++ @Unmodifiable Set registerWithFlags(PluginMeta pluginMeta, LiteralCommandNode node, @Nullable String description, Collection aliases, Set flags); + + /** + * Registers a command under the same logic as {@link Commands#register(LiteralCommandNode, String, Collection)}. @@ -863,7 +867,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param basicCommand the basic command instance to register + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ default @Unmodifiable @NotNull Set register(final @NotNull String label, final @NotNull BasicCommand basicCommand) { ++ default @Unmodifiable Set register(final String label, final BasicCommand basicCommand) { + return this.register(label, null, Collections.emptyList(), basicCommand); + } + @@ -875,7 +879,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param basicCommand the basic command instance to register + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ default @Unmodifiable @NotNull Set register(final @NotNull String label, final @Nullable String description, final @NotNull BasicCommand basicCommand) { ++ default @Unmodifiable Set register(final String label, final @Nullable String description, final BasicCommand basicCommand) { + return this.register(label, description, Collections.emptyList(), basicCommand); + } + @@ -887,7 +891,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param basicCommand the basic command instance to register + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ default @Unmodifiable @NotNull Set register(final @NotNull String label, final @NotNull Collection aliases, final @NotNull BasicCommand basicCommand) { ++ default @Unmodifiable Set register(final String label, final Collection aliases, final BasicCommand basicCommand) { + return this.register(label, null, aliases, basicCommand); + } + @@ -900,7 +904,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param basicCommand the basic command instance to register + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ @Unmodifiable @NotNull Set register(@NotNull String label, @Nullable String description, @NotNull Collection aliases, @NotNull BasicCommand basicCommand); ++ @Unmodifiable Set register(String label, @Nullable String description, Collection aliases, BasicCommand basicCommand); + + /** + * Registers a command under the same logic as {@link Commands#register(PluginMeta, LiteralCommandNode, String, Collection)}. @@ -912,7 +916,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param basicCommand the basic command instance to register + * @return successfully registered root command labels (including aliases and namespaced variants) + */ -+ @Unmodifiable @NotNull Set register(@NotNull PluginMeta pluginMeta, @NotNull String label, @Nullable String description, @NotNull Collection aliases, @NotNull BasicCommand basicCommand); ++ @Unmodifiable Set register(PluginMeta pluginMeta, String label, @Nullable String description, Collection aliases, BasicCommand basicCommand); +} diff --git a/src/main/java/io/papermc/paper/command/brigadier/MessageComponentSerializer.java b/src/main/java/io/papermc/paper/command/brigadier/MessageComponentSerializer.java new file mode 100644 @@ -926,12 +930,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.ComponentSerializer; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +/** + * A component serializer for converting between {@link Message} and {@link Component}. + */ +@ApiStatus.Experimental ++@NullMarked +@ApiStatus.NonExtendable +public interface MessageComponentSerializer extends ComponentSerializer { + @@ -940,7 +945,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return serializer instance + */ -+ static @NotNull MessageComponentSerializer message() { ++ static MessageComponentSerializer message() { + return MessageComponentSerializerHolder.PROVIDER.orElseThrow(); + } +} @@ -998,7 +1003,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.scoreboard.Criteria; +import org.bukkit.scoreboard.DisplaySlot; +import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; ++import org.jspecify.annotations.NullMarked; + +import static io.papermc.paper.command.brigadier.argument.VanillaArgumentProvider.provider; + @@ -1011,6 +1016,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + *

{@link CustomArgumentType} is provided for customizing parsing or result types server-side, while sending the vanilla argument type to the client.

+ */ +@ApiStatus.Experimental ++@NullMarked +public final class ArgumentTypes { + + /** @@ -1019,7 +1025,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument that takes one entity + */ -+ public static @NotNull ArgumentType entity() { ++ public static ArgumentType entity() { + return provider().entity(); + } + @@ -1029,7 +1035,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument that takes multiple entities + */ -+ public static @NotNull ArgumentType entities() { ++ public static ArgumentType entities() { + return provider().entities(); + } + @@ -1039,7 +1045,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument that takes one player + */ -+ public static @NotNull ArgumentType player() { ++ public static ArgumentType player() { + return provider().player(); + } + @@ -1049,7 +1055,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument that takes multiple players + */ -+ public static @NotNull ArgumentType players() { ++ public static ArgumentType players() { + return provider().players(); + } + @@ -1059,7 +1065,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return player profile argument + */ -+ public static @NotNull ArgumentType playerProfiles() { ++ public static ArgumentType playerProfiles() { + return provider().playerProfiles(); + } + @@ -1068,7 +1074,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return block position argument + */ -+ public static @NotNull ArgumentType blockPosition() { ++ public static ArgumentType blockPosition() { + return provider().blockPosition(); + } + @@ -1078,7 +1084,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return fine position argument + * @see #finePosition(boolean) to center whole numbers + */ -+ public static @NotNull ArgumentType finePosition() { ++ public static ArgumentType finePosition() { + return finePosition(false); + } + @@ -1088,7 +1094,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param centerIntegers if whole numbers should be centered (+0.5) + * @return fine position argument + */ -+ public static @NotNull ArgumentType finePosition(final boolean centerIntegers) { ++ public static ArgumentType finePosition(final boolean centerIntegers) { + return provider().finePosition(centerIntegers); + } + @@ -1098,7 +1104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument + */ -+ public static @NotNull ArgumentType blockState() { ++ public static ArgumentType blockState() { + return provider().blockState(); + } + @@ -1108,7 +1114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument + */ -+ public static @NotNull ArgumentType itemStack() { ++ public static ArgumentType itemStack() { + return provider().itemStack(); + } + @@ -1117,7 +1123,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument + */ -+ public static @NotNull ArgumentType itemPredicate() { ++ public static ArgumentType itemPredicate() { + return provider().itemStackPredicate(); + } + @@ -1126,7 +1132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument + */ -+ public static @NotNull ArgumentType namedColor() { ++ public static ArgumentType namedColor() { + return provider().namedColor(); + } + @@ -1135,7 +1141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument + */ -+ public static @NotNull ArgumentType component() { ++ public static ArgumentType component() { + return provider().component(); + } + @@ -1144,7 +1150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return argument + */ -+ public static @NotNull ArgumentType