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

@ -19,11 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffect;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a beacon effect is being applied to a player. + * Called when a beacon effect is being applied to a player.
+ */ + */
+@NullMarked
+public class BeaconEffectEvent extends BlockEvent implements Cancellable { +public class BeaconEffectEvent extends BlockEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -35,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) { + public BeaconEffectEvent(final Block block, final PotionEffect effect, final Player player, final boolean primary) {
+ super(block); + super(block);
+ this.effect = effect; + this.effect = effect;
+ this.player = player; + this.player = player;
@ -47,7 +48,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Potion effect + * @return Potion effect
+ */ + */
+ @NotNull
+ public PotionEffect getEffect() { + public PotionEffect getEffect() {
+ return this.effect; + return this.effect;
+ } + }
@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param effect Potion effect + * @param effect Potion effect
+ */ + */
+ public void setEffect(@NotNull PotionEffect effect) { + public void setEffect(final PotionEffect effect) {
+ this.effect = effect; + this.effect = effect;
+ } + }
+ +
@ -66,7 +66,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Affected player + * @return Affected player
+ */ + */
+ @NotNull
+ public Player getPlayer() { + public Player getPlayer() {
+ return this.player; + return this.player;
+ } + }
@ -86,17 +85,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -12,20 +12,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import java.util.List;
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExpEvent; +import org.bukkit.event.block.BlockExpEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+
+import java.util.List;
+ +
+/** +/**
+ * Called when a block forces another block to break and drop items. + * Called when a block forces another block to break and drop items.
+ * <p> + * <p>
+ * Currently called for piston's and liquid flows. + * Currently called for piston's and liquid flows.
+ */ + */
+@NullMarked
+public class BlockBreakBlockEvent extends BlockExpEvent { +public class BlockBreakBlockEvent extends BlockExpEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -34,18 +34,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final List<ItemStack> drops; + private final List<ItemStack> drops;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockBreakBlockEvent(@NotNull Block block, @NotNull Block source, @NotNull List<ItemStack> drops) { + public BlockBreakBlockEvent(final Block block, final Block source, final List<ItemStack> drops) {
+ super(block, 0); + super(block, 0);
+ this.source = source; + this.source = source;
+ this.drops = drops; + this.drops = drops;
+ } + }
+ +
+ /** + /**
+ * Gets the drops of this event + * Gets a mutable list of drops for this event
+ * + *
+ * @return the drops + * @return the drops
+ */ + */
+ @NotNull
+ public List<ItemStack> getDrops() { + public List<ItemStack> getDrops() {
+ return this.drops; + return this.drops;
+ } + }
@ -55,18 +54,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the source + * @return the source
+ */ + */
+ @NotNull
+ public Block getSource() { + public Block getSource() {
+ return this.source; + return this.source;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -17,20 +17,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Range;
+ +
+/** +/**
+ * Called when the progress of a block break is updated. + * Called when the progress of a block break is updated.
+ */ + */
+@NullMarked
+public class BlockBreakProgressUpdateEvent extends BlockEvent { +public class BlockBreakProgressUpdateEvent extends BlockEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final float progress; + private final float progress;
+ private final Entity entity; + private final Entity entity;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockBreakProgressUpdateEvent(@NotNull final Block block, final float progress, @NotNull final Entity entity) { + public BlockBreakProgressUpdateEvent(final Block block, final float progress, final Entity entity) {
+ super(block); + super(block);
+ this.progress = progress; + this.progress = progress;
+ this.entity = entity; + this.entity = entity;
@ -45,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return The progress of the block break + * @return The progress of the block break
+ */ + */
+ public float getProgress() { + public float getProgress() {
+ return progress; + return this.progress;
+ } + }
+ +
+ /** + /**
@ -53,16 +54,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The entity breaking the block + * @return The entity breaking the block
+ */ + */
+ @NotNull
+ public Entity getEntity() { + public Entity getEntity() {
+ return entity; + return this.entity;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ public static @NotNull HandlerList getHandlerList() { +
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}

View file

@ -15,12 +15,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a block tries to dispense an item, but its inventory is empty. + * Called when a block tries to dispense an item, but its inventory is empty.
+ */ + */
+@NullMarked
+public class BlockFailedDispenseEvent extends BlockEvent { +public class BlockFailedDispenseEvent extends BlockEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -28,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean shouldPlayEffect = true; + private boolean shouldPlayEffect = true;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockFailedDispenseEvent(@NotNull Block theBlock) { + public BlockFailedDispenseEvent(final Block theBlock) {
+ super(theBlock); + super(theBlock);
+ } + }
+ +
@ -44,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param playEffect if the effect should be played + * @param playEffect if the effect should be played
+ */ + */
+ public void shouldPlayEffect(boolean playEffect) { + public void shouldPlayEffect(final boolean playEffect) {
+ this.shouldPlayEffect = playEffect; + this.shouldPlayEffect = playEffect;
+ } + }
+ +
@ -58,11 +60,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}

View file

@ -31,6 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+import io.papermc.paper.block.LockableTileState; +import io.papermc.paper.block.LockableTileState;
+import java.util.Objects;
+import net.kyori.adventure.sound.Sound; +import net.kyori.adventure.sound.Sound;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -40,28 +41,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+
+import java.util.Objects;
+ +
+/** +/**
+ * Called when the server tries to check the lock on a lockable block entity. + * Called when the server tries to check the lock on a lockable block entity.
+ * <br> + * <br>
+ * See {@link #setResult(Result)} to change behavior + * See {@link #setResult(Result)} to change behavior
+ */ + */
+@NullMarked
+public class BlockLockCheckEvent extends BlockEvent { +public class BlockLockCheckEvent extends BlockEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Player player; + private final Player player;
+ private Component lockedMessage; + private @Nullable Component lockedMessage;
+ private Sound lockedSound; + private @Nullable Sound lockedSound;
+ private ItemStack itemStack; + private @Nullable ItemStack itemStack;
+ private Result result = Result.DEFAULT; + private Result result = Result.DEFAULT;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockLockCheckEvent(final @NotNull Block block, final @NotNull Player player, final @NotNull Component lockedMessage, final @NotNull Sound lockedSound) { + public BlockLockCheckEvent(final Block block, final Player player, final Component lockedMessage, final Sound lockedSound) {
+ super(block); + super(block);
+ this.player = player; + this.player = player;
+ this.lockedMessage = lockedMessage; + this.lockedMessage = lockedMessage;
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the snapshot block state. + * @return the snapshot block state.
+ */ + */
+ public @NotNull LockableTileState getBlockState() { + public LockableTileState getBlockState() {
+ final BlockState blockState = this.getBlock().getState(); + final BlockState blockState = this.getBlock().getState();
+ Preconditions.checkState(blockState instanceof LockableTileState, "Block state of lock-checked block is no longer a lockable tile state!"); + Preconditions.checkState(blockState instanceof LockableTileState, "Block state of lock-checked block is no longer a lockable tile state!");
+ return (LockableTileState) blockState; + return (LockableTileState) blockState;
@ -85,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the player + * @return the player
+ */ + */
+ public @NotNull Player getPlayer() { + public Player getPlayer() {
+ return this.player; + return this.player;
+ } + }
+ +
@ -98,7 +98,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the item being used as the key item + * @return the item being used as the key item
+ * @see #isUsingCustomKeyItemStack() + * @see #isUsingCustomKeyItemStack()
+ */ + */
+ public @NotNull ItemStack getKeyItem() { + public ItemStack getKeyItem() {
+ return Objects.requireNonNullElseGet(this.itemStack, this.player.getInventory()::getItemInMainHand); + return Objects.requireNonNullElseGet(this.itemStack, this.player.getInventory()::getItemInMainHand);
+ } + }
+ +
@ -108,7 +108,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param stack the stack to use as a key + * @param stack the stack to use as a key
+ * @see #resetKeyItem() to clear a custom key item + * @see #resetKeyItem() to clear a custom key item
+ */ + */
+ public void setKeyItem(@NotNull ItemStack stack) { + public void setKeyItem(final ItemStack stack) {
+ Preconditions.checkArgument(stack != null, "stack cannot be null"); + Preconditions.checkArgument(stack != null, "stack cannot be null");
+ this.itemStack = stack; + this.itemStack = stack;
+ } + }
@ -135,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the result + * @return the result
+ * @see #setResult(Result) + * @see #setResult(Result)
+ */ + */
+ public @NotNull Result getResult() { + public Result getResult() {
+ return this.result; + return this.result;
+ } + }
+ +
@ -148,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param result the result of this event + * @param result the result of this event
+ */ + */
+ public void setResult(@NotNull Result result) { + public void setResult(final Result result) {
+ this.result = result; + this.result = result;
+ } + }
+ +
@ -159,7 +159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param lockedMessage the message to show if locked (or {@code null} for none) + * @param lockedMessage the message to show if locked (or {@code null} for none)
+ * @param lockedSound the sound to play if locked (or {@code null} for none) + * @param lockedSound the sound to play if locked (or {@code null} for none)
+ */ + */
+ public void denyWithMessageAndSound(@Nullable Component lockedMessage, @Nullable Sound lockedSound) { + public void denyWithMessageAndSound(final @Nullable Component lockedMessage, final @Nullable Sound lockedSound) {
+ this.result = Result.DENY; + this.result = Result.DENY;
+ this.lockedMessage = lockedMessage; + this.lockedMessage = lockedMessage;
+ this.lockedSound = lockedSound; + this.lockedSound = lockedSound;
@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param lockedMessage the locked message (or {@code null} for none) + * @param lockedMessage the locked message (or {@code null} for none)
+ */ + */
+ public void setLockedMessage(@Nullable Component lockedMessage) { + public void setLockedMessage(final @Nullable Component lockedMessage) {
+ this.lockedMessage = lockedMessage; + this.lockedMessage = lockedMessage;
+ } + }
+ +
@ -201,16 +201,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param lockedSound the locked sound (or {@code null} for none) + * @param lockedSound the locked sound (or {@code null} for none)
+ */ + */
+ public void setLockedSound(@Nullable Sound lockedSound) { + public void setLockedSound(final @Nullable Sound lockedSound) {
+ this.lockedSound = lockedSound; + this.lockedSound = lockedSound;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}

View file

@ -18,8 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class BlockPreDispenseEvent extends BlockEvent implements Cancellable { +public class BlockPreDispenseEvent extends BlockEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -30,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockPreDispenseEvent(@NotNull Block block, @NotNull ItemStack itemStack, int slot) { + public BlockPreDispenseEvent(final Block block, final ItemStack itemStack, final int slot) {
+ super(block); + super(block);
+ this.itemStack = itemStack; + this.itemStack = itemStack;
+ this.slot = slot; + this.slot = slot;
@ -41,7 +42,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The item to be dispensed + * @return The item to be dispensed
+ */ + */
+ @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return this.itemStack; + return this.itemStack;
+ } + }
@ -61,16 +61,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -18,12 +18,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.inventory.InventoryMoveItemEvent; +import org.bukkit.event.inventory.InventoryMoveItemEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when an item is about to be composted by a hopper. + * Called when an item is about to be composted by a hopper.
+ * To prevent hoppers from moving items into composters, cancel the {@link InventoryMoveItemEvent}. + * To prevent hoppers from moving items into composters, cancel the {@link InventoryMoveItemEvent}.
+ */ + */
+@NullMarked
+public class CompostItemEvent extends BlockEvent { +public class CompostItemEvent extends BlockEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -32,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean willRaiseLevel; + private boolean willRaiseLevel;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public CompostItemEvent(@NotNull Block composter, @NotNull ItemStack item, boolean willRaiseLevel) { + public CompostItemEvent(final Block composter, final ItemStack item, final boolean willRaiseLevel) {
+ super(composter); + super(composter);
+ this.item = item; + this.item = item;
+ this.willRaiseLevel = willRaiseLevel; + this.willRaiseLevel = willRaiseLevel;
@ -43,7 +44,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the item + * @return the item
+ */ + */
+ @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return this.item; + return this.item;
+ } + }
@ -62,16 +62,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param willRaiseLevel {@code true} if the composter should rise a level + * @param willRaiseLevel {@code true} if the composter should rise a level
+ */ + */
+ public void setWillRaiseLevel(boolean willRaiseLevel) { + public void setWillRaiseLevel(final boolean willRaiseLevel) {
+ this.willRaiseLevel = willRaiseLevel; + this.willRaiseLevel = willRaiseLevel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -91,18 +90,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when an item is about to be composted by an entity. + * Called when an item is about to be composted by an entity.
+ */ + */
+@NullMarked
+public class EntityCompostItemEvent extends CompostItemEvent implements Cancellable { +public class EntityCompostItemEvent extends CompostItemEvent implements Cancellable {
+ +
+ private final Entity entity; + private final Entity entity;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityCompostItemEvent(@NotNull Entity entity, @NotNull Block composter, @NotNull ItemStack item, boolean willRaiseLevel) { + public EntityCompostItemEvent(final Entity entity, final Block composter, final ItemStack item, final boolean willRaiseLevel) {
+ super(composter, item, willRaiseLevel); + super(composter, item, willRaiseLevel);
+ this.entity = entity; + this.entity = entity;
+ } + }
@ -112,7 +112,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entity that composted an item. + * @return the entity that composted an item.
+ */ + */
+ @NotNull
+ public Entity getEntity() { + public Entity getEntity() {
+ return this.entity; + return this.entity;
+ } + }
@ -123,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +

View file

@ -18,11 +18,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Is called when an {@link ElderGuardian} appears in front of a {@link Player}. + * Is called when an {@link ElderGuardian} appears in front of a {@link Player}.
+ */ + */
+@NullMarked
+public class ElderGuardianAppearanceEvent extends EntityEvent implements Cancellable { +public class ElderGuardianAppearanceEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -31,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ElderGuardianAppearanceEvent(@NotNull ElderGuardian guardian, @NotNull Player affectedPlayer) { + public ElderGuardianAppearanceEvent(final ElderGuardian guardian, final Player affectedPlayer) {
+ super(guardian); + super(guardian);
+ this.affectedPlayer = affectedPlayer; + this.affectedPlayer = affectedPlayer;
+ } + }
@ -41,7 +42,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Player affected by the appearance + * @return Player affected by the appearance
+ */ + */
+ @NotNull
+ public Player getAffectedPlayer() { + public Player getAffectedPlayer() {
+ return this.affectedPlayer; + return this.affectedPlayer;
+ } + }
@ -51,7 +51,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The elder guardian + * @return The elder guardian
+ */ + */
+ @NotNull
+ public ElderGuardian getEntity() { + public ElderGuardian getEntity() {
+ return (ElderGuardian) super.getEntity(); + return (ElderGuardian) super.getEntity();
+ } + }
@ -62,17 +61,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -53,24 +53,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when an entity is dyed. Currently, this is called for {@link Sheep} + * Called when an entity is dyed. Currently, this is called for {@link Sheep}
+ * being dyed, and {@link Wolf}/{@link Cat} collars being dyed. + * being dyed, and {@link Wolf}/{@link Cat} collars being dyed.
+ */ + */
+@NullMarked
+public class EntityDyeEvent extends EntityEvent implements Cancellable { +public class EntityDyeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Player player; + private final @Nullable Player player;
+ private DyeColor dyeColor; + private DyeColor dyeColor;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityDyeEvent(@NotNull Entity entity, @NotNull DyeColor dyeColor, @Nullable Player player) { + public EntityDyeEvent(final Entity entity, final DyeColor dyeColor, final @Nullable Player player) {
+ super(entity); + super(entity);
+ this.dyeColor = dyeColor; + this.dyeColor = dyeColor;
+ this.player = player; + this.player = player;
@ -81,7 +82,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the DyeColor the entity is being dyed + * @return the DyeColor the entity is being dyed
+ */ + */
+ public @NotNull DyeColor getColor() { + public DyeColor getColor() {
+ return this.dyeColor; + return this.dyeColor;
+ } + }
+ +
@ -90,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param dyeColor the DyeColor the entity will be dyed + * @param dyeColor the DyeColor the entity will be dyed
+ */ + */
+ public void setColor(@NotNull DyeColor dyeColor) { + public void setColor(final DyeColor dyeColor) {
+ this.dyeColor = dyeColor; + this.dyeColor = dyeColor;
+ } + }
+ +
@ -109,16 +110,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}

View file

@ -21,8 +21,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when two entities mate and the mating process results in a fertilization. + * Called when two entities mate and the mating process results in a fertilization.
@ -35,23 +35,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <li>Sniffers producing the {@link Material#SNIFFER_EGG} item, which needs to be placed before it can begin to hatch.</li> + * <li>Sniffers producing the {@link Material#SNIFFER_EGG} item, which needs to be placed before it can begin to hatch.</li>
+ * <li>A turtle being marked with "HasEgg" and laying a {@link Material#TURTLE_EGG} later.</li> + * <li>A turtle being marked with "HasEgg" and laying a {@link Material#TURTLE_EGG} later.</li>
+ * </ul> + * </ul>
+ * + * <p>
+ * The event hence only exposes the two parent entities in the fertilization process and cannot provide the child entity, as it will only exist at a later point in time. + * The event hence only exposes the two parent entities in the fertilization process and cannot provide the child entity, as it will only exist at a later point in time.
+ */ + */
+@NullMarked
+public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable { +public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final LivingEntity mother; + private final LivingEntity mother;
+ private final LivingEntity father; + private final LivingEntity father;
+ private final Player breeder; + private final @Nullable Player breeder;
+ private final ItemStack bredWith; + private final @Nullable ItemStack bredWith;
+ private int experience; + private int experience;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityFertilizeEggEvent(@NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable Player breeder, @Nullable ItemStack bredWith, int experience) { + public EntityFertilizeEggEvent(final LivingEntity mother, final LivingEntity father, final @Nullable Player breeder, final @Nullable ItemStack bredWith, final int experience) {
+ super(mother); + super(mother);
+ this.mother = mother; + this.mother = mother;
+ this.father = father; + this.father = father;
@ -60,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.experience = experience; + this.experience = experience;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity(); + return (LivingEntity) super.getEntity();
@ -72,7 +72,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The "mother" entity. + * @return The "mother" entity.
+ */ + */
+ @NotNull
+ public LivingEntity getMother() { + public LivingEntity getMother() {
+ return this.mother; + return this.mother;
+ } + }
@ -83,7 +82,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the other parent + * @return the other parent
+ */ + */
+ @NotNull
+ public LivingEntity getFather() { + public LivingEntity getFather() {
+ return this.father; + return this.father;
+ } + }
@ -94,8 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The Entity who initiated fertilization. + * @return The Entity who initiated fertilization.
+ */ + */
+ @Nullable + public @Nullable Player getBreeder() {
+ public Player getBreeder() {
+ return this.breeder; + return this.breeder;
+ } + }
+ +
@ -104,8 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return ItemStack used to initiate fertilization. + * @return ItemStack used to initiate fertilization.
+ */ + */
+ @Nullable + public @Nullable ItemStack getBredWith() {
+ public ItemStack getBredWith() {
+ return this.bredWith; + return this.bredWith;
+ } + }
+ +
@ -124,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param experience experience amount + * @param experience experience amount
+ */ + */
+ public void setExperience(int experience) { + public void setExperience(final int experience) {
+ this.experience = experience; + this.experience = experience;
+ } + }
+ +
@ -134,17 +130,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when an entity enters the hitbox of a block. + * Called when an entity enters the hitbox of a block.
@ -53,6 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <li>Wither rose</li> + * <li>Wither rose</li>
+ * </ul> + * </ul>
+ */ + */
+@NullMarked
+public class EntityInsideBlockEvent extends EntityEvent implements Cancellable { +public class EntityInsideBlockEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -61,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityInsideBlockEvent(@NotNull Entity entity, @NotNull Block block) { + public EntityInsideBlockEvent(final Entity entity, final Block block) {
+ super(entity); + super(entity);
+ this.block = block; + this.block = block;
+ } + }
@ -71,7 +72,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the block + * @return the block
+ */ + */
+ @NotNull
+ public Block getBlock() { + public Block getBlock() {
+ return this.block; + return this.block;
+ } + }
@ -82,17 +82,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -19,11 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a LivingEntity loads a crossbow with a projectile. + * Called when a LivingEntity loads a crossbow with a projectile.
+ */ + */
+@NullMarked
+public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable { +public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -35,13 +36,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @NotNull ItemStack crossbow, @NotNull EquipmentSlot hand) { + public EntityLoadCrossbowEvent(final LivingEntity entity, final ItemStack crossbow, final EquipmentSlot hand) {
+ super(entity); + super(entity);
+ this.crossbow = crossbow; + this.crossbow = crossbow;
+ this.hand = hand; + this.hand = hand;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity(); + return (LivingEntity) super.getEntity();
@ -52,7 +52,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the crossbow involved in this event + * @return the crossbow involved in this event
+ */ + */
+ @NotNull
+ public ItemStack getCrossbow() { + public ItemStack getCrossbow() {
+ return this.crossbow; + return this.crossbow;
+ } + }
@ -62,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the hand + * @return the hand
+ */ + */
+ @NotNull
+ public EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return this.hand; + return this.hand;
+ } + }
@ -77,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @param consume should the item be consumed + * @param consume should the item be consumed
+ */ + */
+ public void setConsumeItem(boolean consume) { + public void setConsumeItem(final boolean consume) {
+ this.consumeItem = consume; + this.consumeItem = consume;
+ } + }
+ +
@ -91,17 +89,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * projectile that would be loaded into the crossbow will not be consumed. + * projectile that would be loaded into the crossbow will not be consumed.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -21,28 +21,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.entity.EntityPortalEvent;
+import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerPortalEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when an entity is ready to be teleported by a plugin. + * Called when an entity is ready to be teleported by a plugin.
+ * Currently this is only called after the required + * Currently, this is only called after the required
+ * ticks have passed for a Nether Portal. + * ticks have passed for a Nether Portal.
+ * <p> + * <p>
+ * Cancelling this event resets the entity's readiness + * Cancelling this event resets the entity's readiness
+ * regarding the current portal. + * regarding the current portal.
+ */ + */
+@NullMarked
+public class EntityPortalReadyEvent extends EntityEvent implements Cancellable { +public class EntityPortalReadyEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final PortalType portalType; + private final PortalType portalType;
+ private World targetWorld; + private @Nullable World targetWorld;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityPortalReadyEvent(final @NotNull Entity entity, final @Nullable World targetWorld, final @NotNull PortalType portalType) { + public EntityPortalReadyEvent(final Entity entity, final @Nullable World targetWorld, final PortalType portalType) {
+ super(entity); + super(entity);
+ this.targetWorld = targetWorld; + this.targetWorld = targetWorld;
+ this.portalType = portalType; + this.portalType = portalType;
@ -81,7 +82,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the portal type + * @return the portal type
+ */ + */
+ public @NotNull PortalType getPortalType() { + public PortalType getPortalType() {
+ return this.portalType; + return this.portalType;
+ } + }
+ +
@ -96,11 +97,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}

View file

@ -17,17 +17,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.entity.EntityTeleportEvent; +import org.bukkit.event.entity.EntityTeleportEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired any time an entity attempts to teleport in an end gateway + * Fired any time an entity attempts to teleport in an end gateway
+ */ + */
+@NullMarked
+public class EntityTeleportEndGatewayEvent extends EntityTeleportEvent { +public class EntityTeleportEndGatewayEvent extends EntityTeleportEvent {
+ +
+ @NotNull private final EndGateway gateway; + private final EndGateway gateway;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityTeleportEndGatewayEvent(@NotNull Entity entity, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { + public EntityTeleportEndGatewayEvent(final Entity entity, final Location from, final Location to, final EndGateway gateway) {
+ super(entity, from, to); + super(entity, from, to);
+ this.gateway = gateway; + this.gateway = gateway;
+ } + }
@ -37,7 +38,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return EndGateway used + * @return EndGateway used
+ */ + */
+ @NotNull
+ public EndGateway getGateway() { + public EndGateway getGateway() {
+ return this.gateway; + return this.gateway;
+ } + }

View file

@ -12,28 +12,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import java.util.Collections;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.LightningStrike;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityTransformEvent;
+
+import java.util.Collections;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when lightning strikes an entity + * Fired when lightning strikes an entity
+ */ + */
+@NullMarked
+public class EntityZapEvent extends EntityTransformEvent implements Cancellable { +public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final LightningStrike bolt; + private final LightningStrike bolt;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) { + public EntityZapEvent(final Entity entity, final LightningStrike bolt, final Entity replacementEntity) {
+ super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING); + super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING);
+ this.bolt = bolt; + this.bolt = bolt;
+ } + }
@ -43,7 +43,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The lightning bolt responsible for this event + * @return The lightning bolt responsible for this event
+ */ + */
+ @NotNull
+ public LightningStrike getBolt() { + public LightningStrike getBolt() {
+ return this.bolt; + return this.bolt;
+ } + }
@ -53,7 +52,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The entity that will replace the struck entity + * @return The entity that will replace the struck entity
+ */ + */
+ @NotNull
+ public Entity getReplacementEntity() { + public Entity getReplacementEntity() {
+ return super.getTransformedEntity(); + return super.getTransformedEntity();
+ } + }
@ -64,17 +62,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -14,17 +14,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList;
+import org.bukkit.Server;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+import java.net.InetAddress; +import java.net.InetAddress;
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.Arrays; +import java.util.Arrays;
+import java.util.Collection; +import java.util.Collection;
+import java.util.List; +import java.util.List;
+import org.bukkit.Server;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * This event is fired if server is getting queried over GS4 Query protocol. + * This event is fired if server is getting queried over GS4 Query protocol.
@ -33,6 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @author Mark Vainomaa + * @author Mark Vainomaa
+ */ + */
+@NullMarked
+public final class GS4QueryEvent extends Event { +public final class GS4QueryEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -42,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private QueryResponse response; + private QueryResponse response;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public GS4QueryEvent(@NotNull QueryType queryType, @NotNull InetAddress querierAddress, @NotNull QueryResponse response) { + public GS4QueryEvent(final QueryType queryType, final InetAddress querierAddress, final QueryResponse response) {
+ super(true); // should always be called async + super(true); // should always be called async
+ this.queryType = queryType; + this.queryType = queryType;
+ this.querierAddress = querierAddress; + this.querierAddress = querierAddress;
@ -54,7 +55,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return query type + * @return query type
+ */ + */
+ @NotNull
+ public QueryType getQueryType() { + public QueryType getQueryType() {
+ return this.queryType; + return this.queryType;
+ } + }
@ -64,7 +64,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return querier address + * @return querier address
+ */ + */
+ @NotNull
+ public InetAddress getQuerierAddress() { + public InetAddress getQuerierAddress() {
+ return this.querierAddress; + return this.querierAddress;
+ } + }
@ -74,7 +73,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return query response + * @return query response
+ */ + */
+ @NotNull
+ public QueryResponse getResponse() { + public QueryResponse getResponse() {
+ return this.response; + return this.response;
+ } + }
@ -84,17 +82,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param response query response + * @param response query response
+ */ + */
+ public void setResponse(@NotNull QueryResponse response) { + public void setResponse(final QueryResponse response) {
+ this.response = Preconditions.checkNotNull(response, "response"); + this.response = Preconditions.checkNotNull(response, "response");
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -115,7 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ FULL + FULL
+ } + }
+ +
+ public final static class QueryResponse { + public static final class QueryResponse {
+ +
+ private final String motd; + private final String motd;
+ private final String gameVersion; + private final String gameVersion;
@ -128,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final String serverVersion; + private final String serverVersion;
+ private final Collection<PluginInformation> plugins; + private final Collection<PluginInformation> plugins;
+ +
+ private QueryResponse(String motd, String gameVersion, String map, int currentPlayers, int maxPlayers, String hostname, int port, Collection<String> players, String serverVersion, Collection<PluginInformation> plugins) { + private QueryResponse(final String motd, final String gameVersion, final String map, final int currentPlayers, final int maxPlayers, final String hostname, final int port, final Collection<String> players, final String serverVersion, final Collection<PluginInformation> plugins) {
+ this.motd = motd; + this.motd = motd;
+ this.gameVersion = gameVersion; + this.gameVersion = gameVersion;
+ this.map = map; + this.map = map;
@ -142,21 +138,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ /** + /**
+ * Get motd which will be used to reply to the query. By default it is {@link Server#getMotd()}. + * Get motd which will be used to reply to the query. By default, it is {@link Server#getMotd()}.
+ * + *
+ * @return motd + * @return motd
+ */ + */
+ @NotNull
+ public String getMotd() { + public String getMotd() {
+ return this.motd; + return this.motd;
+ } + }
+ +
+ /** + /**
+ * Get game version which will be used to reply to the query. By default supported Minecraft versions range is sent. + * Get game version which will be used to reply to the query. By default, supported Minecraft versions range is sent.
+ * + *
+ * @return game version + * @return game version
+ */ + */
+ @NotNull
+ public String getGameVersion() { + public String getGameVersion() {
+ return this.gameVersion; + return this.gameVersion;
+ } + }
@ -166,7 +160,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return map name + * @return map name
+ */ + */
+ @NotNull
+ public String getMap() { + public String getMap() {
+ return this.map; + return this.map;
+ } + }
@ -194,7 +187,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return server hostname + * @return server hostname
+ */ + */
+ @NotNull
+ public String getHostname() { + public String getHostname() {
+ return this.hostname; + return this.hostname;
+ } + }
@ -213,7 +205,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return collection of players + * @return collection of players
+ */ + */
+ @NotNull
+ public Collection<String> getPlayers() { + public Collection<String> getPlayers() {
+ return this.players; + return this.players;
+ } + }
@ -223,7 +214,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return server software + * @return server software
+ */ + */
+ @NotNull
+ public String getServerVersion() { + public String getServerVersion() {
+ return this.serverVersion; + return this.serverVersion;
+ } + }
@ -233,7 +223,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return collection of plugins + * @return collection of plugins
+ */ + */
+ @NotNull
+ public Collection<PluginInformation> getPlugins() { + public Collection<PluginInformation> getPlugins() {
+ return this.plugins; + return this.plugins;
+ } + }
@ -243,19 +232,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@link QueryResponse} builder + * @return {@link QueryResponse} builder
+ */ + */
+ @NotNull
+ public Builder toBuilder() { + public Builder toBuilder() {
+ return QueryResponse.builder() + return QueryResponse.builder()
+ .motd(getMotd()) + .motd(this.getMotd())
+ .gameVersion(getGameVersion()) + .gameVersion(this.getGameVersion())
+ .map(getMap()) + .map(this.getMap())
+ .currentPlayers(getCurrentPlayers()) + .currentPlayers(this.getCurrentPlayers())
+ .maxPlayers(getMaxPlayers()) + .maxPlayers(this.getMaxPlayers())
+ .hostname(getHostname()) + .hostname(this.getHostname())
+ .port(getPort()) + .port(this.getPort())
+ .players(getPlayers()) + .players(this.getPlayers())
+ .serverVersion(getServerVersion()) + .serverVersion(this.getServerVersion())
+ .plugins(getPlugins()); + .plugins(this.getPlugins());
+ } + }
+ +
+ /** + /**
@ -263,7 +251,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@link QueryResponse} builder + * @return {@link QueryResponse} builder
+ */ + */
+ @NotNull
+ public static Builder builder() { + public static Builder builder() {
+ return new Builder(); + return new Builder();
+ } + }
@ -272,11 +259,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * A builder for {@link QueryResponse} objects. + * A builder for {@link QueryResponse} objects.
+ */ + */
+ public static final class Builder { + public static final class Builder {
+ private String motd; +
+ private String gameVersion; + private @MonotonicNonNull String motd;
+ private String map; + private @MonotonicNonNull String gameVersion;
+ private String hostname; + private @MonotonicNonNull String map;
+ private String serverVersion; + private @MonotonicNonNull String hostname;
+ private @MonotonicNonNull String serverVersion;
+ +
+ private int currentPlayers; + private int currentPlayers;
+ private int maxPlayers; + private int maxPlayers;
@ -285,90 +273,77 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final List<String> players = new ArrayList<>(); + private final List<String> players = new ArrayList<>();
+ private final List<PluginInformation> plugins = new ArrayList<>(); + private final List<PluginInformation> plugins = new ArrayList<>();
+ +
+ private Builder() {} + private Builder() {
+ }
+ +
+ @NotNull + public Builder motd(final String motd) {
+ public Builder motd(@NotNull String motd) {
+ this.motd = Preconditions.checkNotNull(motd, "motd"); + this.motd = Preconditions.checkNotNull(motd, "motd");
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder gameVersion(final String gameVersion) {
+ public Builder gameVersion(@NotNull String gameVersion) {
+ this.gameVersion = Preconditions.checkNotNull(gameVersion, "gameVersion"); + this.gameVersion = Preconditions.checkNotNull(gameVersion, "gameVersion");
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder map(final String map) {
+ public Builder map(@NotNull String map) {
+ this.map = Preconditions.checkNotNull(map, "map"); + this.map = Preconditions.checkNotNull(map, "map");
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder currentPlayers(final int currentPlayers) {
+ public Builder currentPlayers(int currentPlayers) {
+ Preconditions.checkArgument(currentPlayers >= 0, "currentPlayers cannot be negative"); + Preconditions.checkArgument(currentPlayers >= 0, "currentPlayers cannot be negative");
+ this.currentPlayers = currentPlayers; + this.currentPlayers = currentPlayers;
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder maxPlayers(final int maxPlayers) {
+ public Builder maxPlayers(int maxPlayers) {
+ Preconditions.checkArgument(maxPlayers >= 0, "maxPlayers cannot be negative"); + Preconditions.checkArgument(maxPlayers >= 0, "maxPlayers cannot be negative");
+ this.maxPlayers = maxPlayers; + this.maxPlayers = maxPlayers;
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder hostname(final String hostname) {
+ public Builder hostname(@NotNull String hostname) {
+ this.hostname = Preconditions.checkNotNull(hostname, "hostname"); + this.hostname = Preconditions.checkNotNull(hostname, "hostname");
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder port(final int port) {
+ public Builder port(int port) {
+ Preconditions.checkArgument(port >= 1 && port <= 65535, "port must be between 1-65535"); + Preconditions.checkArgument(port >= 1 && port <= 65535, "port must be between 1-65535");
+ this.port = port; + this.port = port;
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder players(final Collection<String> players) {
+ public Builder players(@NotNull Collection<String> players) {
+ this.players.addAll(Preconditions.checkNotNull(players, "players")); + this.players.addAll(Preconditions.checkNotNull(players, "players"));
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder players(final String... players) {
+ public Builder players(@NotNull String... players) {
+ this.players.addAll(Arrays.asList(Preconditions.checkNotNull(players, "players"))); + this.players.addAll(Arrays.asList(Preconditions.checkNotNull(players, "players")));
+ return this; + return this;
+ } + }
+ +
+ @NotNull
+ public Builder clearPlayers() { + public Builder clearPlayers() {
+ this.players.clear(); + this.players.clear();
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder serverVersion(final String serverVersion) {
+ public Builder serverVersion(@NotNull String serverVersion) {
+ this.serverVersion = Preconditions.checkNotNull(serverVersion, "serverVersion"); + this.serverVersion = Preconditions.checkNotNull(serverVersion, "serverVersion");
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder plugins(final Collection<PluginInformation> plugins) {
+ public Builder plugins(@NotNull Collection<PluginInformation> plugins) {
+ this.plugins.addAll(Preconditions.checkNotNull(plugins, "plugins")); + this.plugins.addAll(Preconditions.checkNotNull(plugins, "plugins"));
+ return this; + return this;
+ } + }
+ +
+ @NotNull + public Builder plugins(final PluginInformation... plugins) {
+ public Builder plugins(@NotNull PluginInformation... plugins) {
+ this.plugins.addAll(Arrays.asList(Preconditions.checkNotNull(plugins, "plugins"))); + this.plugins.addAll(Arrays.asList(Preconditions.checkNotNull(plugins, "plugins")));
+ return this; + return this;
+ } + }
+ +
+ @NotNull
+ public Builder clearPlugins() { + public Builder clearPlugins() {
+ this.plugins.clear(); + this.plugins.clear();
+ return this; + return this;
@ -379,19 +354,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return response + * @return response
+ */ + */
+ @NotNull
+ public QueryResponse build() { + public QueryResponse build() {
+ return new QueryResponse( + return new QueryResponse(
+ Preconditions.checkNotNull(motd, "motd"), + Preconditions.checkNotNull(this.motd, "motd"),
+ Preconditions.checkNotNull(gameVersion, "gameVersion"), + Preconditions.checkNotNull(this.gameVersion, "gameVersion"),
+ Preconditions.checkNotNull(map, "map"), + Preconditions.checkNotNull(this.map, "map"),
+ currentPlayers, + this.currentPlayers,
+ maxPlayers, + this.maxPlayers,
+ Preconditions.checkNotNull(hostname, "hostname"), + Preconditions.checkNotNull(this.hostname, "hostname"),
+ port, + this.port,
+ ImmutableList.copyOf(players), + ImmutableList.copyOf(this.players),
+ Preconditions.checkNotNull(serverVersion, "serverVersion"), + Preconditions.checkNotNull(this.serverVersion, "serverVersion"),
+ ImmutableList.copyOf(plugins) + ImmutableList.copyOf(this.plugins)
+ ); + );
+ } + }
+ } + }
@ -404,31 +378,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private String name; + private String name;
+ private String version; + private String version;
+ +
+ public PluginInformation(@NotNull String name, @NotNull String version) { + public PluginInformation(final String name, final String version) {
+ this.name = Preconditions.checkNotNull(name, "name"); + this.name = Preconditions.checkNotNull(name, "name");
+ this.version = Preconditions.checkNotNull(version, "version"); + this.version = Preconditions.checkNotNull(version, "version");
+ } + }
+ +
+ @NotNull
+ public String getName() { + public String getName() {
+ return this.name; + return this.name;
+ } + }
+ +
+ public void setName(@NotNull String name) { + public void setName(final String name) {
+ this.name = name; + this.name = name;
+ } + }
+ +
+ public void setVersion(@NotNull String version) { + public void setVersion(final String version) {
+ this.version = version; + this.version = version;
+ } + }
+ +
+ @NotNull
+ public String getVersion() { + public String getVersion() {
+ return this.version; + return this.version;
+ } + }
+ +
+ @NotNull + public static PluginInformation of(final String name, final String version) {
+ public static PluginInformation of(@NotNull String name, @NotNull String version) {
+ return new PluginInformation(name, version); + return new PluginInformation(name, version);
+ } + }
+ } + }

View file

@ -17,13 +17,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a Creeper is ignited either by a + * Called when a Creeper is ignited either by a
+ * flint and steel, {@link Creeper#ignite()} or + * flint and steel, {@link Creeper#ignite()} or
+ * {@link Creeper#setIgnited(boolean)}. + * {@link Creeper#setIgnited(boolean)}.
+ */ + */
+@NullMarked
+public class CreeperIgniteEvent extends EntityEvent implements Cancellable { +public class CreeperIgniteEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -32,12 +33,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public CreeperIgniteEvent(@NotNull Creeper creeper, boolean ignited) { + public CreeperIgniteEvent(final Creeper creeper, final boolean ignited) {
+ super(creeper); + super(creeper);
+ this.ignited = ignited; + this.ignited = ignited;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Creeper getEntity() { + public Creeper getEntity() {
+ return (Creeper) super.getEntity(); + return (Creeper) super.getEntity();
@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.ignited; + return this.ignited;
+ } + }
+ +
+ public void setIgnited(boolean ignited) { + public void setIgnited(final boolean ignited) {
+ this.ignited = ignited; + this.ignited = ignited;
+ } + }
+ +
@ -55,17 +55,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.cancelled; + return this.cancelled;
+ } + }
+ +
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -17,17 +17,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.EntityType; +import org.bukkit.entity.EntityType;
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a phantom is spawned for an exhausted player + * Called when a phantom is spawned for an exhausted player
+ */ + */
+@NullMarked
+public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent { +public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent {
+ +
+ @NotNull private final Entity entity; + private final Entity entity;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PhantomPreSpawnEvent(@NotNull Location location, @NotNull Entity entity, @NotNull CreatureSpawnEvent.SpawnReason reason) { + public PhantomPreSpawnEvent(final Location location, final Entity entity, final CreatureSpawnEvent.SpawnReason reason) {
+ super(location, EntityType.PHANTOM, reason); + super(location, EntityType.PHANTOM, reason);
+ this.entity = entity; + this.entity = entity;
+ } + }
@ -37,7 +38,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the Entity + * @return the Entity
+ */ + */
+ @NotNull
+ public Entity getSpawningEntity() { + public Entity getSpawningEntity() {
+ return this.entity; + return this.entity;
+ } + }

View file

@ -41,15 +41,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+import java.net.InetAddress; +import java.net.InetAddress;
+import java.util.UUID; +import java.util.UUID;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerQuitEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * <p> + * <p>
@ -76,16 +75,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * The event may be invoked asynchronously or synchronously. Plugins should check + * The event may be invoked asynchronously or synchronously. Plugins should check
+ * {@link Event#isAsynchronous()} and handle accordingly. + * {@link Event#isAsynchronous()} and handle accordingly.
+ */ + */
+@NullMarked
+public class PlayerConnectionCloseEvent extends Event { +public class PlayerConnectionCloseEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final UUID playerUniqueId; + private final UUID playerUniqueId;
+ @NotNull private final String playerName; + private final String playerName;
+ @NotNull private final InetAddress ipAddress; + private final InetAddress ipAddress;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, final boolean async) { + public PlayerConnectionCloseEvent(final UUID playerUniqueId, final String playerName, final InetAddress ipAddress, final boolean async) {
+ super(async); + super(async);
+ this.playerUniqueId = playerUniqueId; + this.playerUniqueId = playerUniqueId;
+ this.playerName = playerName; + this.playerName = playerName;
@ -95,7 +95,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Returns the {@code UUID} of the player disconnecting. + * Returns the {@code UUID} of the player disconnecting.
+ */ + */
+ @NotNull
+ public UUID getPlayerUniqueId() { + public UUID getPlayerUniqueId() {
+ return this.playerUniqueId; + return this.playerUniqueId;
+ } + }
@ -103,7 +102,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Returns the name of the player disconnecting. + * Returns the name of the player disconnecting.
+ */ + */
+ @NotNull
+ public String getPlayerName() { + public String getPlayerName() {
+ return this.playerName; + return this.playerName;
+ } + }
@ -111,18 +109,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Returns the player's IP address. + * Returns the player's IP address.
+ */ + */
+ @NotNull
+ public InetAddress getIpAddress() { + public InetAddress getIpAddress() {
+ return this.ipAddress; + return this.ipAddress;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -12,6 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import java.util.List;
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
@ -20,9 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+
+import java.util.List;
+ +
+/** +/**
+ * Called when a player uses sheers on a block. + * Called when a player uses sheers on a block.
@ -32,6 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p> + * <p>
+ * Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb. + * Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb.
+ */ + */
+@NullMarked
+public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable { +public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerShearBlockEvent(@NotNull Player player, @NotNull Block block, @NotNull ItemStack item, @NotNull EquipmentSlot hand, @NotNull List<ItemStack> drops) { + public PlayerShearBlockEvent(final Player player, final Block block, final ItemStack item, final EquipmentSlot hand, final List<ItemStack> drops) {
+ super(player); + super(player);
+ this.block = block; + this.block = block;
+ this.item = item; + this.item = item;
@ -57,7 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The {@link Block} which block is being sheared in this event. + * @return The {@link Block} which block is being sheared in this event.
+ */ + */
+ @NotNull
+ public Block getBlock() { + public Block getBlock() {
+ return this.block; + return this.block;
+ } + }
@ -67,7 +66,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The {@link ItemStack} of the shears. + * @return The {@link ItemStack} of the shears.
+ */ + */
+ @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return this.item; + return this.item;
+ } + }
@ -77,7 +75,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Either {@link EquipmentSlot#HAND} OR {@link EquipmentSlot#OFF_HAND}. + * @return Either {@link EquipmentSlot#HAND} OR {@link EquipmentSlot#OFF_HAND}.
+ */ + */
+ @NotNull
+ public EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return this.hand; + return this.hand;
+ } + }
@ -85,9 +82,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Gets the resulting drops of this event. + * Gets the resulting drops of this event.
+ * + *
+ * @return A {@link List list} of {@link ItemStack items} that will be dropped as result of this event. + * @return A mutable {@link List list} of {@link ItemStack items} that will be dropped as result of this event.
+ */ + */
+ @NotNull
+ public List<ItemStack> getDrops() { + public List<ItemStack> getDrops() {
+ return this.drops; + return this.drops;
+ } + }
@ -108,17 +104,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel whether the shearing of the block should be cancelled or not. + * @param cancel whether the shearing of the block should be cancelled or not.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -58,18 +58,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when an item is put in an inventory containing a result slot + * Called when an item is put in an inventory containing a result slot
+ */ + */
+@NullMarked
+public class PrepareResultEvent extends PrepareInventoryResultEvent { +public class PrepareResultEvent extends PrepareInventoryResultEvent {
+ +
+ // HandlerList on PrepareInventoryResultEvent to ensure api compat + // HandlerList on PrepareInventoryResultEvent to ensure api compat
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { + public PrepareResultEvent(final InventoryView inventory, final @Nullable ItemStack result) {
+ super(inventory, result); + super(inventory, result);
+ } + }
+ +
@ -78,8 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return result item + * @return result item
+ */ + */
+ @Nullable + public @Nullable ItemStack getResult() {
+ public ItemStack getResult() {
+ return super.getResult(); + return super.getResult();
+ } + }
+ +
@ -88,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param result result item + * @param result result item
+ */ + */
+ public void setResult(@Nullable ItemStack result) { + public void setResult(final @Nullable ItemStack result) {
+ super.setResult(result); + super.setResult(result);
+ } + }
+} +}

View file

@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called just before a {@link PufferFish} inflates or deflates. + * Called just before a {@link PufferFish} inflates or deflates.
+ */ + */
+@NullMarked
+public class PufferFishStateChangeEvent extends EntityEvent implements Cancellable { +public class PufferFishStateChangeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -30,12 +31,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PufferFishStateChangeEvent(@NotNull PufferFish entity, int newPuffState) { + public PufferFishStateChangeEvent(final PufferFish entity, final int newPuffState) {
+ super(entity); + super(entity);
+ this.newPuffState = newPuffState; + this.newPuffState = newPuffState;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public PufferFish getEntity() { + public PufferFish getEntity() {
+ return (PufferFish) super.getEntity(); + return (PufferFish) super.getEntity();
@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if you wish to cancel the (in/de)flation + * @param cancel {@code true} if you wish to cancel the (in/de)flation
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
@ -86,13 +86,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.cancelled; + return this.cancelled;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -17,13 +17,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a shulker duplicates itself by spawning a new shulker. + * Fired when a shulker duplicates itself by spawning a new shulker.
+ * <p> + * <p>
+ * The event is fired prior to the newly created shulker, accessible via {@link #getEntity()}, being added to the world. + * The event is fired prior to the newly created shulker, accessible via {@link #getEntity()}, being added to the world.
+ */ + */
+@NullMarked
+public class ShulkerDuplicateEvent extends EntityEvent implements Cancellable { +public class ShulkerDuplicateEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -32,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ShulkerDuplicateEvent(@NotNull Shulker child, @NotNull Shulker parent) { + public ShulkerDuplicateEvent(final Shulker child, final Shulker parent) {
+ super(child); + super(child);
+ this.parent = parent; + this.parent = parent;
+ } + }
@ -44,7 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the newly duplicated shulker. + * @return the newly duplicated shulker.
+ */ + */
+ @Override + @Override
+ @NotNull
+ public Shulker getEntity() { + public Shulker getEntity() {
+ return (Shulker) super.getEntity(); + return (Shulker) super.getEntity();
+ } + }
@ -55,7 +55,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the previously existing shulker which duplicated. + * @return the previously existing shulker which duplicated.
+ */ + */
+ @NotNull
+ public Shulker getParent() { + public Shulker getParent() {
+ return this.parent; + return this.parent;
+ } + }
@ -66,17 +65,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -18,11 +18,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a {@link Tameable} dies and sends a death message. + * Called when a {@link Tameable} dies and sends a death message.
+ */ + */
+@NullMarked
+public class TameableDeathMessageEvent extends EntityEvent implements Cancellable { +public class TameableDeathMessageEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -31,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public TameableDeathMessageEvent(@NotNull Tameable tameable, @NotNull Component deathMessage) { + public TameableDeathMessageEvent(final Tameable tameable, final Component deathMessage) {
+ super(tameable); + super(tameable);
+ this.deathMessage = deathMessage; + this.deathMessage = deathMessage;
+ } + }
@ -41,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param deathMessage Death message to appear + * @param deathMessage Death message to appear
+ */ + */
+ public void deathMessage(@NotNull Component deathMessage) { + public void deathMessage(final Component deathMessage) {
+ this.deathMessage = deathMessage; + this.deathMessage = deathMessage;
+ } + }
+ +
@ -50,12 +51,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Death message to appear + * @return Death message to appear
+ */ + */
+ @NotNull
+ public Component deathMessage() { + public Component deathMessage() {
+ return this.deathMessage; + return this.deathMessage;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Tameable getEntity() { + public Tameable getEntity() {
+ return (Tameable) super.getEntity(); + return (Tameable) super.getEntity();
@ -67,17 +66,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileHitEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Range; +import org.jetbrains.annotations.Range;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a Target Block is hit by a projectile. + * Called when a Target Block is hit by a projectile.
@ -29,6 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * and in the case that the shooter is a player, will stop them from receiving + * and in the case that the shooter is a player, will stop them from receiving
+ * advancement criteria. + * advancement criteria.
+ */ + */
+@NullMarked
+public class TargetHitEvent extends ProjectileHitEvent { +public class TargetHitEvent extends ProjectileHitEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -36,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private int signalStrength; + private int signalStrength;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public TargetHitEvent(@NotNull Projectile projectile, @NotNull Block block, @NotNull BlockFace blockFace, int signalStrength) { + public TargetHitEvent(final Projectile projectile, final Block block, final BlockFace blockFace, final int signalStrength) {
+ super(projectile, null, block, blockFace); + super(projectile, null, block, blockFace);
+ this.signalStrength = signalStrength; + this.signalStrength = signalStrength;
+ } + }
@ -55,18 +56,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param signalStrength the strength of the redstone signal to be emitted + * @param signalStrength the strength of the redstone signal to be emitted
+ */ + */
+ public void setSignalStrength(@Range(from = 0, to = 15) int signalStrength) { + public void setSignalStrength(final @Range(from = 0, to = 15) int signalStrength) {
+ Preconditions.checkArgument(signalStrength >= 0 && signalStrength <= 15, "Signal strength out of range (%s), must be in range [0,15]", signalStrength); + Preconditions.checkArgument(signalStrength >= 0 && signalStrength <= 15, "Signal strength out of range (%s), must be in range [0,15]", signalStrength);
+ this.signalStrength = signalStrength; + this.signalStrength = signalStrength;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -20,13 +20,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a thrown egg might hatch. + * Called when a thrown egg might hatch.
+ * <p> + * <p>
+ * This event fires for all thrown eggs that may hatch, players, dispensers, etc. + * This event fires for all thrown eggs that may hatch, players, dispensers, etc.
+ */ + */
+@NullMarked
+public class ThrownEggHatchEvent extends Event { +public class ThrownEggHatchEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -37,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private EntityType hatchType; + private EntityType hatchType;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ThrownEggHatchEvent(@NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) { + public ThrownEggHatchEvent(final Egg egg, final boolean hatching, final byte numHatches, final EntityType hatchingType) {
+ this.egg = egg; + this.egg = egg;
+ this.hatching = hatching; + this.hatching = hatching;
+ this.numHatches = numHatches; + this.numHatches = numHatches;
@ -49,7 +50,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the egg involved in this event + * @return the egg involved in this event
+ */ + */
+ @NotNull
+ public Egg getEgg() { + public Egg getEgg() {
+ return this.egg; + return this.egg;
+ } + }
@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param hatching {@code true} if you want the egg to hatch, {@code false} if you want it + * @param hatching {@code true} if you want the egg to hatch, {@code false} if you want it
+ * not to + * not to
+ */ + */
+ public void setHatching(boolean hatching) { + public void setHatching(final boolean hatching) {
+ this.hatching = hatching; + this.hatching = hatching;
+ } + }
+ +
@ -79,7 +79,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The type of the mob being hatched by the egg + * @return The type of the mob being hatched by the egg
+ */ + */
+ @NotNull
+ public EntityType getHatchingType() { + public EntityType getHatchingType() {
+ return this.hatchType; + return this.hatchType;
+ } + }
@ -89,13 +88,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param hatchType The type of the mob being hatched by the egg + * @param hatchType The type of the mob being hatched by the egg
+ */ + */
+ public void setHatchingType(@NotNull EntityType hatchType) { + public void setHatchingType(final EntityType hatchType) {
+ Preconditions.checkArgument(hatchType.isSpawnable(), "Can't spawn that entity type from an egg!"); + Preconditions.checkArgument(hatchType.isSpawnable(), "Can't spawn that entity type from an egg!");
+ this.hatchType = hatchType; + this.hatchType = hatchType;
+ } + }
+ +
+ /** + /**
+ * Get the number of mob hatches from the egg. By default the number will + * Get the number of mob hatches from the egg. By default, the number will
+ * be the number the server would've done + * be the number the server would've done
+ * <ul> + * <ul>
+ * <li>7/8 chance of being 0 + * <li>7/8 chance of being 0
@ -117,17 +116,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param numHatches The number of mobs coming out of the egg + * @param numHatches The number of mobs coming out of the egg
+ */ + */
+ public void setNumHatches(byte numHatches) { + public void setNumHatches(final byte numHatches) {
+ this.numHatches = numHatches; + this.numHatches = numHatches;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -21,14 +21,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Range; +import org.jetbrains.annotations.Range;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a Warden's anger level has changed due to another entity. + * Called when a Warden's anger level has changed due to another entity.
+ * <p> + * <p>
+ * If the event is cancelled, the warden's anger level will not change. + * If the event is cancelled, the warden's anger level will not change.
+ */ + */
+@NullMarked
+public class WardenAngerChangeEvent extends EntityEvent implements Cancellable { +public class WardenAngerChangeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -40,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WardenAngerChangeEvent(@NotNull final Warden warden, @NotNull final Entity target, final int oldAnger, final int newAnger) { + public WardenAngerChangeEvent(final Warden warden, final Entity target, final int oldAnger, final int newAnger) {
+ super(warden); + super(warden);
+ this.target = target; + this.target = target;
+ this.oldAnger = oldAnger; + this.oldAnger = oldAnger;
@ -52,7 +53,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return triggering entity + * @return triggering entity
+ */ + */
+ @NotNull
+ public Entity getTarget() { + public Entity getTarget() {
+ return this.target; + return this.target;
+ } + }
@ -63,8 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return old anger level + * @return old anger level
+ * @see Warden#getAnger(Entity) + * @see Warden#getAnger(Entity)
+ */ + */
+ @Range(from = 0, to = 150) + public @Range(from = 0, to = 150) int getOldAnger() {
+ public int getOldAnger() {
+ return this.oldAnger; + return this.oldAnger;
+ } + }
+ +
@ -74,8 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return new anger level + * @return new anger level
+ * @see Warden#getAnger(Entity) + * @see Warden#getAnger(Entity)
+ */ + */
+ @Range(from = 0, to = 150) + public @Range(from = 0, to = 150) int getNewAnger() {
+ public int getNewAnger() {
+ return this.newAnger; + return this.newAnger;
+ } + }
+ +
@ -85,15 +83,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * The anger of a warden is capped at 150. + * The anger of a warden is capped at 150.
+ * + *
+ * @param newAnger the new anger level, max 150 + * @param newAnger the new anger level, max 150
+ * @see Warden#setAnger(Entity, int)
+ * @throws IllegalArgumentException if newAnger is greater than 150 + * @throws IllegalArgumentException if newAnger is greater than 150
+ * @see Warden#setAnger(Entity, int)
+ */ + */
+ public void setNewAnger(@Range(from = 0, to = 150) int newAnger) { + public void setNewAnger(final @Range(from = 0, to = 150) int newAnger) {
+ Preconditions.checkArgument(newAnger <= 150, "newAnger must not be greater than 150"); + Preconditions.checkArgument(newAnger <= 150, "newAnger must not be greater than 150");
+ this.newAnger = newAnger; + this.newAnger = newAnger;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Warden getEntity() { + public Warden getEntity() {
+ return (Warden) super.getEntity(); + return (Warden) super.getEntity();
@ -105,17 +102,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -23,28 +23,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.ThrownPotion;
+import org.bukkit.event.entity.PotionSplashEvent; +import org.bukkit.event.entity.PotionSplashEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Unmodifiable; +import org.jetbrains.annotations.Unmodifiable;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when a splash water potion "splashes" and affects + * Called when a splash water potion "splashes" and affects
+ * different entities in different ways. + * different entities in different ways.
+ */ + */
+@NullMarked
+public class WaterBottleSplashEvent extends PotionSplashEvent { +public class WaterBottleSplashEvent extends PotionSplashEvent {
+ +
+ private final @NotNull Set<LivingEntity> rehydrate; + private final Set<LivingEntity> rehydrate;
+ private final @NotNull Set<LivingEntity> extinguish; + private final Set<LivingEntity> extinguish;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WaterBottleSplashEvent( + public WaterBottleSplashEvent(
+ final @NotNull ThrownPotion potion, + final ThrownPotion potion,
+ final @Nullable Entity hitEntity, + final @Nullable Entity hitEntity,
+ final @Nullable Block hitBlock, + final @Nullable Block hitBlock,
+ final @Nullable BlockFace hitFace, + final @Nullable BlockFace hitFace,
+ final @NotNull Map<LivingEntity, Double> affectedEntities, + final Map<LivingEntity, Double> affectedEntities,
+ final @NotNull Set<LivingEntity> rehydrate, + final Set<LivingEntity> rehydrate,
+ final @NotNull Set<LivingEntity> extinguish + final Set<LivingEntity> extinguish
+ ) { + ) {
+ super(potion, hitEntity, hitBlock, hitFace, affectedEntities); + super(potion, hitEntity, hitBlock, hitFace, affectedEntities);
+ this.rehydrate = rehydrate; + this.rehydrate = rehydrate;
@ -61,7 +62,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @see #doNotDamageAsWaterSensitive(LivingEntity) + * @see #doNotDamageAsWaterSensitive(LivingEntity)
+ * @see #damageAsWaterSensitive(LivingEntity) + * @see #damageAsWaterSensitive(LivingEntity)
+ */ + */
+ @NotNull
+ public @Unmodifiable Collection<LivingEntity> getToDamage() { + public @Unmodifiable Collection<LivingEntity> getToDamage() {
+ return this.affectedEntities.entrySet().stream().filter(entry -> entry.getValue() > 0).map(Map.Entry::getKey).collect(Collectors.toUnmodifiableSet()); + return this.affectedEntities.entrySet().stream().filter(entry -> entry.getValue() > 0).map(Map.Entry::getKey).collect(Collectors.toUnmodifiableSet());
+ } + }
@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param entity entity to remove + * @param entity entity to remove
+ */ + */
+ public void doNotDamageAsWaterSensitive(final @NotNull LivingEntity entity) { + public void doNotDamageAsWaterSensitive(final LivingEntity entity) {
+ this.affectedEntities.remove(entity); + this.affectedEntities.remove(entity);
+ } + }
+ +
@ -82,7 +82,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param entity entity to add + * @param entity entity to add
+ */ + */
+ public void damageAsWaterSensitive(final @NotNull LivingEntity entity) { + public void damageAsWaterSensitive(final LivingEntity entity) {
+ this.affectedEntities.put(entity, 1.0); + this.affectedEntities.put(entity, 1.0);
+ } + }
+ +
@ -96,7 +96,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entities + * @return the entities
+ */ + */
+ @NotNull
+ public Collection<LivingEntity> getToRehydrate() { + public Collection<LivingEntity> getToRehydrate() {
+ return this.rehydrate; + return this.rehydrate;
+ } + }
@ -107,7 +106,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return entities to be extinguished + * @return entities to be extinguished
+ */ + */
+ @NotNull
+ public Collection<LivingEntity> getToExtinguish() { + public Collection<LivingEntity> getToExtinguish() {
+ return this.extinguish; + return this.extinguish;
+ } + }
@ -118,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated(since = "1.19.3") + @Deprecated(since = "1.19.3")
+ @Override + @Override
+ public @NotNull Collection<LivingEntity> getAffectedEntities() { + public Collection<LivingEntity> getAffectedEntities() {
+ return super.getAffectedEntities(); + return super.getAffectedEntities();
+ } + }
+ +
@ -130,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated(since = "1.19.3") + @Deprecated(since = "1.19.3")
+ @Override + @Override
+ public double getIntensity(final @NotNull LivingEntity entity) { + public double getIntensity(final LivingEntity entity) {
+ return super.getIntensity(entity); + return super.getIntensity(entity);
+ } + }
+ +
@ -143,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated(since = "1.19.3") + @Deprecated(since = "1.19.3")
+ @Override + @Override
+ public void setIntensity(final @NotNull LivingEntity entity, final double intensity) { + public void setIntensity(final LivingEntity entity, final double intensity) {
+ super.setIntensity(entity, intensity); + super.setIntensity(entity, intensity);
+ } + }
+} +}

View file

@ -15,13 +15,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * This event is fired when whitelist is toggled + * This event is fired when whitelist is toggled
+ * + *
+ * @author Mark Vainomaa + * @author Mark Vainomaa
+ */ + */
+@NullMarked
+public class WhitelistToggleEvent extends Event { +public class WhitelistToggleEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -29,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final boolean enabled; + private final boolean enabled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WhitelistToggleEvent(boolean enabled) { + public WhitelistToggleEvent(final boolean enabled) {
+ this.enabled = enabled; + this.enabled = enabled;
+ } + }
+ +
@ -42,13 +43,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.enabled; + return this.enabled;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -23,19 +23,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when an Entity is knocked back by the hit of another Entity. The acceleration + * Fired when an Entity is knocked back by the hit of another Entity. The acceleration
+ * vector can be modified. If this event is cancelled, the entity is not knocked back. + * vector can be modified. If this event is cancelled, the entity is not knocked back.
+ */ + */
+@NullMarked
+public class EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent { +public class EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent {
+ +
+ private final float knockbackStrength; + private final float knockbackStrength;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityKnockbackByEntityEvent(final @NonNull LivingEntity entity, final @NonNull Entity hitBy, final EntityKnockbackEvent.@NonNull Cause cause, final float knockbackStrength, final @NonNull Vector knockback) { + public EntityKnockbackByEntityEvent(final LivingEntity entity, final Entity hitBy, final EntityKnockbackEvent.Cause cause, final float knockbackStrength, final Vector knockback) {
+ super(entity, cause, hitBy, knockback); + super(entity, cause, hitBy, knockback);
+ this.knockbackStrength = knockbackStrength; + this.knockbackStrength = knockbackStrength;
+ } + }
@ -44,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the entity which was knocked back + * @return the entity which was knocked back
+ */ + */
+ @Override + @Override
+ public @NonNull LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity(); + return (LivingEntity) super.getEntity();
+ } + }
+ +
@ -62,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the Entity which hit + * @return the Entity which hit
+ */ + */
+ public @NonNull Entity getHitBy() { + public Entity getHitBy() {
+ return super.getPushedBy(); + return super.getPushedBy();
+ } + }
+ +
@ -81,14 +82,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when an entity receives knockback. + * Called when an entity receives knockback.
+ * @see EntityPushedByEntityAttackEvent + * @see EntityPushedByEntityAttackEvent
+ * @see com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent + * @see com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent
+ */ + */
+@NullMarked
+public class EntityKnockbackEvent extends EntityEvent implements Cancellable { +public class EntityKnockbackEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -98,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityKnockbackEvent(final @NonNull Entity entity, final EntityKnockbackEvent.@NonNull Cause cause, final @NonNull Vector knockback) { + public EntityKnockbackEvent(final Entity entity, final EntityKnockbackEvent.Cause cause, final Vector knockback) {
+ super(entity); + super(entity);
+ this.cause = cause; + this.cause = cause;
+ this.knockback = knockback; + this.knockback = knockback;
@ -109,7 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the cause of the knockback + * @return the cause of the knockback
+ */ + */
+ public EntityKnockbackEvent.@NonNull Cause getCause() { + public EntityKnockbackEvent.Cause getCause() {
+ return this.cause; + return this.cause;
+ } + }
+ +
@ -121,7 +123,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the knockback + * @return the knockback
+ */ + */
+ public @NonNull Vector getKnockback() { + public Vector getKnockback() {
+ return this.knockback.clone(); + return this.knockback.clone();
+ } + }
+ +
@ -130,7 +132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param knockback the knockback + * @param knockback the knockback
+ */ + */
+ public void setKnockback(final @NonNull Vector knockback) { + public void setKnockback(final Vector knockback) {
+ Preconditions.checkArgument(knockback != null, "knockback"); + Preconditions.checkArgument(knockback != null, "knockback");
+ this.knockback = knockback.clone(); + this.knockback = knockback.clone();
+ } + }
@ -146,11 +148,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public @NonNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NonNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
@ -200,8 +202,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when an entity is pushed by another entity's attack. The acceleration vector can be + * Fired when an entity is pushed by another entity's attack. The acceleration vector can be
@ -210,12 +212,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Note: Some entities might trigger this multiple times on the same entity + * Note: Some entities might trigger this multiple times on the same entity
+ * as multiple acceleration calculations are done. + * as multiple acceleration calculations are done.
+ */ + */
+@NullMarked
+public class EntityPushedByEntityAttackEvent extends EntityKnockbackEvent implements Cancellable { +public class EntityPushedByEntityAttackEvent extends EntityKnockbackEvent implements Cancellable {
+ +
+ private final Entity pushedBy; + private final Entity pushedBy;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityPushedByEntityAttackEvent(final @NonNull Entity entity, final EntityKnockbackEvent.@NonNull Cause cause, final @NonNull Entity pushedBy, final @NonNull Vector knockback) { + public EntityPushedByEntityAttackEvent(final Entity entity, final EntityKnockbackEvent.Cause cause, final Entity pushedBy, final Vector knockback) {
+ super(entity, cause, knockback); + super(entity, cause, knockback);
+ this.pushedBy = pushedBy; + this.pushedBy = pushedBy;
+ } + }
@ -225,7 +228,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the pushing entity + * @return the pushing entity
+ */ + */
+ public @NonNull Entity getPushedBy() { + public Entity getPushedBy() {
+ return this.pushedBy; + return this.pushedBy;
+ } + }
+ +
@ -236,7 +239,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @deprecated use {@link #getKnockback()} + * @deprecated use {@link #getKnockback()}
+ */ + */
+ @Deprecated(since = "1.20.6", forRemoval = true) + @Deprecated(since = "1.20.6", forRemoval = true)
+ public @NonNull Vector getAcceleration() { + public Vector getAcceleration() {
+ return this.knockback; // TODO Clone in 1.21 to not instantly break what was technically already modifiable (call super.getKnockback()) + return this.knockback; // TODO Clone in 1.21 to not instantly break what was technically already modifiable (call super.getKnockback())
+ } + }
+ +
@ -247,7 +250,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @deprecated use {@link #setKnockback(Vector)} + * @deprecated use {@link #setKnockback(Vector)}
+ */ + */
+ @Deprecated(since = "1.20.6", forRemoval = true) + @Deprecated(since = "1.20.6", forRemoval = true)
+ public void setAcceleration(final @NonNull Vector acceleration) { + public void setAcceleration(final Vector acceleration) {
+ super.setKnockback(acceleration); + super.setKnockback(acceleration);
+ } + }
+ +

View file

@ -14,6 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+import java.util.UUID;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -21,10 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+
+import java.util.UUID;
+ +
+/** +/**
+ * This event is fired during a player handshake. + * This event is fired during a player handshake.
@ -34,16 +33,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * <p>WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS</p> + * <p>WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS</p>
+ */ + */
+@NullMarked
+public class PlayerHandshakeEvent extends Event implements Cancellable { +public class PlayerHandshakeEvent extends Event implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final String originalHandshake; + private final String originalHandshake;
+ @NotNull private final String originalSocketAddressHostname; + private final String originalSocketAddressHostname;
+ @Nullable private String serverHostname; + private @Nullable String serverHostname;
+ @Nullable private String socketAddressHostname; + private @Nullable String socketAddressHostname;
+ @Nullable private UUID uniqueId; + private @Nullable UUID uniqueId;
+ @Nullable private String propertiesJson; + private @Nullable String propertiesJson;
+ private boolean failed; + private boolean failed;
+ private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW); + private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW);
+ +
@ -51,12 +51,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) { + public PlayerHandshakeEvent(final String originalHandshake, final boolean cancelled) {
+ this(originalHandshake, "127.0.0.1", cancelled); + this(originalHandshake, "127.0.0.1", cancelled);
+ } + }
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerHandshakeEvent(@NotNull String originalHandshake, @NotNull String originalSocketAddressHostname, boolean cancelled) { + public PlayerHandshakeEvent(final String originalHandshake, final String originalSocketAddressHostname, final boolean cancelled) {
+ super(true); + super(true);
+ this.originalHandshake = originalHandshake; + this.originalHandshake = originalHandshake;
+ this.originalSocketAddressHostname = originalSocketAddressHostname; + this.originalSocketAddressHostname = originalSocketAddressHostname;
@ -85,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if this event is cancelled, {@code false} otherwise + * @param cancel {@code true} if this event is cancelled, {@code false} otherwise
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
@ -94,7 +94,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the original handshake string + * @return the original handshake string
+ */ + */
+ @NotNull
+ public String getOriginalHandshake() { + public String getOriginalHandshake() {
+ return this.originalHandshake; + return this.originalHandshake;
+ } + }
@ -107,7 +106,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the original socket address hostname + * @return the original socket address hostname
+ */ + */
+ @NotNull
+ public String getOriginalSocketAddressHostname() { + public String getOriginalSocketAddressHostname() {
+ return this.originalSocketAddressHostname; + return this.originalSocketAddressHostname;
+ } + }
@ -119,8 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the server hostname string + * @return the server hostname string
+ */ + */
+ @Nullable + public @Nullable String getServerHostname() {
+ public String getServerHostname() {
+ return this.serverHostname; + return this.serverHostname;
+ } + }
+ +
@ -131,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param serverHostname the server hostname string + * @param serverHostname the server hostname string
+ */ + */
+ public void setServerHostname(@NotNull String serverHostname) { + public void setServerHostname(final String serverHostname) {
+ this.serverHostname = serverHostname; + this.serverHostname = serverHostname;
+ } + }
+ +
@ -142,8 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the socket address hostname string + * @return the socket address hostname string
+ */ + */
+ @Nullable + public @Nullable String getSocketAddressHostname() {
+ public String getSocketAddressHostname() {
+ return this.socketAddressHostname; + return this.socketAddressHostname;
+ } + }
+ +
@ -154,7 +150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param socketAddressHostname the socket address hostname string + * @param socketAddressHostname the socket address hostname string
+ */ + */
+ public void setSocketAddressHostname(@NotNull String socketAddressHostname) { + public void setSocketAddressHostname(final String socketAddressHostname) {
+ this.socketAddressHostname = socketAddressHostname; + this.socketAddressHostname = socketAddressHostname;
+ } + }
+ +
@ -163,8 +159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the unique id + * @return the unique id
+ */ + */
+ @Nullable + public @Nullable UUID getUniqueId() {
+ public UUID getUniqueId() {
+ return this.uniqueId; + return this.uniqueId;
+ } + }
+ +
@ -173,7 +168,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param uniqueId the unique id + * @param uniqueId the unique id
+ */ + */
+ public void setUniqueId(@NotNull UUID uniqueId) { + public void setUniqueId(final UUID uniqueId) {
+ this.uniqueId = uniqueId; + this.uniqueId = uniqueId;
+ } + }
+ +
@ -184,8 +179,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the profile properties, as JSON + * @return the profile properties, as JSON
+ */ + */
+ @Nullable + public @Nullable String getPropertiesJson() {
+ public String getPropertiesJson() {
+ return this.propertiesJson; + return this.propertiesJson;
+ } + }
+ +
@ -209,7 +203,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param failed {@code true} if authentication failed, {@code false} otherwise + * @param failed {@code true} if authentication failed, {@code false} otherwise
+ */ + */
+ public void setFailed(boolean failed) { + public void setFailed(final boolean failed) {
+ this.failed = failed; + this.failed = failed;
+ } + }
+ +
@ -220,7 +214,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param propertiesJson the profile properties, as JSON + * @param propertiesJson the profile properties, as JSON
+ */ + */
+ public void setPropertiesJson(@NotNull String propertiesJson) { + public void setPropertiesJson(final String propertiesJson) {
+ this.propertiesJson = propertiesJson; + this.propertiesJson = propertiesJson;
+ } + }
+ +
@ -229,7 +223,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the message to display to the client + * @return the message to display to the client
+ */ + */
+ @NotNull
+ public Component failMessage() { + public Component failMessage() {
+ return this.failMessage; + return this.failMessage;
+ } + }
@ -239,7 +232,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param failMessage the message to display to the client + * @param failMessage the message to display to the client
+ */ + */
+ public void failMessage(@NotNull Component failMessage) { + public void failMessage(final Component failMessage) {
+ this.failMessage = failMessage; + this.failMessage = failMessage;
+ } + }
+ +
@ -249,7 +242,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the message to display to the client + * @return the message to display to the client
+ * @deprecated use {@link #failMessage()} + * @deprecated use {@link #failMessage()}
+ */ + */
+ @NotNull
+ @Deprecated + @Deprecated
+ public String getFailMessage() { + public String getFailMessage() {
+ return LegacyComponentSerializer.legacySection().serialize(this.failMessage()); + return LegacyComponentSerializer.legacySection().serialize(this.failMessage());
@ -262,18 +254,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @deprecated use {@link #failMessage(Component)} + * @deprecated use {@link #failMessage(Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public void setFailMessage(@NotNull String failMessage) { + public void setFailMessage(final String failMessage) {
+ Preconditions.checkArgument(failMessage != null && !failMessage.isEmpty(), "fail message cannot be null or empty"); + Preconditions.checkArgument(failMessage != null && !failMessage.isEmpty(), "fail message cannot be null or empty");
+ this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage)); + this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage));
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -19,22 +19,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * This event gets called when the whitelist status of a player is changed + * This event gets called when the whitelist status of a player is changed
+ */ + */
+@NullMarked
+public class WhitelistStateUpdateEvent extends Event implements Cancellable { +public class WhitelistStateUpdateEvent extends Event implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final PlayerProfile playerProfile; + private final PlayerProfile playerProfile;
+ @NotNull private final WhitelistStatus status; + private final WhitelistStatus status;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WhitelistStateUpdateEvent(@NotNull PlayerProfile playerProfile, @NotNull WhitelistStatus status) { + public WhitelistStateUpdateEvent(final PlayerProfile playerProfile, final WhitelistStatus status) {
+ this.playerProfile = playerProfile; + this.playerProfile = playerProfile;
+ this.status = status; + this.status = status;
+ } + }
@ -44,7 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the player whose status is being changed + * @return the player whose status is being changed
+ */ + */
+ @NotNull
+ public OfflinePlayer getPlayer() { + public OfflinePlayer getPlayer() {
+ return Bukkit.getOfflinePlayer(this.playerProfile.getId()); + return Bukkit.getOfflinePlayer(this.playerProfile.getId());
+ } + }
@ -54,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the player profile whose status is being changed + * @return the player profile whose status is being changed
+ */ + */
+ @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return this.playerProfile; + return this.playerProfile;
+ } + }
@ -64,7 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the whitelist status + * @return the whitelist status
+ */ + */
+ @NotNull
+ public WhitelistStatus getStatus() { + public WhitelistStatus getStatus() {
+ return this.status; + return this.status;
+ } + }
@ -75,17 +73,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when an item on or used by an entity takes durability damage as a result of being hit/used. + * Called when an item on or used by an entity takes durability damage as a result of being hit/used.
@ -26,6 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * NOTE: default vanilla behaviour dictates that armor/tools picked up by + * NOTE: default vanilla behaviour dictates that armor/tools picked up by
+ * mobs do not take damage (except via Thorns). + * mobs do not take damage (except via Thorns).
+ */ + */
+@NullMarked
+public class EntityDamageItemEvent extends EntityEvent implements Cancellable { +public class EntityDamageItemEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -36,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityDamageItemEvent(@NotNull Entity entity, @NotNull ItemStack item, int damage) { + public EntityDamageItemEvent(final Entity entity, final ItemStack item, final int damage) {
+ super(entity); + super(entity);
+ this.item = item; + this.item = item;
+ this.damage = damage; + this.damage = damage;
@ -47,7 +48,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the item + * @return the item
+ */ + */
+ @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return this.item; + return this.item;
+ } + }
@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param damage the damage amount to cause + * @param damage the damage amount to cause
+ */ + */
+ public void setDamage(int damage) { + public void setDamage(final int damage) {
+ this.damage = damage; + this.damage = damage;
+ } + }
+ +
@ -76,17 +76,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Is called when an entity sits down or stands up. + * Is called when an entity sits down or stands up.
+ */ + */
+@NullMarked
+public class EntityToggleSitEvent extends EntityEvent implements Cancellable { +public class EntityToggleSitEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -30,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityToggleSitEvent(@NotNull Entity entity, boolean isSitting) { + public EntityToggleSitEvent(final Entity entity, final boolean isSitting) {
+ super(entity); + super(entity);
+ this.isSitting = isSitting; + this.isSitting = isSitting;
+ } + }
@ -50,17 +51,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -15,13 +15,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.server.ServerEvent; +import org.bukkit.event.server.ServerEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when resources such as datapacks are reloaded (e.g. /minecraft:reload) + * Called when resources such as datapacks are reloaded (e.g. /minecraft:reload)
+ * <p> + * <p>
+ * Intended for use to re-register custom recipes, advancements that may be lost during a reload like this. + * Intended for use to re-register custom recipes, advancements that may be lost during a reload like this.
+ */ + */
+@NullMarked
+public class ServerResourcesReloadedEvent extends ServerEvent { +public class ServerResourcesReloadedEvent extends ServerEvent {
+ +
+ public static final HandlerList HANDLER_LIST = new HandlerList(); + public static final HandlerList HANDLER_LIST = new HandlerList();
@ -29,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Cause cause; + private final Cause cause;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ServerResourcesReloadedEvent(@NotNull Cause cause) { + public ServerResourcesReloadedEvent(final Cause cause) {
+ this.cause = cause; + this.cause = cause;
+ } + }
+ +
@ -38,17 +39,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the reload cause + * @return the reload cause
+ */ + */
+ @NotNull
+ public Cause getCause() { + public Cause getCause() {
+ return this.cause; + return this.cause;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;

View file

@ -20,12 +20,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.InventoryView;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when an anvil is damaged from being used + * Called when an anvil is damaged from being used
+ */ + */
+@NullMarked
+public class AnvilDamagedEvent extends InventoryEvent implements Cancellable { +public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -34,12 +35,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public AnvilDamagedEvent(@NotNull InventoryView inventory, @Nullable BlockData blockData) { + public AnvilDamagedEvent(final InventoryView inventory, final @Nullable BlockData blockData) {
+ super(inventory); + super(inventory);
+ this.damageState = DamageState.getState(blockData); + this.damageState = DamageState.getState(blockData);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public AnvilInventory getInventory() { + public AnvilInventory getInventory() {
+ return (AnvilInventory) super.getInventory(); + return (AnvilInventory) super.getInventory();
@ -50,7 +50,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Damage state + * @return Damage state
+ */ + */
+ @NotNull
+ public DamageState getDamageState() { + public DamageState getDamageState() {
+ return this.damageState; + return this.damageState;
+ } + }
@ -60,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param damageState Damage state + * @param damageState Damage state
+ */ + */
+ public void setDamageState(@NotNull DamageState damageState) { + public void setDamageState(final DamageState damageState) {
+ this.damageState = damageState; + this.damageState = damageState;
+ } + }
+ +
@ -78,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param breaking {@code true} if breaking + * @param breaking {@code true} if breaking
+ */ + */
+ public void setBreaking(boolean breaking) { + public void setBreaking(final boolean breaking) {
+ if (breaking) { + if (breaking) {
+ this.damageState = DamageState.BROKEN; + this.damageState = DamageState.BROKEN;
+ } else if (this.damageState == DamageState.BROKEN) { + } else if (this.damageState == DamageState.BROKEN) {
@ -92,16 +91,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -117,7 +114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ private final Material material; + private final Material material;
+ +
+ DamageState(@NotNull Material material) { + DamageState(final Material material) {
+ this.material = material; + this.material = material;
+ } + }
+ +
@ -126,7 +123,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Material + * @return Material
+ */ + */
+ @NotNull
+ public Material getMaterial() { + public Material getMaterial() {
+ return this.material; + return this.material;
+ } + }
@ -138,8 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return DamageState + * @return DamageState
+ * @throws IllegalArgumentException If non anvil block data is given + * @throws IllegalArgumentException If non anvil block data is given
+ */ + */
+ @NotNull + public static DamageState getState(final @Nullable BlockData blockData) {
+ public static DamageState getState(@Nullable BlockData blockData) {
+ return blockData == null ? BROKEN : getState(blockData.getMaterial()); + return blockData == null ? BROKEN : getState(blockData.getMaterial());
+ } + }
+ +
@ -150,12 +145,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return DamageState + * @return DamageState
+ * @throws IllegalArgumentException If non anvil material is given + * @throws IllegalArgumentException If non anvil material is given
+ */ + */
+ @NotNull + public static DamageState getState(final @Nullable Material material) {
+ public static DamageState getState(@Nullable Material material) {
+ if (material == null) { + if (material == null) {
+ return BROKEN; + return BROKEN;
+ } + }
+ for (DamageState state : values()) { + for (final DamageState state : values()) {
+ if (state.getMaterial() == material) { + if (state.getMaterial() == material) {
+ return state; + return state;
+ } + }

View file

@ -48,6 +48,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+import io.papermc.paper.util.TransformingRandomAccessList; +import io.papermc.paper.util.TransformingRandomAccessList;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.examination.Examinable; +import net.kyori.examination.Examinable;
+import net.kyori.examination.ExaminableProperty; +import net.kyori.examination.ExaminableProperty;
@ -58,14 +62,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Allows plugins to compute tab completion results asynchronously. + * Allows plugins to compute tab completion results asynchronously.
@ -76,15 +75,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p> + * <p>
+ * Only 1 process will be allowed to provide completions, the Async Event, or the standard process. + * Only 1 process will be allowed to provide completions, the Async Event, or the standard process.
+ */ + */
+@NullMarked
+public class AsyncTabCompleteEvent extends Event implements Cancellable { +public class AsyncTabCompleteEvent extends Event implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final CommandSender sender; + private final CommandSender sender;
+ @NotNull private final String buffer; + private final String buffer;
+ private final boolean isCommand; + private final boolean isCommand;
+ @Nullable + private final @Nullable Location location;
+ private final Location location;
+ private final List<Completion> completions = new ArrayList<>(); + private final List<Completion> completions = new ArrayList<>();
+ private final List<String> stringCompletions = new TransformingRandomAccessList<>( + private final List<String> stringCompletions = new TransformingRandomAccessList<>(
+ this.completions, + this.completions,
@ -95,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, boolean isCommand, @Nullable Location loc) { + public AsyncTabCompleteEvent(final CommandSender sender, final String buffer, final boolean isCommand, final @Nullable Location loc) {
+ super(true); + super(true);
+ this.sender = sender; + this.sender = sender;
+ this.buffer = buffer; + this.buffer = buffer;
@ -105,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull List<String> completions, @NotNull String buffer, boolean isCommand, @Nullable Location loc) { + public AsyncTabCompleteEvent(final CommandSender sender, final List<String> completions, final String buffer, final boolean isCommand, final @Nullable Location loc) {
+ super(true); + super(true);
+ this.sender = sender; + this.sender = sender;
+ this.completions.addAll(fromStrings(completions)); + this.completions.addAll(fromStrings(completions));
@ -119,7 +118,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the {@link CommandSender} instance + * @return the {@link CommandSender} instance
+ */ + */
+ @NotNull
+ public CommandSender getSender() { + public CommandSender getSender() {
+ return this.sender; + return this.sender;
+ } + }
@ -134,7 +132,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return a list of offered completions + * @return a list of offered completions
+ */ + */
+ @NotNull
+ public List<String> getCompletions() { + public List<String> getCompletions() {
+ return this.stringCompletions; + return this.stringCompletions;
+ } + }
@ -149,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param completions the new completions + * @param completions the new completions
+ */ + */
+ public void setCompletions(@NotNull List<String> completions) { + public void setCompletions(final List<String> completions) {
+ Preconditions.checkArgument(completions != null, "Completions list cannot be null"); + Preconditions.checkArgument(completions != null, "Completions list cannot be null");
+ if (completions == this.stringCompletions) { + if (completions == this.stringCompletions) {
+ return; + return;
@ -168,7 +165,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return a list of offered completions + * @return a list of offered completions
+ */ + */
+ public @NotNull List<Completion> completions() { + public List<Completion> completions() {
+ return this.completions; + return this.completions;
+ } + }
+ +
@ -182,7 +179,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param newCompletions the new completions + * @param newCompletions the new completions
+ */ + */
+ public void completions(final @NotNull List<Completion> newCompletions) { + public void completions(final List<Completion> newCompletions) {
+ Preconditions.checkArgument(newCompletions != null, "new completions cannot be null"); + Preconditions.checkArgument(newCompletions != null, "new completions cannot be null");
+ this.completions.clear(); + this.completions.clear();
+ this.completions.addAll(newCompletions); + this.completions.addAll(newCompletions);
@ -193,7 +190,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return command buffer, as entered + * @return command buffer, as entered
+ */ + */
+ @NotNull
+ public String getBuffer() { + public String getBuffer() {
+ return this.buffer; + return this.buffer;
+ } + }
@ -208,8 +204,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The position looked at by the sender, or {@code null} if none + * @return The position looked at by the sender, or {@code null} if none
+ */ + */
+ @Nullable + public @Nullable Location getLocation() {
+ public Location getLocation() {
+ return this.location != null ? this.location.clone() : null; + return this.location != null ? this.location.clone() : null;
+ } + }
+ +
@ -230,7 +225,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param handled if this completion should be marked as being handled + * @param handled if this completion should be marked as being handled
+ */ + */
+ public void setHandled(boolean handled) { + public void setHandled(final boolean handled) {
+ this.handled = handled; + this.handled = handled;
+ } + }
+ +
@ -245,21 +240,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Will provide no completions, and will not fire the synchronous process + * Will provide no completions, and will not fire the synchronous process
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ private static @NotNull List<Completion> fromStrings(final @NotNull List<String> suggestions) { + private static List<Completion> fromStrings(final List<String> suggestions) {
+ final List<Completion> list = new ArrayList<>(suggestions.size()); + final List<Completion> list = new ArrayList<>(suggestions.size());
+ for (final String suggestion : suggestions) { + for (final String suggestion : suggestions) {
+ list.add(new CompletionImpl(suggestion, null)); + list.add(new CompletionImpl(suggestion, null));
@ -277,7 +270,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return suggestion string + * @return suggestion string
+ */ + */
+ @NotNull String suggestion(); + String suggestion();
+ +
+ /** + /**
+ * Get the suggestion tooltip for this {@link Completion}. + * Get the suggestion tooltip for this {@link Completion}.
@ -287,7 +280,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Nullable Component tooltip(); + @Nullable Component tooltip();
+ +
+ @Override + @Override
+ default @NotNull Stream<? extends ExaminableProperty> examinableProperties() { + default Stream<? extends ExaminableProperty> examinableProperties() {
+ return Stream.of(ExaminableProperty.of("suggestion", this.suggestion()), ExaminableProperty.of("tooltip", this.tooltip())); + return Stream.of(ExaminableProperty.of("suggestion", this.suggestion()), ExaminableProperty.of("tooltip", this.tooltip()));
+ } + }
+ +
@ -297,7 +290,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param suggestion suggestion string + * @param suggestion suggestion string
+ * @return new completion instance + * @return new completion instance
+ */ + */
+ static @NotNull Completion completion(final @NotNull String suggestion) { + static Completion completion(final String suggestion) {
+ return new CompletionImpl(suggestion, null); + return new CompletionImpl(suggestion, null);
+ } + }
+ +
@ -310,7 +303,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param tooltip tooltip component, or {@code null} + * @param tooltip tooltip component, or {@code null}
+ * @return new completion instance + * @return new completion instance
+ */ + */
+ static @NotNull Completion completion(final @NotNull String suggestion, final @Nullable Component tooltip) { + static Completion completion(final String suggestion, final @Nullable Component tooltip) {
+ return new CompletionImpl(suggestion, tooltip); + return new CompletionImpl(suggestion, tooltip);
+ } + }
+ } + }
@ -319,15 +312,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ static final class CompletionImpl implements Completion { + static final class CompletionImpl implements Completion {
+ +
+ private final String suggestion; + private final String suggestion;
+ private final Component tooltip; + private final @Nullable Component tooltip;
+ +
+ CompletionImpl(final @NotNull String suggestion, final @Nullable Component tooltip) { + CompletionImpl(final String suggestion, final @Nullable Component tooltip) {
+ this.suggestion = suggestion; + this.suggestion = suggestion;
+ this.tooltip = tooltip; + this.tooltip = tooltip;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull String suggestion() { + public String suggestion() {
+ return this.suggestion; + return this.suggestion;
+ } + }
+ +
@ -355,7 +348,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public @NotNull String toString() { + public String toString() {
+ return StringExaminer.simpleEscaping().examine(this); + return StringExaminer.simpleEscaping().examine(this);
+ } + }
+ } + }

View file

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockExpEvent; +import org.bukkit.event.block.BlockExpEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired anytime the server intends to 'destroy' a block through some triggering reason. + * Fired anytime the server intends to 'destroy' a block through some triggering reason.
@ -36,11 +36,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p> + * <p>
+ * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event. + * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event.
+ */ + */
+@NullMarked
+public class BlockDestroyEvent extends BlockExpEvent implements Cancellable { +public class BlockDestroyEvent extends BlockExpEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final BlockData newState; + private final BlockData newState;
+ private boolean willDrop; + private boolean willDrop;
+ private boolean playEffect = true; + private boolean playEffect = true;
+ private BlockData effectBlock; + private BlockData effectBlock;
@ -48,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, int xp, boolean willDrop) { + public BlockDestroyEvent(final Block block, final BlockData newState, final BlockData effectBlock, final int xp, final boolean willDrop) {
+ super(block, xp); + super(block, xp);
+ this.newState = newState; + this.newState = newState;
+ this.effectBlock = effectBlock; + this.effectBlock = effectBlock;
@ -60,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return block break effect + * @return block break effect
+ */ + */
+ @NotNull
+ public BlockData getEffectBlock() { + public BlockData getEffectBlock() {
+ return this.effectBlock; + return this.effectBlock;
+ } + }
@ -72,14 +72,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param effectBlock block effect + * @param effectBlock block effect
+ */ + */
+ public void setEffectBlock(@NotNull BlockData effectBlock) { + public void setEffectBlock(final BlockData effectBlock) {
+ this.effectBlock = effectBlock; + this.effectBlock = effectBlock;
+ } + }
+ +
+ /** + /**
+ * @return The new state of this block (Air, or a Fluid type) + * @return The new state of this block (Air, or a Fluid type)
+ */ + */
+ public @NotNull BlockData getNewState() { + public BlockData getNewState() {
+ return this.newState.clone(); + return this.newState.clone();
+ } + }
+ +
@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @param willDrop If the server is going to drop the block in question with this destroy event + * @param willDrop If the server is going to drop the block in question with this destroy event
+ */ + */
+ public void setWillDrop(boolean willDrop) { + public void setWillDrop(final boolean willDrop) {
+ this.willDrop = willDrop; + this.willDrop = willDrop;
+ } + }
+ +
@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @param playEffect If the server should play the sound effect for this destruction + * @param playEffect If the server should play the sound effect for this destruction
+ */ + */
+ public void setPlayEffect(boolean playEffect) { + public void setPlayEffect(final boolean playEffect) {
+ this.playEffect = playEffect; + this.playEffect = playEffect;
+ } + }
+ +
@ -123,17 +123,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * If the event is cancelled, the block will remain in its previous state. + * If the event is cancelled, the block will remain in its previous state.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

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

View file

@ -32,6 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ compileOnlyApi(checkerQual) + compileOnlyApi(checkerQual)
+ testCompileOnly(checkerQual) + testCompileOnly(checkerQual)
+ // Paper end + // Paper end
+ api("org.jspecify:jspecify:1.0.0") // Paper - add jspecify
+ +
testImplementation("org.apache.commons:commons-lang3:3.12.0") testImplementation("org.apache.commons:commons-lang3:3.12.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")

View file

@ -12,30 +12,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import java.util.Collection;
+import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.DragonFireball; +import org.bukkit.entity.DragonFireball;
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+
+import java.util.Collection;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud + * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud
+ */ + */
+@NullMarked
+public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable { +public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Collection<LivingEntity> targets; + private final Collection<LivingEntity> targets;
+ @NotNull private final AreaEffectCloud areaEffectCloud; + private final AreaEffectCloud areaEffectCloud;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EnderDragonFireballHitEvent(@NotNull DragonFireball fireball, @NotNull Collection<LivingEntity> targets, @NotNull AreaEffectCloud areaEffectCloud) { + public EnderDragonFireballHitEvent(final DragonFireball fireball, final Collection<LivingEntity> targets, final AreaEffectCloud areaEffectCloud) {
+ super(fireball); + super(fireball);
+ this.targets = targets; + this.targets = targets;
+ this.areaEffectCloud = areaEffectCloud; + this.areaEffectCloud = areaEffectCloud;
@ -44,7 +44,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * The fireball involved in this event + * The fireball involved in this event
+ */ + */
+ @NotNull
+ @Override + @Override
+ public DragonFireball getEntity() { + public DragonFireball getEntity() {
+ return (DragonFireball) super.getEntity(); + return (DragonFireball) super.getEntity();
@ -55,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the targets + * @return the targets
+ */ + */
+ @NotNull
+ public Collection<LivingEntity> getTargets() { + public Collection<LivingEntity> getTargets() {
+ return this.targets; + return this.targets;
+ } + }
@ -63,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The area effect cloud spawned in this collision + * @return The area effect cloud spawned in this collision
+ */ + */
+ @NotNull
+ public AreaEffectCloud getAreaEffectCloud() { + public AreaEffectCloud getAreaEffectCloud() {
+ return this.areaEffectCloud; + return this.areaEffectCloud;
+ } + }
@ -74,17 +71,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -103,20 +98,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames + * Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames
+ */ + */
+@NullMarked
+public class EnderDragonFlameEvent extends EntityEvent implements Cancellable { +public class EnderDragonFlameEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final AreaEffectCloud areaEffectCloud; + private final AreaEffectCloud areaEffectCloud;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EnderDragonFlameEvent(@NotNull EnderDragon enderDragon, @NotNull AreaEffectCloud areaEffectCloud) { + public EnderDragonFlameEvent(final EnderDragon enderDragon, final AreaEffectCloud areaEffectCloud) {
+ super(enderDragon); + super(enderDragon);
+ this.areaEffectCloud = areaEffectCloud; + this.areaEffectCloud = areaEffectCloud;
+ } + }
@ -124,7 +120,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * The enderdragon involved in this event + * The enderdragon involved in this event
+ */ + */
+ @NotNull
+ @Override + @Override
+ public EnderDragon getEntity() { + public EnderDragon getEntity() {
+ return (EnderDragon) super.getEntity(); + return (EnderDragon) super.getEntity();
@ -133,7 +128,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The area effect cloud spawned in this collision + * @return The area effect cloud spawned in this collision
+ */ + */
+ @NotNull
+ public AreaEffectCloud getAreaEffectCloud() { + public AreaEffectCloud getAreaEffectCloud() {
+ return this.areaEffectCloud; + return this.areaEffectCloud;
+ } + }
@ -144,16 +138,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -172,20 +164,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when an EnderDragon shoots a fireball + * Fired when an EnderDragon shoots a fireball
+ */ + */
+@NullMarked
+public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable { +public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final DragonFireball fireball; + private final DragonFireball fireball;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EnderDragonShootFireballEvent(@NotNull EnderDragon entity, @NotNull DragonFireball fireball) { + public EnderDragonShootFireballEvent(final EnderDragon entity, final DragonFireball fireball) {
+ super(entity); + super(entity);
+ this.fireball = fireball; + this.fireball = fireball;
+ } + }
@ -193,7 +186,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * The enderdragon shooting the fireball + * The enderdragon shooting the fireball
+ */ + */
+ @NotNull
+ @Override + @Override
+ public EnderDragon getEntity() { + public EnderDragon getEntity() {
+ return (EnderDragon) super.getEntity(); + return (EnderDragon) super.getEntity();
@ -202,7 +194,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The fireball being shot + * @return The fireball being shot
+ */ + */
+ @NotNull
+ public DragonFireball getFireball() { + public DragonFireball getFireball() {
+ return this.fireball; + return this.fireball;
+ } + }
@ -213,17 +204,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when an Enderman determines if it should attack a player or not. + * Fired when an Enderman determines if it should attack a player or not.
@ -52,15 +52,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Starts off cancelled if the player is wearing a pumpkin head or is not looking + * Starts off cancelled if the player is wearing a pumpkin head or is not looking
+ * at the Enderman, according to Vanilla rules. + * at the Enderman, according to Vanilla rules.
+ */ + */
+@NullMarked
+public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable { +public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Player player; + private final Player player;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EndermanAttackPlayerEvent(@NotNull Enderman entity, @NotNull Player player) { + public EndermanAttackPlayerEvent(final Enderman entity, final Player player) {
+ super(entity); + super(entity);
+ this.player = player; + this.player = player;
+ } + }
@ -70,7 +71,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The enderman considering attacking + * @return The enderman considering attacking
+ */ + */
+ @NotNull
+ @Override + @Override
+ public Enderman getEntity() { + public Enderman getEntity() {
+ return (Enderman) super.getEntity(); + return (Enderman) super.getEntity();
@ -81,7 +81,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The player the Enderman is considering attacking + * @return The player the Enderman is considering attacking
+ */ + */
+ @NotNull
+ public Player getPlayer() { + public Player getPlayer() {
+ return this.player; + return this.player;
+ } + }
@ -100,16 +99,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Cancels if the Enderman will attack this player + * Cancels if the Enderman will attack this player
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -20,22 +20,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class EndermanEscapeEvent extends EntityEvent implements Cancellable { +public class EndermanEscapeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Reason reason; + private final Reason reason;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EndermanEscapeEvent(@NotNull Enderman entity, @NotNull Reason reason) { + public EndermanEscapeEvent(final Enderman entity, final Reason reason) {
+ super(entity); + super(entity);
+ this.reason = reason; + this.reason = reason;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Enderman getEntity() { + public Enderman getEntity() {
+ return (Enderman) super.getEntity(); + return (Enderman) super.getEntity();
@ -44,7 +44,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The reason the enderman is trying to escape + * @return The reason the enderman is trying to escape
+ */ + */
+ @NotNull
+ public Reason getReason() { + public Reason getReason() {
+ return this.reason; + return this.reason;
+ } + }
@ -57,21 +56,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Cancels the escape. + * Cancels the escape.
+ * <p> + * <p>
+ * If this escape normally would of resulted in damage avoidance such as indirect, + * If this escape normally had resulted in damage avoidance such as indirect,
+ * the enderman will now take damage. + * the enderman will now take damage.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -18,21 +18,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired any time an entity is being added to the world for any reason (including a chunk loading). + * Fired any time an entity is being added to the world for any reason (including a chunk loading).
+ * <p> + * <p>
+ * Not to be confused with {@link CreatureSpawnEvent} + * Not to be confused with {@link CreatureSpawnEvent}
+ */ + */
+@NullMarked
+public class EntityAddToWorldEvent extends EntityEvent { +public class EntityAddToWorldEvent extends EntityEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final World world; + private final World world;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityAddToWorldEvent(@NotNull Entity entity, @NotNull World world) { + public EntityAddToWorldEvent(final Entity entity, final World world) {
+ super(entity); + super(entity);
+ this.world = world; + this.world = world;
+ } + }
@ -40,17 +41,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The world that the entity is being added to + * @return The world that the entity is being added to
+ */ + */
+ @NotNull
+ public World getWorld() { + public World getWorld() {
+ return this.world; + return this.world;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -68,20 +66,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired any time an entity is being removed from a world for any reason (including a chunk unloading). + * Fired any time an entity is being removed from a world for any reason (including a chunk unloading).
+ * Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}. + * Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}.
+ */ + */
+@NullMarked
+public class EntityRemoveFromWorldEvent extends EntityEvent { +public class EntityRemoveFromWorldEvent extends EntityEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final World world; + private final World world;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityRemoveFromWorldEvent(@NotNull Entity entity, @NotNull World world) { + public EntityRemoveFromWorldEvent(final Entity entity, final World world) {
+ super(entity); + super(entity);
+ this.world = world; + this.world = world;
+ } + }
@ -89,17 +88,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The world that the entity is being removed from + * @return The world that the entity is being removed from
+ */ + */
+ @NotNull
+ public World getWorld() { + public World getWorld() {
+ return this.world; + return this.world;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -17,13 +17,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when an entity jumps + * Called when an entity jumps
+ * <p> + * <p>
+ * Cancelling the event will stop the entity from jumping + * Cancelling the event will stop the entity from jumping
+ */ + */
+@NullMarked
+public class EntityJumpEvent extends EntityEvent implements Cancellable { +public class EntityJumpEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -31,11 +32,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityJumpEvent(@NotNull LivingEntity entity) { + public EntityJumpEvent(final LivingEntity entity) {
+ super(entity); + super(entity);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity(); + return (LivingEntity) super.getEntity();
@ -45,17 +45,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.cancelled; + return this.cancelled;
+ } + }
+ +
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -20,13 +20,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerMoveEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Holds information for living entity movement events + * Holds information for living entity movement events
+ * <p> + * <p>
+ * Does not fire for players; use {@link PlayerMoveEvent} for player movement. + * Does not fire for players; use {@link PlayerMoveEvent} for player movement.
+ */ + */
+@NullMarked
+public class EntityMoveEvent extends EntityEvent implements Cancellable { +public class EntityMoveEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -37,14 +38,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityMoveEvent(@NotNull LivingEntity entity, @NotNull Location from, @NotNull Location to) { + public EntityMoveEvent(final LivingEntity entity, final Location from, final Location to) {
+ super(entity); + super(entity);
+ this.from = from; + this.from = from;
+ this.to = to; + this.to = to;
+ } + }
+ +
+ @Override + @Override
+ @NotNull
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity(); + return (LivingEntity) super.getEntity();
+ } + }
@ -54,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location the entity moved from + * @return Location the entity moved from
+ */ + */
+ @NotNull
+ public Location getFrom() { + public Location getFrom() {
+ return this.from; + return this.from;
+ } + }
@ -64,8 +63,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param from New location to mark as the entity's previous location + * @param from New location to mark as the entity's previous location
+ */ + */
+ public void setFrom(@NotNull Location from) { + public void setFrom(final Location from) {
+ validateLocation(from); + this.validateLocation(from);
+ this.from = from; + this.from = from;
+ } + }
+ +
@ -74,7 +73,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location the entity moved to + * @return Location the entity moved to
+ */ + */
+ @NotNull
+ public Location getTo() { + public Location getTo() {
+ return this.to; + return this.to;
+ } + }
@ -84,8 +82,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param to New Location this entity will move to + * @param to New Location this entity will move to
+ */ + */
+ public void setTo(@NotNull Location to) { + public void setTo(final Location to) {
+ validateLocation(to); + this.validateLocation(to);
+ this.to = to; + this.to = to;
+ } + }
+ +
@ -95,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return whether the entity has changed position or not + * @return whether the entity has changed position or not
+ */ + */
+ public boolean hasChangedPosition() { + public boolean hasChangedPosition() {
+ return hasExplicitlyChangedPosition() || !this.from.getWorld().equals(this.to.getWorld()); + return this.hasExplicitlyChangedPosition() || !this.from.getWorld().equals(this.to.getWorld());
+ } + }
+ +
+ /** + /**
@ -113,7 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return whether the entity has moved to a new block or not + * @return whether the entity has moved to a new block or not
+ */ + */
+ public boolean hasChangedBlock() { + public boolean hasChangedBlock() {
+ return hasExplicitlyChangedBlock() || !from.getWorld().equals(to.getWorld()); + return this.hasExplicitlyChangedBlock() || !this.from.getWorld().equals(this.to.getWorld());
+ } + }
+ +
+ /** + /**
@ -134,7 +132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.from.getPitch() != this.to.getPitch() || this.from.getYaw() != this.to.getYaw(); + return this.from.getPitch() != this.to.getPitch() || this.from.getYaw() != this.to.getYaw();
+ } + }
+ +
+ private void validateLocation(@NotNull Location loc) { + private void validateLocation(final Location loc) {
+ Preconditions.checkArgument(loc != null, "Cannot use null location!"); + Preconditions.checkArgument(loc != null, "Cannot use null location!");
+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!"); + Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
+ } + }
@ -145,17 +143,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Fired when an Entity decides to start moving towards a location. + * Fired when an Entity decides to start moving towards a location.
@ -28,16 +28,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entities actual movement. Only when it + * This event does not fire for the entities actual movement. Only when it
+ * is choosing to start moving to a location. + * is choosing to start moving to a location.
+ */ + */
+@NullMarked
+public class EntityPathfindEvent extends EntityEvent implements Cancellable { +public class EntityPathfindEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @Nullable private final Entity targetEntity; + private final @Nullable Entity targetEntity;
+ @NotNull private final Location location; + private final Location location;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location location, @Nullable Entity targetEntity) { + public EntityPathfindEvent(final Entity entity, final Location location, final @Nullable Entity targetEntity) {
+ super(entity); + super(entity);
+ this.targetEntity = targetEntity; + this.targetEntity = targetEntity;
+ this.location = location; + this.location = location;
@ -48,7 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The Entity that is pathfinding. + * @return The Entity that is pathfinding.
+ */ + */
+ @NotNull
+ public Entity getEntity() { + public Entity getEntity() {
+ return this.entity; + return this.entity;
+ } + }
@ -56,12 +56,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * If the Entity is trying to pathfind to an entity, this is the entity in relation. + * If the Entity is trying to pathfind to an entity, this is the entity in relation.
+ * <br> + * <br>
+ * Otherwise this will return {@code null}. + * Otherwise, this will return {@code null}.
+ * + *
+ * @return The entity target or {@code null} + * @return The entity target or {@code null}
+ */ + */
+ @Nullable + public @Nullable Entity getTargetEntity() {
+ public Entity getTargetEntity() {
+ return this.targetEntity; + return this.targetEntity;
+ } + }
+ +
@ -72,7 +71,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location of where the entity is trying to pathfind to. + * @return Location of where the entity is trying to pathfind to.
+ */ + */
+ @NotNull
+ public Location getLoc() { + public Location getLoc() {
+ return this.location.clone(); + return this.location.clone();
+ } + }
@ -83,17 +81,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -46,22 +46,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired anytime the server is about to merge 2 experience orbs into one + * Fired anytime the server is about to merge 2 experience orbs into one
+ */ + */
+@NullMarked
+public class ExperienceOrbMergeEvent extends EntityEvent implements Cancellable { +public class ExperienceOrbMergeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final ExperienceOrb mergeTarget; + private final ExperienceOrb mergeTarget;
+ @NotNull private final ExperienceOrb mergeSource; + private final ExperienceOrb mergeSource;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ExperienceOrbMergeEvent(@NotNull ExperienceOrb mergeTarget, @NotNull ExperienceOrb mergeSource) { + public ExperienceOrbMergeEvent(final ExperienceOrb mergeTarget, final ExperienceOrb mergeSource) {
+ super(mergeTarget); + super(mergeTarget);
+ this.mergeTarget = mergeTarget; + this.mergeTarget = mergeTarget;
+ this.mergeSource = mergeSource; + this.mergeSource = mergeSource;
@ -70,7 +71,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The orb that will absorb the other experience orb + * @return The orb that will absorb the other experience orb
+ */ + */
+ @NotNull
+ public ExperienceOrb getMergeTarget() { + public ExperienceOrb getMergeTarget() {
+ return this.mergeTarget; + return this.mergeTarget;
+ } + }
@ -78,7 +78,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The orb that is subject to being removed and merged into the target orb + * @return The orb that is subject to being removed and merged into the target orb
+ */ + */
+ @NotNull
+ public ExperienceOrb getMergeSource() { + public ExperienceOrb getMergeSource() {
+ return this.mergeSource; + return this.mergeSource;
+ } + }
@ -92,17 +91,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if you wish to cancel this event, and prevent the orbs from merging + * @param cancel {@code true} if you wish to cancel this event, and prevent the orbs from merging
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -17,18 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a beacon is activated. + * Called when a beacon is activated.
+ * Activation occurs when the beacon beam becomes visible. + * Activation occurs when the beacon beam becomes visible.
+ */ + */
+@NullMarked
+public class BeaconActivatedEvent extends BlockEvent { +public class BeaconActivatedEvent extends BlockEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BeaconActivatedEvent(@NotNull Block block) { + public BeaconActivatedEvent(final Block block) {
+ super(block); + super(block);
+ } + }
+ +
@ -37,18 +38,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the beacon that was activated. + * @return the beacon that was activated.
+ */ + */
+ @NotNull
+ public Beacon getBeacon() { + public Beacon getBeacon() {
+ return (Beacon) this.block.getState(); + return (Beacon) this.block.getState();
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -67,18 +65,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when a beacon is deactivated, either because its base block(s) or itself were destroyed. + * Called when a beacon is deactivated, either because its base block(s) or itself were destroyed.
+ */ + */
+@NullMarked
+public class BeaconDeactivatedEvent extends BlockEvent { +public class BeaconDeactivatedEvent extends BlockEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BeaconDeactivatedEvent(@NotNull Block block) { + public BeaconDeactivatedEvent(final Block block) {
+ super(block); + super(block);
+ } + }
+ +
@ -89,18 +88,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The beacon that got deactivated, or {@code null} if it does not exist. + * @return The beacon that got deactivated, or {@code null} if it does not exist.
+ */ + */
+ @Nullable + public @Nullable Beacon getBeacon() {
+ public Beacon getBeacon() {
+ return this.block.getType() == Material.BEACON ? (Beacon) this.block.getState() : null; + return this.block.getType() == Material.BEACON ? (Beacon) this.block.getState() : null;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -21,11 +21,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event + * Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event
+ */ + */
+@NullMarked
+public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable { +public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -34,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerNaturallySpawnCreaturesEvent(@NotNull Player player, byte radius) { + public PlayerNaturallySpawnCreaturesEvent(final Player player, final byte radius) {
+ super(player); + super(player);
+ this.radius = radius; + this.radius = radius;
+ } + }
@ -49,12 +50,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @param radius The radius of chunks around this player to be included in natural spawn selection + * @param radius The radius of chunks around this player to be included in natural spawn selection
+ */ + */
+ public void setSpawnRadius(byte radius) { + public void setSpawnRadius(final byte radius) {
+ this.radius = radius; + this.radius = radius;
+ } + }
+ +
+ /** + /**
+ * @return If this players chunks will be excluded from natural spawns + * @return If this player's chunks will be excluded from natural spawns
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
@ -62,20 +63,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ /** + /**
+ * @param cancel {@code true} if you wish to cancel this event, and not include this players chunks for natural spawning + * @param cancel {@code true} if you wish to cancel this event, and not include this player's chunks for natural spawning
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * WARNING: This event only fires for a limited number of cases, and not for every case that {@link CreatureSpawnEvent} does. + * WARNING: This event only fires for a limited number of cases, and not for every case that {@link CreatureSpawnEvent} does.
@ -41,19 +41,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Currently: NATURAL and SPAWNER based reasons. <!-- Please submit a Pull Request for future additions. --> + * Currently: NATURAL and SPAWNER based reasons. <!-- Please submit a Pull Request for future additions. -->
+ * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event. + * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event.
+ */ + */
+@NullMarked
+public class PreCreatureSpawnEvent extends Event implements Cancellable { +public class PreCreatureSpawnEvent extends Event implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Location location; + private final Location location;
+ @NotNull private final EntityType type; + private final EntityType type;
+ @NotNull private final CreatureSpawnEvent.SpawnReason reason; + private final CreatureSpawnEvent.SpawnReason reason;
+ private boolean shouldAbortSpawn; + private boolean shouldAbortSpawn;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PreCreatureSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason) { + public PreCreatureSpawnEvent(final Location location, final EntityType type, final CreatureSpawnEvent.SpawnReason reason) {
+ this.location = location; + this.location = location;
+ this.type = type; + this.type = type;
+ this.reason = reason; + this.reason = reason;
@ -62,7 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The location this creature is being spawned at + * @return The location this creature is being spawned at
+ */ + */
+ @NotNull
+ public Location getSpawnLocation() { + public Location getSpawnLocation() {
+ return this.location.clone(); + return this.location.clone();
+ } + }
@ -70,7 +70,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The type of creature being spawned + * @return The type of creature being spawned
+ */ + */
+ @NotNull
+ public EntityType getType() { + public EntityType getType() {
+ return this.type; + return this.type;
+ } + }
@ -78,7 +77,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return Reason this creature is spawning (ie, NATURAL vs SPAWNER) + * @return Reason this creature is spawning (ie, NATURAL vs SPAWNER)
+ */ + */
+ @NotNull
+ public CreatureSpawnEvent.SpawnReason getReason() { + public CreatureSpawnEvent.SpawnReason getReason() {
+ return this.reason; + return this.reason;
+ } + }
@ -96,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param shouldAbortSpawn Set if the spawn process should be aborted vs trying more attempts + * @param shouldAbortSpawn Set if the spawn process should be aborted vs trying more attempts
+ */ + */
+ public void setShouldAbortSpawn(boolean shouldAbortSpawn) { + public void setShouldAbortSpawn(final boolean shouldAbortSpawn) {
+ this.shouldAbortSpawn = shouldAbortSpawn; + this.shouldAbortSpawn = shouldAbortSpawn;
+ } + }
+ +
@ -114,17 +112,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if you wish to cancel this event, and abort the spawn of this creature + * @param cancel {@code true} if you wish to cancel this event, and abort the spawn of this creature
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.EntityType; +import org.bukkit.entity.EntityType;
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called before an entity is spawned into a world by a spawner. + * Called before an entity is spawned into a world by a spawner.
@ -30,17 +30,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This only includes the spawner's location and not the full BlockState snapshot for performance reasons. + * This only includes the spawner's location and not the full BlockState snapshot for performance reasons.
+ * If you really need it you have to get the spawner yourself. + * If you really need it you have to get the spawner yourself.
+ */ + */
+@NullMarked
+public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent { +public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent {
+ +
+ @NotNull private final Location spawnerLocation; + private final Location spawnerLocation;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PreSpawnerSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull Location spawnerLocation) { + public PreSpawnerSpawnEvent(final Location location, final EntityType type, final Location spawnerLocation) {
+ super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER); + super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER);
+ this.spawnerLocation = spawnerLocation; + this.spawnerLocation = spawnerLocation;
+ } + }
+ +
+ @NotNull
+ public Location getSpawnerLocation() { + public Location getSpawnerLocation() {
+ return this.spawnerLocation.clone(); + return this.spawnerLocation.clone();
+ } + }

View file

@ -18,9 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Allows a plugin to be notified anytime AFTER a Profile has been looked up from the Mojang API + * Allows a plugin to be notified anytime AFTER a Profile has been looked up from the Mojang API
@ -29,14 +28,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * No guarantees are made about thread execution context for this event. If you need to know, check + * No guarantees are made about thread execution context for this event. If you need to know, check
+ * {@link Event#isAsynchronous()} + * {@link Event#isAsynchronous()}
+ */ + */
+@NullMarked
+public class LookupProfileEvent extends Event { +public class LookupProfileEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final PlayerProfile profile; + private final PlayerProfile profile;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public LookupProfileEvent(@NotNull PlayerProfile profile) { + public LookupProfileEvent(final PlayerProfile profile) {
+ super(!Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread());
+ this.profile = profile; + this.profile = profile;
+ } + }
@ -44,18 +44,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The profile that was recently looked up. This profile can be mutated + * @return The profile that was recently looked up. This profile can be mutated
+ */ + */
+ @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return this.profile; + return this.profile;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -69,16 +66,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.event.profile; +package com.destroystokyo.paper.event.profile;
+ +
+import com.destroystokyo.paper.profile.ProfileProperty; +import com.destroystokyo.paper.profile.ProfileProperty;
+import org.bukkit.Bukkit;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+import java.util.HashSet; +import java.util.HashSet;
+import java.util.Set; +import java.util.Set;
+import java.util.UUID; +import java.util.UUID;
+import org.bukkit.Bukkit;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Allows a plugin to intercept a Profile Lookup for a Profile by name + * Allows a plugin to intercept a Profile Lookup for a Profile by name
@ -90,17 +86,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * No guarantees are made about thread execution context for this event. If you need to know, check + * No guarantees are made about thread execution context for this event. If you need to know, check
+ * {@link Event#isAsynchronous()} + * {@link Event#isAsynchronous()}
+ */ + */
+@NullMarked
+public class PreLookupProfileEvent extends Event { +public class PreLookupProfileEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final String name; + private final String name;
+ +
+ private UUID uuid; + private @Nullable UUID uuid;
+ @NotNull private Set<ProfileProperty> properties = new HashSet<>(); + private Set<ProfileProperty> properties = new HashSet<>();
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PreLookupProfileEvent(@NotNull String name) { + public PreLookupProfileEvent(final String name) {
+ super(!Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread());
+ this.name = name; + this.name = name;
+ } + }
@ -108,7 +105,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return Name of the profile + * @return Name of the profile
+ */ + */
+ @NotNull
+ public String getName() { + public String getName() {
+ return this.name; + return this.name;
+ } + }
@ -120,8 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The UUID of the profile if it has already been provided by a plugin + * @return The UUID of the profile if it has already been provided by a plugin
+ */ + */
+ @Nullable + public @Nullable UUID getUUID() {
+ public UUID getUUID() {
+ return this.uuid; + return this.uuid;
+ } + }
+ +
@ -132,7 +127,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param uuid the UUID to set for the profile or {@code null} to reset + * @param uuid the UUID to set for the profile or {@code null} to reset
+ */ + */
+ public void setUUID(@Nullable UUID uuid) { + public void setUUID(final @Nullable UUID uuid) {
+ this.uuid = uuid; + this.uuid = uuid;
+ } + }
+ +
@ -140,7 +135,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return The currently pending pre-populated properties. + * @return The currently pending pre-populated properties.
+ * Any property in this Set will be automatically prefilled on this Profile + * Any property in this Set will be automatically prefilled on this Profile
+ */ + */
+ @NotNull
+ public Set<ProfileProperty> getProfileProperties() { + public Set<ProfileProperty> getProfileProperties() {
+ return this.properties; + return this.properties;
+ } + }
@ -151,7 +145,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param properties The properties to add + * @param properties The properties to add
+ */ + */
+ public void setProfileProperties(@NotNull Set<ProfileProperty> properties) { + public void setProfileProperties(final Set<ProfileProperty> properties) {
+ this.properties = new HashSet<>(); + this.properties = new HashSet<>();
+ this.properties.addAll(properties); + this.properties.addAll(properties);
+ } + }
@ -162,17 +156,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param properties The properties to add + * @param properties The properties to add
+ */ + */
+ public void addProfileProperties(@NotNull Set<ProfileProperty> properties) { + public void addProfileProperties(final Set<ProfileProperty> properties) {
+ this.properties.addAll(properties); + this.properties.addAll(properties);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -16,11 +16,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when the server has finished ticking the main loop + * Called when the server has finished ticking the main loop
+ */ + */
+@NullMarked
+public class ServerTickEndEvent extends Event { +public class ServerTickEndEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -30,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final long timeEnd; + private final long timeEnd;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ServerTickEndEvent(int tickNumber, double tickDuration, long timeRemaining) { + public ServerTickEndEvent(final int tickNumber, final double tickDuration, final long timeRemaining) {
+ this.tickNumber = tickNumber; + this.tickNumber = tickNumber;
+ this.tickDuration = tickDuration; + this.tickDuration = tickDuration;
+ this.timeEnd = System.nanoTime() + timeRemaining; + this.timeEnd = System.nanoTime() + timeRemaining;
@ -63,12 +64,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.timeEnd - System.nanoTime(); + return this.timeEnd - System.nanoTime();
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -84,8 +83,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class ServerTickStartEvent extends Event { +public class ServerTickStartEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final int tickNumber; + private final int tickNumber;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ServerTickStartEvent(int tickNumber) { + public ServerTickStartEvent(final int tickNumber) {
+ this.tickNumber = tickNumber; + this.tickNumber = tickNumber;
+ } + }
+ +
@ -104,12 +104,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.tickNumber; + return this.tickNumber;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -13,19 +13,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.HumanEntity;
+import org.bukkit.entity.SkeletonHorse; +import org.bukkit.entity.SkeletonHorse;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+
+import java.util.List;
+ +
+/** +/**
+ * Event called when a player gets close to a skeleton horse and triggers the lightning trap + * Event called when a player gets close to a skeleton horse and triggers the lightning trap
+ */ + */
+@NullMarked
+public class SkeletonHorseTrapEvent extends EntityEvent implements Cancellable { +public class SkeletonHorseTrapEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -35,23 +35,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse) { + public SkeletonHorseTrapEvent(final SkeletonHorse horse) {
+ this(horse, ImmutableList.of()); + this(horse, ImmutableList.of());
+ } + }
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse, @NotNull List<HumanEntity> eligibleHumans) { + public SkeletonHorseTrapEvent(final SkeletonHorse horse, final List<HumanEntity> eligibleHumans) {
+ super(horse); + super(horse);
+ this.eligibleHumans = eligibleHumans; + this.eligibleHumans = eligibleHumans;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public SkeletonHorse getEntity() { + public SkeletonHorse getEntity() {
+ return (SkeletonHorse) super.getEntity(); + return (SkeletonHorse) super.getEntity();
+ } + }
+ +
+ @NotNull
+ public List<HumanEntity> getEligibleHumans() { + public List<HumanEntity> getEligibleHumans() {
+ return this.eligibleHumans; + return this.eligibleHumans;
+ } + }
@ -62,17 +60,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Slime decides to change its facing direction. + * Fired when a Slime decides to change its facing direction.
@ -22,12 +22,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to change direction. + * is choosing to change direction.
+ */ + */
+@NullMarked
+public class SlimeChangeDirectionEvent extends SlimePathfindEvent { +public class SlimeChangeDirectionEvent extends SlimePathfindEvent {
+ +
+ private float yaw; + private float yaw;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) { + public SlimeChangeDirectionEvent(final Slime slime, final float yaw) {
+ super(slime); + super(slime);
+ this.yaw = yaw; + this.yaw = yaw;
+ } + }
@ -46,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param yaw Chosen yaw + * @param yaw Chosen yaw
+ */ + */
+ public void setNewYaw(float yaw) { + public void setNewYaw(final float yaw) {
+ this.yaw = yaw; + this.yaw = yaw;
+ } + }
+} +}
@ -63,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Slime decides to start pathfinding. + * Fired when a Slime decides to start pathfinding.
@ -71,6 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving. + * is choosing to start moving.
+ */ + */
+@NullMarked
+public class SlimePathfindEvent extends EntityEvent implements Cancellable { +public class SlimePathfindEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -78,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SlimePathfindEvent(@NotNull Slime slime) { + public SlimePathfindEvent(final Slime slime) {
+ super(slime); + super(slime);
+ } + }
+ +
@ -87,7 +89,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The Slime that is pathfinding. + * @return The Slime that is pathfinding.
+ */ + */
+ @NotNull
+ public Slime getEntity() { + public Slime getEntity() {
+ return (Slime) super.getEntity(); + return (Slime) super.getEntity();
+ } + }
@ -98,16 +99,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -122,7 +121,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Slime decides to start jumping while swimming in water/lava. + * Fired when a Slime decides to start jumping while swimming in water/lava.
@ -130,10 +129,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start jumping. + * is choosing to start jumping.
+ */ + */
+@NullMarked
+public class SlimeSwimEvent extends SlimeWanderEvent { +public class SlimeSwimEvent extends SlimeWanderEvent {
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SlimeSwimEvent(@NotNull Slime slime) { + public SlimeSwimEvent(final Slime slime) {
+ super(slime); + super(slime);
+ } + }
+} +}
@ -148,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Slime decides to change direction to target a LivingEntity. + * Fired when a Slime decides to change direction to target a LivingEntity.
@ -156,12 +156,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving. + * is choosing to start moving.
+ */ + */
+@NullMarked
+public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent { +public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
+ +
+ @NotNull private final LivingEntity target; + private final LivingEntity target;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) { + public SlimeTargetLivingEntityEvent(final Slime slime, final LivingEntity target) {
+ super(slime); + super(slime);
+ this.target = target; + this.target = target;
+ } + }
@ -171,7 +172,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Targeted entity + * @return Targeted entity
+ */ + */
+ @NotNull
+ public LivingEntity getTarget() { + public LivingEntity getTarget() {
+ return this.target; + return this.target;
+ } + }
@ -186,7 +186,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Slime decides to start wandering. + * Fired when a Slime decides to start wandering.
@ -194,10 +194,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving. + * is choosing to start moving.
+ */ + */
+@NullMarked
+public class SlimeWanderEvent extends SlimePathfindEvent { +public class SlimeWanderEvent extends SlimePathfindEvent {
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public SlimeWanderEvent(@NotNull Slime slime) { + public SlimeWanderEvent(final Slime slime) {
+ super(slime); + super(slime);
+ } + }
+} +}

View file

@ -104,6 +104,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Test @Test
@@ -0,0 +0,0 @@ public class AnnotationTest { @@ -0,0 +0,0 @@ public class AnnotationTest {
continue;
}
+ // Paper start - skip class if it's @NullMarked
+ if (isClassNullMarked(clazz)) {
+ return;
+ }
+ // Paper end - skip class if it's @NullMarked
+
for (MethodNode method : clazz.methods) {
if (!isMethodIncluded(clazz, method, foundClasses)) {
continue;
} }
if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) { if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) {
@ -175,6 +187,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
private static void collectClasses(@NotNull File from, @NotNull Map<String, ClassNode> to) throws IOException { private static void collectClasses(@NotNull File from, @NotNull Map<String, ClassNode> to) throws IOException {
@@ -0,0 +0,0 @@ public class AnnotationTest {
}
}
+ // Paper start - skip class if it's @NullMarked
+ private static boolean isClassNullMarked(@NotNull ClassNode clazz) {
+ return clazz.visibleAnnotations != null && clazz.visibleAnnotations.stream().anyMatch(node -> "Lorg/jspecify/annotations/NullMarked;".equals(node.desc));
+ }
+ // Paper end - skip class if it's @NullMarked
+
private static boolean isClassIncluded(@NotNull ClassNode clazz, @NotNull Map<String, ClassNode> allClasses) {
// Exclude private, synthetic or deprecated classes and annotations, since their members can't be null
if ((clazz.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_DEPRECATED | Opcodes.ACC_ANNOTATION)) != 0) {
@@ -0,0 +0,0 @@ public class AnnotationTest { @@ -0,0 +0,0 @@ public class AnnotationTest {
// Exceptions are excluded // Exceptions are excluded
return false; return false;

View file

@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Turtle decides to go home + * Fired when a Turtle decides to go home
+ */ + */
+@NullMarked
+public class TurtleGoHomeEvent extends EntityEvent implements Cancellable { +public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -29,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public TurtleGoHomeEvent(@NotNull Turtle turtle) { + public TurtleGoHomeEvent(final Turtle turtle) {
+ super(turtle); + super(turtle);
+ } + }
+ +
@ -38,7 +39,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The turtle + * @return The turtle
+ */ + */
+ @NotNull
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) super.getEntity(); + return (Turtle) super.getEntity();
+ } + }
@ -49,16 +49,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -77,23 +75,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Turtle lays eggs + * Fired when a Turtle lays eggs
+ */ + */
+@NullMarked
+public class TurtleLayEggEvent extends EntityEvent implements Cancellable { +public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull
+ private final Location location; + private final Location location;
+ private int eggCount; + private int eggCount;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) { + public TurtleLayEggEvent(final Turtle turtle, final Location location, final int eggCount) {
+ super(turtle); + super(turtle);
+ this.location = location; + this.location = location;
+ this.eggCount = eggCount; + this.eggCount = eggCount;
@ -104,7 +102,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The turtle + * @return The turtle
+ */ + */
+ @NotNull
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) super.getEntity(); + return (Turtle) super.getEntity();
+ } + }
@ -114,7 +111,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location of eggs + * @return Location of eggs
+ */ + */
+ @NotNull
+ public Location getLocation() { + public Location getLocation() {
+ return this.location.clone(); + return this.location.clone();
+ } + }
@ -133,7 +129,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param eggCount Number of eggs + * @param eggCount Number of eggs
+ */ + */
+ public void setEggCount(int eggCount) { + public void setEggCount(final int eggCount) {
+ if (eggCount < 1) { + if (eggCount < 1) {
+ this.cancelled = true; + this.cancelled = true;
+ return; + return;
@ -147,16 +143,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -175,20 +169,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a Turtle starts digging to lay eggs + * Fired when a Turtle starts digging to lay eggs
+ */ + */
+@NullMarked
+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable { +public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Location location; + private final Location location;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) { + public TurtleStartDiggingEvent(final Turtle turtle, final Location location) {
+ super(turtle); + super(turtle);
+ this.location = location; + this.location = location;
+ } + }
@ -198,7 +193,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The turtle + * @return The turtle
+ */ + */
+ @NotNull
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) super.getEntity(); + return (Turtle) super.getEntity();
+ } + }
@ -208,7 +202,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location where digging + * @return Location where digging
+ */ + */
+ @NotNull
+ public Location getLocation() { + public Location getLocation() {
+ return this.location.clone(); + return this.location.clone();
+ } + }
@ -219,16 +212,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -19,26 +19,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Fired when a witch consumes the potion in their hand to buff themselves. + * Fired when a witch consumes the potion in their hand to buff themselves.
+ */ + */
+@NullMarked
+public class WitchConsumePotionEvent extends EntityEvent implements Cancellable { +public class WitchConsumePotionEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @Nullable private ItemStack potion; + private @Nullable ItemStack potion;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WitchConsumePotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) { + public WitchConsumePotionEvent(final Witch witch, final @Nullable ItemStack potion) {
+ super(witch); + super(witch);
+ this.potion = potion; + this.potion = potion;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Witch getEntity() { + public Witch getEntity() {
+ return (Witch) super.getEntity(); + return (Witch) super.getEntity();
@ -47,8 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return the potion the witch will consume and have the effects applied. + * @return the potion the witch will consume and have the effects applied.
+ */ + */
+ @Nullable + public @Nullable ItemStack getPotion() {
+ public ItemStack getPotion() {
+ return this.potion; + return this.potion;
+ } + }
+ +
@ -57,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param potion The potion + * @param potion The potion
+ */ + */
+ public void setPotion(@Nullable ItemStack potion) { + public void setPotion(final @Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null; + this.potion = potion != null ? potion.clone() : null;
+ } + }
+ +
@ -70,16 +69,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -19,23 +19,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+@NullMarked
+public class WitchReadyPotionEvent extends EntityEvent implements Cancellable { +public class WitchReadyPotionEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private ItemStack potion; + private @Nullable ItemStack potion;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WitchReadyPotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) { + public WitchReadyPotionEvent(final Witch witch, final @Nullable ItemStack potion) {
+ super(witch); + super(witch);
+ this.potion = potion; + this.potion = potion;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Witch getEntity() { + public Witch getEntity() {
+ return (Witch) super.getEntity(); + return (Witch) super.getEntity();
@ -44,8 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return the potion the witch is readying to use + * @return the potion the witch is readying to use
+ */ + */
+ @Nullable + public @Nullable ItemStack getPotion() {
+ public ItemStack getPotion() {
+ return this.potion; + return this.potion;
+ } + }
+ +
@ -54,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param potion The potion + * @param potion The potion
+ */ + */
+ public void setPotion(@Nullable ItemStack potion) { + public void setPotion(final @Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null; + this.potion = potion != null ? potion.clone() : null;
+ } + }
+ +
@ -64,17 +63,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -20,28 +20,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Fired when a witch throws a potion at a player + * Fired when a witch throws a potion at a player
+ */ + */
+@NullMarked
+public class WitchThrowPotionEvent extends EntityEvent implements Cancellable { +public class WitchThrowPotionEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final LivingEntity target; + private final LivingEntity target;
+ @Nullable private ItemStack potion; + private @Nullable ItemStack potion;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WitchThrowPotionEvent(@NotNull Witch witch, @NotNull LivingEntity target, @Nullable ItemStack potion) { + public WitchThrowPotionEvent(final Witch witch, final LivingEntity target, final @Nullable ItemStack potion) {
+ super(witch); + super(witch);
+ this.target = target; + this.target = target;
+ this.potion = potion; + this.potion = potion;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Witch getEntity() { + public Witch getEntity() {
+ return (Witch) super.getEntity(); + return (Witch) super.getEntity();
@ -50,7 +50,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The target of the potion + * @return The target of the potion
+ */ + */
+ @NotNull
+ public LivingEntity getTarget() { + public LivingEntity getTarget() {
+ return this.target; + return this.target;
+ } + }
@ -58,8 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The potion the witch will throw at a player + * @return The potion the witch will throw at a player
+ */ + */
+ @Nullable + public @Nullable ItemStack getPotion() {
+ public ItemStack getPotion() {
+ return this.potion; + return this.potion;
+ } + }
+ +
@ -68,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param potion The potion + * @param potion The potion
+ */ + */
+ public void setPotion(@Nullable ItemStack potion) { + public void setPotion(final @Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null; + this.potion = potion != null ? potion.clone() : null;
+ } + }
+ +
@ -81,17 +79,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View file

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFormEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle}, + * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle},
@ -30,6 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <b>This event might be cancelled by default depending on + * <b>This event might be cancelled by default depending on
+ * e.g. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b> + * e.g. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b>
+ */ + */
+@NullMarked
+public class DragonEggFormEvent extends BlockFormEvent { +public class DragonEggFormEvent extends BlockFormEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -37,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final DragonBattle dragonBattle; + private final DragonBattle dragonBattle;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState, @NotNull DragonBattle dragonBattle) { + public DragonEggFormEvent(final Block block, final BlockState newState, final DragonBattle dragonBattle) {
+ super(block, newState); + super(block, newState);
+ this.dragonBattle = dragonBattle; + this.dragonBattle = dragonBattle;
+ } + }
@ -49,18 +50,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the dragon battle + * @return the dragon battle
+ */ + */
+ @NotNull
+ public DragonBattle getDragonBattle() { + public DragonBattle getDragonBattle() {
+ return this.dragonBattle; + return this.dragonBattle;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }