Finish converting most of the undeprecated api to jspecify

This commit is contained in:
Jake Potrebic
2024-09-30 11:44:36 -07:00
parent 29a25df60e
commit 0adf5876db
45 changed files with 782 additions and 718 deletions

View File

@@ -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;
+ }