Begin switching to JSpecify annotations (#11448)

* Begin switching to JSpecify annotations

* more

* fixes
This commit is contained in:
Jake Potrebic
2024-09-29 12:52:13 -07:00
parent fa1f6a5d78
commit 64e918335c
62 changed files with 580 additions and 750 deletions

View File

@@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired any time a Brigadier RootCommandNode is generated for a player to inform the client of commands.
@@ -138,6 +138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p>This is a draft/experimental API and is subject to change.</p>
+ */
+@ApiStatus.Experimental
+@NullMarked
+public class AsyncPlayerSendCommandsEvent<S extends CommandSourceStack> extends PlayerEvent {
+
+ private static final HandlerList handlers = new HandlerList();
@@ -145,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final boolean hasFiredAsync;
+
+ @ApiStatus.Internal
+ public AsyncPlayerSendCommandsEvent(@NotNull Player player, @NotNull RootCommandNode<S> node, boolean hasFiredAsync) {
+ public AsyncPlayerSendCommandsEvent(final Player player, final RootCommandNode<S> node, final boolean hasFiredAsync) {
+ super(player, !Bukkit.isPrimaryThread());
+ this.node = node;
+ this.hasFiredAsync = hasFiredAsync;
@@ -156,8 +157,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the root command node
+ */
+ public @NotNull RootCommandNode<S> getCommandNode() {
+ return node;
+ public RootCommandNode<S> getCommandNode() {
+ return this.node;
+ }
+
+ /**
@@ -166,15 +167,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return whether this event has already fired asynchronously
+ */
+ public boolean hasFiredAsync() {
+ return hasFiredAsync;
+ return this.hasFiredAsync;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
@@ -194,13 +193,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when sending {@link Suggestions} to the client. Will be called asynchronously if a plugin
+ * marks the {@link com.destroystokyo.paper.event.server.AsyncTabCompleteEvent} event handled asynchronously,
+ * otherwise called synchronously.
+ */
+@NullMarked
+public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
@@ -210,7 +210,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final String buffer;
+
+ @ApiStatus.Internal
+ public AsyncPlayerSendSuggestionsEvent(@NotNull Player player, @NotNull Suggestions suggestions, @NotNull String buffer) {
+ public AsyncPlayerSendSuggestionsEvent(final Player player, final Suggestions suggestions, final String buffer) {
+ super(player, !Bukkit.isPrimaryThread());
+ this.suggestions = suggestions;
+ this.buffer = buffer;
@@ -221,8 +221,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the input buffer
+ */
+ public @NotNull String getBuffer() {
+ return buffer;
+ public String getBuffer() {
+ return this.buffer;
+ }
+
+ /**
@@ -230,8 +230,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the suggestions
+ */
+ public @NotNull Suggestions getSuggestions() {
+ return suggestions;
+ public Suggestions getSuggestions() {
+ return this.suggestions;
+ }
+
+ /**
@@ -239,7 +239,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param suggestions suggestions
+ */
+ public void setSuggestions(@NotNull Suggestions suggestions) {
+ public void setSuggestions(final Suggestions suggestions) {
+ this.suggestions = suggestions;
+ }
+
@@ -256,16 +256,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * {@inheritDoc}
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }