Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic 2024-09-29 16:48:34 -07:00
parent ea00be3aaa
commit ba3c29b92e
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
82 changed files with 977 additions and 1103 deletions

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Added WorldGameRuleChangeEvent
diff --git a/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java b/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba2432109f01
index 0000000000000000000000000000000000000000..4d259e31c4b1bb01318c727d8e340b6b23084067
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java
@@ -0,0 +1,92 @@
@@ -0,0 +1,88 @@
+package io.papermc.paper.event.world;
+
+import org.bukkit.GameRule;
@ -19,23 +19,24 @@ index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba24
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.WorldEvent;
+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;
+
+/**
+ * Called when a world's gamerule is changed, either by command or by api.
+ */
+@NullMarked
+public class WorldGameRuleChangeEvent extends WorldEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final CommandSender commandSender;
+ private final @Nullable CommandSender commandSender;
+ private final GameRule<?> gameRule;
+ private String value;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public WorldGameRuleChangeEvent(@NotNull World world, @Nullable CommandSender commandSender, @NotNull GameRule<?> gameRule, @NotNull String value) {
+ public WorldGameRuleChangeEvent(final World world, final @Nullable CommandSender commandSender, final GameRule<?> gameRule, final String value) {
+ super(world);
+ this.commandSender = commandSender;
+ this.gameRule = gameRule;
@ -47,8 +48,7 @@ index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba24
+ *
+ * @return {@code null} if the gamerule was changed via api, otherwise the {@link CommandSender}.
+ */
+ @Nullable
+ public CommandSender getCommandSender() {
+ public @Nullable CommandSender getCommandSender() {
+ return this.commandSender;
+ }
+
@ -57,7 +57,6 @@ index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba24
+ *
+ * @return the gamerule being changed.
+ */
+ @NotNull
+ public GameRule<?> getGameRule() {
+ return this.gameRule;
+ }
@ -67,7 +66,6 @@ index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba24
+ *
+ * @return the new value of the gamerule.
+ */
+ @NotNull
+ public String getValue() {
+ return this.value;
+ }
@ -77,7 +75,7 @@ index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba24
+ *
+ * @param value the new value of the gamerule.
+ */
+ public void setValue(@NotNull String value) {
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
@ -87,17 +85,15 @@ index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba24
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }