switch to JSpecify annotations

This commit is contained in:
granny
2024-10-03 19:33:40 -07:00
parent 212c942316
commit 2eaea6a060
13 changed files with 158 additions and 173 deletions

View File

@@ -39,10 +39,10 @@ index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..a09b5458191eb5df4787859b72a37fa1
server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
diff --git a/src/main/java/org/purpurmc/purpur/event/ExecuteCommandEvent.java b/src/main/java/org/purpurmc/purpur/event/ExecuteCommandEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798702a8179
index 0000000000000000000000000000000000000000..55feef2321c7d966c72a33a58cf10136a9cacfa6
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/ExecuteCommandEvent.java
@@ -0,0 +1,130 @@
@@ -0,0 +1,127 @@
+package org.purpurmc.purpur.event;
+
+import com.google.common.base.Preconditions;
@@ -51,21 +51,24 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+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;
+
+/**
+ * This event is called whenever someone runs a command
+ */
+@NullMarked
+public class ExecuteCommandEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancel = false;
+ private CommandSender sender;
+ private Command command;
+ private String label;
+ private String[] args;
+ private @Nullable String[] args;
+
+ public ExecuteCommandEvent(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @Nullable String[] args) {
+ @ApiStatus.Internal
+ public ExecuteCommandEvent(CommandSender sender, Command command, String label, @Nullable String[] args) {
+ this.sender = sender;
+ this.command = command;
+ this.label = label;
@@ -77,7 +80,6 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ *
+ * @return Command the player is attempting to execute
+ */
+ @NotNull
+ public Command getCommand() {
+ return command;
+ }
@@ -88,7 +90,7 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ * @param command New command that the player will execute
+ * @throws IllegalArgumentException if command is null or empty
+ */
+ public void setCommand(@NotNull Command command) throws IllegalArgumentException {
+ public void setCommand(Command command) throws IllegalArgumentException {
+ Preconditions.checkArgument(command != null, "Command cannot be null");
+ this.command = command;
+ }
@@ -98,7 +100,6 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ *
+ * @return Sender this command will be executed as
+ */
+ @NotNull
+ public CommandSender getSender() {
+ return sender;
+ }
@@ -109,7 +110,7 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ * @param sender New sender which this event will execute as
+ * @throws IllegalArgumentException if the sender provided is null
+ */
+ public void setSender(@NotNull final CommandSender sender) throws IllegalArgumentException {
+ public void setSender(final CommandSender sender) throws IllegalArgumentException {
+ Preconditions.checkArgument(sender != null, "Sender cannot be null");
+ this.sender = sender;
+ }
@@ -119,7 +120,6 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ *
+ * @return Label used to execute this command
+ */
+ @NotNull
+ public String getLabel() {
+ return label;
+ }
@@ -129,7 +129,7 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ *
+ * @param label Label used
+ */
+ public void setLabel(@NotNull String label) {
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
@@ -138,7 +138,6 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ *
+ * @return Args passed to the command
+ */
+ @NotNull
+ public String[] getArgs() {
+ return args;
+ }
@@ -148,7 +147,7 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ *
+ * @param args Args passed to the command
+ */
+ public void setArgs(@NotNull String[] args) {
+ public void setArgs(String[] args) {
+ this.args = args;
+ }
+
@@ -162,13 +161,11 @@ index 0000000000000000000000000000000000000000..bc590c4d49d32f4365a50ceb5785e798
+ this.cancel = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }