Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic
2024-09-29 16:48:34 -07:00
parent fa97c59a4e
commit 29a25df60e
78 changed files with 757 additions and 883 deletions

View File

@@ -19,23 +19,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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..00000000000000000000000000000000
+ *
+ * @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..00000000000000000000000000000000
+ *
+ * @return the gamerule being changed.
+ */
+ @NotNull
+ public GameRule<?> getGameRule() {
+ return this.gameRule;
+ }
@@ -67,7 +66,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the new value of the gamerule.
+ */
+ @NotNull
+ public String getValue() {
+ return this.value;
+ }
@@ -77,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @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..00000000000000000000000000000000
+ }
+
+ @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;
+ }