diff --git a/patches/api/Add-BeaconEffectEvent.patch b/patches/api/Add-BeaconEffectEvent.patch index cd6ce9ac3e..7d4b19c8b8 100644 --- a/patches/api/Add-BeaconEffectEvent.patch +++ b/patches/api/Add-BeaconEffectEvent.patch @@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; +import org.bukkit.potion.PotionEffect; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a beacon effect is being applied to a player. + */ +public class BeaconEffectEvent extends BlockEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ private PotionEffect effect; -+ private Player player; -+ private boolean primary; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private final Player player; ++ private final boolean primary; ++ private PotionEffect effect; ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) { + super(block); + this.effect = effect; @@ -37,16 +42,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.primary = primary; + } + -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; -+ } -+ + /** + * Gets the potion effect being applied. + * @@ -54,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PotionEffect getEffect() { -+ return effect; ++ return this.effect; + } + + /** @@ -73,26 +68,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Player getPlayer() { -+ return player; ++ return this.player; + } + + /** + * Gets whether the effect is a primary beacon effect. + * -+ * @return true if this event represents a primary effect ++ * @return {@code true} if this event represents a primary effect + */ + public boolean isPrimary() { -+ return primary; ++ return this.primary; ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-BellRevealRaiderEvent.patch b/patches/api/Add-BellRevealRaiderEvent.patch index aaed3f322b..293b9fbc38 100644 --- a/patches/api/Add-BellRevealRaiderEvent.patch +++ b/patches/api/Add-BellRevealRaiderEvent.patch @@ -13,27 +13,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.event.block; + +import org.bukkit.block.Block; -+import org.bukkit.entity.Entity; +import org.bukkit.entity.Raider; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** -+ * Called when a {@link org.bukkit.entity.Raider} is revealed by a bell. ++ * Called when a {@link Raider} is revealed by a bell. ++ * + * @deprecated use {@link org.bukkit.event.block.BellResonateEvent} + */ +@Deprecated +public class BellRevealRaiderEvent extends BlockEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); + -+ private boolean cancelled = false; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Raider raider; ++ private boolean cancelled; + -+ public BellRevealRaiderEvent(@NotNull Block theBlock, @NotNull Entity raider) { ++ @ApiStatus.Internal ++ public BellRevealRaiderEvent(@NotNull Block theBlock, @NotNull Raider raider) { + super(theBlock); -+ this.raider = (Raider) raider; ++ this.raider = raider; + } + + /** @@ -43,12 +46,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Raider getEntity() { -+ return raider; ++ return this.raider; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** @@ -63,10 +66,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public @NotNull HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + public static @NotNull HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-BellRingEvent.patch b/patches/api/Add-BellRingEvent.patch index 62f1c01811..2871cb8d6a 100644 --- a/patches/api/Add-BellRingEvent.patch +++ b/patches/api/Add-BellRingEvent.patch @@ -17,17 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; -+import org.bukkit.event.Cancellable; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Called when a bell is rung. ++ * + * @deprecated use {@link org.bukkit.event.block.BellRingEvent} + */ +@Deprecated -+public class BellRingEvent extends org.bukkit.event.block.BellRingEvent implements Cancellable { ++public class BellRingEvent extends org.bukkit.event.block.BellRingEvent { + ++ @ApiStatus.Internal + public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) { + super(block, direction, entity); + } diff --git a/patches/api/Add-BlockBreakBlockEvent.patch b/patches/api/Add-BlockBreakBlockEvent.patch index 856ee9f7c7..981ddd8f87 100644 --- a/patches/api/Add-BlockBreakBlockEvent.patch +++ b/patches/api/Add-BlockBreakBlockEvent.patch @@ -14,9 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; -+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockExpEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @@ -30,9 +30,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private final List drops; + private final Block source; ++ private final List drops; + ++ @ApiStatus.Internal + public BlockBreakBlockEvent(@NotNull Block block, @NotNull Block source, @NotNull List drops) { + super(block, 0); + this.source = source; @@ -40,13 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Get the drops of this event ++ * Gets the drops of this event + * + * @return the drops + */ + @NotNull + public List getDrops() { -+ return drops; ++ return this.drops; + } + + /** @@ -56,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Block getSource() { -+ return source; ++ return this.source; + } + + @NotNull diff --git a/patches/api/Add-BlockFailedDispenseEvent.patch b/patches/api/Add-BlockFailedDispenseEvent.patch index 97c81a6f76..bf32471416 100644 --- a/patches/api/Add-BlockFailedDispenseEvent.patch +++ b/patches/api/Add-BlockFailedDispenseEvent.patch @@ -15,16 +15,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a block tries to dispense an item, but its inventory is empty. + */ +public class BlockFailedDispenseEvent extends BlockEvent { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + private boolean shouldPlayEffect = true; + ++ @ApiStatus.Internal + public BlockFailedDispenseEvent(@NotNull Block theBlock) { + super(theBlock); + } @@ -46,8 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * {@inheritDoc} -+ * + * @return {@link #shouldPlayEffect()} + */ + @Override @@ -57,13 +58,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public @NotNull -+ HandlerList getHandlers() { -+ return handlers; ++ public @NotNull HandlerList getHandlers() { ++ return HANDLER_LIST; + } + -+ public static @NotNull -+ HandlerList getHandlerList() { -+ return handlers; ++ public static @NotNull HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-BlockLockCheckEvent.patch b/patches/api/Add-BlockLockCheckEvent.patch index 5773e2e475..fd08737c84 100644 --- a/patches/api/Add-BlockLockCheckEvent.patch +++ b/patches/api/Add-BlockLockCheckEvent.patch @@ -33,23 +33,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.block.LockableTileState; +import net.kyori.adventure.sound.Sound; +import net.kyori.adventure.text.Component; -+import org.bukkit.Nameable; +import org.bukkit.block.Block; -+import org.bukkit.block.BlockState; -+import org.bukkit.block.Lockable; -+import org.bukkit.block.TileState; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; + +/** -+ * Called when the server tries to check the lock on a lockable tile entity. -+ * @see #setResult(Result) to change behavior ++ * Called when the server tries to check the lock on a lockable block entity. ++ *
++ * See {@link #setResult(Result)} to change behavior + */ +public class BlockLockCheckEvent extends BlockEvent { + @@ -57,11 +55,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final LockableTileState state; + private final Player player; -+ private ItemStack itemStack; -+ private Result result = Result.DEFAULT; + private Component lockedMessage; + private Sound lockedSound; ++ private ItemStack itemStack; ++ private Result result = Result.DEFAULT; + ++ @ApiStatus.Internal + public BlockLockCheckEvent(final @NotNull Block block, final @NotNull LockableTileState state, final @NotNull Player player, final @NotNull Component lockedMessage, final @NotNull Sound lockedSound) { + super(block); + this.state = state; @@ -71,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Gets the snapshot {@link LockableTileState} of the tile entity ++ * Gets the snapshot {@link LockableTileState} of the block entity + * whose lock is being checked. + * + * @return the snapshot block state. @@ -105,11 +104,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Sets the itemstack that will be used as the key item. + * -+ * @param stack the stack to use as a key (or null to fall back to the player's main hand item) ++ * @param stack the stack to use as a key + * @see #resetKeyItem() to clear a custom key item + */ + public void setKeyItem(@NotNull ItemStack stack) { -+ Preconditions.checkNotNull(stack, "stack is null"); ++ Preconditions.checkArgument(stack != null, "stack cannot be null"); + this.itemStack = stack; + } + @@ -123,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Checks if a custom key stack has been set. + * -+ * @return true if a custom key itemstack has been set ++ * @return {@code true} if a custom key itemstack has been set + */ + public boolean isUsingCustomKeyItemStack() { + return this.itemStack != null; @@ -140,11 +139,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Gets the result of this event. {@link org.bukkit.event.Event.Result#DEFAULT} is the default -+ * allowing the vanilla logic to check the lock of this block. Set to {@link org.bukkit.event.Event.Result#ALLOW} -+ * or {@link org.bukkit.event.Event.Result#DENY} to override that behavior. ++ * Gets the result of this event. {@link Result#DEFAULT} is the default ++ * allowing the vanilla logic to check the lock of this block. Set to {@link Result#ALLOW} ++ * or {@link Result#DENY} to override that behavior. + *

-+ * Setting this to {@link org.bukkit.event.Event.Result#ALLOW} bypasses the spectator check. ++ * Setting this to {@link Result#ALLOW} bypasses the spectator check. + * + * @param result the result of this event + */ @@ -153,11 +152,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Shorthand method to set the {@link #getResult()} to {@link org.bukkit.event.Event.Result#DENY}, ++ * Shorthand method to set the {@link #getResult()} to {@link Result#DENY}, + * the locked message and locked sound. + * -+ * @param lockedMessage the message to show if locked (or null for none) -+ * @param lockedSound the sound to play if locked (or 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) + */ + public void denyWithMessageAndSound(@Nullable Component lockedMessage, @Nullable Sound lockedSound) { + this.result = Result.DENY; @@ -169,7 +168,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Gets the locked message that will be sent if the + * player cannot open the block. + * -+ * @return the locked message (or null if none) ++ * @return the locked message (or {@code null} if none) + */ + public @Nullable Component getLockedMessage() { + return this.lockedMessage; @@ -179,7 +178,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sets the locked message that will be sent if the + * player cannot open the block. + * -+ * @param lockedMessage the locked message (or null for none) ++ * @param lockedMessage the locked message (or {@code null} for none) + */ + public void setLockedMessage(@Nullable Component lockedMessage) { + this.lockedMessage = lockedMessage; @@ -189,7 +188,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Gets the locked sound that will play if the + * player cannot open the block. + * -+ * @return the locked sound (or null if none) ++ * @return the locked sound (or {@code null} if none) + */ + public @Nullable Sound getLockedSound() { + return this.lockedSound; @@ -199,7 +198,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sets the locked sound that will play if the + * player cannot open the block. + * -+ * @param lockedSound the locked sound (or null for none) ++ * @param lockedSound the locked sound (or {@code null} for none) + */ + public void setLockedSound(@Nullable Sound lockedSound) { + this.lockedSound = lockedSound; diff --git a/patches/api/Add-BlockPreDispenseEvent.patch b/patches/api/Add-BlockPreDispenseEvent.patch index 66a427a76e..9991c2c31e 100644 --- a/patches/api/Add-BlockPreDispenseEvent.patch +++ b/patches/api/Add-BlockPreDispenseEvent.patch @@ -17,14 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public class BlockPreDispenseEvent extends BlockEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled = false; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final ItemStack itemStack; + private final int slot; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public BlockPreDispenseEvent(@NotNull Block block, @NotNull ItemStack itemStack, int slot) { + super(block); + this.itemStack = itemStack; @@ -38,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItemStack() { -+ return itemStack; ++ return this.itemStack; + } + + /** @@ -47,17 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return The inventory slot + */ + public int getSlot() { -+ return slot; -+ } -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; ++ return this.slot; + } + + @Override @@ -69,4 +64,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } +} diff --git a/patches/api/Add-CompostItemEvent-and-EntityCompostItemEvent.patch b/patches/api/Add-CompostItemEvent-and-EntityCompostItemEvent.patch index 472cd97582..0a745c8a19 100644 --- a/patches/api/Add-CompostItemEvent-and-EntityCompostItemEvent.patch +++ b/patches/api/Add-CompostItemEvent-and-EntityCompostItemEvent.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.inventory.InventoryMoveItemEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -30,6 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final ItemStack item; + private boolean willRaiseLevel; + ++ @ApiStatus.Internal + public CompostItemEvent(@NotNull Block composter, @NotNull ItemStack item, boolean willRaiseLevel) { + super(composter); + this.item = item; @@ -49,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Gets whether the composter will rise a level. + * -+ * @return true if successful ++ * @return {@code true} if successful + */ + public boolean willRaiseLevel() { + return this.willRaiseLevel; @@ -58,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Sets whether the composter will rise a level. + * -+ * @param willRaiseLevel true if the composter should rise a level ++ * @param willRaiseLevel {@code true} if the composter should rise a level + */ + public void setWillRaiseLevel(boolean willRaiseLevel) { + this.willRaiseLevel = willRaiseLevel; @@ -88,6 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -95,12 +98,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class EntityCompostItemEvent extends CompostItemEvent implements Cancellable { + -+ private final Entity who; ++ private final Entity entity; + private boolean cancelled; + -+ public EntityCompostItemEvent(@NotNull Entity who, @NotNull Block composter, @NotNull ItemStack item, boolean willRaiseLevel) { ++ @ApiStatus.Internal ++ public EntityCompostItemEvent(@NotNull Entity entity, @NotNull Block composter, @NotNull ItemStack item, boolean willRaiseLevel) { + super(composter, item, willRaiseLevel); -+ this.who = who; ++ this.entity = entity; + } + + /** @@ -110,7 +114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getEntity() { -+ return this.who; ++ return this.entity; + } + + @Override diff --git a/patches/api/Add-ElderGuardianAppearanceEvent.patch b/patches/api/Add-ElderGuardianAppearanceEvent.patch index cd56465804..32b03d0ae1 100644 --- a/patches/api/Add-ElderGuardianAppearanceEvent.patch +++ b/patches/api/Add-ElderGuardianAppearanceEvent.patch @@ -13,28 +13,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.event.entity; + +import org.bukkit.entity.ElderGuardian; -+import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + -+import java.util.Collections; -+import java.util.List; -+ +/** -+ * Is called when an {@link org.bukkit.entity.ElderGuardian} appears in front of a {@link org.bukkit.entity.Player}. ++ * Is called when an {@link ElderGuardian} appears in front of a {@link Player}. + */ +public class ElderGuardianAppearanceEvent extends EntityEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancelled; + private final Player affectedPlayer; ++ private boolean cancelled; + -+ public ElderGuardianAppearanceEvent(@NotNull Entity what, @NotNull Player affectedPlayer) { -+ super(what); ++ @ApiStatus.Internal ++ public ElderGuardianAppearanceEvent(@NotNull ElderGuardian guardian, @NotNull Player affectedPlayer) { ++ super(guardian); + this.affectedPlayer = affectedPlayer; + } + @@ -45,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Player getAffectedPlayer() { -+ return affectedPlayer; ++ return this.affectedPlayer; + } + + /** @@ -55,12 +53,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ElderGuardian getEntity() { -+ return (ElderGuardian) entity; ++ return (ElderGuardian) super.getEntity(); + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -71,11 +69,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch b/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch index d133a0dd9f..a67b22d742 100644 --- a/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch +++ b/patches/api/Add-EntityDyeEvent-and-CollarColorable-interface.patch @@ -44,26 +44,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.event.entity; + +import org.bukkit.DyeColor; ++import org.bukkit.entity.Cat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; ++import org.bukkit.entity.Sheep; ++import org.bukkit.entity.Wolf; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** -+ * Called when an entity is dyed. Currently, this is called for {@link org.bukkit.entity.Sheep} -+ * being dyed, and {@link org.bukkit.entity.Wolf}/{@link org.bukkit.entity.Cat} collars being dyed. ++ * Called when an entity is dyed. Currently, this is called for {@link Sheep} ++ * being dyed, and {@link Wolf}/{@link Cat} collars being dyed. + */ +public class EntityDyeEvent extends EntityEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private DyeColor dyeColor; + private final Player player; -+ private boolean cancel; ++ private DyeColor dyeColor; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EntityDyeEvent(@NotNull Entity entity, @NotNull DyeColor dyeColor, @Nullable Player player) { + super(entity); + this.dyeColor = dyeColor; @@ -91,20 +97,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Returns the player dyeing the entity, if available. + * -+ * @return player or null ++ * @return player or {@code null} + */ + public @Nullable Player getPlayer() { -+ return player; ++ return this.player; + } + + @Override + public boolean isCancelled() { -+ return this.cancel; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @Override diff --git a/patches/api/Add-EntityFertilizeEggEvent.patch b/patches/api/Add-EntityFertilizeEggEvent.patch index ba7d99470a..18c8a8b34e 100644 --- a/patches/api/Add-EntityFertilizeEggEvent.patch +++ b/patches/api/Add-EntityFertilizeEggEvent.patch @@ -12,26 +12,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.entity; + -+import com.google.common.base.Preconditions; ++import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityBreedEvent; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Called when two entities mate and the mating process results in a fertilization. -+ * Fertilization differs from normal breeding, as represented by the {@link org.bukkit.event.entity.EntityBreedEvent}, as ++ * Fertilization differs from normal breeding, as represented by the {@link EntityBreedEvent}, as + * it does not result in the immediate creation of the child entity in the world. + *

+ * An example of this would be: + *

    -+ *
  • A frog being marked as "is_pregnant" and laying {@link org.bukkit.Material#FROGSPAWN} later.
  • -+ *
  • Sniffers producing the {@link org.bukkit.Material#SNIFFER_EGG} item, which needs to be placed before it can begin to hatch.
  • -+ *
  • A turtle being marked with "HasEgg" and laying a {@link org.bukkit.Material#TURTLE_EGG} later.
  • ++ *
  • A frog being marked as "is_pregnant" and laying {@link Material#FROGSPAWN} later.
  • ++ *
  • Sniffers producing the {@link Material#SNIFFER_EGG} item, which needs to be placed before it can begin to hatch.
  • ++ *
  • A turtle being marked with "HasEgg" and laying a {@link Material#TURTLE_EGG} later.
  • + *
+ * + * 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. @@ -46,14 +48,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final ItemStack bredWith; + private int experience; + -+ private boolean cancel; ++ private boolean cancelled; + ++ @ApiStatus.Internal + public EntityFertilizeEggEvent(@NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable Player breeder, @Nullable ItemStack bredWith, int experience) { + super(mother); -+ Preconditions.checkArgument(mother != null, "Cannot have null mother"); -+ Preconditions.checkArgument(father != null, "Cannot have null father"); -+ -+ // Breeder can be null in the case of spontaneous conception + this.mother = mother; + this.father = father; + this.breeder = breeder; @@ -64,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public LivingEntity getEntity() { -+ return (LivingEntity) entity; ++ return (LivingEntity) super.getEntity(); + } + + /** @@ -75,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public LivingEntity getMother() { -+ return mother; ++ return this.mother; + } + + /** @@ -86,28 +85,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public LivingEntity getFather() { -+ return father; ++ return this.father; + } + + /** -+ * Gets the Entity responsible for fertilization. Breeder is null for spontaneous ++ * Gets the Entity responsible for fertilization. Breeder is {@code null} for spontaneous + * conception. + * -+ * @return The Entity who initiated breeding. ++ * @return The Entity who initiated fertilization. + */ + @Nullable + public Player getBreeder() { -+ return breeder; ++ return this.breeder; + } + + /** + * The ItemStack that was used to initiate fertilization, if present. + * -+ * @return ItemStack used to initiate breeding. ++ * @return ItemStack used to initiate fertilization. + */ + @Nullable + public ItemStack getBredWith() { -+ return bredWith; ++ return this.bredWith; + } + + /** @@ -116,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return experience amount + */ + public int getExperience() { -+ return experience; ++ return this.experience; + } + + /** @@ -131,12 +130,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancel; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @NotNull diff --git a/patches/api/Add-EntityInsideBlockEvent.patch b/patches/api/Add-EntityInsideBlockEvent.patch index 51dc10d001..5f0108d979 100644 --- a/patches/api/Add-EntityInsideBlockEvent.patch +++ b/patches/api/Add-EntityInsideBlockEvent.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -58,6 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final Block block; + private boolean cancelled; + ++ @ApiStatus.Internal + public EntityInsideBlockEvent(@NotNull Entity entity, @NotNull Block block) { + super(entity); + this.block = block; @@ -70,12 +72,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Block getBlock() { -+ return block; ++ return this.block; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index 3639107edd..6862c84c8c 100644 --- a/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch +++ b/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -18,16 +18,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.util.Vector; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * 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. -+ * + */ +public class EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent { ++ + private final float knockbackStrength; + ++ @ApiStatus.Internal + public EntityKnockbackByEntityEvent(@NotNull LivingEntity entity, @NotNull Entity hitBy, float knockbackStrength, @NotNull Vector acceleration) { + super(entity, hitBy, acceleration); + this.knockbackStrength = knockbackStrength; @@ -46,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the original knockback strength. + */ + public float getKnockbackStrength() { -+ return knockbackStrength; ++ return this.knockbackStrength; + } + + /** @@ -71,6 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.util.Vector; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -82,38 +85,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class EntityPushedByEntityAttackEvent extends EntityEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final @NotNull Entity pushedBy; + private final @NotNull Vector acceleration; -+ private boolean cancelled = false; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EntityPushedByEntityAttackEvent(@NotNull Entity entity, @NotNull Entity pushedBy, @NotNull Vector acceleration) { + super(entity); + this.pushedBy = pushedBy; + this.acceleration = acceleration; + } + -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancel) { -+ cancelled = cancel; -+ } -+ + /** + * Gets the entity which pushed the affected entity. + * @@ -121,7 +106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getPushedBy() { -+ return pushedBy; ++ return this.pushedBy; + } + + /** @@ -131,6 +116,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Vector getAcceleration() { -+ return acceleration; ++ return this.acceleration; ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-EntityLoadCrossbowEvent.patch b/patches/api/Add-EntityLoadCrossbowEvent.patch index 1a6d90f321..5c191dd0c2 100644 --- a/patches/api/Add-EntityLoadCrossbowEvent.patch +++ b/patches/api/Add-EntityLoadCrossbowEvent.patch @@ -25,12 +25,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Called when a LivingEntity loads a crossbow with a projectile. + */ +public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final ItemStack crossbow; + private final EquipmentSlot hand; -+ private boolean cancelled; ++ + private boolean consumeItem = true; ++ private boolean cancelled; + + @ApiStatus.Internal + public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @NotNull ItemStack crossbow, @NotNull EquipmentSlot hand) { @@ -42,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public LivingEntity getEntity() { -+ return (LivingEntity) entity; ++ return (LivingEntity) super.getEntity(); + } + + /** @@ -52,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getCrossbow() { -+ return crossbow; ++ return this.crossbow; + } + + /** @@ -62,19 +64,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public EquipmentSlot getHand() { -+ return hand; ++ return this.hand; + } + + /** -+ * + * @return should the itemstack be consumed + */ + public boolean shouldConsumeItem() { -+ return consumeItem; ++ return this.consumeItem; + } + + /** -+ * + * @param consume should the item be consumed + */ + public void setConsumeItem(boolean consume) { @@ -83,14 +83,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** -+ * Set whether or not to cancel the crossbow being loaded. If canceled, the ++ * Set whether to cancel the crossbow being loaded. If canceled, the + * projectile that would be loaded into the crossbow will not be consumed. -+ * -+ * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { diff --git a/patches/api/Add-EntityPortalReadyEvent.patch b/patches/api/Add-EntityPortalReadyEvent.patch index a61a8911c5..e8ca1299eb 100644 --- a/patches/api/Add-EntityPortalReadyEvent.patch +++ b/patches/api/Add-EntityPortalReadyEvent.patch @@ -18,6 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.bukkit.event.entity.EntityPortalEvent; ++import org.bukkit.event.player.PlayerPortalEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -33,10 +36,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private World targetWorld; + private final PortalType portalType; ++ private World targetWorld; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public EntityPortalReadyEvent(final @NotNull Entity entity, final @Nullable World targetWorld, final @NotNull PortalType portalType) { + super(entity); + this.targetWorld = targetWorld; @@ -45,25 +50,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the world this portal will teleport to. -+ * Can be null if "allow-nether" is false in server.properties ++ * Can be {@code null} if "allow-nether" is false in server.properties + * or if there is another situation where there is no world to teleport to. + *

-+ * This world may be modified by later events such as {@link org.bukkit.event.player.PlayerPortalEvent} -+ * or {@link org.bukkit.event.entity.EntityPortalEvent}. ++ * This world may be modified by later events such as {@link PlayerPortalEvent} ++ * or {@link EntityPortalEvent}. + * + * @return the world the portal will teleport the entity to. + */ + public @Nullable World getTargetWorld() { -+ return targetWorld; ++ return this.targetWorld; + } + + /** -+ * Sets the world this portal will teleport to. A null value ++ * Sets the world this portal will teleport to. A {@code null} value + * will essentially cancel the teleport and prevent further events -+ * such as {@link org.bukkit.event.player.PlayerPortalEvent} from firing. ++ * such as {@link PlayerPortalEvent} from firing. + *

-+ * This world may be modified by later events such as {@link org.bukkit.event.player.PlayerPortalEvent} -+ * or {@link org.bukkit.event.entity.EntityPortalEvent}. ++ * This world may be modified by later events such as {@link PlayerPortalEvent} ++ * or {@link EntityPortalEvent}. + * + * @param targetWorld the world + */ @@ -77,12 +82,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the portal type + */ + public @NotNull PortalType getPortalType() { -+ return portalType; ++ return this.portalType; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Add-EntityTeleportEndGatewayEvent.patch b/patches/api/Add-EntityTeleportEndGatewayEvent.patch index cde44a82b6..497c6b8b0e 100644 --- a/patches/api/Add-EntityTeleportEndGatewayEvent.patch +++ b/patches/api/Add-EntityTeleportEndGatewayEvent.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.EndGateway; +import org.bukkit.entity.Entity; +import org.bukkit.event.entity.EntityTeleportEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -25,8 +26,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull private final EndGateway gateway; + -+ public EntityTeleportEndGatewayEvent(@NotNull Entity what, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { -+ super(what, from, to); ++ @ApiStatus.Internal ++ public EntityTeleportEndGatewayEvent(@NotNull Entity entity, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { ++ super(entity, from, to); + this.gateway = gateway; + } + @@ -37,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public EndGateway getGateway() { -+ return gateway; ++ return this.gateway; + } + +} diff --git a/patches/api/Add-EntityZapEvent.patch b/patches/api/Add-EntityZapEvent.patch index f6a5afa2e5..9f421e0861 100644 --- a/patches/api/Add-EntityZapEvent.patch +++ b/patches/api/Add-EntityZapEvent.patch @@ -12,7 +12,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.entity; + -+import com.google.common.base.Preconditions; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LightningStrike; +import org.bukkit.event.Cancellable; @@ -20,87 +19,85 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.entity.EntityTransformEvent; + +import java.util.Collections; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** -+ * Fired when lightning strikes an entity ++ * Fired when lightning strikes an entity + */ +public class EntityZapEvent extends EntityTransformEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ @NotNull private final LightningStrike bolt; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final LightningStrike bolt; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) { + super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING); -+ Preconditions.checkNotNull(bolt); -+ Preconditions.checkNotNull(replacementEntity); + this.bolt = bolt; + } + -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ public void setCancelled(boolean cancel) { -+ this.cancelled = cancel; -+ } -+ + /** + * Gets the lightning bolt that is striking the entity. ++ * + * @return The lightning bolt responsible for this event + */ + @NotNull + public LightningStrike getBolt() { -+ return bolt; ++ return this.bolt; + } + + /** + * Gets the entity that will replace the struck entity. ++ * + * @return The entity that will replace the struck entity + */ + @NotNull + public Entity getReplacementEntity() { -+ return getTransformedEntity(); ++ return super.getTransformedEntity(); ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/src/main/java/org/bukkit/event/entity/PigZapEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java -@@ -0,0 +0,0 @@ package org.bukkit.event.entity; - - import java.util.Collections; - import org.bukkit.entity.Entity; -+import com.destroystokyo.paper.event.entity.EntityZapEvent; - import org.bukkit.entity.LightningStrike; - import org.bukkit.entity.Pig; - import org.bukkit.entity.PigZombie; @@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; /** * Stores data for pigs being zapped */ -public class PigZapEvent extends EntityTransformEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); -+public class PigZapEvent extends EntityZapEvent implements Cancellable { -+ //private static final HandlerList handlers = new HandlerList(); ++public class PigZapEvent extends com.destroystokyo.paper.event.entity.EntityZapEvent implements Cancellable { // Paper ++ // private static final HandlerList handlers = new HandlerList(); // Paper - moved in the super class private boolean canceled; private final PigZombie pigzombie; private final LightningStrike bolt; public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) { - super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING); -+ super(pig, bolt, pigzombie); ++ super(pig, bolt, pigzombie); // Paper this.bolt = bolt; this.pigzombie = pigzombie; } diff --git a/patches/api/Add-GS4-Query-event.patch b/patches/api/Add-GS4-Query-event.patch index 2ae210b7f9..52156b15cb 100644 --- a/patches/api/Add-GS4-Query-event.patch +++ b/patches/api/Add-GS4-Query-event.patch @@ -14,8 +14,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import com.google.common.base.Preconditions; +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; @@ -25,79 +27,76 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.List; + +/** -+ * 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. ++ *
+ * Adapted from Velocity's ProxyQueryEvent + * + * @author Mark Vainomaa + */ +public final class GS4QueryEvent extends Event { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final QueryType queryType; + private final InetAddress querierAddress; + private QueryResponse response; + ++ @ApiStatus.Internal + public GS4QueryEvent(@NotNull QueryType queryType, @NotNull InetAddress querierAddress, @NotNull QueryResponse response) { + super(true); // should always be called async -+ this.queryType = Preconditions.checkNotNull(queryType, "queryType"); -+ this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress"); -+ this.response = Preconditions.checkNotNull(response, "response"); ++ this.queryType = queryType; ++ this.querierAddress = querierAddress; ++ this.response = response; + } + + /** + * Get query type ++ * + * @return query type + */ + @NotNull + public QueryType getQueryType() { -+ return queryType; ++ return this.queryType; + } + + /** + * Get querier address ++ * + * @return querier address + */ + @NotNull + public InetAddress getQuerierAddress() { -+ return querierAddress; ++ return this.querierAddress; + } + + /** + * Get query response ++ * + * @return query response + */ + @NotNull + public QueryResponse getResponse() { -+ return response; ++ return this.response; + } + + /** + * Set query response ++ * + * @param response query response + */ + public void setResponse(@NotNull QueryResponse response) { + this.response = Preconditions.checkNotNull(response, "response"); + } + -+ @Override -+ public String toString() { -+ return "GS4QueryEvent{" + -+ "queryType=" + queryType + -+ ", querierAddress=" + querierAddress + -+ ", response=" + response + -+ '}'; -+ } -+ + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } + + /** @@ -114,10 +113,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Full query asks pretty much everything present on this event (only hardcoded values cannot be modified here). + */ + FULL -+ ; + } + + public final static class QueryResponse { ++ + private final String motd; + private final String gameVersion; + private final String map; @@ -143,95 +142,105 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Get motd which will be used to reply to the query. By default it is {@link org.bukkit.Server#getMotd()}. ++ * Get motd which will be used to reply to the query. By default it is {@link Server#getMotd()}. ++ * + * @return motd + */ + @NotNull + public String getMotd() { -+ return motd; ++ return this.motd; + } + + /** + * Get game version which will be used to reply to the query. By default supported Minecraft versions range is sent. ++ * + * @return game version + */ + @NotNull + public String getGameVersion() { -+ return gameVersion; ++ return this.gameVersion; + } + + /** + * Get map name which will be used to reply to the query. By default {@code world} is sent. ++ * + * @return map name + */ + @NotNull + public String getMap() { -+ return map; ++ return this.map; + } + + /** + * Get current online player count which will be used to reply to the query. ++ * + * @return online player count + */ + public int getCurrentPlayers() { -+ return currentPlayers; ++ return this.currentPlayers; + } + + /** + * Get max player count which will be used to reply to the query. ++ * + * @return max player count + */ + public int getMaxPlayers() { -+ return maxPlayers; ++ return this.maxPlayers; + } + + /** -+ * Get server (public facing) hostname ++ * Get server (public facing) hostname. ++ * + * @return server hostname + */ + @NotNull + public String getHostname() { -+ return hostname; ++ return this.hostname; + } + + /** -+ * Get server (public facing) port ++ * Get server (public facing) port. ++ * + * @return server port + */ + public int getPort() { -+ return port; ++ return this.port; + } + + /** + * Get collection of players which will be used to reply to the query. ++ * + * @return collection of players + */ + @NotNull + public Collection getPlayers() { -+ return players; ++ return this.players; + } + + /** + * Get server software (name and version) which will be used to reply to the query. ++ * + * @return server software + */ + @NotNull + public String getServerVersion() { -+ return serverVersion; ++ return this.serverVersion; + } + + /** + * Get list of plugins which will be used to reply to the query. ++ * + * @return collection of plugins + */ + @NotNull + public Collection getPlugins() { -+ return plugins; ++ return this.plugins; + } + -+ + /** -+ * Creates a new {@link Builder} instance from data represented by this response ++ * Creates a new {@link Builder} instance from data represented by this response. ++ * + * @return {@link QueryResponse} builder + */ + @NotNull @@ -250,7 +259,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Creates a new {@link Builder} instance ++ * Creates a new {@link Builder} instance. ++ * + * @return {@link QueryResponse} builder + */ + @NotNull @@ -272,8 +282,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private int maxPlayers; + private int port; + -+ private List players = new ArrayList<>(); -+ private List plugins = new ArrayList<>(); ++ private final List players = new ArrayList<>(); ++ private final List plugins = new ArrayList<>(); + + private Builder() {} + @@ -365,7 +375,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Builds new {@link QueryResponse} with supplied data ++ * Builds new {@link QueryResponse} with supplied data. ++ * + * @return response + */ + @NotNull @@ -389,6 +400,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Plugin information + */ + public static class PluginInformation { ++ + private String name; + private String version; + @@ -399,7 +411,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public String getName() { -+ return name; ++ return this.name; + } + + public void setName(@NotNull String name) { @@ -412,7 +424,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public String getVersion() { -+ return version; ++ return this.version; + } + + @NotNull diff --git a/patches/api/Add-More-Creeper-API.patch b/patches/api/Add-More-Creeper-API.patch index 01f8bf718e..7039036a63 100644 --- a/patches/api/Add-More-Creeper-API.patch +++ b/patches/api/Add-More-Creeper-API.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -24,10 +25,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * {@link Creeper#setIgnited(boolean)}. + */ +public class CreeperIgniteEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean canceled; -+ private boolean ignited; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private boolean ignited; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public CreeperIgniteEvent(@NotNull Creeper creeper, boolean ignited) { + super(creeper); + this.ignited = ignited; @@ -36,11 +40,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public Creeper getEntity() { -+ return (Creeper) entity; ++ return (Creeper) super.getEntity(); + } + + public boolean isIgnited() { -+ return ignited; ++ return this.ignited; + } + + public void setIgnited(boolean ignited) { @@ -48,22 +52,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public boolean isCancelled() { -+ return canceled; ++ return this.cancelled; + } + + public void setCancelled(boolean cancel) { -+ canceled = cancel; ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/entity/Creeper.java b/src/main/java/org/bukkit/entity/Creeper.java diff --git a/patches/api/Add-PhantomPreSpawnEvent.patch b/patches/api/Add-PhantomPreSpawnEvent.patch index 802753fce8..acf4b22814 100644 --- a/patches/api/Add-PhantomPreSpawnEvent.patch +++ b/patches/api/Add-PhantomPreSpawnEvent.patch @@ -18,13 +18,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ + +/** + * Called when a phantom is spawned for an exhausted player + */ +public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent { ++ + @NotNull private final Entity entity; + + @ApiStatus.Internal @@ -36,11 +35,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Get the entity this phantom is spawning for + * -+ * @return Entity ++ * @return the Entity + */ + @NotNull + public Entity getSpawningEntity() { -+ return entity; ++ return this.entity; + } +} diff --git a/src/main/java/org/bukkit/entity/Phantom.java b/src/main/java/org/bukkit/entity/Phantom.java diff --git a/patches/api/Add-Player-Client-Options-API.patch b/patches/api/Add-Player-Client-Options-API.patch index aba1be8c1e..a83bf921be 100644 --- a/patches/api/Add-Player-Client-Options-API.patch +++ b/patches/api/Add-Player-Client-Options-API.patch @@ -103,6 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.MainHand; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; @@ -112,7 +113,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerClientOptionsChangeEvent extends PlayerEvent { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final String locale; + private final int viewDistance; @@ -136,6 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.textFilteringEnabled = false; + } + ++ @ApiStatus.Internal + public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull Map, ?> options) { + super(player); + @@ -151,81 +153,81 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public String getLocale() { -+ return locale; ++ return this.locale; + } + + public boolean hasLocaleChanged() { -+ return !locale.equals(player.getClientOption(ClientOption.LOCALE)); ++ return !this.locale.equals(this.player.getClientOption(ClientOption.LOCALE)); + } + + public int getViewDistance() { -+ return viewDistance; ++ return this.viewDistance; + } + + public boolean hasViewDistanceChanged() { -+ return viewDistance != player.getClientOption(ClientOption.VIEW_DISTANCE); ++ return this.viewDistance != this.player.getClientOption(ClientOption.VIEW_DISTANCE); + } + + @NotNull + public ChatVisibility getChatVisibility() { -+ return chatVisibility; ++ return this.chatVisibility; + } + + public boolean hasChatVisibilityChanged() { -+ return chatVisibility != player.getClientOption(ClientOption.CHAT_VISIBILITY); ++ return this.chatVisibility != this.player.getClientOption(ClientOption.CHAT_VISIBILITY); + } + + public boolean hasChatColorsEnabled() { -+ return chatColors; ++ return this.chatColors; + } + + public boolean hasChatColorsEnabledChanged() { -+ return chatColors != player.getClientOption(ClientOption.CHAT_COLORS_ENABLED); ++ return this.chatColors != this.player.getClientOption(ClientOption.CHAT_COLORS_ENABLED); + } + + @NotNull + public SkinParts getSkinParts() { -+ return skinparts; ++ return this.skinparts; + } + + public boolean hasSkinPartsChanged() { -+ return skinparts.getRaw() != player.getClientOption(ClientOption.SKIN_PARTS).getRaw(); ++ return this.skinparts.getRaw() != this.player.getClientOption(ClientOption.SKIN_PARTS).getRaw(); + } + + @NotNull + public MainHand getMainHand() { -+ return mainHand; ++ return this.mainHand; + } + + public boolean hasMainHandChanged() { -+ return mainHand != player.getClientOption(ClientOption.MAIN_HAND); ++ return this.mainHand != this.player.getClientOption(ClientOption.MAIN_HAND); + } + + public boolean allowsServerListings() { -+ return allowsServerListings; ++ return this.allowsServerListings; + } + + public boolean hasAllowServerListingsChanged() { -+ return allowsServerListings != player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS); ++ return this.allowsServerListings != this.player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS); + } + + public boolean hasTextFilteringEnabled() { -+ return textFilteringEnabled; ++ return this.textFilteringEnabled; + } + + public boolean hasTextFilteringChanged() { -+ return textFilteringEnabled != player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED); ++ return this.textFilteringEnabled != this.player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED); + } + + @Override + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java diff --git a/patches/api/Add-PlayerAdvancementCriterionGrantEvent.patch b/patches/api/Add-PlayerAdvancementCriterionGrantEvent.patch index 3e71cd1a3e..f189a7c092 100644 --- a/patches/api/Add-PlayerAdvancementCriterionGrantEvent.patch +++ b/patches/api/Add-PlayerAdvancementCriterionGrantEvent.patch @@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -26,17 +27,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * If cancelled the criteria will be revoked. + */ +public class PlayerAdvancementCriterionGrantEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final Advancement advancement; + @NotNull private final String criterion; + @NotNull private final AdvancementProgress advancementProgress; -+ private boolean cancel = false; + -+ public PlayerAdvancementCriterionGrantEvent(@NotNull Player who, @NotNull Advancement advancement, @NotNull String criterion) { -+ super(who); ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public PlayerAdvancementCriterionGrantEvent(@NotNull Player player, @NotNull Advancement advancement, @NotNull String criterion) { ++ super(player); + this.advancement = advancement; + this.criterion = criterion; -+ this.advancementProgress = who.getAdvancementProgress(advancement); ++ this.advancementProgress = player.getAdvancementProgress(advancement); + } + + /** @@ -46,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Advancement getAdvancement() { -+ return advancement; ++ return this.advancement; + } + + /** @@ -56,36 +61,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public String getCriterion() { -+ return criterion; -+ } -+ -+ public boolean isCancelled() { -+ return cancel; ++ return this.criterion; + } + + /** + * Gets the current AdvancementProgress. -+ * See {@link PlayerAdvancementCriterionGrantEvent} + * + * @return advancement progress + */ + @NotNull + public AdvancementProgress getAdvancementProgress() { -+ return advancementProgress; ++ return this.advancementProgress; + } + ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerArmorChangeEvent.patch b/patches/api/Add-PlayerArmorChangeEvent.patch index d56d166eee..c4814965b9 100644 --- a/patches/api/Add-PlayerArmorChangeEvent.patch +++ b/patches/api/Add-PlayerArmorChangeEvent.patch @@ -18,9 +18,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; + -+import java.util.Arrays; -+import java.util.Collections; -+import java.util.HashSet; +import java.util.Set; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; @@ -34,7 +31,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Not currently called for environmental factors though it MAY BE IN THE FUTURE + */ +public class PlayerArmorChangeEvent extends PlayerEvent { -+ private static final HandlerList HANDLERS = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + @NotNull private final SlotType slotType; + @NotNull private final ItemStack oldItem; @@ -78,20 +76,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.newItem; + } + -+ @Override -+ public String toString() { -+ return "ArmorChangeEvent{" + "player=" + player + ", slotType=" + slotType + ", oldItem=" + oldItem + ", newItem=" + newItem + '}'; -+ } -+ + @NotNull + @Override + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + public enum SlotType { @@ -100,11 +93,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + LEGS(NETHERITE_LEGGINGS, DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, CHAINMAIL_LEGGINGS, LEATHER_LEGGINGS), + FEET(NETHERITE_BOOTS, DIAMOND_BOOTS, GOLDEN_BOOTS, IRON_BOOTS, CHAINMAIL_BOOTS, LEATHER_BOOTS); + -+ private final Set mutableTypes = new HashSet<>(); -+ private Set immutableTypes; ++ private final Set types; + + SlotType(Material... types) { -+ this.mutableTypes.addAll(Arrays.asList(types)); ++ this.types = Set.of(types); + } + + /** @@ -115,18 +107,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Set getTypes() { -+ if (immutableTypes == null) { -+ immutableTypes = Collections.unmodifiableSet(mutableTypes); -+ } -+ -+ return immutableTypes; ++ return this.types; + } + + /** + * Gets the type of slot via the specified material + * + * @param material material to get slot by -+ * @return slot type the material will go in, or null if it won't ++ * @return slot type the material will go in, or {@code null} if it won't + */ + @Nullable + public static SlotType getByMaterial(@NotNull Material material) { diff --git a/patches/api/Add-PlayerAttackEntityCooldownResetEvent.patch b/patches/api/Add-PlayerAttackEntityCooldownResetEvent.patch index 42c48ac51b..f111a83542 100644 --- a/patches/api/Add-PlayerAttackEntityCooldownResetEvent.patch +++ b/patches/api/Add-PlayerAttackEntityCooldownResetEvent.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -24,56 +25,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements Cancellable { + -+ private final float cooledAttackStrength; -+ private boolean cancel = false; -+ private static final HandlerList handlers = new HandlerList(); -+ @NotNull private final Entity attackedEntity; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ public PlayerAttackEntityCooldownResetEvent(@NotNull Player who, @NotNull Entity attackedEntity, float cooledAttackStrength) { -+ super(who); ++ @NotNull private final Entity attackedEntity; ++ private final float cooledAttackStrength; ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public PlayerAttackEntityCooldownResetEvent(@NotNull Player player, @NotNull Entity attackedEntity, float cooledAttackStrength) { ++ super(player); + this.attackedEntity = attackedEntity; + this.cooledAttackStrength = cooledAttackStrength; + } + -+ @Override -+ public @NotNull HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ public static @NotNull HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ /** -+ * Gets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins -+ *

-+ * If an attack cooldown event is cancelled, the players attack strength will remain at the same value instead of being reset. -+ * -+ * @return true if this event is cancelled -+ */ -+ @Override -+ public boolean isCancelled() { -+ return cancel; -+ } -+ -+ /** -+ * Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity -+ * -+ * @param cancel true if you wish to cancel this event -+ */ -+ @Override -+ public void setCancelled(boolean cancel) { -+ this.cancel = cancel; -+ } -+ + /** + * Get the value of the players cooldown attack strength when they initiated the attack + * + * @return returns the original player cooldown value + */ + public float getCooledAttackStrength() { -+ return cooledAttackStrength; ++ return this.cooledAttackStrength; + } + + /** @@ -83,6 +55,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getAttackedEntity() { -+ return attackedEntity; ++ return this.attackedEntity; ++ } ++ ++ /** ++ * {@inheritDoc} ++ *

++ * If an attack cooldown event is cancelled, the players attack strength will remain at the same value instead of being reset. ++ */ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ /** ++ * {@inheritDoc} ++ *

++ * Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity ++ */ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @Override ++ public @NotNull HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ public static @NotNull HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerConnectionCloseEvent.patch b/patches/api/Add-PlayerConnectionCloseEvent.patch index dc295f873d..d195e2a65c 100644 --- a/patches/api/Add-PlayerConnectionCloseEvent.patch +++ b/patches/api/Add-PlayerConnectionCloseEvent.patch @@ -46,6 +46,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import java.net.InetAddress; +import java.util.UUID; ++import org.bukkit.event.player.AsyncPlayerPreLoginEvent; ++import org.bukkit.event.player.PlayerQuitEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -53,45 +56,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * This event is invoked when a player has disconnected. It is guaranteed that, + * if the server is in online-mode, that the provided uuid and username have been + * validated. -+ *

-+ * + *

+ * The event is invoked for players who have not yet logged into the world, whereas -+ * {@link org.bukkit.event.player.PlayerQuitEvent} is only invoked on players who have logged into the world. -+ *

-+ * ++ * {@link PlayerQuitEvent} is only invoked on players who have logged into the world. + *

+ * The event is invoked for players who have already logged into the world, + * although whether or not the player exists in the world at the time of + * firing is undefined. (That is, whether the plugin can retrieve a Player object + * using the event parameters is undefined). However, it is guaranteed that this -+ * event is invoked AFTER {@link org.bukkit.event.player.PlayerQuitEvent}, if the player has already logged into the world. -+ *

-+ * ++ * event is invoked AFTER {@link PlayerQuitEvent}, if the player has already logged into the world. + *

-+ * This event is guaranteed to never fire unless {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} has ++ * This event is guaranteed to never fire unless {@link AsyncPlayerPreLoginEvent} has + * been fired beforehand, and this event may not be called in parallel with -+ * {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} for the same connection. -+ *

-+ * ++ * {@link AsyncPlayerPreLoginEvent} for the same connection. + *

-+ * Cancelling the {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} guarantees the corresponding ++ * Cancelling the {@link AsyncPlayerPreLoginEvent} guarantees the corresponding + * {@code PlayerConnectionCloseEvent} is never called. -+ *

-+ * + *

+ * The event may be invoked asynchronously or synchronously. Plugins should check + * {@link Event#isAsynchronous()} and handle accordingly. -+ *

+ */ +public class PlayerConnectionCloseEvent extends Event { + -+ private static final HandlerList HANDLERS = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + @NotNull private final UUID playerUniqueId; + @NotNull private final String playerName; + @NotNull private final InetAddress ipAddress; + ++ @ApiStatus.Internal + public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, final boolean async) { + super(async); + this.playerUniqueId = playerUniqueId; @@ -126,11 +119,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerFailMoveEvent.patch b/patches/api/Add-PlayerFailMoveEvent.patch index 316e780469..bcbe0696db 100644 --- a/patches/api/Add-PlayerFailMoveEvent.patch +++ b/patches/api/Add-PlayerFailMoveEvent.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -26,14 +27,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final FailReason failReason; -+ private boolean allowed; -+ private boolean logWarning; + private final Location from; + private final Location to; ++ private boolean allowed; ++ private boolean logWarning; + -+ public PlayerFailMoveEvent(@NotNull Player who, @NotNull FailReason failReason, boolean allowed, ++ @ApiStatus.Internal ++ public PlayerFailMoveEvent(@NotNull Player player, @NotNull FailReason failReason, boolean allowed, + boolean logWarning, @NotNull Location from, @NotNull Location to) { -+ super(who); ++ super(player); + this.failReason = failReason; + this.allowed = allowed; + this.logWarning = logWarning; @@ -43,41 +45,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the reason this movement was prevented by the server ++ * + * @return The reason the movement was prevented + */ + @NotNull + public FailReason getFailReason() { -+ return failReason; ++ return this.failReason; + } + + /** + * Gets the location this player moved from ++ * + * @return Location the player moved from + */ + @NotNull + public Location getFrom() { -+ return from.clone(); ++ return this.from.clone(); + } + + /** + * Gets the location this player tried to move to ++ * + * @return Location the player tried to move to + */ + @NotNull + public Location getTo() { -+ return to.clone(); ++ return this.to.clone(); + } + + /** + * Gets if the check should be bypassed, allowing the movement ++ * + * @return whether to bypass the check + */ + public boolean isAllowed() { -+ return allowed; ++ return this.allowed; + } + + /** + * Set if the check should be bypassed and the movement should be allowed ++ * + * @param allowed whether to bypass the check + */ + public void setAllowed(boolean allowed) { @@ -85,15 +92,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Gets if warnings will be printed to console. eg. "Player123 moved too quickly!" ++ * Gets if warnings will be printed to console. e.g. "Player123 moved too quickly!" ++ * + * @return whether to log warnings + */ + public boolean getLogWarning() { -+ return logWarning; ++ return this.logWarning; + } + + /** -+ * Set if a warning is printed to console. eg. "Player123 moved too quickly!" ++ * Set if a warning is printed to console. e.g. "Player123 moved too quickly!" ++ * + * @param logWarning whether to log warnings + */ + public void setLogWarning(boolean logWarning) { diff --git a/patches/api/Add-PlayerFlowerPotManipulateEvent.patch b/patches/api/Add-PlayerFlowerPotManipulateEvent.patch index 8e299dbfe0..88ab8d7377 100644 --- a/patches/api/Add-PlayerFlowerPotManipulateEvent.patch +++ b/patches/api/Add-PlayerFlowerPotManipulateEvent.patch @@ -18,13 +18,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a player places an item in or takes an item out of a flowerpot. + */ +public class PlayerFlowerPotManipulateEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + @NotNull + private final Block flowerpot; @@ -32,8 +34,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final ItemStack item; + private final boolean placing; + -+ private boolean cancel = false; ++ private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerFlowerPotManipulateEvent(@NotNull final Player player, @NotNull final Block flowerpot, @NotNull final ItemStack item, final boolean placing) { + super(player); + this.flowerpot = flowerpot; @@ -41,16 +44,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.placing = placing; + } + -+ @Override -+ public boolean isCancelled() { -+ return cancel; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancel) { -+ this.cancel = cancel; -+ } -+ + /** + * Gets the flowerpot that is involved in this event. + * @@ -58,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Block getFlowerpot() { -+ return flowerpot; ++ return this.flowerpot; + } + + /** @@ -69,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItem() { -+ return item; ++ return this.item; + } + + /** @@ -78,17 +71,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return if the item is being placed into the flowerpot + */ + public boolean isPlacing() { -+ return placing; ++ return this.placing; ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerInitialSpawnEvent.patch b/patches/api/Add-PlayerInitialSpawnEvent.patch index 3e31548fd0..c5077e2cd2 100644 --- a/patches/api/Add-PlayerInitialSpawnEvent.patch +++ b/patches/api/Add-PlayerInitialSpawnEvent.patch @@ -25,7 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent { + -+ public PlayerInitialSpawnEvent(@NotNull Player who, @NotNull Location spawnLocation) { -+ super(who, spawnLocation); ++ @ApiStatus.Internal ++ public PlayerInitialSpawnEvent(@NotNull Player player, @NotNull Location spawnLocation) { ++ super(player, spawnLocation); + } +} diff --git a/patches/api/Add-PlayerInventorySlotChangeEvent.patch b/patches/api/Add-PlayerInventorySlotChangeEvent.patch index a0ccd039a2..5647dab88c 100644 --- a/patches/api/Add-PlayerInventorySlotChangeEvent.patch +++ b/patches/api/Add-PlayerInventorySlotChangeEvent.patch @@ -23,7 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Called when a slot contents change in a player's inventory. + */ +public class PlayerInventorySlotChangeEvent extends PlayerEvent { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final int rawSlot; + private final int slot; + private final ItemStack oldItemStack; @@ -44,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return The raw slot number. + */ + public int getRawSlot() { -+ return rawSlot; ++ return this.rawSlot; + } + + /** @@ -57,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return The slot number. + */ + public int getSlot() { -+ return slot; ++ return this.slot; + } + + /** @@ -67,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getOldItemStack() { -+ return oldItemStack; ++ return this.oldItemStack; + } + + /** @@ -77,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getNewItemStack() { -+ return newItemStack; ++ return this.newItemStack; + } + + /** @@ -86,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return Whether the slot change advancements will be triggered. + */ + public boolean shouldTriggerAdvancements() { -+ return triggerAdvancements; ++ return this.triggerAdvancements; + } + + /** @@ -101,11 +103,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerItemCooldownEvent.patch b/patches/api/Add-PlayerItemCooldownEvent.patch index 2995f6443e..1248dc3478 100644 --- a/patches/api/Add-PlayerItemCooldownEvent.patch +++ b/patches/api/Add-PlayerItemCooldownEvent.patch @@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a player receives an item cooldown. + */ +public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull + private final Material type; -+ private boolean cancelled; + private int cooldown; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerItemCooldownEvent(@NotNull Player player, @NotNull Material type, int cooldown) { + super(player); + this.type = type; @@ -43,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Material getType() { -+ return type; ++ return this.type; + } + + /** @@ -52,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return cooldown in ticks + */ + public int getCooldown() { -+ return cooldown; ++ return this.cooldown; + } + + /** @@ -68,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -79,11 +84,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerItemFrameChangeEvent.patch b/patches/api/Add-PlayerItemFrameChangeEvent.patch index 27a9f13201..481bca5422 100644 --- a/patches/api/Add-PlayerItemFrameChangeEvent.patch +++ b/patches/api/Add-PlayerItemFrameChangeEvent.patch @@ -12,13 +12,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.player; + -+import org.bukkit.Material; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -27,12 +27,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerItemFrameChangeEvent extends PlayerEvent implements Cancellable { + -+ private static final HandlerList HANDLERS = new HandlerList(); -+ private boolean cancelled; -+ private final ItemFrame itemFrame; -+ private ItemStack itemStack; -+ private final ItemFrameChangeAction action; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + ++ private final ItemFrame itemFrame; ++ private final ItemFrameChangeAction action; ++ private ItemStack itemStack; ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerItemFrameChangeEvent(@NotNull Player player, @NotNull ItemFrame itemFrame, + @NotNull ItemStack itemStack, @NotNull ItemFrameChangeAction action) { + super(player); @@ -43,46 +46,50 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the {@link ItemFrame} involved in this event. ++ * + * @return the {@link ItemFrame} + */ + @NotNull + public ItemFrame getItemFrame() { -+ return itemFrame; ++ return this.itemFrame; + } + + /** + * Gets the {@link ItemStack} involved in this event. + * This is the item being added, rotated, or removed from the {@link ItemFrame}. -+ *

If this method returns air, then the resulting item in the ItemFrame will be empty.

++ *

++ * If this method returns air, then the resulting item in the ItemFrame will be empty. ++ * + * @return the {@link ItemStack} being added, rotated, or removed + */ + @NotNull + public ItemStack getItemStack() { -+ return itemStack; ++ return this.itemStack; + } + + /** + * Sets the {@link ItemStack} that this {@link ItemFrame} holds. -+ * If null is provided, the ItemStack will become air and the result in the ItemFrame will be empty. ++ * If {@code null} is provided, the ItemStack will become air and the result in the ItemFrame will be empty. ++ * + * @param itemStack {@link ItemFrame} item + */ + public void setItemStack(@Nullable ItemStack itemStack) { -+ this.itemStack = itemStack == null ? new ItemStack(Material.AIR) : itemStack; ++ this.itemStack = itemStack == null ? ItemStack.empty() : itemStack; + } + + /** + * Gets the action that was performed on this {@link ItemFrame}. -+ * @see ItemFrameChangeAction ++ * + * @return action performed on the item frame in this event + */ + @NotNull + public ItemFrameChangeAction getAction() { -+ return action; ++ return this.action; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -93,12 +100,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + @NotNull + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + public enum ItemFrameChangeAction { diff --git a/patches/api/Add-PlayerJumpEvent.patch b/patches/api/Add-PlayerJumpEvent.patch index 00407cd6da..712ff53bb1 100644 --- a/patches/api/Add-PlayerJumpEvent.patch +++ b/patches/api/Add-PlayerJumpEvent.patch @@ -18,21 +18,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.bukkit.event.player.PlayerMoveEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when the server detects the player is jumping. + *

+ * Added to avoid the overhead and special case logic that many plugins use -+ * when checking for jumps via PlayerMoveEvent, this event is fired whenever ++ * when checking for jumps via {@link PlayerMoveEvent}, this event is fired whenever + * the server detects that the player is jumping. + */ +public class PlayerJumpEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancel = false; -+ @NotNull private Location from; -+ @NotNull private Location to; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final Location to; ++ @NotNull private Location from; ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerJumpEvent(@NotNull final Player player, @NotNull final Location from, @NotNull final Location to) { + super(player); + this.from = from; @@ -40,31 +46,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Gets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins ++ * {@inheritDoc} + *

+ * If a jump event is cancelled, the player will be moved or -+ * teleported back to the Location as defined by getFrom(). This will not ++ * teleported back to the Location as defined by {@link #getFrom()}. This will not + * fire an event + * -+ * @return true if this event is cancelled ++ * @return {@code true} if this event is cancelled + */ + public boolean isCancelled() { -+ return cancel; ++ return this.cancelled; + } + + /** -+ * Sets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins ++ * {@inheritDoc} + *

+ * If a jump event is cancelled, the player will be moved or -+ * teleported back to the Location as defined by getFrom(). This will not ++ * teleported back to the Location as defined by {@link #getFrom()}. This will not + * fire an event + * -+ * @param cancel true if you wish to cancel this event ++ * @param cancel {@code true} if you wish to cancel this event + */ + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + /** @@ -74,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getFrom() { -+ return from; ++ return this.from; + } + + /** @@ -83,13 +87,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param from New location to mark as the players previous location + */ + public void setFrom(@NotNull Location from) { -+ validateLocation(from); ++ Preconditions.checkArgument(from != null, "Cannot use null from location!"); ++ Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!"); + this.from = from; + } + + /** + * Gets the location this player jumped to -+ * ++ *

+ * This information is based on what the client sends, it typically + * has little relation to the arc of the jump at any given point. + * @@ -97,22 +102,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getTo() { -+ return to; -+ } -+ -+ private void validateLocation(Location loc) { -+ Preconditions.checkArgument(loc != null, "Cannot use null location!"); -+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use location with null world!"); ++ return this.to; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerLocaleChangeEvent.patch b/patches/api/Add-PlayerLocaleChangeEvent.patch index 1237323719..0dcfedba82 100644 --- a/patches/api/Add-PlayerLocaleChangeEvent.patch +++ b/patches/api/Add-PlayerLocaleChangeEvent.patch @@ -16,6 +16,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; + +/** + * Called when the locale of the player is changed. @@ -24,11 +26,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +public class PlayerLocaleChangeEvent extends PlayerEvent { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final String oldLocale; + private final String newLocale; + -+ public PlayerLocaleChangeEvent(final Player player, final String oldLocale, final String newLocale) { ++ @ApiStatus.Internal ++ public PlayerLocaleChangeEvent(final @NotNull Player player, final @Nullable String oldLocale, final @NotNull String newLocale) { + super(player); + this.oldLocale = oldLocale; + this.newLocale = newLocale; @@ -39,8 +44,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return player's old locale + */ ++ @Nullable + public String getOldLocale() { -+ return oldLocale; ++ return this.oldLocale; + } + + /** @@ -48,16 +54,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @return player's new locale + */ ++ @NotNull + public String getNewLocale() { -+ return newLocale; ++ return this.newLocale; + } + + @Override ++ @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + ++ @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerPickItemEvent.patch b/patches/api/Add-PlayerPickItemEvent.patch index 8ab9a1014a..4c203b36e9 100644 --- a/patches/api/Add-PlayerPickItemEvent.patch +++ b/patches/api/Add-PlayerPickItemEvent.patch @@ -12,11 +12,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.player; + -+import org.apache.commons.lang3.Validate; ++import com.google.common.base.Preconditions; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Range; + @@ -29,11 +30,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Note: This event will not be fired for players in creative mode. + */ +public class PlayerPickItemEvent extends PlayerEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private int targetSlot; + private int sourceSlot; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerPickItemEvent(@NotNull Player player, int targetSlot, int sourceSlot) { + super(player); + this.targetSlot = targetSlot; @@ -56,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param targetSlot hotbar slot (0-8 inclusive) + */ + public void setTargetSlot(@Range(from = 0, to = 8) int targetSlot) { -+ Validate.isTrue(targetSlot >= 0 && targetSlot <= 8, "Target slot must be in range 0 - 8 (inclusive)"); ++ Preconditions.checkArgument(targetSlot >= 0 && targetSlot <= 8, "Target slot must be in range 0 - 8 (inclusive)"); + this.targetSlot = targetSlot; + } + @@ -76,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param sourceSlot player inventory slot (0-35 inclusive) + */ + public void setSourceSlot(@Range(from = 0, to = 35) int sourceSlot) { -+ Validate.isTrue(sourceSlot >= 0 && sourceSlot <= 35, "Source slot must be in range of the players inventorys slot ids"); ++ Preconditions.checkArgument(sourceSlot >= 0 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot"); + this.sourceSlot = sourceSlot; + } + diff --git a/patches/api/Add-PlayerPostRespawnEvent.patch b/patches/api/Add-PlayerPostRespawnEvent.patch index bc47721c55..6bd8835ee9 100644 --- a/patches/api/Add-PlayerPostRespawnEvent.patch +++ b/patches/api/Add-PlayerPostRespawnEvent.patch @@ -16,16 +16,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired after a player has respawned + */ +public class PlayerPostRespawnEvent extends PlayerEvent { -+ private final static HandlerList handlers = new HandlerList(); ++ ++ private final static HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Location respawnedLocation; + private final boolean isBedSpawn; + ++ @ApiStatus.Internal + public PlayerPostRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnedLocation, final boolean isBedSpawn) { + super(respawnPlayer); + this.respawnedLocation = respawnedLocation; @@ -39,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getRespawnedLocation() { -+ return respawnedLocation.clone(); ++ return this.respawnedLocation.clone(); + } + + /** @@ -48,18 +52,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return whether the player respawned to their bed + */ + public boolean isBedSpawn() { -+ return isBedSpawn; ++ return this.isBedSpawn; + } + + @Override + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java b/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java diff --git a/patches/api/Add-PlayerSetSpawnEvent.patch b/patches/api/Add-PlayerSetSpawnEvent.patch index 664cba2b90..71983776e8 100644 --- a/patches/api/Add-PlayerSetSpawnEvent.patch +++ b/patches/api/Add-PlayerSetSpawnEvent.patch @@ -18,11 +18,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** -+ * Called when a player's spawn is set, either by themselves or otherwise.
++ * Called when a player's spawn is set, either by themselves or otherwise. ++ *
+ * Cancelling this event will prevent the spawn from being set. + */ +public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable { @@ -37,8 +39,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private boolean cancelled; + -+ public PlayerSetSpawnEvent(@NotNull Player who, @NotNull Cause cause, @Nullable Location location, boolean forced, boolean notifyPlayer, @Nullable Component notification) { -+ super(who); ++ @ApiStatus.Internal ++ public PlayerSetSpawnEvent(@NotNull Player player, @NotNull Cause cause, @Nullable Location location, boolean forced, boolean notifyPlayer, @Nullable Component notification) { ++ super(player); + this.cause = cause; + this.location = location; + this.forced = forced; @@ -53,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Cause getCause() { -+ return cause; ++ return this.cause; + } + + /** @@ -62,18 +65,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * will change the resulting spawn point of the player. Use + * {@link Location#clone()} to get a copy of this location. + * -+ * @return the spawn location, or null if removing the location ++ * @return the spawn location, or {@code null} if removing the location + */ + @Nullable + public Location getLocation() { -+ return location; ++ return this.location; + } + + /** + * Sets the location to be set as the spawn location. The yaw + * of this location is the spawn angle. + * -+ * @param location the spawn location, or null to remove the spawn location ++ * @param location the spawn location, or {@code null} to remove the spawn location + */ + public void setLocation(@Nullable Location location) { + this.location = location; @@ -82,16 +85,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Gets if this is a force spawn location + * -+ * @return true if forced ++ * @return {@code true} if forced + */ + public boolean isForced() { -+ return forced; ++ return this.forced; + } + + /** + * Sets if this is a forced spawn location + * -+ * @param forced true to force ++ * @param forced {@code true} to force + */ + public void setForced(boolean forced) { + this.forced = forced; @@ -101,17 +104,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Gets if this action will notify the player their spawn + * has been set. + * -+ * @return true to notify ++ * @return {@code true} to notify + */ + public boolean willNotifyPlayer() { -+ return notifyPlayer; ++ return this.notifyPlayer; + } + + /** + * Sets if this action will notify the player that their spawn + * has been set. + * -+ * @param notifyPlayer true to notify ++ * @param notifyPlayer {@code true} to notify + */ + public void setNotifyPlayer(boolean notifyPlayer) { + this.notifyPlayer = notifyPlayer; @@ -121,17 +124,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Gets the notification message that will be sent to the player + * if {@link #willNotifyPlayer()} returns true. + * -+ * @return null if no notification ++ * @return {@code null} if no notification + */ + @Nullable + public Component getNotification() { -+ return notification; ++ return this.notification; + } + + /** + * Sets the notification message that will be sent to the player. + * -+ * @param notification null to send no message ++ * @param notification {@code null} to send no message + */ + public void setNotification(@Nullable Component notification) { + this.notification = notification; @@ -175,8 +178,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + COMMAND, + /** -+ * When a plugin uses {@link Player#setBedSpawnLocation(Location)} or -+ * {@link Player#setBedSpawnLocation(Location, boolean)}. ++ * When a plugin uses {@link Player#setRespawnLocation(Location)} or ++ * {@link Player#setRespawnLocation(Location, boolean)}. + */ + PLUGIN, + /** diff --git a/patches/api/Add-PlayerShearBlockEvent.patch b/patches/api/Add-PlayerShearBlockEvent.patch index fb24a825ef..aeb51b79b3 100644 --- a/patches/api/Add-PlayerShearBlockEvent.patch +++ b/patches/api/Add-PlayerShearBlockEvent.patch @@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @@ -32,15 +33,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb. + */ +public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled = false; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Block block; + private final ItemStack item; + private final EquipmentSlot hand; + private final List drops; + -+ public PlayerShearBlockEvent(@NotNull Player who, @NotNull Block block, @NotNull ItemStack item, @NotNull EquipmentSlot hand, @NotNull List drops) { -+ super(who); ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public PlayerShearBlockEvent(@NotNull Player player, @NotNull Block block, @NotNull ItemStack item, @NotNull EquipmentSlot hand, @NotNull List drops) { ++ super(player); + this.block = block; + this.item = item; + this.hand = hand; @@ -54,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Block getBlock() { -+ return block; ++ return this.block; + } + + /** @@ -64,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItem() { -+ return item; ++ return this.item; + } + + /** @@ -74,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public EquipmentSlot getHand() { -+ return hand; ++ return this.hand; + } + + /** @@ -84,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public List getDrops() { -+ return drops; ++ return this.drops; + } + + /** @@ -94,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** @@ -110,11 +115,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerShieldDisableEvent.patch b/patches/api/Add-PlayerShieldDisableEvent.patch index a87e01927a..5eadfa4c77 100644 --- a/patches/api/Add-PlayerShieldDisableEvent.patch +++ b/patches/api/Add-PlayerShieldDisableEvent.patch @@ -42,10 +42,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * disabled in the first place. + */ +public class PlayerShieldDisableEvent extends PlayerEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Entity damager; + private int cooldown; ++ + private boolean cancelled; + + @ApiStatus.Internal @@ -62,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getDamager() { -+ return damager; ++ return this.damager; + } + + /** @@ -74,7 +76,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return cooldown in ticks + */ + public int getCooldown() { -+ return cooldown; ++ return this.cooldown; + } + + /** @@ -90,23 +92,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.cooldown = cooldown; + } + -+ /** -+ * Gets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins -+ * -+ * @return true if this event is cancelled -+ */ + @Override + public boolean isCancelled() { + return this.cancelled; + } + -+ /** -+ * Sets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins. -+ * -+ * @param cancel true if you wish to cancel this event -+ */ + @Override + public void setCancelled(final boolean cancel) { + this.cancelled = cancel; diff --git a/patches/api/Add-PlayerStopUsingItemEvent.patch b/patches/api/Add-PlayerStopUsingItemEvent.patch index 1a6ed616fc..00d01b35a1 100644 --- a/patches/api/Add-PlayerStopUsingItemEvent.patch +++ b/patches/api/Add-PlayerStopUsingItemEvent.patch @@ -23,7 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Examples of this are letting go of the interact button when holding a bow, an edible item, or a spyglass. + */ +public class PlayerStopUsingItemEvent extends PlayerEvent { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final ItemStack item; + private final int ticksHeldFor; + @@ -40,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItem() { -+ return item; ++ return this.item; + } + + /** @@ -49,17 +51,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return int the number of ticks the item was held for + */ + public int getTicksHeldFor() { -+ return ticksHeldFor; ++ return this.ticksHeldFor; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PlayerUseUnknownEntityEvent.patch b/patches/api/Add-PlayerUseUnknownEntityEvent.patch index 494ff1c326..dcc3da7c48 100644 --- a/patches/api/Add-PlayerUseUnknownEntityEvent.patch +++ b/patches/api/Add-PlayerUseUnknownEntityEvent.patch @@ -19,8 +19,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.util.Vector; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -33,14 +35,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerUseUnknownEntityEvent extends PlayerEvent { + -+ private static final HandlerList HANDLERS = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final int entityId; + private final boolean attack; + private final @NotNull EquipmentSlot hand; + private final @Nullable Vector clickedPosition; + -+ public PlayerUseUnknownEntityEvent(@NotNull Player who, int entityId, boolean attack, @NotNull EquipmentSlot hand, @Nullable Vector clickedPosition) { -+ super(who); ++ @ApiStatus.Internal ++ public PlayerUseUnknownEntityEvent(@NotNull Player player, int entityId, boolean attack, @NotNull EquipmentSlot hand, @Nullable Vector clickedPosition) { ++ super(player); + this.entityId = entityId; + this.attack = attack; + this.hand = hand; @@ -59,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Returns whether the interaction was an attack. + * -+ * @return true if the player is attacking the entity, false if the player is interacting with the entity ++ * @return {@code true} if the player is attacking the entity, {@code false} if the player is interacting with the entity + */ + public boolean isAttack() { + return this.attack; @@ -75,11 +79,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Returns the position relative to the entity that was clicked, or null if not available. -+ * See {@link org.bukkit.event.player.PlayerInteractAtEntityEvent} for more details. ++ * Returns the position relative to the entity that was clicked, or {@code null} if not available. ++ * See {@link PlayerInteractAtEntityEvent} for more details. + * -+ * @return the position relative to the entity that was clicked, or null if not available -+ * @see org.bukkit.event.player.PlayerInteractAtEntityEvent ++ * @return the position relative to the entity that was clicked, or {@code null} if not available ++ * @see PlayerInteractAtEntityEvent + */ + public @Nullable Vector getClickedRelativePosition() { + return this.clickedPosition != null ? this.clickedPosition.clone() : null; @@ -88,11 +92,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-PrePlayerAttackEntityEvent.patch b/patches/api/Add-PrePlayerAttackEntityEvent.patch index ded2277093..2dd944464f 100644 --- a/patches/api/Add-PrePlayerAttackEntityEvent.patch +++ b/patches/api/Add-PrePlayerAttackEntityEvent.patch @@ -17,18 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when the player tries to attack an entity. -+ * ++ *

+ * This occurs before any of the damage logic, so cancelling this event + * will prevent any sort of sounds from being played when attacking. -+ * ++ *

+ * This event will fire as cancelled for certain entities, with {@link PrePlayerAttackEntityEvent#willAttack()} being false + * to indicate that this entity will not actually be attacked. + *

-+ * Note: there may be other factors (invulnerability, etc) that will prevent this entity from being attacked that this event will not cover ++ * Note: there may be other factors (invulnerability, etc.) that will prevent this entity from being attacked that this event will not cover + */ +public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellable { + @@ -36,11 +37,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + private final Entity attacked; -+ private boolean cancelled; + private final boolean willAttack; + -+ public PrePlayerAttackEntityEvent(@NotNull Player who, @NotNull Entity attacked, boolean willAttack) { -+ super(who); ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public PrePlayerAttackEntityEvent(@NotNull Player player, @NotNull Entity attacked, boolean willAttack) { ++ super(player); + this.attacked = attacked; + this.willAttack = willAttack; + this.cancelled = !willAttack; @@ -48,6 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the entity that was attacked in this event. ++ * + * @return entity that was attacked + */ + @NotNull @@ -57,16 +61,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets if this entity will be attacked normally. -+ * Entities like falling sand will return false because ++ * Entities like falling sand will return {@code false} because + * their entity type does not allow them to be attacked. + *

-+ * Note: there may be other factors (invulnerability, etc) that will prevent this entity from being attacked that this event will not cover ++ * Note: there may be other factors (invulnerability, etc.) that will prevent this entity from being attacked that this event will not cover ++ * + * @return if the entity will actually be attacked + */ + public boolean willAttack() { + return this.willAttack; + } + ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ /** ++ * Sets if this attack should be cancelled, note if {@link PrePlayerAttackEntityEvent#willAttack()} returns false ++ * this event will always be cancelled. ++ * ++ * @param cancel {@code true} if you wish to cancel this event ++ */ ++ @Override ++ public void setCancelled(boolean cancel) { ++ if (!this.willAttack) { ++ return; ++ } ++ ++ this.cancelled = cancel; ++ } ++ + @NotNull + @Override + public HandlerList getHandlers() { @@ -77,23 +102,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } -+ -+ @Override -+ public boolean isCancelled() { -+ return this.cancelled; -+ } -+ -+ /** -+ * Sets if this attack should be cancelled, note if {@link PrePlayerAttackEntityEvent#willAttack()} returns false -+ * this event will always be cancelled. -+ * @param cancel true if you wish to cancel this event -+ */ -+ @Override -+ public void setCancelled(boolean cancel) { -+ if (!this.willAttack) { -+ return; -+ } -+ -+ this.cancelled = cancel; -+ } +} diff --git a/patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch b/patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch index b561f8820c..5314547b93 100644 --- a/patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch +++ b/patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch @@ -21,17 +21,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.inventory.GrindstoneInventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Called when an item is put in a slot for grinding in a Grindstone ++ * + * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent} + */ +@Deprecated -+@Warning(false) ++@Warning +public class PrepareGrindstoneEvent extends PrepareResultEvent { + ++ @ApiStatus.Internal + public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { + super(inventory, result); + } @@ -54,6 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.inventory.PrepareInventoryResultEvent; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -63,12 +67,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public class PrepareResultEvent extends PrepareInventoryResultEvent { + + // HandlerList on PrepareInventoryResultEvent to ensure api compat ++ ++ @ApiStatus.Internal + public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { + super(inventory, result); + } + + /** -+ * Get result item, may be null. ++ * Get result item, may be {@code null}. + * + * @return result item + */ @@ -78,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Set result item, may be null. ++ * Set result item, may be {@code null}. + * + * @param result result item + */ diff --git a/patches/api/Add-ProjectileCollideEvent.patch b/patches/api/Add-ProjectileCollideEvent.patch index 35a493ac89..d91b3e8cdd 100644 --- a/patches/api/Add-ProjectileCollideEvent.patch +++ b/patches/api/Add-ProjectileCollideEvent.patch @@ -17,31 +17,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Projectile; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a projectile collides with an entity + *

-+ * This event is called before {@link org.bukkit.event.entity.EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying ++ * This event is called before {@link EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying ++ * + * @deprecated Deprecated, use {@link org.bukkit.event.entity.ProjectileHitEvent} and check if there is a hit entity + */ +@Deprecated +public class ProjectileCollideEvent extends EntityEvent implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final Entity collidedWith; + -+ /** -+ * Get the entity the projectile collided with -+ * -+ * @return the entity collided with -+ */ -+ @NotNull -+ public Entity getCollidedWith() { -+ return collidedWith; -+ } ++ private boolean cancelled; + -+ public ProjectileCollideEvent(@NotNull Projectile what, @NotNull Entity collidedWith) { -+ super(what); ++ @ApiStatus.Internal ++ public ProjectileCollideEvent(@NotNull Projectile projectile, @NotNull Entity collidedWith) { ++ super(projectile); + this.collidedWith = collidedWith; + } + @@ -55,28 +54,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return (Projectile) super.getEntity(); + } + -+ private static final HandlerList handlerList = new HandlerList(); -+ ++ /** ++ * Get the entity the projectile collided with ++ * ++ * @return the entity collided with ++ */ + @NotNull -+ public static HandlerList getHandlerList() { -+ return handlerList; ++ public Entity getCollidedWith() { ++ return this.collidedWith; + } + -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlerList; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } +} diff --git a/patches/api/Add-PufferFishStateChangeEvent.patch b/patches/api/Add-PufferFishStateChangeEvent.patch index 396eb57c6a..d80049ff4e 100644 --- a/patches/api/Add-PufferFishStateChangeEvent.patch +++ b/patches/api/Add-PufferFishStateChangeEvent.patch @@ -16,16 +16,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called just before a {@link PufferFish} inflates or deflates. + */ +public class PufferFishStateChangeEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ private int newPuffState; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private final int newPuffState; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PufferFishStateChangeEvent(@NotNull PufferFish entity, int newPuffState) { + super(entity); + this.newPuffState = newPuffState; @@ -34,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public PufferFish getEntity() { -+ return (PufferFish) entity; ++ return (PufferFish) super.getEntity(); + } + + /** @@ -42,6 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + *

+ * This is what the {@link PufferFish}'s new puff state will be after this event if it isn't cancelled.
+ * Refer to {@link PufferFish#getPuffState()} to get the current puff state. ++ * + * @return The new puff state, 0 being not inflated, 1 being slightly inflated and 2 being fully inflated + */ + public int getNewPuffState() { @@ -50,24 +55,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Get if the {@link PufferFish} is going to inflate. -+ * @return If its going to inflate ++ * ++ * @return If it's going to inflate + */ + public boolean isInflating() { -+ return getNewPuffState() > getEntity().getPuffState(); ++ return this.newPuffState > this.getEntity().getPuffState(); + } + + /** + * Get if the {@link PufferFish} is going to deflate. -+ * @return If its going to deflate ++ * ++ * @return If it's going to deflate + */ + public boolean isDeflating() { -+ return getNewPuffState() < getEntity().getPuffState(); ++ return this.newPuffState < this.getEntity().getPuffState(); + } + + /** -+ * Set whether or not to cancel the {@link PufferFish} (in/de)flating. ++ * Set whether to cancel the {@link PufferFish} (in/de)flating. + * -+ * @param cancel true if you wish to cancel the (in/de)flation ++ * @param cancel {@code true} if you wish to cancel the (in/de)flation + */ + @Override + public void setCancelled(boolean cancel) { @@ -76,17 +83,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-ShulkerDuplicateEvent.patch b/patches/api/Add-ShulkerDuplicateEvent.patch index cd7f3e5a6b..5336040586 100644 --- a/patches/api/Add-ShulkerDuplicateEvent.patch +++ b/patches/api/Add-ShulkerDuplicateEvent.patch @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + @NotNull + public Shulker getEntity() { -+ return (Shulker) entity; ++ return (Shulker) super.getEntity(); + } + + /** @@ -57,12 +57,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Shulker getParent() { -+ return parent; ++ return this.parent; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Add-StructuresLocateEvent.patch b/patches/api/Add-StructuresLocateEvent.patch index 5838fff4c6..0a3724585f 100644 --- a/patches/api/Add-StructuresLocateEvent.patch +++ b/patches/api/Add-StructuresLocateEvent.patch @@ -32,18 +32,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + *

  • An Explorer/Treasure Map is activated.
  • + *
  • {@link World#locateNearestStructure(Location, StructureType, int, boolean)} is invoked.
  • + * ++ * + * @deprecated no longer used, see {@link StructuresLocateEvent} + */ +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +public class StructureLocateEvent extends WorldEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Location origin; + private Location result = null; + private StructureType type; + private int radius; + private boolean findUnexplored; -+ private boolean cancelled = false; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public StructureLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) { + super(world); + this.origin = origin; @@ -52,29 +57,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.findUnexplored = findUnexplored; + } + -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ + /** + * Gets the location set as the structure location, if it was defined. + *

    + * Returns {@code null} if it has not been set by {@link StructureLocateEvent#setResult(Location)}. + * Since this event fires before the search is done, the actual location is unknown at this point. + * -+ * @return The result location, if it has been set. null if it has not. ++ * @return The result location, if it has been set. {@code null} if it has not. + * @see World#locateNearestStructure(Location, StructureType, int, boolean) + */ + @Nullable + public Location getResult() { -+ return result; ++ return this.result; + } + + /** @@ -93,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public StructureType getType() { -+ return type; ++ return this.type; + } + + /** @@ -112,7 +106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getOrigin() { -+ return origin; ++ return this.origin; + } + + /** @@ -123,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the search radius. + */ + public int getRadius() { -+ return radius; ++ return this.radius; + } + + /** @@ -145,7 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return Whether to search for only unexplored structures. + */ + public boolean shouldFindUnexplored() { -+ return findUnexplored; ++ return this.findUnexplored; + } + + /** @@ -161,13 +155,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } +} diff --git a/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java new file mode 100644 @@ -190,6 +195,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.world.WorldEvent; +import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.StructureType; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; @@ -217,8 +223,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private List legacy$structures; + private int radius; + private boolean findUnexplored; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List structures, int radius, boolean findUnexplored) { + super(world); + this.origin = origin; @@ -242,8 +250,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Returns {@code null} if it has not been set by {@link StructuresLocateEvent#setResult(Result)}. + * Since this event fires before the search is done, the actual result is unknown at this point. + * -+ * @return The result location and structure, if it has been set. null if it has not. -+ * @see World#locateNearestStructure(Location, org.bukkit.generator.structure.StructureType, int, boolean) ++ * @return The result location and structure, if it has been set. {@code null} if it has not. ++ * @see World#locateNearestStructure(Location, StructureType, int, boolean) + */ + public @Nullable Result getResult() { + return this.result; diff --git a/patches/api/Add-TNTPrimeEvent.patch b/patches/api/Add-TNTPrimeEvent.patch index 1192baba55..ce9179d666 100644 --- a/patches/api/Add-TNTPrimeEvent.patch +++ b/patches/api/Add-TNTPrimeEvent.patch @@ -12,18 +12,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.block; + ++import org.bukkit.Material; +import org.bukkit.block.Block; ++import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; ++import org.bukkit.entity.Player; ++import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** -+ * Called when TNT block is about to turn into {@link org.bukkit.entity.TNTPrimed} ++ * Called when TNT block is about to turn into {@link TNTPrimed} + *

    -+ * Cancelling it won't turn TNT into {@link org.bukkit.entity.TNTPrimed} and leaves ++ * Cancelling it won't turn TNT into {@link TNTPrimed} and leaves + * the TNT block as-is + * + * @author Mark Vainomaa @@ -31,11 +36,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@Deprecated(forRemoval = true) +public class TNTPrimeEvent extends BlockEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ @NotNull private PrimeReason reason; -+ @Nullable private Entity primerEntity; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final PrimeReason reason; ++ @Nullable private final Entity primerEntity; ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public TNTPrimeEvent(@NotNull Block theBlock, @NotNull PrimeReason reason, @Nullable Entity primerEntity) { + super(theBlock); + this.reason = reason; @@ -54,10 +63,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the TNT primer {@link Entity}. -+ * -+ * It's null if {@link #getReason()} is {@link PrimeReason#REDSTONE} or {@link PrimeReason#FIRE}. -+ * It's not null if {@link #getReason()} is {@link PrimeReason#ITEM} or {@link PrimeReason#PROJECTILE} -+ * It might be null if {@link #getReason()} is {@link PrimeReason#EXPLOSION} ++ *

    ++ * It's {@code null} if {@link #getReason()} is {@link PrimeReason#REDSTONE} or {@link PrimeReason#FIRE}. ++ * It's not {@code null} if {@link #getReason()} is {@link PrimeReason#ITEM} or {@link PrimeReason#PROJECTILE} ++ * It might be {@code null} if {@link #getReason()} is {@link PrimeReason#EXPLOSION} + * + * @return The {@link Entity} who primed the TNT + */ @@ -67,9 +76,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Gets whether spawning {@link org.bukkit.entity.TNTPrimed} should be cancelled or not ++ * Gets whether spawning {@link TNTPrimed} should be cancelled or not + * -+ * @return Whether spawning {@link org.bukkit.entity.TNTPrimed} should be cancelled or not ++ * @return Whether spawning {@link TNTPrimed} should be cancelled or not + */ + @Override + public boolean isCancelled() { @@ -77,24 +86,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Sets whether to cancel spawning {@link org.bukkit.entity.TNTPrimed} or not ++ * Sets whether to cancel spawning {@link TNTPrimed} or not + * -+ * @param cancel whether spawning {@link org.bukkit.entity.TNTPrimed} should be cancelled or not ++ * @param cancel whether spawning {@link TNTPrimed} should be cancelled or not + */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + -+ @Nullable ++ @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + -+ @Nullable ++ @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } + + public enum PrimeReason { @@ -109,14 +118,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + FIRE, + + /** -+ * When {@link org.bukkit.entity.Player} used {@link org.bukkit.Material#FLINT_AND_STEEL} or -+ * {@link org.bukkit.Material#FIRE_CHARGE} on given TNT block ++ * When {@link Player} used {@link Material#FLINT_AND_STEEL} or ++ * {@link Material#FIRE_CHARGE} on given TNT block + */ + ITEM, + + /** + * When TNT prime was caused by an {@link Entity} shooting TNT -+ * using a bow with {@link org.bukkit.enchantments.Enchantment#ARROW_FIRE} enchantment ++ * using a bow with {@link Enchantment#ARROW_FIRE} enchantment + */ + PROJECTILE, + diff --git a/patches/api/Add-TameableDeathMessageEvent.patch b/patches/api/Add-TameableDeathMessageEvent.patch index 3f5328ed28..69049c2934 100644 --- a/patches/api/Add-TameableDeathMessageEvent.patch +++ b/patches/api/Add-TameableDeathMessageEvent.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -24,12 +25,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class TameableDeathMessageEvent extends EntityEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ private Component deathMessage; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ public TameableDeathMessageEvent(@NotNull Tameable what, @NotNull Component deathMessage) { -+ super(what); ++ private Component deathMessage; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public TameableDeathMessageEvent(@NotNull Tameable tameable, @NotNull Component deathMessage) { ++ super(tameable); + this.deathMessage = deathMessage; + } + @@ -49,12 +52,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Component deathMessage() { -+ return deathMessage; ++ return this.deathMessage; ++ } ++ ++ @NotNull ++ @Override ++ public Tameable getEntity() { ++ return (Tameable) super.getEntity(); + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -64,18 +73,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + @Override -+ public Tameable getEntity() { -+ return (Tameable) super.getEntity(); -+ } -+ -+ @NotNull -+ @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-TargetHitEvent-API.patch b/patches/api/Add-TargetHitEvent-API.patch index bb3db1b652..9ddfd8c4d9 100644 --- a/patches/api/Add-TargetHitEvent-API.patch +++ b/patches/api/Add-TargetHitEvent-API.patch @@ -12,13 +12,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.block; + ++import com.google.common.base.Preconditions; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Projectile; -+import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.ProjectileHitEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Range; + +/** + * Called when a Target Block is hit by a projectile. @@ -27,44 +29,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * and in the case that the shooter is a player, will stop them from receiving + * advancement criteria. + */ -+public class TargetHitEvent extends ProjectileHitEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; ++public class TargetHitEvent extends ProjectileHitEvent { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private int signalStrength; + ++ @ApiStatus.Internal + public TargetHitEvent(@NotNull Projectile projectile, @NotNull Block block, @NotNull BlockFace blockFace, int signalStrength) { + super(projectile, null, block, blockFace); + this.signalStrength = signalStrength; + } + -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ + /** + * Gets the strength of the redstone signal to be emitted by the Target block + * + * @return the strength of the redstone signal to be emitted + */ -+ public int getSignalStrength() { -+ return signalStrength; ++ public @Range(from = 0, to = 15) int getSignalStrength() { ++ return this.signalStrength; + } + + /** @@ -72,10 +55,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param signalStrength the strength of the redstone signal to be emitted + */ -+ public void setSignalStrength(int signalStrength) { -+ if (signalStrength < 0 || signalStrength > 15) { -+ throw new IllegalArgumentException("Signal strength out of range (" + signalStrength + "), must be in range [0,15]"); -+ } ++ public void setSignalStrength(@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); + this.signalStrength = signalStrength; + } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } +} diff --git a/patches/api/Add-ThrownEggHatchEvent.patch b/patches/api/Add-ThrownEggHatchEvent.patch index 72087c7fa3..52e8097808 100644 --- a/patches/api/Add-ThrownEggHatchEvent.patch +++ b/patches/api/Add-ThrownEggHatchEvent.patch @@ -14,10 +14,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.entity; + ++import com.google.common.base.Preconditions; +import org.bukkit.entity.Egg; +import org.bukkit.entity.EntityType; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -26,12 +28,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * This event fires for all thrown eggs that may hatch, players, dispensers, etc. + */ +public class ThrownEggHatchEvent extends Event { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Egg egg; + private boolean hatching; -+ private EntityType hatchType; + private byte numHatches; ++ private EntityType hatchType; + ++ @ApiStatus.Internal + public ThrownEggHatchEvent(@NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) { + this.egg = egg; + this.hatching = hatching; @@ -46,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Egg getEgg() { -+ return egg; ++ return this.egg; + } + + /** @@ -56,13 +61,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return boolean Whether the egg is going to hatch or not + */ + public boolean isHatching() { -+ return hatching; ++ return this.hatching; + } + + /** + * Sets whether the egg will hatch or not. + * -+ * @param hatching true if you want the egg to hatch, false if you want it ++ * @param hatching {@code true} if you want the egg to hatch, {@code false} if you want it + * not to + */ + public void setHatching(boolean hatching) { @@ -70,13 +75,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Get the type of the mob being hatched (EntityType.CHICKEN by default) ++ * Get the type of the mob being hatched ({@link EntityType#CHICKEN} by default) + * + * @return The type of the mob being hatched by the egg + */ + @NotNull + public EntityType getHatchingType() { -+ return hatchType; ++ return this.hatchType; + } + + /** @@ -85,7 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param hatchType The type of the mob being hatched by the egg + */ + public void setHatchingType(@NotNull EntityType hatchType) { -+ if (!hatchType.isSpawnable()) throw new IllegalArgumentException("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; + } + @@ -93,22 +98,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Get the number of mob hatches from the egg. By default the number will + * be the number the server would've done + *

      -+ *
    • 7/8 chance of being 0 -+ *
    • 31/256 ~= 1/8 chance to be 1 -+ *
    • 1/256 chance to be 4 ++ *
    • 7/8 chance of being 0 ++ *
    • 31/256 ~= 1/8 chance to be 1 ++ *
    • 1/256 chance to be 4 + *
    + * + * @return The number of mobs going to be hatched by the egg + */ + public byte getNumHatches() { -+ return numHatches; ++ return this.numHatches; + } + + /** + * Change the number of mobs coming out of the hatched egg + *

    -+ * The boolean hatching will override this number. Ie. If hatching = -+ * false, this number will not matter ++ * The boolean hatching will override this number. I.e. If hatching is ++ * {@code false}, this number will not matter + * + * @param numHatches The number of mobs coming out of the egg + */ @@ -119,11 +124,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-UnknownCommandEvent.patch b/patches/api/Add-UnknownCommandEvent.patch index d43167b7ce..79d8f5023b 100644 --- a/patches/api/Add-UnknownCommandEvent.patch +++ b/patches/api/Add-UnknownCommandEvent.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.command.CommandSender; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @@ -25,11 +26,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Thrown when a player executes a command that is not defined + */ +public class UnknownCommandEvent extends Event { -+ private static final HandlerList handlers = new HandlerList(); -+ @NotNull private CommandSender sender; -+ @NotNull private String commandLine; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final CommandSender sender; ++ @NotNull private final String commandLine; + @Nullable private Component message; + ++ @ApiStatus.Internal + public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) { + super(false); + this.sender = sender; @@ -39,29 +43,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the CommandSender or ConsoleCommandSender -+ *

    + * + * @return Sender of the command + */ + @NotNull + public CommandSender getSender() { -+ return sender; ++ return this.sender; + } + + /** -+ * Gets the command that was send -+ *

    ++ * Gets the command that was sent + * + * @return Command sent + */ + @NotNull + public String getCommandLine() { -+ return commandLine; ++ return this.commandLine; + } + + /** + * Gets message that will be returned -+ *

    + * + * @return Unknown command message + * @deprecated use {@link #message()} @@ -75,9 +76,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Sets message that will be returned + *

    -+ * Set to null to avoid any message being sent ++ * Set to {@code null} to avoid any message being sent + * -+ * @param message the message to be returned, or null ++ * @param message the message to be returned, or {@code null} + * @deprecated use {@link #message(Component)} + */ + @Deprecated @@ -87,7 +88,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets message that will be returned -+ *

    + * + * @return Unknown command message + */ @@ -100,9 +100,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Sets message that will be returned + *

    -+ * Set to null to avoid any message being sent ++ * Set to {@code null} to avoid any message being sent + * -+ * @param message the message to be returned, or null ++ * @param message the message to be returned, or {@code null} + */ + public void message(@Nullable Component message) { + this.message = message; @@ -111,12 +111,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} + diff --git a/patches/api/Add-WardenAngerChangeEvent.patch b/patches/api/Add-WardenAngerChangeEvent.patch index 4112914d12..56c2db6f00 100644 --- a/patches/api/Add-WardenAngerChangeEvent.patch +++ b/patches/api/Add-WardenAngerChangeEvent.patch @@ -14,6 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.entity; + ++import com.google.common.base.Preconditions; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Warden; +import org.bukkit.event.Cancellable; @@ -21,6 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.entity.EntityEvent; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Range; + +/** + * Called when a Warden's anger level has changed due to another entity. @@ -31,11 +33,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancelled; + private final Entity target; + private final int oldAnger; + private int newAnger; + ++ private boolean cancelled; ++ + @ApiStatus.Internal + public WardenAngerChangeEvent(@NotNull final Warden warden, @NotNull final Entity target, final int oldAnger, final int newAnger) { + super(warden); @@ -51,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getTarget() { -+ return target; ++ return this.target; + } + + /** @@ -60,8 +63,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return old anger level + * @see Warden#getAnger(Entity) + */ ++ @Range(from = 0, to = 150) + public int getOldAnger() { -+ return oldAnger; ++ return this.oldAnger; + } + + /** @@ -70,8 +74,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return new anger level + * @see Warden#getAnger(Entity) + */ ++ @Range(from = 0, to = 150) + public int getNewAnger() { -+ return newAnger; ++ return this.newAnger; + } + + /** @@ -83,27 +88,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @see Warden#setAnger(Entity, int) + * @throws IllegalArgumentException if newAnger is greater than 150 + */ -+ public void setNewAnger(int newAnger) { -+ if (newAnger > 150) -+ throw new IllegalArgumentException("newAnger must not be greater than 150"); -+ ++ public void setNewAnger(@Range(from = 0, to = 150) int newAnger) { ++ Preconditions.checkArgument(newAnger <= 150, "newAnger must not be greater than 150"); + this.newAnger = newAnger; + } + + @NotNull + @Override + public Warden getEntity() { -+ return (Warden) entity; ++ return (Warden) super.getEntity(); + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + + @NotNull diff --git a/patches/api/Add-WaterBottleSplashEvent.patch b/patches/api/Add-WaterBottleSplashEvent.patch index e48d7a3520..e4b96586bd 100644 --- a/patches/api/Add-WaterBottleSplashEvent.patch +++ b/patches/api/Add-WaterBottleSplashEvent.patch @@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.entity.PotionSplashEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + @@ -27,9 +28,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * different entities in different ways. + */ +public class WaterBottleSplashEvent extends PotionSplashEvent { ++ + private final @NotNull Set rehydrate; + private final @NotNull Set extinguish; + ++ @ApiStatus.Internal + public WaterBottleSplashEvent( + final @NotNull ThrownPotion potion, + final @NotNull Map affectedEntities, @@ -114,6 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Doesn't make sense for this event as intensity doesn't vary. ++ * + * @return a confusing value + * @deprecated check if {@link #getToDamage()} contains an entity + */ @@ -125,6 +129,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Doesn't make sense for this event as intensity doesn't vary. ++ * + * @deprecated use {@link #damageAsWaterSensitive(LivingEntity)} + * or {@link #doNotDamageAsWaterSensitive(LivingEntity)} to change which entities are + * damaged diff --git a/patches/api/Add-WhitelistToggleEvent.patch b/patches/api/Add-WhitelistToggleEvent.patch index 2f74403c37..6bbfd990b6 100644 --- a/patches/api/Add-WhitelistToggleEvent.patch +++ b/patches/api/Add-WhitelistToggleEvent.patch @@ -14,6 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -22,10 +23,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @author Mark Vainomaa + */ +public class WhitelistToggleEvent extends Event { -+ private static final HandlerList handlers = new HandlerList(); + -+ private boolean enabled; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + ++ private final boolean enabled; ++ ++ @ApiStatus.Internal + public WhitelistToggleEvent(boolean enabled) { + this.enabled = enabled; + } @@ -36,17 +39,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return Whether whitelist is going to be enabled or not + */ + public boolean isEnabled() { -+ return enabled; ++ return this.enabled; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-and-implement-PlayerRecipeBookClickEvent.patch b/patches/api/Add-and-implement-PlayerRecipeBookClickEvent.patch index e2f715daca..7055e92701 100644 --- a/patches/api/Add-and-implement-PlayerRecipeBookClickEvent.patch +++ b/patches/api/Add-and-implement-PlayerRecipeBookClickEvent.patch @@ -17,17 +17,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a player clicks a recipe in the recipe book + */ +public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancel = false; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private NamespacedKey recipe; + private boolean makeAll; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerRecipeBookClickEvent(@NotNull Player player, @NotNull NamespacedKey recipe, boolean makeAll) { + super(player); + this.recipe = recipe; @@ -41,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public NamespacedKey getRecipe() { -+ return recipe; ++ return this.recipe; + } + + /** @@ -54,17 +59,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Gets a boolean which indicates whether or not the player requested to make the maximum amount of results. This is -+ * true if shift is pressed while the recipe is clicked in the recipe book ++ * Gets a boolean which indicates whether the player requested to make the maximum amount of results. This is ++ * {@code true} if shift is pressed while the recipe is clicked in the recipe book + * + * @return {@code true} if shift is pressed while the recipe is clicked + */ + public boolean isMakeAll() { -+ return makeAll; ++ return this.makeAll; + } + + /** -+ * Sets whether or not the maximum amount of results should be made. If this is true, the request is handled as if ++ * Sets whether the maximum amount of results should be made. If this is {@code true}, the request is handled as if + * the player had pressed shift while clicking on the recipe + * + * @param makeAll {@code true} if the request should attempt to make the maximum amount of results @@ -75,23 +80,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancel; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java diff --git a/patches/api/Add-event-for-player-editing-sign.patch b/patches/api/Add-event-for-player-editing-sign.patch index 175f837edc..5eb1a2f789 100644 --- a/patches/api/Add-event-for-player-editing-sign.patch +++ b/patches/api/Add-event-for-player-editing-sign.patch @@ -14,6 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; ++import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; @@ -27,12 +28,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Cancelling this event stops the sign editing menu from opening. + */ +public class PlayerOpenSignEvent extends PlayerEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); -+ private boolean cancel = false; ++ + private final Sign sign; + private final Side side; + private final Cause cause; + ++ private boolean cancelled; ++ + @ApiStatus.Internal + public PlayerOpenSignEvent(final @NotNull Player editor, final @NotNull Sign sign, final @NotNull Side side, final @NotNull Cause cause) { + super(editor); @@ -48,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Sign getSign() { -+ return sign; ++ return this.sign; + } + + /** @@ -59,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Side getSide() { -+ return side; ++ return this.side; + } + + /** @@ -68,17 +72,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the cause + */ + public @NotNull Cause getCause() { -+ return cause; ++ return this.cause; + } + + @Override + public boolean isCancelled() { -+ return cancel; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @NotNull @@ -105,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + INTERACT, + /** -+ * The event was triggered via a plugin with {@link org.bukkit.entity.HumanEntity#openSign(Sign, Side)} ++ * The event was triggered via a plugin with {@link HumanEntity#openSign(Sign, Side)} + */ + PLUGIN, + /** diff --git a/patches/api/Add-exception-reporting-event.patch b/patches/api/Add-exception-reporting-event.patch index adc44eb4cb..14c5ddfe0d 100644 --- a/patches/api/Add-exception-reporting-event.patch +++ b/patches/api/Add-exception-reporting-event.patch @@ -12,23 +12,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.server; + -+import com.google.common.base.Preconditions; +import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import com.destroystokyo.paper.exception.ServerException; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called whenever an exception is thrown in a recoverable section of the server. + */ +public class ServerExceptionEvent extends Event { -+ private static final HandlerList handlers = new HandlerList(); -+ @NotNull private ServerException exception; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final ServerException exception; ++ ++ @ApiStatus.Internal + public ServerExceptionEvent(@NotNull ServerException exception) { + super(!Bukkit.isPrimaryThread()); -+ this.exception = Preconditions.checkNotNull(exception, "exception"); ++ this.exception = exception; + } + + /** @@ -38,18 +41,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ServerException getException() { -+ return exception; ++ return this.exception; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java b/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java diff --git a/patches/api/Add-extended-PaperServerListPingEvent.patch b/patches/api/Add-extended-PaperServerListPingEvent.patch index dbbf58919c..02f3b734bb 100644 --- a/patches/api/Add-extended-PaperServerListPingEvent.patch +++ b/patches/api/Add-extended-PaperServerListPingEvent.patch @@ -30,6 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.NoSuchElementException; +import java.util.UUID; + ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -56,6 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private Object[] players; + + @Deprecated ++ @ApiStatus.Internal + public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers, + @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) { + super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers); @@ -66,6 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + setServerIcon(favicon); + } + ++ @ApiStatus.Internal + public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull net.kyori.adventure.text.Component motd, int numPlayers, int maxPlayers, + @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) { + super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers); @@ -103,9 +106,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Sets the number of players displayed in the server list. -+ * -+ *

    Note that this won't have any effect if {@link #shouldHidePlayers()} -+ * is enabled.

    ++ *

    ++ * Note that this won't have any effect if {@link #shouldHidePlayers()} ++ * is enabled. + * + * @param numPlayers The number of online players + */ @@ -118,9 +121,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * {@inheritDoc} -+ * -+ *

    Returns {@code -1} if players are hidden using -+ * {@link #shouldHidePlayers()}.

    ++ *

    ++ * Returns {@code -1} if players are hidden using ++ * {@link #shouldHidePlayers()}. + */ + @Override + public int getMaxPlayers() { @@ -135,23 +138,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Returns whether all player related information is hidden in the server + * list. This will cause {@link #getNumPlayers()}, {@link #getMaxPlayers()} + * and {@link #getPlayerSample()} to be skipped in the response. -+ * -+ *

    The Vanilla Minecraft client will display the player count as {@code ???} -+ * when this option is enabled.

    ++ *

    ++ * The Vanilla Minecraft client will display the player count as {@code ???} ++ * when this option is enabled. + * + * @return {@code true} if the player count is hidden + */ + public boolean shouldHidePlayers() { -+ return hidePlayers; ++ return this.hidePlayers; + } + + /** + * Sets whether all player related information is hidden in the server + * list. This will cause {@link #getNumPlayers()}, {@link #getMaxPlayers()} + * and {@link #getPlayerSample()} to be skipped in the response. -+ * -+ *

    The Vanilla Minecraft client will display the player count as {@code ???} -+ * when this option is enabled.

    ++ *

    ++ * The Vanilla Minecraft client will display the player count as {@code ???} ++ * when this option is enabled. + * + * @param hidePlayers {@code true} if the player count should be hidden + */ @@ -162,9 +165,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Returns a mutable list of {@link PlayerProfile} that will be displayed + * as online players on the client. -+ * -+ *

    The Vanilla Minecraft client will display them when hovering the -+ * player count with the mouse.

    ++ *

    ++ * The Vanilla Minecraft client will display them when hovering the ++ * player count with the mouse. + * + * @return The mutable player sample list + */ @@ -180,7 +183,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public String getVersion() { -+ return version; ++ return this.version; + } + + /** @@ -200,7 +203,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * has not finished initialization yet + */ + public int getProtocolVersion() { -+ return protocolVersion; ++ return this.protocolVersion; + } + + /** @@ -240,9 +243,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * {@inheritDoc} -+ * -+ *

    Cancelling this event will cause the connection to be closed immediately, -+ * without sending a response to the client.

    ++ *

    ++ * Cancelling this event will cause the connection to be closed immediately, ++ * without sending a response to the client. + */ + @Override + public boolean isCancelled() { @@ -251,9 +254,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * {@inheritDoc} -+ * -+ *

    Cancelling this event will cause the connection to be closed immediately, -+ * without sending a response to the client.

    ++ *

    ++ * Cancelling this event will cause the connection to be closed immediately, ++ * without sending a response to the client. + */ + @Override + public void setCancelled(boolean cancel) { @@ -262,10 +265,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * {@inheritDoc} -+ * -+ *

    Note: For compatibility reasons, this method will return all ++ *

    ++ * Note: For compatibility reasons, this method will return all + * online players, not just the ones referenced in {@link #getPlayerSample()}. -+ * Removing a player will:

    ++ * Removing a player will: + * + *
      + *
    • Decrement the online player count (if and only if) the player @@ -294,6 +297,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return (Player) player; + } + ++ @ApiStatus.Internal + private final class PlayerIterator implements Iterator { + + private int next; diff --git a/patches/api/Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/patches/api/Add-handshake-event-to-allow-plugins-to-handle-clien.patch index 43714cf59f..e5ed9d8104 100644 --- a/patches/api/Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/patches/api/Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -20,6 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -27,18 +28,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +/** + * This event is fired during a player handshake. -+ * -+ *

      If there are no listeners listening to this event, the logic default -+ * to your server platform will be ran.

      ++ *

      ++ * If there are no listeners listening to this event, the logic default ++ * to your server platform will be run. + * + *

      WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS

      + */ +public class PlayerHandshakeEvent extends Event implements Cancellable { + -+ private static final HandlerList HANDLERS = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final String originalHandshake; + @NotNull private final String originalSocketAddressHostname; -+ private boolean cancelled; + @Nullable private String serverHostname; + @Nullable private String socketAddressHostname; + @Nullable private UUID uniqueId; @@ -46,26 +47,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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); + -+ /** -+ * Creates a new {@link PlayerHandshakeEvent}. -+ * -+ * @param originalHandshake the original handshake string -+ * @param cancelled if this event is enabled -+ * -+ * @deprecated in favour of {@link PlayerHandshakeEvent(String, String, boolean)} -+ */ ++ private boolean cancelled; ++ + @Deprecated ++ @ApiStatus.Internal + public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) { + this(originalHandshake, "127.0.0.1", cancelled); + } + -+ /** -+ * Creates a new {@link PlayerHandshakeEvent}. -+ * -+ * @param originalHandshake the original handshake string -+ * @param originalSocketAddressHostname the original socket address hostname -+ * @param cancelled if this event is enabled -+ */ ++ @ApiStatus.Internal + public PlayerHandshakeEvent(@NotNull String originalHandshake, @NotNull String originalSocketAddressHostname, boolean cancelled) { + super(true); + this.originalHandshake = originalHandshake; @@ -75,9 +65,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Determines if this event is cancelled. -+ * -+ *

      When this event is cancelled, custom handshake logic will not -+ * be processed.

      ++ *

      ++ * When this event is cancelled, custom handshake logic will not ++ * be processed. + * + * @return {@code true} if this event is cancelled, {@code false} otherwise + */ @@ -88,15 +78,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Sets if this event is cancelled. ++ *

      ++ * When this event is cancelled, custom handshake logic will not ++ * be processed. + * -+ *

      When this event is cancelled, custom handshake logic will not -+ * be processed.

      -+ * -+ * @param cancelled {@code true} if this event is cancelled, {@code false} otherwise ++ * @param cancel {@code true} if this event is cancelled, {@code false} otherwise + */ + @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + + /** @@ -201,9 +191,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Determines if authentication failed. -+ * -+ *

      When {@code true}, the client connecting will be disconnected -+ * with the {@link #getFailMessage() fail message}.

      ++ *

      ++ * When {@code true}, the client connecting will be disconnected ++ * with the {@link #getFailMessage() fail message}. + * + * @return {@code true} if authentication failed, {@code false} otherwise + */ @@ -213,9 +203,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Sets if authentication failed and the client should be disconnected. -+ * -+ *

      When {@code true}, the client connecting will be disconnected -+ * with the {@link #getFailMessage() fail message}.

      ++ *

      ++ * When {@code true}, the client connecting will be disconnected ++ * with the {@link #getFailMessage() fail message}. + * + * @param failed {@code true} if authentication failed, {@code false} otherwise + */ @@ -280,11 +270,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-more-fields-to-AsyncPreLoginEvent.patch b/patches/api/Add-more-fields-to-AsyncPreLoginEvent.patch index e8a8798a7c..e7d053079f 100644 --- a/patches/api/Add-more-fields-to-AsyncPreLoginEvent.patch +++ b/patches/api/Add-more-fields-to-AsyncPreLoginEvent.patch @@ -14,7 +14,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.net.InetAddress; import java.util.UUID; -+ +import com.destroystokyo.paper.profile.PlayerProfile; +import org.bukkit.Bukkit; import org.bukkit.event.Event; @@ -80,8 +79,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public UUID getUniqueId() { - return uniqueId; + return profile.getId(); // Paper - } - ++ } ++ + // Paper start + /** + * Gets the PlayerProfile of the player logging in @@ -107,8 +106,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + public InetAddress getRawAddress() { + return rawAddress; -+ } -+ + } + + /** + * Gets the hostname that the player used to connect to the server, or + * blank if unknown diff --git a/patches/api/Add-spectator-target-events.patch b/patches/api/Add-spectator-target-events.patch index c45d79f19d..52c1ecf707 100644 --- a/patches/api/Add-spectator-target-events.patch +++ b/patches/api/Add-spectator-target-events.patch @@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -26,11 +27,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final Entity currentSpectatorTarget; + @NotNull private final Entity newSpectatorTarget; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerStartSpectatingEntityEvent(@NotNull Player player, @NotNull Entity currentSpectatorTarget, @NotNull Entity newSpectatorTarget) { + super(player); + this.currentSpectatorTarget = currentSpectatorTarget; @@ -44,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getCurrentSpectatorTarget() { -+ return currentSpectatorTarget; ++ return this.currentSpectatorTarget; + } + + /** @@ -54,12 +58,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getNewSpectatorTarget() { -+ return newSpectatorTarget; ++ return this.newSpectatorTarget; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -70,12 +74,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} + @@ -92,6 +96,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -99,10 +104,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ @NotNull private final Entity spectatorTarget; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + ++ @NotNull private final Entity spectatorTarget; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerStopSpectatingEntityEvent(@NotNull Player player, @NotNull Entity spectatorTarget) { + super(player); + this.spectatorTarget = spectatorTarget; @@ -115,12 +122,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getSpectatorTarget() { -+ return spectatorTarget; ++ return this.spectatorTarget; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -131,11 +138,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Add-whitelist-events.patch b/patches/api/Add-whitelist-events.patch index d79d068cb0..beb2b50c6d 100644 --- a/patches/api/Add-whitelist-events.patch +++ b/patches/api/Add-whitelist-events.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -26,12 +27,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public class WhitelistStateUpdateEvent extends Event implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); -+ private boolean cancel = false; ++ + @NotNull private final PlayerProfile playerProfile; + @NotNull private final WhitelistStatus status; + -+ public WhitelistStateUpdateEvent(@NotNull PlayerProfile who, @NotNull WhitelistStatus status) { -+ this.playerProfile = who; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public WhitelistStateUpdateEvent(@NotNull PlayerProfile playerProfile, @NotNull WhitelistStatus status) { ++ this.playerProfile = playerProfile; + this.status = status; + } + @@ -42,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public OfflinePlayer getPlayer() { -+ return Bukkit.getOfflinePlayer(playerProfile.getId()); ++ return Bukkit.getOfflinePlayer(this.playerProfile.getId()); + } + + /** @@ -52,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PlayerProfile getPlayerProfile() { -+ return playerProfile; ++ return this.playerProfile; + } + + /** @@ -62,17 +66,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public WhitelistStatus getStatus() { -+ return status; ++ return this.status; + } + + @Override + public boolean isCancelled() { -+ return cancel; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @NotNull diff --git a/patches/api/Add-worldborder-events.patch b/patches/api/Add-worldborder-events.patch index 86953bb271..930584fce3 100644 --- a/patches/api/Add-worldborder-events.patch +++ b/patches/api/Add-worldborder-events.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.WorldBorder; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -31,6 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private long duration; + private boolean cancelled; + ++ @ApiStatus.Internal + public WorldBorderBoundsChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Type type, double oldSize, double newSize, long duration) { + super(world, worldBorder); + this.type = type; @@ -46,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Type getType() { -+ return type; ++ return this.type; + } + + /** @@ -55,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the old size + */ + public double getOldSize() { -+ return oldSize; ++ return this.oldSize; + } + + /** @@ -64,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the new size + */ + public double getNewSize() { -+ return newSize; ++ return this.newSize; + } + + /** @@ -73,8 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param newSize the new size + */ + public void setNewSize(double newSize) { -+ // PAIL: TODO: Magic Values -+ this.newSize = Math.min(6.0E7D, Math.max(1.0D, newSize)); ++ this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize)); + } + + /** @@ -83,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the time in milliseconds for the change + */ + public long getDuration() { -+ return duration; ++ return this.duration; + } + + /** @@ -95,12 +96,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setDuration(long duration) { + // PAIL: TODO: Magic Values + this.duration = Math.min(9223372036854775L, Math.max(0L, duration)); -+ if (duration >= 0 && type == Type.INSTANT_MOVE) type = Type.STARTED_MOVE; ++ if (duration >= 0 && this.type == Type.INSTANT_MOVE) { ++ this.type = Type.STARTED_MOVE; ++ } + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -135,6 +138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.World; +import org.bukkit.WorldBorder; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -148,6 +152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final double newSize; + private final double duration; + ++ @ApiStatus.Internal + public WorldBorderBoundsChangeFinishEvent(@NotNull World world, @NotNull WorldBorder worldBorder, double oldSize, double newSize, double duration) { + super(world, worldBorder); + this.oldSize = oldSize; @@ -161,7 +166,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the old size + */ + public double getOldSize() { -+ return oldSize; ++ return this.oldSize; + } + + /** @@ -170,18 +175,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the new size + */ + public double getNewSize() { -+ return newSize; ++ return this.newSize; + } + + /** + * Gets the duration this worldborder took to make the change. + *

      -+ * Can be 0 if handlers for {@link io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent} set the duration to 0. ++ * Can be 0 if handlers for {@link WorldBorderCenterChangeEvent} set the duration to 0. + * + * @return the duration of the transition + */ + public double getDuration() { -+ return duration; ++ return this.duration; + } + + @NotNull @@ -208,7 +213,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.WorldBorder; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; -+import org.bukkit.event.world.WorldEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -220,8 +225,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final Location oldCenter; + private Location newCenter; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public WorldBorderCenterChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Location oldCenter, @NotNull Location newCenter) { + super(world, worldBorder); + this.oldCenter = oldCenter; @@ -235,7 +242,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getOldCenter() { -+ return oldCenter; ++ return this.oldCenter; + } + + /** @@ -245,7 +252,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getNewCenter() { -+ return newCenter; ++ return this.newCenter; + } + + /** @@ -259,7 +266,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -288,21 +295,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.World; +import org.bukkit.WorldBorder; -+import org.bukkit.event.Cancellable; +import org.bukkit.event.world.WorldEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public abstract class WorldBorderEvent extends WorldEvent { + -+ private final WorldBorder worldBorder; ++ protected final WorldBorder worldBorder; + -+ public WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) { ++ @ApiStatus.Internal ++ protected WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) { + super(world); + this.worldBorder = worldBorder; + } + + @NotNull + public WorldBorder getWorldBorder() { -+ return worldBorder; ++ return this.worldBorder; + } +} diff --git a/patches/api/Added-EntityDamageItemEvent.patch b/patches/api/Added-EntityDamageItemEvent.patch index e638d2351c..f134d3993c 100644 --- a/patches/api/Added-EntityDamageItemEvent.patch +++ b/patches/api/Added-EntityDamageItemEvent.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -28,10 +29,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public class EntityDamageItemEvent extends EntityEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final ItemStack item; + private int damage; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public EntityDamageItemEvent(@NotNull Entity entity, @NotNull ItemStack item, int damage) { + super(entity); + this.item = item; @@ -45,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItem() { -+ return item; ++ return this.item; + } + + /** @@ -54,7 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return durability change + */ + public int getDamage() { -+ return damage; ++ return this.damage; + } + + /** @@ -68,12 +72,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull diff --git a/patches/api/Added-EntityToggleSitEvent.patch b/patches/api/Added-EntityToggleSitEvent.patch index 4e9afcb22f..624fed62fc 100644 --- a/patches/api/Added-EntityToggleSitEvent.patch +++ b/patches/api/Added-EntityToggleSitEvent.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -25,9 +26,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancelled; + private final boolean isSitting; ++ private boolean cancelled; + ++ @ApiStatus.Internal + public EntityToggleSitEvent(@NotNull Entity entity, boolean isSitting) { + super(entity); + this.isSitting = isSitting; diff --git a/patches/api/Added-PlayerBedFailEnterEvent.patch b/patches/api/Added-PlayerBedFailEnterEvent.patch index 9d604798ba..eff5f28a33 100644 --- a/patches/api/Added-PlayerBedFailEnterEvent.patch +++ b/patches/api/Added-PlayerBedFailEnterEvent.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -29,8 +30,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final Block bed; + private boolean willExplode; + private Component message; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerBedFailEnterEvent(@NotNull Player player, @NotNull FailReason failReason, @NotNull Block bed, boolean willExplode, @Nullable Component message) { + super(player); + this.failReason = failReason; @@ -41,16 +44,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public FailReason getFailReason() { -+ return failReason; ++ return this.failReason; + } + + @NotNull + public Block getBed() { -+ return bed; ++ return this.bed; + } + + public boolean getWillExplode() { -+ return willExplode; ++ return this.willExplode; + } + + public void setWillExplode(boolean willExplode) { @@ -59,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Nullable + public Component getMessage() { -+ return message; ++ return this.message; + } + + public void setMessage(@Nullable Component message) { @@ -68,19 +71,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** -+ * Cancel this event. ++ * {@inheritDoc} + *

      -+ * NOTE: This does not cancel the player getting in the bed, but any messages/explosions -+ * that may occur because of the interaction. -+ * @param cancel true if you wish to cancel this event ++ * NOTE: This does not cancel the player getting in the bed, but any messages/explosions ++ * that may occur because of the interaction. + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull @@ -94,7 +96,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return HANDLER_LIST; + } + -+ public static enum FailReason { ++ public enum FailReason { + /** + * The world doesn't allow sleeping (ex. Nether or The End). Entering + * the bed is prevented and the bed explodes. @@ -124,8 +126,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Entering the bed is prevented due to there being monsters nearby. + */ -+ NOT_SAFE; -+ -+ public static final FailReason[] VALUES = values(); ++ NOT_SAFE + } +} diff --git a/patches/api/Added-PlayerChangeBeaconEffectEvent.patch b/patches/api/Added-PlayerChangeBeaconEffectEvent.patch index 6fa051f11c..741e023b05 100644 --- a/patches/api/Added-PlayerChangeBeaconEffectEvent.patch +++ b/patches/api/Added-PlayerChangeBeaconEffectEvent.patch @@ -26,21 +26,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Called when a player sets the effect for a beacon + */ +public class PlayerChangeBeaconEffectEvent extends PlayerEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); + ++ private final Block beacon; + private PotionEffectType primary; + private PotionEffectType secondary; -+ private final Block beacon; + private boolean consumeItem = true; + -+ private boolean isCancelled; ++ private boolean cancelled; + + @ApiStatus.Internal + public PlayerChangeBeaconEffectEvent(@NotNull Player player, @Nullable PotionEffectType primary, @Nullable PotionEffectType secondary, @NotNull Block beacon) { + super(player); + this.primary = primary; + this.secondary = secondary; -+ this.isCancelled = false; + this.beacon = beacon; + } + @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the primary effect + */ + @Nullable public PotionEffectType getPrimary() { -+ return primary; ++ return this.primary; + } + + /** @@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the secondary effect + */ + @Nullable public PotionEffectType getSecondary() { -+ return secondary; ++ return this.secondary; + } + + /** @@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Block getBeacon() { -+ return beacon; ++ return this.beacon; + } + + /** @@ -95,10 +95,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Independent of {@link #isCancelled()}. If the event is cancelled + * the item will NOT be consumed. + * -+ * @return true if item will be consumed ++ * @return {@code true} if item will be consumed + */ + public boolean willConsumeItem() { -+ return consumeItem; ++ return this.consumeItem; + } + + /** @@ -107,40 +107,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Independent of {@link #isCancelled()}. If the event is cancelled + * the item will NOT be consumed. + * -+ * @param consumeItem true if item should be consumed ++ * @param consumeItem {@code true} if item should be consumed + */ + public void setConsumeItem(boolean consumeItem) { + this.consumeItem = consumeItem; + } + + /** -+ * Gets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins ++ * {@inheritDoc} + *

      + * If a {@link PlayerChangeBeaconEffectEvent} is cancelled, the changes will + * not take effect -+ * -+ * @return true if this event is cancelled + */ + @Override + public boolean isCancelled() { -+ return this.isCancelled; ++ return this.cancelled; + } + + /** -+ * Sets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins ++ * {@inheritDoc} + *

      + * If cancelled, the item will NOT be consumed regardless of what {@link #willConsumeItem()} says + *

      + * If a {@link PlayerChangeBeaconEffectEvent} is cancelled, the changes will not be applied + * or saved. -+ * -+ * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { -+ this.isCancelled = cancel; ++ this.cancelled = cancel; + } + + @Override diff --git a/patches/api/Added-PlayerDeepSleepEvent.patch b/patches/api/Added-PlayerDeepSleepEvent.patch index 37dc0ce4cf..c78c4cb01a 100644 --- a/patches/api/Added-PlayerDeepSleepEvent.patch +++ b/patches/api/Added-PlayerDeepSleepEvent.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -31,13 +32,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerDeepSleepEvent(@NotNull Player player) { + super(player); + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Added-PlayerLecternPageChangeEvent.patch b/patches/api/Added-PlayerLecternPageChangeEvent.patch index 6028a7e2bf..13507005bc 100644 --- a/patches/api/Added-PlayerLecternPageChangeEvent.patch +++ b/patches/api/Added-PlayerLecternPageChangeEvent.patch @@ -18,20 +18,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; + +public class PlayerLecternPageChangeEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancelled; + private final Lectern lectern; + private final ItemStack book; + private final PageChangeDirection pageChangeDirection; + private final int oldPage; + private int newPage; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerLecternPageChangeEvent(@NotNull Player player, @NotNull Lectern lectern, @NotNull ItemStack book, @NotNull PageChangeDirection pageChangeDirection, int oldPage, int newPage) { + super(player); + this.lectern = lectern; @@ -48,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Lectern getLectern() { -+ return lectern; ++ return this.lectern; + } + + /** @@ -68,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PageChangeDirection getPageChangeDirection() { -+ return pageChangeDirection; ++ return this.pageChangeDirection; + } + + /** @@ -77,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the page changed from + */ + public int getOldPage() { -+ return oldPage; ++ return this.oldPage; + } + + /** @@ -86,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the page changed to + */ + public int getNewPage() { -+ return newPage; ++ return this.newPage; + } + + /** @@ -101,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Added-PlayerLoomPatternSelectEvent.patch b/patches/api/Added-PlayerLoomPatternSelectEvent.patch index b9236806c2..956b2b6ba1 100644 --- a/patches/api/Added-PlayerLoomPatternSelectEvent.patch +++ b/patches/api/Added-PlayerLoomPatternSelectEvent.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.LoomInventory; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -27,10 +28,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancelled; + private final LoomInventory loomInventory; + private PatternType patternType; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerLoomPatternSelectEvent(@NotNull Player player, @NotNull LoomInventory loomInventory, @NotNull PatternType patternType) { + super(player); + this.loomInventory = loomInventory; @@ -44,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public LoomInventory getLoomInventory() { -+ return loomInventory; ++ return this.loomInventory; + } + + /** @@ -54,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PatternType getPatternType() { -+ return patternType; ++ return this.patternType; + } + + /** @@ -68,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Added-PlayerStonecutterRecipeSelectEvent.patch b/patches/api/Added-PlayerStonecutterRecipeSelectEvent.patch index 9fda4e2755..2ec5bdb075 100644 --- a/patches/api/Added-PlayerStonecutterRecipeSelectEvent.patch +++ b/patches/api/Added-PlayerStonecutterRecipeSelectEvent.patch @@ -24,10 +24,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancelled; + private final StonecutterInventory stonecutterInventory; + private StonecuttingRecipe stonecuttingRecipe; + ++ private boolean cancelled; ++ + public PlayerStonecutterRecipeSelectEvent(@NotNull Player player, @NotNull StonecutterInventory stonecutterInventory, @NotNull StonecuttingRecipe stonecuttingRecipe) { + super(player); + this.stonecutterInventory = stonecutterInventory; @@ -36,12 +37,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public StonecutterInventory getStonecutterInventory() { -+ return stonecutterInventory; ++ return this.stonecutterInventory; + } + + @NotNull + public StonecuttingRecipe getStonecuttingRecipe() { -+ return stonecuttingRecipe; ++ return this.stonecuttingRecipe; + } + + public void setStonecuttingRecipe(@NotNull StonecuttingRecipe stonecuttingRecipe) { @@ -50,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Added-PlayerTradeEvent.patch b/patches/api/Added-PlayerTradeEvent.patch index 470a0a1017..d8ca8fafc3 100644 --- a/patches/api/Added-PlayerTradeEvent.patch +++ b/patches/api/Added-PlayerTradeEvent.patch @@ -19,30 +19,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.event.player; + -+import java.util.Objects; ++import com.google.common.base.Preconditions; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.MerchantRecipe; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a player trades with a standalone merchant GUI. + */ +public class PlayerPurchaseEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; + -+ private boolean increaseTradeUses; ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private boolean rewardExp; ++ private boolean increaseTradeUses; + private MerchantRecipe trade; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerPurchaseEvent(@NotNull Player player, + @NotNull MerchantRecipe trade, + boolean rewardExp, + boolean increaseTradeUses) { -+ super(Objects.requireNonNull(player, "Player cannot be null!")); ++ super(player); + setTrade(trade); + this.rewardExp = rewardExp; + this.increaseTradeUses = increaseTradeUses; @@ -50,6 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the associated trade with this event ++ * + * @return the trade + */ + @NotNull @@ -59,10 +64,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Sets the trade. This is then used to determine the next prices ++ * + * @param trade the trade to use + */ + public void setTrade(@NotNull MerchantRecipe trade) { -+ this.trade = Objects.requireNonNull(trade, "Trade cannot be null!"); ++ Preconditions.checkArgument(trade != null, "Trade cannot be null!"); ++ this.trade = trade; + } + + /** @@ -74,6 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Sets whether the trade will try to reward exp ++ * + * @param rewardExp try to reward exp + */ + public void setRewardExp(boolean rewardExp) { @@ -81,37 +89,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * @return whether or not the trade will count as a use of the trade ++ * @return whether the trade will count as a use of the trade + */ + public boolean willIncreaseTradeUses() { + return this.increaseTradeUses; + } + + /** -+ * Sets whether or not the trade will count as a use -+ * @param increaseTradeUses true to count/false to not count ++ * Sets whether the trade will count as a use ++ * ++ * @param increaseTradeUses {@code true} to count, {@code false} otherwise + */ + public void setIncreaseTradeUses(boolean increaseTradeUses) { + this.increaseTradeUses = increaseTradeUses; + } + -+ /** -+ * Gets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins -+ * -+ * @return true if this event is cancelled -+ */ + @Override + public boolean isCancelled() { + return this.cancelled; + } + -+ /** -+ * Sets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins. -+ * -+ * @param cancel true if you wish to cancel this event -+ */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; @@ -120,12 +117,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } + +} @@ -140,6 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.AbstractVillager; +import org.bukkit.entity.Player; +import org.bukkit.inventory.MerchantRecipe; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -149,6 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final AbstractVillager villager; + ++ @ApiStatus.Internal + public PlayerTradeEvent(@NotNull Player player, @NotNull AbstractVillager villager, @NotNull MerchantRecipe trade, boolean rewardExp, boolean increaseTradeUses) { + super(player, trade, rewardExp, increaseTradeUses); + this.villager = villager; @@ -156,6 +155,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the Villager or Wandering trader associated with this event ++ * + * @return the villager or wandering trader + */ + @NotNull diff --git a/patches/api/Added-ServerResourcesReloadedEvent.patch b/patches/api/Added-ServerResourcesReloadedEvent.patch index f1ca58f47d..517a5e74e0 100644 --- a/patches/api/Added-ServerResourcesReloadedEvent.patch +++ b/patches/api/Added-ServerResourcesReloadedEvent.patch @@ -14,13 +14,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.event.HandlerList; +import org.bukkit.event.server.ServerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when resources such as datapacks are reloaded (e.g. /minecraft:reload) + *

      -+ * 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. + */ +public class ServerResourcesReloadedEvent extends ServerEvent { + @@ -28,6 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final Cause cause; + ++ @ApiStatus.Internal + public ServerResourcesReloadedEvent(@NotNull Cause cause) { + this.cause = cause; + } @@ -39,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Cause getCause() { -+ return cause; ++ return this.cause; + } + + @NotNull diff --git a/patches/api/Added-WorldGameRuleChangeEvent.patch b/patches/api/Added-WorldGameRuleChangeEvent.patch index ca63f0abfd..3164c0d828 100644 --- a/patches/api/Added-WorldGameRuleChangeEvent.patch +++ b/patches/api/Added-WorldGameRuleChangeEvent.patch @@ -15,10 +15,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.GameRule; +import org.bukkit.World; +import org.bukkit.command.CommandSender; -+import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.world.WorldEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -34,6 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private String value; + private boolean cancelled; + ++ @ApiStatus.Internal + public WorldGameRuleChangeEvent(@NotNull World world, @Nullable CommandSender commandSender, @NotNull GameRule gameRule, @NotNull String value) { + super(world); + this.commandSender = commandSender; @@ -48,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Nullable + public CommandSender getCommandSender() { -+ return commandSender; ++ return this.commandSender; + } + + /** @@ -58,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public GameRule getGameRule() { -+ return gameRule; ++ return this.gameRule; + } + + /** @@ -68,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public String getValue() { -+ return value; ++ return this.value; + } + + /** @@ -82,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override diff --git a/patches/api/Adds-PlayerArmSwingEvent.patch b/patches/api/Adds-PlayerArmSwingEvent.patch index 996d15175a..a2a4d7f1e0 100644 --- a/patches/api/Adds-PlayerArmSwingEvent.patch +++ b/patches/api/Adds-PlayerArmSwingEvent.patch @@ -16,12 +16,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.player.PlayerAnimationEvent; +import org.bukkit.event.player.PlayerAnimationType; +import org.bukkit.inventory.EquipmentSlot; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public class PlayerArmSwingEvent extends PlayerAnimationEvent { + + private final EquipmentSlot equipmentSlot; + ++ @ApiStatus.Internal + public PlayerArmSwingEvent(@NotNull Player player, @NotNull EquipmentSlot equipmentSlot) { + super(player, equipmentSlot == EquipmentSlot.HAND ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING); + this.equipmentSlot = equipmentSlot; diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 2175563f9a..a5346cde98 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -231,12 +231,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@ApiStatus.NonExtendable +public abstract class AbstractChatEvent extends PlayerEvent implements Cancellable { ++ + private final Set viewers; + private final Component originalMessage; + private final SignedMessage signedMessage; + private ChatRenderer renderer; + private Component message; -+ private boolean cancelled = false; ++ ++ private boolean cancelled; + + AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + super(player, async); @@ -331,8 +333,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public final void setCancelled(final boolean cancelled) { -+ this.cancelled = cancelled; ++ public final void setCancelled(final boolean cancel) { ++ this.cancelled = cancel; + } +} diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java @@ -381,6 +383,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; ++import org.bukkit.event.player.AsyncPlayerChatPreviewEvent; +import org.bukkit.event.server.ServerEvent; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; @@ -393,7 +396,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * message here, and use the chat events for modifying receivers and later the chat type. If you + * want to keep the message as "signed" for the clients who get it, be sure to include the entire + * original message somewhere in the final message. -+ * @see AsyncChatCommandDecorateEvent for the decoration of messages sent via commands ++ *
      ++ * See {@link AsyncChatCommandDecorateEvent} for the decoration of messages sent via commands + */ +@ApiStatus.Experimental +public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable { @@ -403,6 +407,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final Player player; + private final Component originalMessage; + private Component result; ++ + private boolean cancelled; + + @ApiStatus.Internal @@ -419,7 +424,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Certain commands request decorations without a player context + * which is why this is possibly null. + * -+ * @return the player or null ++ * @return the player or {@code null} + */ + public @Nullable Player player() { + return this.player; @@ -437,7 +442,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Gets the decoration result. This may already be different from + * {@link #originalMessage()} if some other listener to this event -+ * OR the legacy preview event ({@link org.bukkit.event.player.AsyncPlayerChatPreviewEvent} ++ * OR the legacy preview event ({@link AsyncPlayerChatPreviewEvent}) + * changed the result. + * + * @return the result @@ -458,10 +463,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * If this decorating is part of a preview request/response. + * -+ * @return true if part of previewing ++ * @return {@code true} if part of previewing + * @deprecated chat preview was removed in 1.19.3 + */ -+ @Deprecated(forRemoval = true) ++ @Deprecated(forRemoval = true, since = "1.19.3") + @ApiStatus.ScheduledForRemoval(inVersion = "1.21") + @Contract(value = "-> false", pure = true) + public boolean isPreview() { @@ -524,11 +529,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * appropriately. + */ +public final class AsyncChatEvent extends AbstractChatEvent { -+ private static final HandlerList HANDLERS = new HandlerList(); + -+ /** -+ * @param viewers A mutable set of viewers -+ */ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @ApiStatus.Internal + public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + super(async, player, viewers, renderer, message, originalMessage, signedMessage); @@ -537,12 +540,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/io/papermc/paper/event/player/ChatEvent.java b/src/main/java/io/papermc/paper/event/player/ChatEvent.java @@ -567,16 +570,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +/** + * An event fired when a {@link Player} sends a chat message to the server. + * -+ * @deprecated Listening to this event forces chat to wait for the main thread, delaying chat messages. It is recommended to use {@link AsyncChatEvent} instead, wherever possible. ++ * @deprecated Listening to this event forces chat to wait for the main thread, delaying chat messages. ++ * It is recommended to use {@link AsyncChatEvent} instead, wherever possible. + */ +@Deprecated +@Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.") +public final class ChatEvent extends AbstractChatEvent { -+ private static final HandlerList HANDLERS = new HandlerList(); + -+ /** -+ * @param viewers A mutable set of viewers -+ */ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @ApiStatus.Internal + public ChatEvent(final @NotNull Player player, final @NotNull Set viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + super(false, player, viewers, renderer, message, originalMessage, signedMessage); @@ -585,12 +587,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return HANDLERS; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return HANDLERS; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/io/papermc/paper/text/PaperComponents.java b/src/main/java/io/papermc/paper/text/PaperComponents.java diff --git a/patches/api/AnvilDamageEvent.patch b/patches/api/AnvilDamageEvent.patch index 1131b72c08..24896322f5 100644 --- a/patches/api/AnvilDamageEvent.patch +++ b/patches/api/AnvilDamageEvent.patch @@ -27,10 +27,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Called when an anvil is damaged from being used + */ +public class AnvilDamagedEvent extends InventoryEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private boolean cancel; + private DamageState damageState; ++ private boolean cancelled; + + @ApiStatus.Internal + public AnvilDamagedEvent(@NotNull InventoryView inventory, @Nullable BlockData blockData) { @@ -51,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public DamageState getDamageState() { -+ return damageState; ++ return this.damageState; + } + + /** @@ -66,31 +67,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Gets if anvil is breaking on this use + * -+ * @return True if breaking ++ * @return {@code true} if breaking + */ + public boolean isBreaking() { -+ return damageState == DamageState.BROKEN; ++ return this.damageState == DamageState.BROKEN; + } + + /** + * Sets if anvil is breaking on this use + * -+ * @param breaking True if breaking ++ * @param breaking {@code true} if breaking + */ + public void setBreaking(boolean breaking) { + if (breaking) { -+ damageState = DamageState.BROKEN; -+ } else if (damageState == DamageState.BROKEN) { -+ damageState = DamageState.DAMAGED; ++ this.damageState = DamageState.BROKEN; ++ } else if (this.damageState == DamageState.BROKEN) { ++ this.damageState = DamageState.DAMAGED; + } + } + ++ @Override + public boolean isCancelled() { -+ return cancel; ++ return this.cancelled; + } + ++ @Override + public void setCancelled(boolean cancel) { -+ this.cancel = cancel; ++ this.cancelled = cancel; + } + + @NotNull @@ -125,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Material getMaterial() { -+ return material; ++ return this.material; + } + + /** @@ -153,7 +156,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return BROKEN; + } + for (DamageState state : values()) { -+ if (state.material == material) { ++ if (state.getMaterial() == material) { + return state; + } + } diff --git a/patches/api/AsyncTabCompleteEvent.patch b/patches/api/AsyncTabCompleteEvent.patch index 4b2f4d8c03..f3ff39f75e 100644 --- a/patches/api/AsyncTabCompleteEvent.patch +++ b/patches/api/AsyncTabCompleteEvent.patch @@ -59,47 +59,57 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +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.NotNull; +import org.jetbrains.annotations.Nullable; + +/** -+ * Allows plugins to compute tab completion results asynchronously. If this event provides completions, then the standard synchronous process will not be fired to populate the results. However, the synchronous TabCompleteEvent will fire with the Async results. -+ * ++ * Allows plugins to compute tab completion results asynchronously. ++ *

      ++ * If this event provides completions, then the standard synchronous process ++ * will not be fired to populate the results. ++ * However, the synchronous TabCompleteEvent will fire with the Async results. ++ *

      + * Only 1 process will be allowed to provide completions, the Async Event, or the standard process. + */ +public class AsyncTabCompleteEvent extends Event implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final CommandSender sender; + @NotNull private final String buffer; + private final boolean isCommand; + @Nullable -+ private final Location loc; ++ private final Location location; + private final List completions = new ArrayList<>(); + private final List stringCompletions = new TransformingRandomAccessList<>( + this.completions, + Completion::suggestion, + Completion::completion + ); ++ private boolean handled; + private boolean cancelled; -+ private boolean handled = false; -+ private boolean fireSyncHandler = true; + ++ @ApiStatus.Internal + public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, boolean isCommand, @Nullable Location loc) { + super(true); + this.sender = sender; + this.buffer = buffer; + this.isCommand = isCommand; -+ this.loc = loc; ++ this.location = loc; + } + + @Deprecated ++ @ApiStatus.Internal + public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull List completions, @NotNull String buffer, boolean isCommand, @Nullable Location loc) { + super(true); + this.sender = sender; + this.completions.addAll(fromStrings(completions)); + this.buffer = buffer; + this.isCommand = isCommand; -+ this.loc = loc; ++ this.location = loc; + } + + /** @@ -109,13 +119,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public CommandSender getSender() { -+ return sender; ++ return this.sender; + } + + /** + * The list of completions which will be offered to the sender, in order. + * This list is mutable and reflects what will be offered. -+ * ++ *

      + * If this collection is not empty after the event is fired, then + * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * or current player names will not be called. @@ -132,16 +142,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * If this collection is not empty after the event is fired, then + * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * or current player names will not be called. -+ * -+ * The passed collection will be cloned to a new List. You must call {{@link #getCompletions()}} to mutate from here ++ *

      ++ * The passed collection will be cloned to a new {@code List}. You must call {{@link #getCompletions()}} to mutate from here + * + * @param completions the new completions + */ + public void setCompletions(@NotNull List completions) { ++ Preconditions.checkArgument(completions != null, "Completions list cannot be null"); + if (completions == this.stringCompletions) { + return; + } -+ Preconditions.checkNotNull(completions); + this.completions.clear(); + this.completions.addAll(fromStrings(completions)); + } @@ -166,12 +176,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * or current player names will not be called. + *

      -+ * The passed collection will be cloned to a new List. You must call {{@link #completions()}} to mutate from here ++ * The passed collection will be cloned to a new {@code List}. You must call {@link #completions()} to mutate from here + * + * @param newCompletions the new completions + */ + public void completions(final @NotNull List newCompletions) { -+ Preconditions.checkNotNull(newCompletions, "new completions"); ++ Preconditions.checkArgument(newCompletions != null, "new completions cannot be null"); + this.completions.clear(); + this.completions.addAll(newCompletions); + } @@ -183,37 +193,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public String getBuffer() { -+ return buffer; ++ return this.buffer; + } + + /** -+ * @return True if it is a command being tab completed, false if it is a chat message. ++ * @return {@code true} if it is a command being tab completed, {@code false} if it is a chat message. + */ + public boolean isCommand() { -+ return isCommand; ++ return this.isCommand; + } + + /** -+ * @return The position looked at by the sender, or null if none ++ * @return The position looked at by the sender, or {@code null} if none + */ + @Nullable + public Location getLocation() { -+ return loc; ++ return this.location; + } + + /** -+ * If true, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} ++ * If {@code true}, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * or current player names will not be called. + * -+ * @return Is completions considered handled. Always true if completions is not empty. ++ * @return Is completions considered handled. Always {@code true} if completions is not empty. + */ + public boolean isHandled() { -+ return !completions.isEmpty() || handled; ++ return !this.completions.isEmpty() || this.handled; + } + + /** -+ * Sets whether or not to consider the completion request handled. -+ * If true, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} ++ * Sets whether to consider the completion request handled. ++ * If {@code true}, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * or current player names will not be called. + * + * @param handled if this completion should be marked as being handled @@ -222,37 +232,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.handled = handled; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** ++ * {@inheritDoc} ++ *
      + * Will provide no completions, and will not fire the synchronous process -+ * @param cancelled true if you wish to cancel this event + */ + @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } + -+ private static @NotNull List fromStrings(final @NotNull List strings) { -+ final List list = new ArrayList<>(); -+ for (final String it : strings) { -+ list.add(new CompletionImpl(it, null)); ++ private static @NotNull List fromStrings(final @NotNull List suggestions) { ++ final List list = new ArrayList<>(suggestions.size()); ++ for (final String suggestion : suggestions) { ++ list.add(new CompletionImpl(suggestion, null)); + } + return list; + } @@ -261,6 +269,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * A rich tab completion, consisting of a string suggestion, and a nullable {@link Component} tooltip. + */ + public interface Completion extends Examinable { ++ + /** + * Get the suggestion string for this {@link Completion}. + * @@ -292,11 +301,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Create a new {@link Completion} from a suggestion string and a tooltip {@link Component}. -+ * -+ *

      If the provided component is null, the suggestion will not have a tooltip.

      ++ *

      ++ * If the provided component is {@code null}, the suggestion will not have a tooltip. + * + * @param suggestion suggestion string -+ * @param tooltip tooltip component, or null ++ * @param tooltip tooltip component, or {@code null} + * @return new completion instance + */ + static @NotNull Completion completion(final @NotNull String suggestion, final @Nullable Component tooltip) { @@ -304,7 +313,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + ++ @ApiStatus.Internal + static final class CompletionImpl implements Completion { ++ + private final String suggestion; + private final Component tooltip; + @@ -333,12 +344,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + final CompletionImpl that = (CompletionImpl) o; + return this.suggestion.equals(that.suggestion) -+ && java.util.Objects.equals(this.tooltip, that.tooltip); ++ && Objects.equals(this.tooltip, that.tooltip); + } + + @Override + public int hashCode() { -+ return java.util.Objects.hash(this.suggestion, this.tooltip); ++ return Objects.hash(this.suggestion, this.tooltip); + } + + @Override diff --git a/patches/api/BlockDestroyEvent.patch b/patches/api/BlockDestroyEvent.patch index 633e43e137..b34e128ad2 100644 --- a/patches/api/BlockDestroyEvent.patch +++ b/patches/api/BlockDestroyEvent.patch @@ -30,23 +30,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Fired anytime the server intends to 'destroy' a block through some triggering reason. + * This does not fire anytime a block is set to air, but only with more direct triggers such + * as physics updates, pistons, Entities changing blocks, commands set to "Destroy". -+ * ++ *

      + * This event is associated with the game playing a sound effect at the block in question, when + * something can be described as "intend to destroy what is there", -+ * ++ *

      + * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event. -+ * + */ +public class BlockDestroyEvent extends BlockExpEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + @NotNull private final BlockData newState; + private boolean willDrop; + private boolean playEffect = true; + private BlockData effectBlock; + -+ private boolean cancelled = false; ++ private boolean cancelled; + + @ApiStatus.Internal + public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, int xp, boolean willDrop) { @@ -58,6 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Get the effect that will be played when the block is broken. ++ * + * @return block break effect + */ + @NotNull @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Sets the effect that will be played when the block is broken. -+ * Note: {@link BlockDestroyEvent#playEffect()} must be true in order for this effect to be ++ * Note: {@link BlockDestroyEvent#playEffect()} must be {@code true} in order for this effect to be + * played. + * + * @param effectBlock block effect @@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public BlockData getNewState() { -+ return newState; ++ return this.newState; + } + + /** @@ -117,25 +117,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** + * If the event is cancelled, the block will remain in its previous state. -+ * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull ++ @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/EnderDragon-Events.patch b/patches/api/EnderDragon-Events.patch index f06e078d8b..5ee4c46487 100644 --- a/patches/api/EnderDragon-Events.patch +++ b/patches/api/EnderDragon-Events.patch @@ -27,11 +27,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud + */ +public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable { ++ + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @NotNull private final Collection targets; + @NotNull private final AreaEffectCloud areaEffectCloud; -+ private boolean cancelled = false; ++ private boolean cancelled; + + @ApiStatus.Internal + public EnderDragonFireballHitEvent(@NotNull DragonFireball fireball, @NotNull Collection targets, @NotNull AreaEffectCloud areaEffectCloud) { @@ -56,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Collection getTargets() { -+ return targets; ++ return this.targets; + } + + /** @@ -64,20 +65,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public AreaEffectCloud getAreaEffectCloud() { -+ return areaEffectCloud; ++ return this.areaEffectCloud; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull ++ @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } @@ -100,14 +102,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames + */ +public class EnderDragonFlameEvent extends EntityEvent implements Cancellable { -+ @NotNull private final AreaEffectCloud areaEffectCloud; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final AreaEffectCloud areaEffectCloud; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EnderDragonFlameEvent(@NotNull EnderDragon enderDragon, @NotNull AreaEffectCloud areaEffectCloud) { + super(enderDragon); + this.areaEffectCloud = areaEffectCloud; @@ -127,31 +135,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public AreaEffectCloud getAreaEffectCloud() { -+ return areaEffectCloud; ++ return this.areaEffectCloud; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java @@ -167,14 +171,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when an EnderDragon shoots a fireball + */ +public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable { -+ @NotNull private final DragonFireball fireball; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final DragonFireball fireball; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EnderDragonShootFireballEvent(@NotNull EnderDragon entity, @NotNull DragonFireball fireball) { + super(entity); + this.fireball = fireball; @@ -194,30 +204,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public DragonFireball getFireball() { -+ return fireball; ++ return this.fireball; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/EndermanAttackPlayerEvent.patch b/patches/api/EndermanAttackPlayerEvent.patch index 886f3e8840..0edc9366af 100644 --- a/patches/api/EndermanAttackPlayerEvent.patch +++ b/patches/api/EndermanAttackPlayerEvent.patch @@ -39,23 +39,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.event.entity; + +import org.bukkit.entity.Enderman; -+import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when an Enderman determines if it should attack a player or not. ++ *

      + * Starts off cancelled if the player is wearing a pumpkin head or is not looking + * at the Enderman, according to Vanilla rules. -+ * + */ +public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable { -+ @NotNull private final Player player; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final Player player; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EndermanAttackPlayerEvent(@NotNull Enderman entity, @NotNull Player player) { + super(entity); + this.player = player; @@ -79,38 +83,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Player getPlayer() { -+ return player; ++ return this.player; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + /** -+ * + * @return If cancelled, the enderman will not attack + */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** ++ * {@inheritDoc} ++ *
      + * Cancels if the Enderman will attack this player -+ * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/EndermanEscapeEvent.patch b/patches/api/EndermanEscapeEvent.patch index aac4ab511d..69c3cb2549 100644 --- a/patches/api/EndermanEscapeEvent.patch +++ b/patches/api/EndermanEscapeEvent.patch @@ -16,16 +16,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.event.entity; + +import org.bukkit.entity.Enderman; -+import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public class EndermanEscapeEvent extends EntityEvent implements Cancellable { -+ @NotNull private final Reason reason; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final Reason reason; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EndermanEscapeEvent(@NotNull Enderman entity, @NotNull Reason reason) { + super(entity); + this.reason = reason; @@ -42,39 +46,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Reason getReason() { -+ return reason; ++ return this.reason; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** + * Cancels the escape. -+ * ++ *

      + * If this escape normally would of resulted in damage avoidance such as indirect, + * the enderman will now take damage. -+ * -+ * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } + + public enum Reason { @@ -95,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + STARE, + /** -+ * Specific case for CRITICAL_HIT where the enderman is taking rain damage ++ * Specific case for {@link #CRITICAL_HIT} where the enderman is taking rain damage + */ + DROWN + } diff --git a/patches/api/Entity-AddTo-RemoveFrom-World-Events.patch b/patches/api/Entity-AddTo-RemoveFrom-World-Events.patch index bbc34a5062..b8d176441e 100644 --- a/patches/api/Entity-AddTo-RemoveFrom-World-Events.patch +++ b/patches/api/Entity-AddTo-RemoveFrom-World-Events.patch @@ -15,17 +15,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired any time an entity is being added to the world for any reason (including a chunk loading). -+ * -+ * Not to be confused with {@link org.bukkit.event.entity.CreatureSpawnEvent} ++ *

      ++ * Not to be confused with {@link CreatureSpawnEvent} + */ +public class EntityAddToWorldEvent extends EntityEvent { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final World world; + ++ @ApiStatus.Internal + public EntityAddToWorldEvent(@NotNull Entity entity, @NotNull World world) { + super(entity); + this.world = world; @@ -36,19 +42,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public World getWorld() { -+ return world; ++ return this.world; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java @@ -63,6 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -70,8 +75,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}. + */ +public class EntityRemoveFromWorldEvent extends EntityEvent { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final World world; + ++ @ApiStatus.Internal + public EntityRemoveFromWorldEvent(@NotNull Entity entity, @NotNull World world) { + super(entity); + this.world = world; @@ -82,18 +91,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public World getWorld() { -+ return world; ++ return this.world; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Entity-Jump-API.patch b/patches/api/Entity-Jump-API.patch index 818e31d486..28f3c16563 100644 --- a/patches/api/Entity-Jump-API.patch +++ b/patches/api/Entity-Jump-API.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -24,9 +25,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Cancelling the event will stop the entity from jumping + */ +public class EntityJumpEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean canceled; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EntityJumpEvent(@NotNull LivingEntity entity) { + super(entity); + } @@ -34,26 +38,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public LivingEntity getEntity() { -+ return (LivingEntity) entity; ++ return (LivingEntity) super.getEntity(); + } + + public boolean isCancelled() { -+ return canceled; ++ return this.cancelled; + } + + public void setCancelled(boolean cancel) { -+ canceled = cancel; ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/patches/api/EntityMoveEvent.patch b/patches/api/EntityMoveEvent.patch index c3bedb31d4..93a4bcba4e 100644 --- a/patches/api/EntityMoveEvent.patch +++ b/patches/api/EntityMoveEvent.patch @@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.player.PlayerMoveEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -27,11 +28,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Does not fire for players; use {@link PlayerMoveEvent} for player movement. + */ +public class EntityMoveEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean canceled; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private Location from; + private Location to; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public EntityMoveEvent(@NotNull LivingEntity entity, @NotNull Location from, @NotNull Location to) { + super(entity); + this.from = from; @@ -41,15 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + @NotNull + public LivingEntity getEntity() { -+ return (LivingEntity) entity; -+ } -+ -+ public boolean isCancelled() { -+ return canceled; -+ } -+ -+ public void setCancelled(boolean cancel) { -+ canceled = cancel; ++ return (LivingEntity) super.getEntity(); + } + + /** @@ -59,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getFrom() { -+ return from; ++ return this.from; + } + + /** @@ -79,7 +76,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getTo() { -+ return to; ++ return this.to; + } + + /** @@ -98,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return whether the entity has changed position or not + */ + public boolean hasChangedPosition() { -+ return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld()); ++ return hasExplicitlyChangedPosition() || !this.from.getWorld().equals(this.to.getWorld()); + } + + /** @@ -107,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return whether the entity has changed position or not + */ + public boolean hasExplicitlyChangedPosition() { -+ return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ(); ++ return this.from.getX() != this.to.getX() || this.from.getY() != this.to.getY() || this.from.getZ() != this.to.getZ(); + } + + /** @@ -125,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return whether the entity has moved to a new block or not + */ + public boolean hasExplicitlyChangedBlock() { -+ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ(); ++ return this.from.getBlockX() != this.to.getBlockX() || this.from.getBlockY() != this.to.getBlockY() || this.from.getBlockZ() != this.to.getBlockZ(); + } + + /** @@ -134,7 +131,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return whether the entity has changed orientation or not + */ + public boolean hasChangedOrientation() { -+ return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw(); ++ return this.from.getPitch() != this.to.getPitch() || this.from.getYaw() != this.to.getYaw(); + } + + private void validateLocation(@NotNull Location loc) { @@ -143,13 +140,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @Override + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/EntityPathfindEvent.patch b/patches/api/EntityPathfindEvent.patch index 99c4df9cbb..ebbdee4fd7 100644 --- a/patches/api/EntityPathfindEvent.patch +++ b/patches/api/EntityPathfindEvent.patch @@ -18,78 +18,83 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Fired when an Entity decides to start moving towards a location. -+ * ++ *

      + * This event does not fire for the entities actual movement. Only when it + * is choosing to start moving to a location. + */ +public class EntityPathfindEvent extends EntityEvent implements Cancellable { -+ @Nullable private final Entity targetEntity; -+ @NotNull private final Location loc; + -+ public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location loc, @Nullable Entity targetEntity) { ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @Nullable private final Entity targetEntity; ++ @NotNull private final Location location; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location location, @Nullable Entity targetEntity) { + super(entity); + this.targetEntity = targetEntity; -+ this.loc = loc; ++ this.location = location; + } + + /** + * The Entity that is pathfinding. ++ * + * @return The Entity that is pathfinding. + */ + @NotNull + public Entity getEntity() { -+ return entity; ++ return this.entity; + } + + /** + * If the Entity is trying to pathfind to an entity, this is the entity in relation. ++ *
      ++ * Otherwise this will return {@code null}. + * -+ * Otherwise this will return null. -+ * -+ * @return The entity target or null ++ * @return The entity target or {@code null} + */ + @Nullable + public Entity getTargetEntity() { -+ return targetEntity; ++ return this.targetEntity; + } + + /** + * The Location of where the entity is about to move to. -+ * ++ *
      + * Note that if the target happened to of been an entity ++ * + * @return Location of where the entity is trying to pathfind to. + */ + @NotNull + public Location getLoc() { -+ return loc; ++ return this.location; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/EntityTransformedEvent.patch b/patches/api/EntityTransformedEvent.patch index 6f77d2918d..e2d6c4a4fa 100644 --- a/patches/api/EntityTransformedEvent.patch +++ b/patches/api/EntityTransformedEvent.patch @@ -12,28 +12,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.entity; + -+ +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; -+import org.bukkit.event.entity.EntityTransformEvent; +import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; + +/** + * Fired when an entity transforms into another entity + *

      + * If the event is cancelled, the entity will not transform -+ * @deprecated Bukkit has added {@link EntityTransformEvent}, you should start using that ++ * ++ * @deprecated Bukkit has added {@link org.bukkit.event.entity.EntityTransformEvent}, you should start using that + */ +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +public class EntityTransformedEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Entity transformed; + private final TransformedReason reason; + -+ public EntityTransformedEvent(Entity entity, Entity transformed, TransformedReason reason) { ++ private boolean cancelled; ++ ++ @ApiStatus.Internal ++ public EntityTransformedEvent(@NotNull Entity entity, @NotNull Entity transformed, @NotNull TransformedReason reason) { + super(entity); + this.transformed = transformed; + this.reason = reason; @@ -43,40 +47,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * The entity after it has transformed + * + * @return Transformed entity -+ * @deprecated see {@link EntityTransformEvent#getTransformedEntity()} + */ -+ @Deprecated ++ @NotNull + public Entity getTransformed() { -+ return transformed; ++ return this.transformed; + } + + /** + * @return The reason for the transformation -+ * @deprecated see {@link EntityTransformEvent#getTransformReason()} + */ -+ @Deprecated ++ @NotNull + public TransformedReason getReason() { -+ return reason; -+ } -+ -+ -+ @Override -+ public HandlerList getHandlers(){ -+ return handlers; -+ } -+ -+ public static HandlerList getHandlerList(){ -+ return handlers; ++ return this.reason; + } + + @Override + public boolean isCancelled(){ -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel){ -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @Override ++ @NotNull ++ public HandlerList getHandlers(){ ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList(){ ++ return HANDLER_LIST; + } + + public enum TransformedReason { @@ -97,9 +100,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + SHEARED, + /** -+ * When a pig turns to a zombiepigman ++ * When a pig turns to a zombified piglin + */ + LIGHTNING -+ + } +} diff --git a/patches/api/ExperienceOrbMergeEvent.patch b/patches/api/ExperienceOrbMergeEvent.patch index 7d9efedf8e..d3ac57a57c 100644 --- a/patches/api/ExperienceOrbMergeEvent.patch +++ b/patches/api/ExperienceOrbMergeEvent.patch @@ -42,15 +42,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired anytime the server is about to merge 2 experience orbs into one + */ +public class ExperienceOrbMergeEvent extends EntityEvent implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final ExperienceOrb mergeTarget; + @NotNull private final ExperienceOrb mergeSource; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public ExperienceOrbMergeEvent(@NotNull ExperienceOrb mergeTarget, @NotNull ExperienceOrb mergeSource) { + super(mergeTarget); + this.mergeTarget = mergeTarget; @@ -62,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ExperienceOrb getMergeTarget() { -+ return mergeTarget; ++ return this.mergeTarget; + } + + /** @@ -70,33 +77,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ExperienceOrb getMergeSource() { -+ return mergeSource; ++ return this.mergeSource; + } + -+ private static final HandlerList handlers = new HandlerList(); ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ /** ++ * @param cancel {@code true} if you wish to cancel this event, and prevent the orbs from merging ++ */ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } + + @NotNull ++ @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ /** -+ * @param cancel true if you wish to cancel this event, and prevent the orbs from merging -+ */ -+ @Override -+ public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Fill-Profile-Property-Events.patch b/patches/api/Fill-Profile-Property-Events.patch index be7b1f2376..1ad6342921 100644 --- a/patches/api/Fill-Profile-Property-Events.patch +++ b/patches/api/Fill-Profile-Property-Events.patch @@ -47,14 +47,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; + +import java.util.Set; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired once a profiles additional properties (such as textures) has been filled + */ +public class FillProfileEvent extends Event { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final PlayerProfile profile; + ++ @ApiStatus.Internal + public FillProfileEvent(@NotNull PlayerProfile profile) { + super(!org.bukkit.Bukkit.isPrimaryThread()); + this.profile = profile; @@ -65,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PlayerProfile getPlayerProfile() { -+ return profile; ++ return this.profile; + } + + /** @@ -76,19 +81,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Set getProperties() { -+ return profile.getProperties(); ++ return this.profile.getProperties(); + } + -+ private static final HandlerList handlers = new HandlerList(); -+ + @NotNull ++ @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java @@ -128,16 +132,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; + +import java.util.Collection; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when the server is requesting to fill in properties of an incomplete profile, such as textures. -+ * -+ * Allows plugins to pre populate cached properties and avoid a call to the Mojang API ++ *

      ++ * Allows plugins to pre-populate cached properties and avoid a call to the Mojang API + */ +public class PreFillProfileEvent extends Event { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final PlayerProfile profile; + ++ @ApiStatus.Internal + public PreFillProfileEvent(@NotNull PlayerProfile profile) { + super(!org.bukkit.Bukkit.isPrimaryThread()); + this.profile = profile; @@ -148,7 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PlayerProfile getPlayerProfile() { -+ return profile; ++ return this.profile; + } + + /** @@ -159,18 +168,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param properties The properties to set/append + */ + public void setProperties(@NotNull Collection properties) { -+ profile.setProperties(properties); ++ this.profile.setProperties(properties); + } + -+ private static final HandlerList handlers = new HandlerList(); -+ + @NotNull ++ @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/IllegalPacketEvent.patch b/patches/api/IllegalPacketEvent.patch index be437c09ce..6a60ddff00 100644 --- a/patches/api/IllegalPacketEvent.patch +++ b/patches/api/IllegalPacketEvent.patch @@ -15,10 +15,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.player; + -+import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -27,20 +27,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +@Deprecated +public class IllegalPacketEvent extends PlayerEvent { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @Nullable private final String type; -+ @Nullable private final String ex; ++ @Nullable private final String exceptionMessage; + @Nullable private String kickMessage; + private boolean shouldKick = true; + ++ @ApiStatus.Internal + public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) { + super(player); + this.type = type; + this.kickMessage = kickMessage; -+ this.ex = e.getMessage(); ++ this.exceptionMessage = e.getMessage(); + } + + public boolean isShouldKick() { -+ return shouldKick; ++ return this.shouldKick; + } + + public void setShouldKick(boolean shouldKick) { @@ -49,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Nullable + public String getKickMessage() { -+ return kickMessage; ++ return this.kickMessage; + } + + public void setKickMessage(@Nullable String kickMessage) { @@ -58,32 +62,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Nullable + public String getType() { -+ return type; ++ return this.type; + } + + @Nullable + public String getExceptionMessage() { -+ return ex; ++ return this.exceptionMessage; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ public static void process(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception exception) { -+ IllegalPacketEvent event = new IllegalPacketEvent(player, type, kickMessage, exception); -+ event.callEvent(); -+ if (event.shouldKick) { -+ player.kickPlayer(kickMessage); -+ } -+ Bukkit.getLogger().severe(player.getName() + "/" + type + ": " + exception.getMessage()); ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Introduce-beacon-activation-deactivation-events.patch b/patches/api/Introduce-beacon-activation-deactivation-events.patch index c2c29633c0..9024ef0525 100644 --- a/patches/api/Introduce-beacon-activation-deactivation-events.patch +++ b/patches/api/Introduce-beacon-activation-deactivation-events.patch @@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -23,8 +24,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Activation occurs when the beacon beam becomes visible. + */ +public class BeaconActivatedEvent extends BlockEvent { -+ private static final HandlerList handlers = new HandlerList(); + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @ApiStatus.Internal + public BeaconActivatedEvent(@NotNull Block block) { + super(block); + } @@ -36,18 +39,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Beacon getBeacon() { -+ return (Beacon) block.getState(); ++ return (Beacon) this.block.getState(); + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java b/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java @@ -63,6 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -70,32 +74,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Called when a beacon is deactivated, either because its base block(s) or itself were destroyed. + */ +public class BeaconDeactivatedEvent extends BlockEvent { -+ private static final HandlerList handlers = new HandlerList(); + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @ApiStatus.Internal + public BeaconDeactivatedEvent(@NotNull Block block) { + super(block); + } + + /** + * Returns the beacon that was deactivated. -+ * This will return null if the beacon does not exist. ++ * This will return {@code null} if the beacon does not exist. + * (which can occur after the deactivation of a now broken beacon) + * -+ * @return The beacon that got deactivated, or null if it does not exist. ++ * @return The beacon that got deactivated, or {@code null} if it does not exist. + */ + @Nullable + public Beacon getBeacon() { -+ return block.getType() == Material.BEACON ? (Beacon) block.getState() : null; ++ return this.block.getType() == Material.BEACON ? (Beacon) this.block.getState() : null; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/LootTable-API.patch b/patches/api/LootTable-API.patch index 21c649f4d8..358ae1b5fd 100644 --- a/patches/api/LootTable-API.patch +++ b/patches/api/LootTable-API.patch @@ -199,11 +199,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable { -+ @NotNull private final LootableInventory inventory; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final LootableInventory inventory; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public LootableInventoryReplenishEvent(@NotNull Player player, @NotNull LootableInventory inventory) { + super(player); + this.inventory = inventory; @@ -211,31 +217,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public LootableInventory getInventory() { -+ return inventory; ++ return this.inventory; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/block/Barrel.java b/src/main/java/org/bukkit/block/Barrel.java diff --git a/patches/api/Player-Chunk-Load-Unload-Events.patch b/patches/api/Player-Chunk-Load-Unload-Events.patch index 69b3c97f58..5b28480f69 100644 --- a/patches/api/Player-Chunk-Load-Unload-Events.patch +++ b/patches/api/Player-Chunk-Load-Unload-Events.patch @@ -16,40 +16,43 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.world.ChunkEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** -+ * Is called when a {@link org.bukkit.entity.Player} receives a {@link org.bukkit.Chunk} ++ * Is called when a {@link Player} receives a {@link Chunk} + *

      + * Can for example be used for spawning a fake entity when the player receives a chunk. -+ * ++ *

      + * Should only be used for packet/clientside related stuff. + * Not intended for modifying server side state. + */ +public class PlayerChunkLoadEvent extends ChunkEvent { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Player player; + ++ @ApiStatus.Internal + public PlayerChunkLoadEvent(@NotNull Chunk chunk, @NotNull Player player) { + super(chunk); + this.player = player; + } + + @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; ++ public Player getPlayer() { ++ return this.player; + } + + @NotNull -+ public Player getPlayer() { -+ return player; ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java @@ -64,37 +67,40 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.world.ChunkEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Is called when a {@link Player} receives a chunk unload packet. -+ * ++ *

      + * Should only be used for packet/clientside related stuff. + * Not intended for modifying server side. + */ +public class PlayerChunkUnloadEvent extends ChunkEvent { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Player player; + ++ @ApiStatus.Internal + public PlayerChunkUnloadEvent(@NotNull Chunk chunk, @NotNull Player player) { + super(chunk); + this.player = player; + } + + @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; ++ public Player getPlayer() { ++ return this.player; + } + + @NotNull -+ public Player getPlayer() { -+ return player; ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Player-Entity-Tracking-Events.patch b/patches/api/Player-Entity-Tracking-Events.patch index 6164d2da9b..5f891d3d25 100644 --- a/patches/api/Player-Entity-Tracking-Events.patch +++ b/patches/api/Player-Entity-Tracking-Events.patch @@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -29,26 +30,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerTrackEntityEvent extends PlayerEvent implements Cancellable { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Entity entity; + private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerTrackEntityEvent(@NotNull Player player, @NotNull Entity entity) { + super(player); + this.entity = entity; + } + -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ + /** + * Gets the entity that will be tracked + * @@ -56,18 +48,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Entity getEntity() { -+ return entity; ++ return this.entity; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } +} diff --git a/src/main/java/io/papermc/paper/event/player/PlayerUntrackEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerUntrackEntityEvent.java new file mode 100644 @@ -81,6 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -91,31 +95,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerUntrackEntityEvent extends PlayerEvent { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final Entity entity; + ++ @ApiStatus.Internal + public PlayerUntrackEntityEvent(@NotNull Player player, @NotNull Entity entity) { + super(player); + this.entity = entity; + } + ++ /** ++ * Gets the entity that will be untracked ++ * ++ * @return the entity untracked ++ */ ++ @NotNull ++ public Entity getEntity() { ++ return this.entity; ++ } ++ + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ /** -+ * Gets the entity that will be untracked -+ * @return the entity untracked -+ */ -+ @NotNull -+ public Entity getEntity() { -+ return entity; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerAttemptPickupItemEvent.patch b/patches/api/PlayerAttemptPickupItemEvent.patch index 54fed39209..5faa145f74 100644 --- a/patches/api/PlayerAttemptPickupItemEvent.patch +++ b/patches/api/PlayerAttemptPickupItemEvent.patch @@ -16,23 +16,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Thrown when a player attempts to pick an item up from the ground + */ +public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final Item item; + private final int remaining; + private boolean flyAtPlayer = true; -+ private boolean isCancelled = false; ++ ++ private boolean cancelled; + + @Deprecated // Remove in 1.13 // Remove in 1.14? ++ @ApiStatus.Internal + public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item) { + this(player, item, 0); + } + ++ @ApiStatus.Internal + public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) { + super(player); + this.item = item; @@ -46,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Item getItem() { -+ return item; ++ return this.item; + } + + /** @@ -55,14 +61,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return amount that will remain on the ground + */ + public int getRemaining() { -+ return remaining; ++ return this.remaining; + } + + /** + * Set if the item will fly at the player + *

      Cancelling the event will set this value to false.

      + * -+ * @param flyAtPlayer True for item to fly at player ++ * @param flyAtPlayer {@code true} for item to fly at player + */ + public void setFlyAtPlayer(boolean flyAtPlayer) { + this.flyAtPlayer = flyAtPlayer; @@ -71,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Gets if the item will fly at the player + * -+ * @return True if the item will fly at the player ++ * @return {@code true} if the item will fly at the player + */ + public boolean getFlyAtPlayer() { + return this.flyAtPlayer; @@ -80,23 +86,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return this.isCancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ this.isCancelled = cancel; ++ this.cancelled = cancel; + this.flyAtPlayer = !cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerElytraBoostEvent.patch b/patches/api/PlayerElytraBoostEvent.patch index 3a16e17657..b947bdf0a4 100644 --- a/patches/api/PlayerElytraBoostEvent.patch +++ b/patches/api/PlayerElytraBoostEvent.patch @@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a player boosts elytra flight with a firework + */ +public class PlayerElytraBoostEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled = false; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final ItemStack itemStack; -+ @NotNull private Firework firework; ++ @NotNull private final Firework firework; + private boolean consume = true; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerElytraBoostEvent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull Firework firework) { + super(player); + this.itemStack = itemStack; @@ -43,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItemStack() { -+ return itemStack; ++ return this.itemStack; + } + + /** @@ -53,45 +58,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Firework getFirework() { -+ return firework; ++ return this.firework; + } + + /** + * Get whether to consume the firework or not + * -+ * @return True to consume ++ * @return {@code true} to consume + */ + public boolean shouldConsume() { -+ return consume; ++ return this.consume; + } + + /** + * Set whether to consume the firework or not + * -+ * @param consume True to consume ++ * @param consume {@code true} to consume + */ + public void setShouldConsume(boolean consume) { + this.consume = consume; + } + -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerLaunchProjectileEvent.patch b/patches/api/PlayerLaunchProjectileEvent.patch index 1affff198b..c08581d7af 100644 --- a/patches/api/PlayerLaunchProjectileEvent.patch +++ b/patches/api/PlayerLaunchProjectileEvent.patch @@ -16,24 +16,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.Projectile; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a player shoots a projectile. + *

      + * Notably this event is not called for arrows as the player does not launch them, rather shoots them with the help -+ * of a bow or crossbow. A plugin may listen to {@link org.bukkit.event.entity.EntityShootBowEvent} for these actions -+ * instead. ++ * of a bow or crossbow. A plugin may listen to {@link EntityShootBowEvent} ++ * for these actions instead. + */ +public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final Projectile projectile; + @NotNull private final ItemStack itemStack; + private boolean consumeItem = true; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerLaunchProjectileEvent(@NotNull Player shooter, @NotNull ItemStack itemStack, @NotNull Projectile projectile) { + super(shooter); + this.itemStack = itemStack; @@ -47,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Projectile getProjectile() { -+ return projectile; ++ return this.projectile; + } + + /** @@ -57,43 +63,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getItemStack() { -+ return itemStack; ++ return this.itemStack; + } + + /** + * Get whether to consume the ItemStack or not + * -+ * @return True to consume ++ * @return {@code true} to consume + */ + public boolean shouldConsume() { -+ return consumeItem; ++ return this.consumeItem; + } + + /** + * Set whether to consume the ItemStack or not + * -+ * @param consumeItem True to consume ++ * @param consumeItem {@code true} to consume + */ + public void setShouldConsume(boolean consumeItem) { + this.consumeItem = consumeItem; + } + ++ @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + ++ @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerNaturallySpawnCreaturesEvent.patch b/patches/api/PlayerNaturallySpawnCreaturesEvent.patch index 21ed564e30..9f9ac299bb 100644 --- a/patches/api/PlayerNaturallySpawnCreaturesEvent.patch +++ b/patches/api/PlayerNaturallySpawnCreaturesEvent.patch @@ -18,17 +18,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event + */ +public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable { -+ private byte radius; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private byte radius; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerNaturallySpawnCreaturesEvent(@NotNull Player player, byte radius) { + super(player); + this.radius = radius; @@ -38,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return The radius of chunks around this player to be included in natural spawn selection + */ + public byte getSpawnRadius() { -+ return radius; ++ return this.radius; + } + + /** @@ -48,33 +53,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.radius = radius; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + /** + * @return If this players chunks will be excluded from natural spawns + */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** -+ * @param cancel 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 players chunks for natural spawning + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerPickupExperienceEvent.patch b/patches/api/PlayerPickupExperienceEvent.patch index ad99ddd576..ef85c5b775 100644 --- a/patches/api/PlayerPickupExperienceEvent.patch +++ b/patches/api/PlayerPickupExperienceEvent.patch @@ -39,17 +39,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a player is attempting to pick up an experience orb + */ +public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancellable { -+ @NotNull private final ExperienceOrb experienceOrb; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final ExperienceOrb experienceOrb; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PlayerPickupExperienceEvent(@NotNull Player player, @NotNull ExperienceOrb experienceOrb) { + super(player); + this.experienceOrb = experienceOrb; @@ -60,34 +65,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ExperienceOrb getExperienceOrb() { -+ return experienceOrb; ++ return this.experienceOrb; + } + -+ private static final HandlerList handlers = new HandlerList(); ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ /** ++ * {@inheritDoc} ++ *
      ++ * If {@code true}, cancels picking up the experience orb, leaving it in the world ++ */ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } + + @NotNull ++ @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ /** -+ * If true, Cancels picking up the experience orb, leaving it in the world -+ * @param cancel true if you wish to cancel this event -+ */ -+ @Override -+ public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerPickupItemEvent-setFlyAtPlayer.patch b/patches/api/PlayerPickupItemEvent-setFlyAtPlayer.patch index 51830b3d17..ec4243b877 100644 --- a/patches/api/PlayerPickupItemEvent-setFlyAtPlayer.patch +++ b/patches/api/PlayerPickupItemEvent-setFlyAtPlayer.patch @@ -23,9 +23,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + /** + * Set if the item will fly at the player -+ *

      Cancelling the event will set this value to false.

      ++ *

      ++ * Cancelling the event will set this value to false. + * -+ * @param flyAtPlayer True for item to fly at player ++ * @param flyAtPlayer true for item to fly at player + */ + public void setFlyAtPlayer(boolean flyAtPlayer) { + this.flyAtPlayer = flyAtPlayer; @@ -34,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Gets if the item will fly at the player + * -+ * @return True if the item will fly at the player ++ * @return true if the item will fly at the player + */ + public boolean getFlyAtPlayer() { + return flyAtPlayer; diff --git a/patches/api/PlayerReadyArrowEvent.patch b/patches/api/PlayerReadyArrowEvent.patch index 73f73bd98d..ab8e049080 100644 --- a/patches/api/PlayerReadyArrowEvent.patch +++ b/patches/api/PlayerReadyArrowEvent.patch @@ -39,7 +39,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; @@ -49,9 +48,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Called when a player is firing a bow and the server is choosing an arrow to use. + */ +public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final ItemStack bow; + @NotNull private final ItemStack arrow; + ++ private boolean cancelled; ++ + public PlayerReadyArrowEvent(@NotNull Player player, @NotNull ItemStack bow, @NotNull ItemStack arrow) { + super(player); + this.bow = bow; @@ -63,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getBow() { -+ return bow; ++ return this.bow; + } + + /** @@ -71,37 +75,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public ItemStack getArrow() { -+ return arrow; ++ return this.arrow; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + /** -+ * Whether or not use of this arrow is cancelled. On cancel, the server will try the next arrow available and fire another event. ++ * {@inheritDoc} ++ *
      ++ * Whether use of this arrow is cancelled. On cancel, the server will try the next arrow available and fire another event. + */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** + * Cancel use of this arrow. On cancel, the server will try the next arrow available and fire another event. -+ * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PlayerTeleportEndGatewayEvent.patch b/patches/api/PlayerTeleportEndGatewayEvent.patch index 72fe48a39f..69b61ed8bd 100644 --- a/patches/api/PlayerTeleportEndGatewayEvent.patch +++ b/patches/api/PlayerTeleportEndGatewayEvent.patch @@ -17,14 +17,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.EndGateway; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a teleport is triggered for an End Gateway + */ +public class PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent { ++ + @NotNull private final EndGateway gateway; + ++ @ApiStatus.Internal + public PlayerTeleportEndGatewayEvent(@NotNull Player player, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { + super(player, from, to, PlayerTeleportEvent.TeleportCause.END_GATEWAY); + this.gateway = gateway; @@ -37,6 +40,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public EndGateway getGateway() { -+ return gateway; ++ return this.gateway; + } +} diff --git a/patches/api/PreCreatureSpawnEvent.patch b/patches/api/PreCreatureSpawnEvent.patch index c4e0841e2d..163c736bbb 100644 --- a/patches/api/PreCreatureSpawnEvent.patch +++ b/patches/api/PreCreatureSpawnEvent.patch @@ -22,35 +22,41 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.entity; + -+import com.google.common.base.Preconditions; +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** -+ * WARNING: This event only fires for a limited number of cases, and not for every case that CreatureSpawnEvent does. -+ * -+ * You should still listen to CreatureSpawnEvent as a backup, and only use this event as an "enhancement". ++ * WARNING: This event only fires for a limited number of cases, and not for every case that {@link CreatureSpawnEvent} does. ++ *

      ++ * You should still listen to {@link CreatureSpawnEvent} as a backup, and only use this event as an "enhancement". + * The intent of this event is to improve server performance, so it fires even if the spawning might fail later, for + * example when the entity would be unable to spawn due to limited space or lighting. -+ * -+ * Currently: NATURAL and SPAWNER based reasons. Please submit a Pull Request for future additions. ++ *

      ++ * Currently: NATURAL and SPAWNER based reasons. + * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event. + */ +public class PreCreatureSpawnEvent extends Event implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final Location location; + @NotNull private final EntityType type; + @NotNull private final CreatureSpawnEvent.SpawnReason reason; + private boolean shouldAbortSpawn; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public PreCreatureSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason) { -+ this.location = Preconditions.checkNotNull(location, "Location may not be null"); -+ this.type = Preconditions.checkNotNull(type, "Type may not be null"); -+ this.reason = Preconditions.checkNotNull(reason, "Reason may not be null"); ++ this.location = location; ++ this.type = type; ++ this.reason = reason; + } + + /** @@ -58,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getSpawnLocation() { -+ return location; ++ return this.location; + } + + /** @@ -66,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public EntityType getType() { -+ return type; ++ return this.type; + } + + /** @@ -74,14 +80,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public CreatureSpawnEvent.SpawnReason getReason() { -+ return reason; ++ return this.reason; + } + + /** + * @return If the spawn process should be aborted vs trying more attempts + */ + public boolean shouldAbortSpawn() { -+ return shouldAbortSpawn; ++ return this.shouldAbortSpawn; + } + + /** @@ -94,34 +100,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.shouldAbortSpawn = shouldAbortSpawn; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + /** + * @return If the spawn of this creature is cancelled or not + */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + /** -+ * Cancelling this event is more efficient than cancelling CreatureSpawnEvent -+ * @param cancel true if you wish to cancel this event, and abort the spawn of this creature ++ * Cancelling this event is more efficient than cancelling {@link CreatureSpawnEvent} ++ * ++ * @param cancel {@code true} if you wish to cancel this event, and abort the spawn of this creature + */ + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/PreSpawnerSpawnEvent.patch b/patches/api/PreSpawnerSpawnEvent.patch index 391d4675fa..2e38fd0699 100644 --- a/patches/api/PreSpawnerSpawnEvent.patch +++ b/patches/api/PreSpawnerSpawnEvent.patch @@ -18,30 +18,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.entity; + -+ -+import com.google.common.base.Preconditions; +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called before an entity is spawned into a world by a spawner. -+ * ++ *

      + * 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. + */ -+ +public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent { ++ + @NotNull private final Location spawnerLocation; + ++ @ApiStatus.Internal + public PreSpawnerSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull Location spawnerLocation) { + super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER); -+ this.spawnerLocation = Preconditions.checkNotNull(spawnerLocation, "Spawner location may not be null"); ++ this.spawnerLocation = spawnerLocation; + } + + @NotNull + public Location getSpawnerLocation() { -+ return spawnerLocation; ++ return this.spawnerLocation; + } +} diff --git a/patches/api/Profile-Lookup-Events.patch b/patches/api/Profile-Lookup-Events.patch index 2052315a20..2fb070da82 100644 --- a/patches/api/Profile-Lookup-Events.patch +++ b/patches/api/Profile-Lookup-Events.patch @@ -19,21 +19,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Allows a plugin to be notified anytime AFTER a Profile has been looked up from the Mojang API + * This is an opportunity to view the response and potentially cache things. -+ * ++ *

      + * No guarantees are made about thread execution context for this event. If you need to know, check -+ * event.isAsync() ++ * {@link Event#isAsynchronous()} + */ +public class LookupProfileEvent extends Event { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); + + @NotNull private final PlayerProfile profile; + ++ @ApiStatus.Internal + public LookupProfileEvent(@NotNull PlayerProfile profile) { + super(!Bukkit.isPrimaryThread()); + this.profile = profile; @@ -44,18 +46,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PlayerProfile getPlayerProfile() { -+ return profile; ++ return this.profile; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java @@ -66,9 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.profile; + -+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.ProfileProperty; -+import com.google.common.collect.ArrayListMultimap; +import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; @@ -76,26 +76,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Allows a plugin to intercept a Profile Lookup for a Profile by name -+ * ++ *

      + * At the point of event fire, the UUID and properties are unset. -+ * ++ *

      + * If a plugin sets the UUID, and optionally the properties, the API call to look up the profile may be skipped. -+ * ++ *

      + * No guarantees are made about thread execution context for this event. If you need to know, check -+ * event.isAsync() ++ * {@link Event#isAsynchronous()} + */ +public class PreLookupProfileEvent extends Event { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final String name; ++ + private UUID uuid; + @NotNull private Set properties = new HashSet<>(); + ++ @ApiStatus.Internal + public PreLookupProfileEvent(@NotNull String name) { + super(!Bukkit.isPrimaryThread()); + this.name = name; @@ -106,11 +110,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public String getName() { -+ return name; ++ return this.name; + } + + /** -+ * If this value is left null by the completion of the event call, then the server will ++ * If this value is left {@code null} by the completion of the event call, then the server will + * trigger a call to the Mojang API to look up the UUID (Network Request), and subsequently, fire a + * {@link LookupProfileEvent} + * @@ -118,22 +122,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Nullable + public UUID getUUID() { -+ return uuid; ++ return this.uuid; + } + + /** + * Sets the UUID for this player name. This will skip the initial API call to find the players UUID. -+ * ++ *

      + * However, if Profile Properties are needed by the server, you must also set them or else an API call might still be made. + * -+ * @param uuid the UUID to set for the profile or null to reset ++ * @param uuid the UUID to set for the profile or {@code null} to reset + */ + public void setUUID(@Nullable UUID uuid) { + this.uuid = uuid; + } + + /** -+ * @return The currently pending prepopulated properties. ++ * @return The currently pending pre-populated properties. + * Any property in this Set will be automatically prefilled on this Profile + */ + @NotNull @@ -142,8 +146,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Clears any existing prepopulated properties and uses the supplied properties ++ * Clears any existing pre-populated properties and uses the supplied properties + * Any property in this Set will be automatically prefilled on this Profile ++ * + * @param properties The properties to add + */ + public void setProfileProperties(@NotNull Set properties) { @@ -152,8 +157,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * Adds any properties currently missing to the prepopulated properties set, replacing any that already were set. ++ * Adds any properties currently missing to the pre-populated properties set, replacing any that already were set. + * Any property in this Set will be automatically prefilled on this Profile ++ * + * @param properties The properties to add + */ + public void addProfileProperties(@NotNull Set properties) { @@ -163,12 +169,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } + +} diff --git a/patches/api/ProfileWhitelistVerifyEvent.patch b/patches/api/ProfileWhitelistVerifyEvent.patch index 617d89de3d..a4c86876a1 100644 --- a/patches/api/ProfileWhitelistVerifyEvent.patch +++ b/patches/api/ProfileWhitelistVerifyEvent.patch @@ -43,28 +43,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Fires when the server needs to verify if a player is whitelisted. -+ * ++ *

      + * Plugins may override/control the servers whitelist with this event, + * and dynamically change the kick message. + */ +public class ProfileWhitelistVerifyEvent extends Event { -+ private static final HandlerList handlers = new HandlerList(); ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final PlayerProfile profile; + private final boolean whitelistEnabled; -+ private boolean whitelisted; + private final boolean isOp; ++ private boolean whitelisted; + @Nullable private Component kickMessage; + + @Deprecated ++ @ApiStatus.Internal + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) { + this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); + } + ++ @ApiStatus.Internal + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) { + this.profile = profile; + this.whitelistEnabled = whitelistEnabled; @@ -80,11 +85,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated + @Nullable + public String getKickMessage() { -+ return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(kickMessage); ++ return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.kickMessage); + } + + /** -+ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default ++ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to {@code null} to use the server configured default + * @deprecated Use {@link #kickMessage(Component)} + */ + @Deprecated @@ -101,7 +106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** -+ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default ++ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to {@code null} to use the server configured default + */ + public void kickMessage(@Nullable Component kickMessage) { + this.kickMessage = kickMessage; @@ -112,18 +117,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public PlayerProfile getPlayerProfile() { -+ return profile; ++ return this.profile; + } + + /** + * @return Whether the player is whitelisted to play on this server (whitelist may be off is why its true) + */ + public boolean isWhitelisted() { -+ return whitelisted; ++ return this.whitelisted; + } + + /** -+ * Changes the players whitelisted state. false will deny the login ++ * Changes the players whitelisted state. {@code false} will deny the login + * @param whitelisted The new whitelisted state + */ + public void setWhitelisted(boolean whitelisted) { @@ -134,24 +139,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return if the player obtained whitelist status by having op + */ + public boolean isOp() { -+ return isOp; ++ return this.isOp; + } + + /** + * @return if the server even has whitelist on + */ + public boolean isWhitelistEnabled() { -+ return whitelistEnabled; ++ return this.whitelistEnabled; + } + + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/Server-Tick-Events.patch b/patches/api/Server-Tick-Events.patch index 5ed173c913..7d78e94997 100644 --- a/patches/api/Server-Tick-Events.patch +++ b/patches/api/Server-Tick-Events.patch @@ -15,6 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -22,11 +23,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class ServerTickEndEvent extends Event { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final int tickNumber; + private final double tickDuration; + private final long timeEnd; + ++ @ApiStatus.Internal + public ServerTickEndEvent(int tickNumber, double tickDuration, long timeRemaining) { + this.tickNumber = tickNumber; + this.tickDuration = tickDuration; @@ -37,21 +40,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return What tick this was since start (first tick = 1) + */ + public int getTickNumber() { -+ return tickNumber; ++ return this.tickNumber; + } + + /** + * @return Time in milliseconds of how long this tick took + */ + public double getTickDuration() { -+ return tickDuration; ++ return this.tickDuration; + } + + /** + * Amount of nanoseconds remaining before the next tick should start. -+ * ++ *

      + * If this value is negative, then that means the server has exceeded the tick time limit and TPS has been lost. -+ * ++ *

      + * Method will continuously return the updated time remaining value. (return value is not static) + * + * @return Amount of nanoseconds remaining before the next tick should start @@ -62,12 +65,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java @@ -80,13 +83,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public class ServerTickStartEvent extends Event { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private final int tickNumber; + ++ @ApiStatus.Internal + public ServerTickStartEvent(int tickNumber) { + this.tickNumber = tickNumber; + } @@ -95,16 +101,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return What tick this is going be since start (first tick = 1) + */ + public int getTickNumber() { -+ return tickNumber; ++ return this.tickNumber; + } + + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/SkeletonHorse-Additions.patch b/patches/api/SkeletonHorse-Additions.patch index 3836f5ad5e..9f7e1aed8b 100644 --- a/patches/api/SkeletonHorse-Additions.patch +++ b/patches/api/SkeletonHorse-Additions.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @@ -26,14 +27,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Event called when a player gets close to a skeleton horse and triggers the lightning trap + */ +public class SkeletonHorseTrapEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ private final List eligibleHumans; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private final List eligibleHumans; ++ private boolean cancelled; ++ ++ @Deprecated ++ @ApiStatus.Internal + public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse) { + this(horse, ImmutableList.of()); + } + ++ @ApiStatus.Internal + public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse, @NotNull List eligibleHumans) { + super(horse); + this.eligibleHumans = eligibleHumans; @@ -45,9 +51,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return (SkeletonHorse) super.getEntity(); + } + ++ @NotNull ++ public List getEligibleHumans() { ++ return this.eligibleHumans; ++ } ++ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override @@ -56,19 +67,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @NotNull -+ public List getEligibleHumans() { -+ return eligibleHumans; -+ } -+ -+ @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} + diff --git a/patches/api/Slime-Pathfinder-Events.patch b/patches/api/Slime-Pathfinder-Events.patch index 9859b911e9..10d0081507 100644 --- a/patches/api/Slime-Pathfinder-Events.patch +++ b/patches/api/Slime-Pathfinder-Events.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.event.entity; + +import org.bukkit.entity.Slime; -+import org.bukkit.event.Cancellable; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -22,9 +22,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * This event does not fire for the entity's actual movement. Only when it + * is choosing to change direction. + */ -+public class SlimeChangeDirectionEvent extends SlimePathfindEvent implements Cancellable { ++public class SlimeChangeDirectionEvent extends SlimePathfindEvent { ++ + private float yaw; + ++ @ApiStatus.Internal + public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) { + super(slime); + this.yaw = yaw; @@ -36,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return Chosen yaw + */ + public float getNewYaw() { -+ return yaw; ++ return this.yaw; + } + + /** @@ -60,6 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -69,6 +72,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * is choosing to start moving. + */ +public class SlimePathfindEvent extends EntityEvent implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public SlimePathfindEvent(@NotNull Slime slime) { + super(slime); + } @@ -80,31 +89,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Slime getEntity() { -+ return (Slime) entity; ++ return (Slime) super.getEntity(); + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java @@ -116,7 +121,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.event.entity; + +import org.bukkit.entity.Slime; -+import org.bukkit.event.Cancellable; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -125,7 +130,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * This event does not fire for the entity's actual movement. Only when it + * is choosing to start jumping. + */ -+public class SlimeSwimEvent extends SlimeWanderEvent implements Cancellable { ++public class SlimeSwimEvent extends SlimeWanderEvent { ++ ++ @ApiStatus.Internal + public SlimeSwimEvent(@NotNull Slime slime) { + super(slime); + } @@ -140,7 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Slime; -+import org.bukkit.event.Cancellable; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -149,9 +156,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * This event does not fire for the entity's actual movement. Only when it + * is choosing to start moving. + */ -+public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent implements Cancellable { ++public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent { ++ + @NotNull private final LivingEntity target; + ++ @ApiStatus.Internal + public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) { + super(slime); + this.target = target; @@ -164,7 +173,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public LivingEntity getTarget() { -+ return target; ++ return this.target; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java @@ -176,7 +185,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.event.entity; + +import org.bukkit.entity.Slime; -+import org.bukkit.event.Cancellable; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -185,7 +194,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * This event does not fire for the entity's actual movement. Only when it + * is choosing to start moving. + */ -+public class SlimeWanderEvent extends SlimePathfindEvent implements Cancellable { ++public class SlimeWanderEvent extends SlimePathfindEvent { ++ ++ @ApiStatus.Internal + public SlimeWanderEvent(@NotNull Slime slime) { + super(slime); + } diff --git a/patches/api/Turtle-API.patch b/patches/api/Turtle-API.patch index b1cffde761..5a14e1413d 100644 --- a/patches/api/Turtle-API.patch +++ b/patches/api/Turtle-API.patch @@ -16,15 +16,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a Turtle decides to go home + */ +public class TurtleGoHomeEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled = false; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public TurtleGoHomeEvent(@NotNull Turtle turtle) { + super(turtle); + } @@ -36,27 +40,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Turtle getEntity() { -+ return (Turtle) entity; ++ return (Turtle) super.getEntity(); + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java @@ -72,18 +76,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a Turtle lays eggs + */ +public class TurtleLayEggEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled = false; ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull + private final Location location; + private int eggCount; + ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) { + super(turtle); + this.location = location; @@ -97,7 +106,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Turtle getEntity() { -+ return (Turtle) entity; ++ return (Turtle) super.getEntity(); + } + + /** @@ -107,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getLocation() { -+ return location; ++ return this.location; + } + + /** @@ -116,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return Number of eggs + */ + public int getEggCount() { -+ return eggCount; ++ return this.eggCount; + } + + /** @@ -126,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + public void setEggCount(int eggCount) { + if (eggCount < 1) { -+ cancelled = true; ++ this.cancelled = true; + return; + } + this.eggCount = Math.min(eggCount, 4); @@ -134,22 +143,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java @@ -165,16 +174,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Fired when a Turtle starts digging to lay eggs + */ +public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled = false; -+ @NotNull private final Location location; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @NotNull private final Location location; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) { + super(turtle); + this.location = location; @@ -187,7 +200,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Turtle getEntity() { -+ return (Turtle) entity; ++ return (Turtle) super.getEntity(); + } + + /** @@ -197,27 +210,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Location getLocation() { -+ return location; ++ return this.location; + } + + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; + } + + @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLER_LIST; + } +} diff --git a/src/main/java/org/bukkit/entity/Turtle.java b/src/main/java/org/bukkit/entity/Turtle.java diff --git a/patches/api/Use-ASM-for-event-executors.patch b/patches/api/Use-ASM-for-event-executors.patch index 9e03995c7a..415bd0983b 100644 --- a/patches/api/Use-ASM-for-event-executors.patch +++ b/patches/api/Use-ASM-for-event-executors.patch @@ -83,7 +83,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import com.destroystokyo.paper.util.SneakyThrow; +import com.google.common.base.Preconditions; + -+import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.event.EventException; +import org.bukkit.event.Listener; @@ -224,14 +223,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.executor.asm; + -+import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import com.google.common.base.Preconditions; + +import com.google.common.collect.MapMaker; +import org.jetbrains.annotations.NotNull; -+import org.objectweb.asm.Type; + +public class SafeClassDefiner implements ClassDefiner { + /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner(); diff --git a/patches/api/WitchConsumePotionEvent.patch b/patches/api/WitchConsumePotionEvent.patch index 25e72a8ad3..a7ae78f70f 100644 --- a/patches/api/WitchConsumePotionEvent.patch +++ b/patches/api/WitchConsumePotionEvent.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -25,8 +26,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Fired when a witch consumes the potion in their hand to buff themselves. + */ +public class WitchConsumePotionEvent extends EntityEvent implements Cancellable { -+ @Nullable private ItemStack potion; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ @Nullable private ItemStack potion; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public WitchConsumePotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) { + super(witch); + this.potion = potion; @@ -43,80 +49,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Nullable + public ItemStack getPotion() { -+ return potion; ++ return this.potion; + } + + /** + * Sets the potion to be consumed and applied to the witch. ++ * + * @param potion The potion + */ + public void setPotion(@Nullable ItemStack potion) { + this.potion = potion != null ? potion.clone() : null; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + /** -+ * @return Event was cancelled or potion was null ++ * @return Event was cancelled or potion was {@code null} + */ + @Override + public boolean isCancelled() { -+ return cancelled || potion == null; ++ return this.cancelled || this.potion == null; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; -+ } -+} -diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- /dev/null -+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java -@@ -0,0 +0,0 @@ -+package com.destroystokyo.paper.event.entity; -+ -+import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; -+import org.bukkit.event.HandlerList; -+ -+public class WitchThrowPotionEvent extends Event implements Cancellable { -+ public WitchThrowPotionEvent() { ++ this.cancelled = cancel; + } + -+ -+ private static final HandlerList handlers = new HandlerList(); -+ ++ @NotNull + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLER_LIST; + } + ++ @NotNull + public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ return HANDLER_LIST; + } +} diff --git a/patches/api/WitchReadyPotionEvent.patch b/patches/api/WitchReadyPotionEvent.patch index 47b260c6e2..c24fe8e100 100644 --- a/patches/api/WitchReadyPotionEvent.patch +++ b/patches/api/WitchReadyPotionEvent.patch @@ -13,38 +13,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.entity; + -+import org.bukkit.Material; +import org.bukkit.entity.Witch; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class WitchReadyPotionEvent extends EntityEvent implements Cancellable { -+ private ItemStack potion; + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private ItemStack potion; ++ private boolean cancelled; ++ ++ @ApiStatus.Internal + public WitchReadyPotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) { + super(witch); + this.potion = potion; + } + -+ /** -+ * Fires the event, returning the desired potion, or air of cancelled -+ * @param witch the witch whom is readying to use a potion -+ * @param potion the potion to be used -+ * @return The ItemStack to be used -+ */ -+ @Nullable -+ public static ItemStack process(@NotNull Witch witch, @Nullable ItemStack potion) { -+ WitchReadyPotionEvent event = new WitchReadyPotionEvent(witch, potion); -+ if (!event.callEvent() || event.getPotion() == null) { -+ return new ItemStack(Material.AIR); -+ } -+ return event.getPotion(); -+ } -+ + @NotNull + @Override + public Witch getEntity() { @@ -56,38 +46,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Nullable + public ItemStack getPotion() { -+ return potion; ++ return this.potion; + } + + /** + * Sets the potion the which is going to hold and use ++ * + * @param potion The potion + */ + public void setPotion(@Nullable ItemStack potion) { + this.potion = potion != null ? potion.clone() : null; + } + -+ private static final HandlerList handlers = new HandlerList(); -+ -+ @NotNull -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ private boolean cancelled = false; -+ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} diff --git a/patches/api/WitchThrowPotionEvent.patch b/patches/api/WitchThrowPotionEvent.patch index e3f292d006..54a95d363e 100644 --- a/patches/api/WitchThrowPotionEvent.patch +++ b/patches/api/WitchThrowPotionEvent.patch @@ -6,37 +6,41 @@ Subject: [PATCH] WitchThrowPotionEvent Fired when a witch throws a potion at a player diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java @@ -0,0 +0,0 @@ - package com.destroystokyo.paper.event.entity; - ++package com.destroystokyo.paper.event.entity; ++ +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Witch; - import org.bukkit.event.Cancellable; --import org.bukkit.event.Event; - import org.bukkit.event.HandlerList; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.inventory.ItemStack; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; - --public class WitchThrowPotionEvent extends Event implements Cancellable { -- public WitchThrowPotionEvent() { ++ +/** + * Fired when a witch throws a potion at a player + */ +public class WitchThrowPotionEvent extends EntityEvent implements Cancellable { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + @NotNull private final LivingEntity target; + @Nullable private ItemStack potion; ++ private boolean cancelled; + ++ @ApiStatus.Internal + public WitchThrowPotionEvent(@NotNull Witch witch, @NotNull LivingEntity target, @Nullable ItemStack potion) { + super(witch); + this.target = target; + this.potion = potion; - } - ++ } ++ + @NotNull + @Override + public Witch getEntity() { @@ -48,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public LivingEntity getTarget() { -+ return target; ++ return this.target; + } + + /** @@ -56,38 +60,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Nullable + public ItemStack getPotion() { -+ return potion; ++ return this.potion; + } + + /** + * Sets the potion to be thrown at a player ++ * + * @param potion The potion + */ + public void setPotion(@Nullable ItemStack potion) { + this.potion = potion != null ? potion.clone() : null; + } - - private static final HandlerList handlers = new HandlerList(); - -+ @NotNull - public HandlerList getHandlers() { - return handlers; - } - -+ @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - - private boolean cancelled = false; - ++ + /** -+ * @return Event was cancelled or potion was null ++ * @return Event was cancelled or potion was {@code null} + */ - @Override - public boolean isCancelled() { -- return cancelled; -+ return cancelled || potion == null; - } - - @Override ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled || this.potion == null; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } ++} diff --git a/patches/api/add-DragonEggFormEvent.patch b/patches/api/add-DragonEggFormEvent.patch index 3df2fe335f..a180bacbd1 100644 --- a/patches/api/add-DragonEggFormEvent.patch +++ b/patches/api/add-DragonEggFormEvent.patch @@ -17,59 +17,51 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.BlockState; +import org.bukkit.boss.DragonBattle; +import org.bukkit.entity.EnderDragon; -+import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockFormEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle}, + * causing a {@link Material#DRAGON_EGG} (more formally: {@link #getNewState()}) + * to possibly appear depending on {@link #isCancelled()}. ++ *

      + * This event might be cancelled by default depending on -+ * eg. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration. ++ * e.g. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration. + */ -+public class DragonEggFormEvent extends BlockFormEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private final DragonBattle dragonBattle; -+ private boolean cancelled; -+ -+ public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState, -+ @NotNull DragonBattle dragonBattle) { -+ super(block, newState); -+ this.dragonBattle = dragonBattle; -+ } -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; -+ } -+ -+ /** -+ * Gets the {@link DragonBattle} associated with this event. -+ * Keep in mind that the {@link EnderDragon} is already dead -+ * when this event is called. -+ * -+ * @return the dragon battle -+ */ -+ @NotNull -+ public DragonBattle getDragonBattle() { -+ return dragonBattle; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } ++public class DragonEggFormEvent extends BlockFormEvent { ++ ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ ++ private final DragonBattle dragonBattle; ++ ++ @ApiStatus.Internal ++ public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState, @NotNull DragonBattle dragonBattle) { ++ super(block, newState); ++ this.dragonBattle = dragonBattle; ++ } ++ ++ /** ++ * Gets the {@link DragonBattle} associated with this event. ++ * Keep in mind that the {@link EnderDragon} is already dead ++ * when this event is called. ++ * ++ * @return the dragon battle ++ */ ++ @NotNull ++ public DragonBattle getDragonBattle() { ++ return this.dragonBattle; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } +} diff --git a/patches/api/added-PlayerNameEntityEvent.patch b/patches/api/added-PlayerNameEntityEvent.patch index 374b592f49..7619e3089b 100644 --- a/patches/api/added-PlayerNameEntityEvent.patch +++ b/patches/api/added-PlayerNameEntityEvent.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -26,11 +27,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ +public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable { + ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ + private LivingEntity entity; + private Component name; + private boolean persistent; ++ + private boolean cancelled; + ++ @ApiStatus.Internal + public PlayerNameEntityEvent(@NotNull Player player, @NotNull LivingEntity entity, @NotNull Component name, boolean persistent) { + super(player); + this.entity = entity; @@ -40,11 +45,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * Gets the name to be given to the entity. ++ * + * @return the name + */ + @Nullable + public Component getName() { -+ return name; ++ return this.name; + } + + /** @@ -63,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public LivingEntity getEntity() { -+ return entity; ++ return this.entity; + } + + /** @@ -81,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return persistent + */ + public boolean isPersistent() { -+ return persistent; ++ return this.persistent; + } + + /** @@ -93,30 +99,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.persistent = persistent; + } + -+ /** -+ * Gets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins -+ * -+ * @return true if this event is cancelled -+ */ + @Override + public boolean isCancelled() { -+ return cancelled; ++ return this.cancelled; + } + -+ /** -+ * Sets the cancellation state of this event. A cancelled event will not -+ * be executed in the server, but will still pass to other plugins. -+ * -+ * @param cancel true if you wish to cancel this event -+ */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + -+ private static final HandlerList HANDLER_LIST = new HandlerList(); -+ + @NotNull + @Override + public HandlerList getHandlers() { diff --git a/patches/server/Add-Alternate-Current-redstone-implementation.patch b/patches/server/Add-Alternate-Current-redstone-implementation.patch index 6922035420..5f74f89ee9 100644 --- a/patches/server/Add-Alternate-Current-redstone-implementation.patch +++ b/patches/server/Add-Alternate-Current-redstone-implementation.patch @@ -28,6 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package alternate.current.wire; + ++import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.block.BlockRedstoneEvent; + +import net.minecraft.core.BlockPos; @@ -41,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public class LevelHelper { + + static int doRedstoneEvent(ServerLevel level, BlockPos pos, int prevPower, int newPower) { -+ BlockRedstoneEvent event = new BlockRedstoneEvent(level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), prevPower, newPower); ++ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(level, pos), prevPower, newPower); + level.getCraftServer().getPluginManager().callEvent(event); + + return event.getNewCurrent(); diff --git a/patches/server/Add-BeaconEffectEvent.patch b/patches/server/Add-BeaconEffectEvent.patch index c496287ad1..c5a61301c9 100644 --- a/patches/server/Add-BeaconEffectEvent.patch +++ b/patches/server/Add-BeaconEffectEvent.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Player entityhuman; + // Paper start - BeaconEffectEvent -+ org.bukkit.block.Block block = ((Player) list.get(0)).level().getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(((Player) list.get(0)).level(), worldPosition); + PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffectInstance(effects, i, b0, true, true)); + // Paper end - BeaconEffectEvent diff --git a/patches/server/Add-BellRevealRaiderEvent.patch b/patches/server/Add-BellRevealRaiderEvent.patch index 34ce82469a..7c6dfcc709 100644 --- a/patches/server/Add-BellRevealRaiderEvent.patch +++ b/patches/server/Add-BellRevealRaiderEvent.patch @@ -18,14 +18,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity { - return entity.isAlive() && !entity.isRemoved() && pos.closerToCenterThan(entity.position(), 48.0D) && entity.getType().is(EntityTypeTags.RAIDERS); } -- private static void glow(LivingEntity entity) { -+ // Paper start - Add BellRevealRaiderEvent -+ private static void glow(LivingEntity entity) { glow(entity, null); } + private static void glow(LivingEntity entity) { ++ // Paper start - Add BellRevealRaiderEvent ++ glow(entity, null); ++ } ++ + private static void glow(LivingEntity entity, @javax.annotation.Nullable BlockPos pos) { -+ if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(entity.level().getWorld().getBlockAt(io.papermc.paper.util.MCUtil.toLocation(entity.level(), pos)), entity.getBukkitEntity()).callEvent()) return; ++ if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(org.bukkit.craftbukkit.block.CraftBlock.at(entity.level(), pos), (org.bukkit.entity.Raider) entity.getBukkitEntity()).callEvent()) return; + // Paper end - Add BellRevealRaiderEvent entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60)); } diff --git a/patches/server/Add-BlockBreakBlockEvent.patch b/patches/server/Add-BlockBreakBlockEvent.patch index 6488a966c4..73d0ce2bce 100644 --- a/patches/server/Add-BlockBreakBlockEvent.patch +++ b/patches/server/Add-BlockBreakBlockEvent.patch @@ -9,29 +9,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -0,0 +0,0 @@ public class Block extends BlockBehaviour implements ItemLike { - } } + + // Paper start - Add BlockBreakBlockEvent -+ public static boolean dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity, BlockPos source) { -+ if (world instanceof ServerLevel) { -+ List items = com.google.common.collect.Lists.newArrayList(); -+ for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(state, world.getMinecraftWorld(), pos, blockEntity)) { ++ public static boolean dropResources(BlockState state, LevelAccessor levelAccessor, BlockPos pos, @Nullable BlockEntity blockEntity, BlockPos source) { ++ if (levelAccessor instanceof ServerLevel serverLevel) { ++ List items = new java.util.ArrayList<>(); ++ for (ItemStack drop : Block.getDrops(state, serverLevel, pos, blockEntity)) { + items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop)); + } -+ io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items); ++ io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, pos), org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, source), items); + event.callEvent(); -+ for (var drop : event.getDrops()) { -+ popResource(world.getMinecraftWorld(), pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop)); ++ for (org.bukkit.inventory.ItemStack drop : event.getDrops()) { ++ popResource(serverLevel, pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop)); + } -+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, true); ++ state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, true); + } + return true; + } + // Paper end - Add BlockBreakBlockEvent - ++ public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { if (world instanceof ServerLevel) { + Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, tool).forEach((itemstack1) -> { diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java diff --git a/patches/server/Add-BlockFailedDispenseEvent.patch b/patches/server/Add-BlockFailedDispenseEvent.patch index 4466e4fc54..63a8ac09aa 100644 --- a/patches/server/Add-BlockFailedDispenseEvent.patch +++ b/patches/server/Add-BlockFailedDispenseEvent.patch @@ -36,13 +36,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { - Bukkit.getPluginManager().callEvent(event); - return event; + return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion()); } + // Paper end - WitchReadyPotionEvent + + // Paper start -+ public static boolean handleBlockFailedDispenseEvent(ServerLevel serverLevel, BlockPos blockposition) { -+ org.bukkit.block.Block block = serverLevel.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ public static boolean handleBlockFailedDispenseEvent(ServerLevel serverLevel, BlockPos pos) { ++ org.bukkit.block.Block block = CraftBlock.at(serverLevel, pos); + io.papermc.paper.event.block.BlockFailedDispenseEvent event = new io.papermc.paper.event.block.BlockFailedDispenseEvent(block); + return event.callEvent(); + } diff --git a/patches/server/Add-BlockPreDispenseEvent.patch b/patches/server/Add-BlockPreDispenseEvent.patch index 35c3d9ea83..559f1f6146 100644 --- a/patches/server/Add-BlockPreDispenseEvent.patch +++ b/patches/server/Add-BlockPreDispenseEvent.patch @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + + public static boolean handleBlockPreDispenseEvent(ServerLevel serverLevel, BlockPos pos, ItemStack itemStack, int slot) { -+ org.bukkit.block.Block block = serverLevel.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = CraftBlock.at(serverLevel, pos); + io.papermc.paper.event.block.BlockPreDispenseEvent event = new io.papermc.paper.event.block.BlockPreDispenseEvent(block, org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), slot); + return event.callEvent(); + } diff --git a/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch b/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch index c809ab5204..b2704964b0 100644 --- a/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch +++ b/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch @@ -32,14 +32,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else { int j = i + 1; @@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { + if (!itemstack.isEmpty()) { this.changed = true; BlockState iblockdata = ComposterBlock.addItem((Entity) null, this.state, this.level, this.pos, itemstack); - + // Paper start - Add CompostItemEvent and EntityCompostItemEvent + if (iblockdata == null) { + return; + } + // Paper end - Add CompostItemEvent and EntityCompostItemEvent + this.level.levelEvent(1500, this.pos, iblockdata != this.state ? 1 : 0); this.removeItemNoUpdate(0); - } diff --git a/patches/server/Add-ElderGuardianAppearanceEvent.patch b/patches/server/Add-ElderGuardianAppearanceEvent.patch index db52fad94a..d6592fa2cc 100644 --- a/patches/server/Add-ElderGuardianAppearanceEvent.patch +++ b/patches/server/Add-ElderGuardianAppearanceEvent.patch @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if ((this.tickCount + this.getId()) % 1200 == 0) { MobEffectInstance mobeffect = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2); - List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit -+ List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent(getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent ++ List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent((org.bukkit.entity.ElderGuardian) this.getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent list.forEach((entityplayer) -> { entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)); diff --git a/patches/server/Add-EntityFertilizeEggEvent.patch b/patches/server/Add-EntityFertilizeEggEvent.patch index 8dbf824a87..190e5b4aec 100644 --- a/patches/server/Add-EntityFertilizeEggEvent.patch +++ b/patches/server/Add-EntityFertilizeEggEvent.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper; -+ if(event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event ++ if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event } } @@ -79,20 +79,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Paper start - add EntityFertilizeEggEvent + /** -+ * Calls the io.papermc.paper.event.entity.EntityFertilizeEggEvent. ++ * Calls the {@link io.papermc.paper.event.entity.EntityFertilizeEggEvent}. + * If the event is cancelled, this method also resets the love on both the {@code breeding} and {@code other} entity. + * + * @param breeding the entity on which #spawnChildFromBreeding was called. + * @param other the partner of the entity. + * @return the event after it was called. The instance may be used to retrieve the experience of the event. + */ -+ public static io.papermc.paper.event.entity.EntityFertilizeEggEvent callEntityFertilizeEggEvent(net.minecraft.world.entity.animal.Animal breeding, -+ net.minecraft.world.entity.animal.Animal other) { -+ net.minecraft.server.level.ServerPlayer serverPlayer = breeding.getLoveCause(); ++ public static io.papermc.paper.event.entity.EntityFertilizeEggEvent callEntityFertilizeEggEvent(Animal breeding, Animal other) { ++ ServerPlayer serverPlayer = breeding.getLoveCause(); + if (serverPlayer == null) serverPlayer = other.getLoveCause(); + final int experience = breeding.getRandom().nextInt(7) + 1; // From Animal#spawnChildFromBreeding(ServerLevel, Animal) + -+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent event = new io.papermc.paper.event.entity.EntityFertilizeEggEvent((org.bukkit.entity.LivingEntity) breeding.getBukkitEntity(), (org.bukkit.entity.LivingEntity) other.getBukkitEntity(), serverPlayer == null ? null : serverPlayer.getBukkitEntity(), breeding.breedItem == null ? null : org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(breeding.breedItem).clone(), experience); ++ final io.papermc.paper.event.entity.EntityFertilizeEggEvent event = new io.papermc.paper.event.entity.EntityFertilizeEggEvent((LivingEntity) breeding.getBukkitEntity(), (LivingEntity) other.getBukkitEntity(), serverPlayer == null ? null : serverPlayer.getBukkitEntity(), breeding.breedItem == null ? null : CraftItemStack.asCraftMirror(breeding.breedItem).clone(), experience); + if (!event.callEvent()) { + breeding.resetLove(); + other.resetLove(); // stop the pathfinding to avoid infinite loop diff --git a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index a1836eb575..d2fcb1a690 100644 --- a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch +++ b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength); this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z); -+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEventt ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + Vec3 currentMovement = this.getDeltaMovement(); + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z); + // Restore old velocity to be able to access it in the event diff --git a/patches/server/Add-EntityLoadCrossbowEvent.patch b/patches/server/Add-EntityLoadCrossbowEvent.patch index 7bc9ae4030..7ea980c884 100644 --- a/patches/server/Add-EntityLoadCrossbowEvent.patch +++ b/patches/server/Add-EntityLoadCrossbowEvent.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (f >= 1.0F && !CrossbowItem.isCharged(stack) && CrossbowItem.tryLoadProjectiles(user, stack)) { + // Paper start - Add EntityLoadCrossbowEvent + if (f >= 1.0F && !CrossbowItem.isCharged(stack) /*&& CrossbowItem.tryLoadProjectiles(entityliving, itemstack)*/) { -+ final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(user.getBukkitLivingEntity(), stack.asBukkitMirror(), user.getUsedItemHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND); ++ final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(user.getBukkitLivingEntity(), stack.asBukkitMirror(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(user.getUsedItemHand())); + if (!event.callEvent() || !tryLoadProjectiles(user, stack, event.shouldConsumeItem())) { + if (user instanceof ServerPlayer player) player.containerMenu.sendAllDataToRemote(); + return; diff --git a/patches/server/Add-EntityMoveEvent.patch b/patches/server/Add-EntityMoveEvent.patch index 5de8d63f0a..96604ba155 100644 --- a/patches/server/Add-EntityMoveEvent.patch +++ b/patches/server/Add-EntityMoveEvent.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent + worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent + worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent this.profiler.push(() -> { @@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (((ServerLevel) this.level()).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { + if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { + Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -+ Location to = new Location (this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); ++ Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); + if (!event.callEvent()) { + this.absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); diff --git a/patches/server/Add-EntityTeleportEndGatewayEvent.patch b/patches/server/Add-EntityTeleportEndGatewayEvent.patch index 7f322bb1c5..f74a3c437c 100644 --- a/patches/server/Add-EntityTeleportEndGatewayEvent.patch +++ b/patches/server/Add-EntityTeleportEndGatewayEvent.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } -- org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); // Paper - diff on change +- org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); - if (teleEvent.isCancelled()) { + // Paper start - EntityTeleportEndGatewayEvent + org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D); diff --git a/patches/server/Add-EntityZapEvent.patch b/patches/server/Add-EntityZapEvent.patch index 58a84922e9..6fb303b934 100644 --- a/patches/server/Add-EntityZapEvent.patch +++ b/patches/server/Add-EntityZapEvent.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start -+ public static com.destroystokyo.paper.event.entity.EntityZapEvent callEntityZapEvent (Entity entity, Entity lightning, Entity changedEntity) { ++ public static com.destroystokyo.paper.event.entity.EntityZapEvent callEntityZapEvent(Entity entity, Entity lightning, Entity changedEntity) { + com.destroystokyo.paper.event.entity.EntityZapEvent event = new com.destroystokyo.paper.event.entity.EntityZapEvent(entity.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), changedEntity.getBukkitEntity()); + entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); + return event; diff --git a/patches/server/Add-PlayerArmSwingEvent.patch b/patches/server/Add-PlayerArmSwingEvent.patch index c4195b2c65..23dc2e7aee 100644 --- a/patches/server/Add-PlayerArmSwingEvent.patch +++ b/patches/server/Add-PlayerArmSwingEvent.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Arm swing animation - PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer(), (packet.getHand() == InteractionHand.MAIN_HAND) ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING); -+ io.papermc.paper.event.player.PlayerArmSwingEvent event = new io.papermc.paper.event.player.PlayerArmSwingEvent(this.getCraftPlayer(), packet.getHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND); // Paper - Add PlayerArmSwingEvent ++ io.papermc.paper.event.player.PlayerArmSwingEvent event = new io.papermc.paper.event.player.PlayerArmSwingEvent(this.getCraftPlayer(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(packet.getHand())); // Paper - Add PlayerArmSwingEvent this.cserver.getPluginManager().callEvent(event); if (event.isCancelled()) return; diff --git a/patches/server/Add-PlayerArmorChangeEvent.patch b/patches/server/Add-PlayerArmorChangeEvent.patch index 376e162d8d..782bb9fc1a 100644 --- a/patches/server/Add-PlayerArmorChangeEvent.patch +++ b/patches/server/Add-PlayerArmorChangeEvent.patch @@ -8,13 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -0,0 +0,0 @@ - package net.minecraft.world.entity; - -+import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; // Paper - import com.google.common.base.Objects; - import com.google.common.collect.ImmutableList; - import com.google.common.collect.ImmutableMap; @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { ItemStack itemstack1 = this.getItemBySlot(enumitemslot); @@ -23,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (this instanceof ServerPlayer && enumitemslot.getType() == EquipmentSlot.Type.ARMOR) { + final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack); + final org.bukkit.inventory.ItemStack newItem = CraftItemStack.asBukkitCopy(itemstack1); -+ new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent(); ++ new com.destroystokyo.paper.event.player.PlayerArmorChangeEvent((Player) this.getBukkitEntity(), com.destroystokyo.paper.event.player.PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent(); + } + // Paper end - PlayerArmorChangeEvent if (map == null) { diff --git a/patches/server/Add-PlayerBedFailEnterEvent.patch b/patches/server/Add-PlayerBedFailEnterEvent.patch index 4c0b4ed1fd..88703ed557 100644 --- a/patches/server/Add-PlayerBedFailEnterEvent.patch +++ b/patches/server/Add-PlayerBedFailEnterEvent.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> { + // Paper start - PlayerBedFailEnterEvent + if (entityhuman_enumbedresult != null) { -+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), !world.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage())); ++ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.values()[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), !world.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage())); + if (!event.callEvent()) { + return; + } diff --git a/patches/server/Add-PlayerChangeBeaconEffectEvent.patch b/patches/server/Add-PlayerChangeBeaconEffectEvent.patch index e1cd8c774d..6ee5d02c34 100644 --- a/patches/server/Add-PlayerChangeBeaconEffectEvent.patch +++ b/patches/server/Add-PlayerChangeBeaconEffectEvent.patch @@ -9,17 +9,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java +++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java @@ -0,0 +0,0 @@ public class BeaconMenu extends AbstractContainerMenu { - public MobEffect getSecondaryEffect() { return BeaconMenu.decodeEffect(this.beaconData.get(2)); } + + // Paper start - Add PlayerChangeBeaconEffectEvent -+ private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional effect) { -+ return effect.flatMap(net.minecraft.core.registries.BuiltInRegistries.MOB_EFFECT::getResourceKey).map(key -> { -+ return org.bukkit.potion.PotionEffectType.getByKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location())); -+ }).orElse(null); ++ private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional optionalEffect) { ++ return optionalEffect.map(org.bukkit.craftbukkit.potion.CraftPotionEffectType::minecraftToBukkit).orElse(null); + } + // Paper end - Add PlayerChangeBeaconEffectEvent - ++ public void updateEffects(Optional primary, Optional secondary) { if (this.paymentSlot.hasItem()) { - this.beaconData.set(1, BeaconMenu.encodeEffect((MobEffect) primary.orElse(null))); // CraftBukkit - decompile error diff --git a/patches/server/Add-PlayerConnectionCloseEvent.patch b/patches/server/Add-PlayerConnectionCloseEvent.patch index fd55e089fd..079953370a 100644 --- a/patches/server/Add-PlayerConnectionCloseEvent.patch +++ b/patches/server/Add-PlayerConnectionCloseEvent.patch @@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /* Player was logged in, either game listener or configuration listener */ + final com.mojang.authlib.GameProfile profile = commonPacketListener.getOwner(); + new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(profile.getId(), -+ profile.getName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); ++ profile.getName(), ((InetSocketAddress) this.address).getAddress(), false).callEvent(); + } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener) { + /* Player is login stage */ + switch (loginListener.state) { @@ -61,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + case ACCEPTED: + final com.mojang.authlib.GameProfile profile = loginListener.authenticatedProfile; /* Should be non-null at this stage */ + new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(profile.getId(), profile.getName(), -+ ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); ++ ((InetSocketAddress) this.address).getAddress(), false).callEvent(); + } + } + // Paper end - Add PlayerConnectionCloseEvent diff --git a/patches/server/Add-PlayerDeepSleepEvent.patch b/patches/server/Add-PlayerDeepSleepEvent.patch index d7806b8dfb..fd35043bb4 100644 --- a/patches/server/Add-PlayerDeepSleepEvent.patch +++ b/patches/server/Add-PlayerDeepSleepEvent.patch @@ -13,8 +13,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.isSleeping()) { ++this.sleepCounter; + // Paper start - Add PlayerDeepSleepEvent -+ if (this.sleepCounter == 100) { -+ if (!new io.papermc.paper.event.player.PlayerDeepSleepEvent((org.bukkit.entity.Player) getBukkitEntity()).callEvent()) { this.sleepCounter = Integer.MIN_VALUE; } ++ if (this.sleepCounter == SLEEP_DURATION) { ++ if (!new io.papermc.paper.event.player.PlayerDeepSleepEvent((org.bukkit.entity.Player) getBukkitEntity()).callEvent()) { ++ this.sleepCounter = Integer.MIN_VALUE; ++ } + } + // Paper end - Add PlayerDeepSleepEvent if (this.sleepCounter > 100) { diff --git a/patches/server/Add-PlayerFlowerPotManipulateEvent.patch b/patches/server/Add-PlayerFlowerPotManipulateEvent.patch index 0482075f4f..763e37850b 100644 --- a/patches/server/Add-PlayerFlowerPotManipulateEvent.patch +++ b/patches/server/Add-PlayerFlowerPotManipulateEvent.patch @@ -13,20 +13,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean bl2 = this.isEmpty(); if (bl != bl2) { + // Paper start - Add PlayerFlowerPotManipulateEvent -+ org.bukkit.entity.Player player1 = (org.bukkit.entity.Player) player.getBukkitEntity(); -+ boolean placing = bl2; -+ org.bukkit.block.Block bukkitblock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); -+ org.bukkit.inventory.ItemStack bukkititemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack); -+ org.bukkit.Material mat = org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this.potted); -+ org.bukkit.inventory.ItemStack bukkititemstack1 = new org.bukkit.inventory.ItemStack(mat, 1); -+ org.bukkit.inventory.ItemStack whichitem = placing ? bukkititemstack : bukkititemstack1; ++ boolean placing = bl2; // OBFHELPER ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); ++ org.bukkit.inventory.ItemStack placedStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack); ++ org.bukkit.inventory.ItemStack pottedStack = new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.block.CraftBlockType.minecraftToBukkit(this.potted)); ++ org.bukkit.inventory.ItemStack stack = placing ? placedStack : pottedStack; + -+ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent(player1, bukkitblock, whichitem, placing); -+ player1.getServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { ++ io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent event = new io.papermc.paper.event.player.PlayerFlowerPotManipulateEvent((org.bukkit.entity.Player) player.getBukkitEntity(), block, stack, placing); ++ if (!event.callEvent()) { + // Update client -+ player1.updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + + return InteractionResult.PASS; + } diff --git a/patches/server/Add-PlayerItemCooldownEvent.patch b/patches/server/Add-PlayerItemCooldownEvent.patch index 4d21405f22..b9ec5eb903 100644 --- a/patches/server/Add-PlayerItemCooldownEvent.patch +++ b/patches/server/Add-PlayerItemCooldownEvent.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Add PlayerItemCooldownEvent + @Override + public void addCooldown(Item item, int duration) { -+ io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent(this.player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), duration); ++ io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent(this.player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(item), duration); + if (event.callEvent()) { + super.addCooldown(item, event.getCooldown()); + } diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 3a5133a03e..58d6a1da6d 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -405,7 +405,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } else { - ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked")); -+ ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_ENTITY_ATTACKED); // Paper - add cause ++ ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_ENTITY_ATTACKED); // Paper - add cause ServerGamePacketListenerImpl.LOGGER.warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getName().getString()); } } @@ -413,8 +413,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - auto recipe limit if (!org.bukkit.Bukkit.isPrimaryThread()) { if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { -- this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam", new Object[0]))); -+ this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause +- this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"))); ++ this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause return; } } @@ -445,7 +445,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entityplayer = (ServerPlayer) iterator.next(); this.save(entityplayer); // CraftBukkit - Force the player's inventory to be saved - entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login")); -+ entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause ++ entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"), org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause } // Instead of kicking then returning, we need to store the kick reason diff --git a/patches/server/Add-PlayerLoomPatternSelectEvent.patch b/patches/server/Add-PlayerLoomPatternSelectEvent.patch index 9ff8a8d770..767b7724b9 100644 --- a/patches/server/Add-PlayerLoomPatternSelectEvent.patch +++ b/patches/server/Add-PlayerLoomPatternSelectEvent.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int selectablePatternIndex = id; + io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.block.banner.PatternType.getByIdentifier(this.selectablePatterns.get(selectablePatternIndex).value().getHashname())); + if (!event.callEvent()) { -+ ((Player) player.getBukkitEntity()).updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + return false; + } + Holder selectedPattern = null; @@ -33,13 +33,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (selectedPattern == null) { + for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) { + if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) { -+ selectedPattern = BuiltInRegistries.BANNER_PATTERN.getHolder(BuiltInRegistries.BANNER_PATTERN.getId(pattern)).orElseThrow(); ++ selectedPattern = BuiltInRegistries.BANNER_PATTERN.wrapAsHolder(pattern); + break; + } + } + selectablePatternIndex = -1; + } -+ ((Player) player.getBukkitEntity()).updateInventory(); ++ ++ player.containerMenu.sendAllDataToRemote(); + this.selectedBannerPatternIndex.set(selectablePatternIndex); + this.setupResultSlot(java.util.Objects.requireNonNull(selectedPattern, "selectedPattern was null, this is unexpected")); + // Paper end - Add PlayerLoomPatternSelectEvent diff --git a/patches/server/Add-PlayerNameEntityEvent.patch b/patches/server/Add-PlayerNameEntityEvent.patch index be82062a8f..e8f2a3da76 100644 --- a/patches/server/Add-PlayerNameEntityEvent.patch +++ b/patches/server/Add-PlayerNameEntityEvent.patch @@ -18,10 +18,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Add PlayerNameEntityEvent + io.papermc.paper.event.player.PlayerNameEntityEvent event = new io.papermc.paper.event.player.PlayerNameEntityEvent(((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity(), entity.getBukkitLivingEntity(), io.papermc.paper.adventure.PaperAdventure.asAdventure(stack.getHoverName()), true); + if (!event.callEvent()) return InteractionResult.PASS; -+ LivingEntity newEntityLiving = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getEntity()).getHandle(); -+ newEntityLiving.setCustomName(event.getName() != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(event.getName()) : null); -+ if (event.isPersistent() && newEntityLiving instanceof Mob) { -+ ((Mob) newEntityLiving).setPersistenceRequired(); ++ LivingEntity newEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getEntity()).getHandle(); ++ newEntity.setCustomName(event.getName() != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(event.getName()) : null); ++ if (event.isPersistent() && newEntity instanceof Mob) { ++ ((Mob) newEntity).setPersistenceRequired(); + // Paper end - Add PlayerNameEntityEvent } diff --git a/patches/server/Add-PlayerShearBlockEvent.patch b/patches/server/Add-PlayerShearBlockEvent.patch index 4534a6ef4a..bd19ba6a2a 100644 --- a/patches/server/Add-PlayerShearBlockEvent.patch +++ b/patches/server/Add-PlayerShearBlockEvent.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (itemstack.is(Items.SHEARS)) { + // Paper start - Add PlayerShearBlockEvent -+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>()); ++ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>()); + event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.HONEYCOMB, 3))); + if (!event.callEvent()) { + return InteractionResult.PASS; @@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (itemStack.is(Items.SHEARS)) { if (!world.isClientSide) { + // Paper start - Add PlayerShearBlockEvent -+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>()); ++ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>()); + event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4))); + if (!event.callEvent()) { + return InteractionResult.PASS; diff --git a/patches/server/Add-PlayerShieldDisableEvent.patch b/patches/server/Add-PlayerShieldDisableEvent.patch index ab943067a4..0e4d5cf3d5 100644 --- a/patches/server/Add-PlayerShieldDisableEvent.patch +++ b/patches/server/Add-PlayerShieldDisableEvent.patch @@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.attack(target); } -+ @io.papermc.paper.annotation.DoNotUse // Paper - Add PlayerShieldDisableEvent ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerShieldDisableEvent public void disableShield(boolean sprinting) { + // Paper start - Add PlayerShieldDisableEvent + disableShield(sprinting, null); diff --git a/patches/server/Add-PlayerStonecutterRecipeSelectEvent.patch b/patches/server/Add-PlayerStonecutterRecipeSelectEvent.patch index b268345965..81accc5f74 100644 --- a/patches/server/Add-PlayerStonecutterRecipeSelectEvent.patch +++ b/patches/server/Add-PlayerStonecutterRecipeSelectEvent.patch @@ -30,20 +30,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (this.isValidRecipeIndex(id)) { + io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent event = new io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent((Player) player.getBukkitEntity(), (org.bukkit.inventory.StonecutterInventory) getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) this.getRecipes().get(id).toBukkitRecipe()); + if (!event.callEvent()) { -+ ((Player) player.getBukkitEntity()).updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + return false; + } -+ int newRecipeIndex; -+ if (!this.getRecipes().get(recipeIndex).id().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { // If the recipe did NOT stay the same -+ for (newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) { -+ if (this.getRecipes().get(newRecipeIndex).id().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { ++ ++ net.minecraft.resources.ResourceLocation key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); ++ if (!this.getRecipes().get(recipeIndex).id().equals(key)) { // If the recipe did NOT stay the same ++ for (int newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) { ++ if (this.getRecipes().get(newRecipeIndex).id().equals(key)) { + recipeIndex = newRecipeIndex; + break; + } + } + } + } -+ ((Player) player.getBukkitEntity()).updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it + // Paper end - Add PlayerStonecutterRecipeSelectEvent this.setupResultSlot(); diff --git a/patches/server/Add-PlayerUseUnknownEntityEvent.patch b/patches/server/Add-PlayerUseUnknownEntityEvent.patch index c31824f99b..9f076a43c9 100644 --- a/patches/server/Add-PlayerUseUnknownEntityEvent.patch +++ b/patches/server/Add-PlayerUseUnknownEntityEvent.patch @@ -40,33 +40,40 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + packet.dispatch(new net.minecraft.network.protocol.game.ServerboundInteractPacket.Handler() { + @Override + public void onInteraction(net.minecraft.world.InteractionHand hand) { -+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, hand, null); ++ CraftEventFactory.callPlayerUseUnknownEntityEvent(ServerGamePacketListenerImpl.this.player, packet, hand, null); + } + + @Override + public void onInteraction(net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.Vec3 pos) { -+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, hand, pos); ++ CraftEventFactory.callPlayerUseUnknownEntityEvent(ServerGamePacketListenerImpl.this.player, packet, hand, pos); + } -+ + + @Override + public void onAttack() { -+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, net.minecraft.world.InteractionHand.MAIN_HAND, null); ++ CraftEventFactory.callPlayerUseUnknownEntityEvent(ServerGamePacketListenerImpl.this.player, packet, net.minecraft.world.InteractionHand.MAIN_HAND, null); + } + }); + } -+ -+ } - -+ private void callPlayerUseUnknownEntityEvent(ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) { -+ this.cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent( -+ this.getCraftPlayer(), -+ packet.getEntityId(), -+ packet.isAttack(), -+ hand == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND, -+ vector != null ? new org.bukkit.util.Vector(vector.x, vector.y, vector.z) : null) -+ ); ++ // Paper end - PlayerUseUnknownEntityEvent } -+ // Paper end - PlayerUseUnknownEntityEvent @Override - public void handleClientCommand(ServerboundClientCommandPacket packet) { +diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +@@ -0,0 +0,0 @@ public class CraftEventFactory { + Bukkit.getPluginManager().callEvent(event); + return event; + } ++ ++ // Paper start - PlayerUseUnknownEntityEvent ++ public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) { ++ new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent( ++ (Player) player.getBukkitEntity(), packet.getEntityId(), packet.isAttack(), ++ CraftEquipmentSlot.getHand(hand), ++ vector != null ? CraftVector.toBukkit(vector) : null ++ ).callEvent(); ++ } ++ // Paper end - PlayerUseUnknownEntityEvent + } diff --git a/patches/server/Add-PrepareResultEvent.patch b/patches/server/Add-PrepareResultEvent.patch index 2b4372d4a3..0a63dc6d24 100644 --- a/patches/server/Add-PrepareResultEvent.patch +++ b/patches/server/Add-PrepareResultEvent.patch @@ -98,51 +98,50 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { + } + + public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) { ++ // Paper start - Add PrepareResultEvent ++ if (true) { ++ view.getTopInventory().setItem(net.minecraft.world.inventory.AnvilMenu.RESULT_SLOT, CraftItemStack.asCraftMirror(item)); ++ return null; // verify nothing uses return - disable event: handled below in PrepareResult ++ } ++ // Paper end - Add PrepareResultEvent + PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone()); + event.getView().getPlayer().getServer().getPluginManager().callEvent(event); + event.getInventory().setItem(2, event.getResult()); +@@ -0,0 +0,0 @@ public class CraftEventFactory { + } + + public static PrepareGrindstoneEvent callPrepareGrindstoneEvent(InventoryView view, ItemStack item) { ++ // Paper start - Add PrepareResultEvent ++ if (true) { ++ view.getTopInventory().setItem(net.minecraft.world.inventory.GrindstoneMenu.RESULT_SLOT, CraftItemStack.asCraftMirror(item)); ++ return null; // verify nothing uses return - disable event: handled below in PrepareResult ++ } ++ // Paper end - Add PrepareResultEvent + PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(view, CraftItemStack.asCraftMirror(item).clone()); + event.getView().getPlayer().getServer().getPluginManager().callEvent(event); + event.getInventory().setItem(2, event.getResult()); +@@ -0,0 +0,0 @@ public class CraftEventFactory { + } + + public static PrepareSmithingEvent callPrepareSmithingEvent(InventoryView view, ItemStack item) { ++ // Paper start - Add PrepareResultEvent ++ if (true) { ++ view.getTopInventory().setItem(net.minecraft.world.inventory.SmithingMenu.RESULT_SLOT, CraftItemStack.asCraftMirror(item)); ++ return null; // verify nothing uses return - disable event: handled below in PrepareResult ++ } ++ // Paper end - Add PrepareResultEvent + PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item).clone()); + event.getView().getPlayer().getServer().getPluginManager().callEvent(event); + event.getInventory().setResult(event.getResult()); return event; } -- public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) { -- PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone()); -- event.getView().getPlayer().getServer().getPluginManager().callEvent(event); -+ // Paper start - Add PrepareResultEvent; disable this method, handled below -+ public static void callPrepareAnvilEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult -+ PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone -+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event - event.getInventory().setItem(2, event.getResult()); -- return event; -+ //return event; - } -+ // Paper end - Add PrepareResultEvent - -- public static PrepareGrindstoneEvent callPrepareGrindstoneEvent(InventoryView view, ItemStack item) { -- PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(view, CraftItemStack.asCraftMirror(item).clone()); -- event.getView().getPlayer().getServer().getPluginManager().callEvent(event); -+ // Paper start - Add PrepareResultEvent; disable this method, handled below -+ public static void callPrepareGrindstoneEvent(InventoryView view, ItemStack item) { -+ PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone -+ // event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event - event.getInventory().setItem(2, event.getResult()); -- return event; -+ // return event; - } -+ // Paper end - Add PrepareResultEvent - -- public static PrepareSmithingEvent callPrepareSmithingEvent(InventoryView view, ItemStack item) { -- PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item).clone()); -- event.getView().getPlayer().getServer().getPluginManager().callEvent(event); -+ // Paper start - Add PrepareResultEvent; disable this method, handled in callPrepareResultEvent -+ public static void callPrepareSmithingEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult -+ PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone -+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event - event.getInventory().setResult(event.getResult()); -- return event; -+ //return event; // Paper -+ } -+ // Paper end - Add PrepareResultEvent -+ + // Paper start - Add PrepareResultEvent + public static void callPrepareResultEvent(AbstractContainerMenu container, int resultSlot) { -+ com.destroystokyo.paper.event.inventory.PrepareResultEvent event; ++ final com.destroystokyo.paper.event.inventory.PrepareResultEvent event; + InventoryView view = container.getBukkitView(); + org.bukkit.inventory.ItemStack origItem = view.getTopInventory().getItem(resultSlot); + CraftItemStack result = origItem != null ? CraftItemStack.asCraftCopy(origItem) : null; @@ -158,8 +157,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + event.callEvent(); + event.getInventory().setItem(resultSlot, event.getResult()); + container.broadcastChanges();; - } ++ } + // Paper end - Add PrepareResultEvent - ++ /** * Mob spawner event. + */ diff --git a/patches/server/Add-TNTPrimeEvent.patch b/patches/server/Add-TNTPrimeEvent.patch index 16262b0e2f..8696d623ee 100644 --- a/patches/server/Add-TNTPrimeEvent.patch +++ b/patches/server/Add-TNTPrimeEvent.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition, ItemStack.EMPTY, false); } + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = this.level().getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.block.Block tntBlock = CraftBlock.at(this.level(), blockposition); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent()) + continue; + // Paper end - TNTPrimeEvent @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (block instanceof TntBlock) { + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, blockposition); ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.FIRE, null).callEvent()) { + return; + } @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!oldState.is(state.getBlock())) { if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos); ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { + return; + } @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, sourcePos)) { // CraftBukkit - TNTPrimeEvent + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos); ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { + return; + } @@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void wasExploded(Level world, BlockPos pos, Explosion explosion) { if (!world.isClientSide) { + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos); ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + org.bukkit.entity.Entity source = explosion.source != null ? explosion.source.getBukkitEntity() : null; + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) { + return; @@ -94,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // CraftBukkit end + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos); ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent()) { + return InteractionResult.FAIL; + } @@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // CraftBukkit end + // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, blockposition); ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.PROJECTILE, projectile.getBukkitEntity()).callEvent()) { + return; + } diff --git a/patches/server/Add-UnknownCommandEvent.patch b/patches/server/Add-UnknownCommandEvent.patch index 6087146f01..3b3d6c1633 100644 --- a/patches/server/Add-UnknownCommandEvent.patch +++ b/patches/server/Add-UnknownCommandEvent.patch @@ -118,7 +118,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - sender.sendMessage(org.spigotmc.SpigotConfig.unknownCommandMessage); + // Paper start + org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(sender, commandLine, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.unknownCommandMessage)); -+ Bukkit.getServer().getPluginManager().callEvent(event); ++ this.getPluginManager().callEvent(event); + if (event.message() != null) { + sender.sendMessage(event.message()); + } diff --git a/patches/server/Add-back-EntityPortalExitEvent.patch b/patches/server/Add-back-EntityPortalExitEvent.patch index f79fd54d6a..5103e03a4f 100644 --- a/patches/server/Add-back-EntityPortalExitEvent.patch +++ b/patches/server/Add-back-EntityPortalExitEvent.patch @@ -13,11 +13,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start worldserver = shapedetectorshape.world; + // Paper start - Call EntityPortalExitEvent -+ CraftEntity bukkitEntity = this.getBukkitEntity(); + Vec3 position = shapedetectorshape.pos; + float yaw = shapedetectorshape.yRot; -+ float pitch = bukkitEntity.getLocation().getPitch(); // Keep entity pitch as per moveTo line below ++ float pitch = this.getXRot(); // Keep entity pitch as per moveTo line below + Vec3 velocity = shapedetectorshape.speed; ++ CraftEntity bukkitEntity = this.getBukkitEntity(); + org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(bukkitEntity, + bukkitEntity.getLocation(), new Location(worldserver.getWorld(), position.x, position.y, position.z, yaw, pitch), + bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(shapedetectorshape.speed)); @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + if (!event.isCancelled() && event.getTo() != null) { + worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); -+ position = new Vec3(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); ++ position = CraftLocation.toVec3D(event.getTo()); + yaw = event.getTo().getYaw(); + pitch = event.getTo().getPitch(); + velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter()); diff --git a/patches/server/Add-critical-damage-API.patch b/patches/server/Add-critical-damage-API.patch index a4cadcf76e..98da1a922f 100644 --- a/patches/server/Add-critical-damage-API.patch +++ b/patches/server/Add-critical-damage-API.patch @@ -120,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Add critical damage API + @Deprecated private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions, boolean cancelled) { -+ return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false, false); ++ return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, cancelled, false); + } + + private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions, boolean cancelled, boolean critical) { diff --git a/patches/server/Add-drops-to-shear-events.patch b/patches/server/Add-drops-to-shear-events.patch index 274d7656ab..fdcea1765f 100644 --- a/patches/server/Add-drops-to-shear-events.patch +++ b/patches/server/Add-drops-to-shear-events.patch @@ -268,21 +268,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack { - } return stack; } + + // Paper start + public static java.util.List asNMSCopy(java.util.List originals) { -+ final java.util.List nms = new java.util.ArrayList<>(); -+ for (final org.bukkit.inventory.ItemStack original : originals) { -+ nms.add(asNMSCopy(original)); ++ final java.util.List items = new java.util.ArrayList<>(originals.size()); ++ for (final ItemStack original : originals) { ++ items.add(asNMSCopy(original)); + } -+ return nms; ++ return items; + } + // Paper end - ++ public static net.minecraft.world.item.ItemStack copyNMSStack(net.minecraft.world.item.ItemStack original, int amount) { net.minecraft.world.item.ItemStack stack = original.copy(); + stack.setCount(amount); diff --git a/src/test/java/io/papermc/paper/entity/ShearableDropsTest.java b/src/test/java/io/papermc/paper/entity/ShearableDropsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Add-exception-reporting-event.patch b/patches/server/Add-exception-reporting-event.patch index 76200db71d..aacb3a9ed7 100644 --- a/patches/server/Add-exception-reporting-event.patch +++ b/patches/server/Add-exception-reporting-event.patch @@ -52,18 +52,11 @@ diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java +++ b/src/main/java/net/minecraft/server/players/OldUsersConverter.java -@@ -0,0 +0,0 @@ - package net.minecraft.server.players; - -+import com.destroystokyo.paper.exception.ServerInternalException; - import com.google.common.collect.Lists; - import com.google.common.collect.Maps; - import com.google.common.io.Files; @@ -0,0 +0,0 @@ public class OldUsersConverter { root = NbtIo.readCompressed(new java.io.FileInputStream(file5), NbtAccounter.unlimitedHeap()); } catch (Exception exception) { exception.printStackTrace(); -+ ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent } if (root != null) { @@ -71,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 NbtIo.writeCompressed(root, new java.io.FileOutputStream(file2)); } catch (Exception exception) { exception.printStackTrace(); -+ ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent } } // CraftBukkit end @@ -91,22 +84,11 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ - package net.minecraft.world.level; - -+import co.aikar.timings.Timing; -+import co.aikar.timings.Timings; -+import com.destroystokyo.paper.event.server.ServerExceptionEvent; -+import com.destroystokyo.paper.exception.ServerInternalException; -+import com.google.common.base.MoreObjects; - import com.google.common.collect.Lists; - import com.mojang.serialization.Codec; - import java.io.IOException; @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper start - Prevent block entity and entity crashes final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); MinecraftServer.LOGGER.error(msg, throwable); -+ getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent ++ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent entity.discard(); // Paper end - Prevent block entity and entity crashes } diff --git a/patches/server/Add-fire-tick-delay-option.patch b/patches/server/Add-fire-tick-delay-option.patch index ec80e863f2..df09fbe72c 100644 --- a/patches/server/Add-fire-tick-delay-option.patch +++ b/patches/server/Add-fire-tick-delay-option.patch @@ -18,19 +18,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!state.canSurvive(world, pos)) { this.fireExtinguished(world, pos); // CraftBukkit - invalid place location @@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock { - public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) { - super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, itemActionContext); - // Paper end - ItemActionContext param -- world.scheduleTick(blockposition, this, getFireTickDelay(world.random)); -+ world.scheduleTick(blockposition, this, getFireTickDelay(world)); // Paper - Add fire-tick-delay option + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) { + super.onPlace(state, world, pos, oldState, notify, context); + // Paper end - UseOnContext param +- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random)); ++ world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option } - private static int getFireTickDelay(RandomSource random) { - return 30 + random.nextInt(10); -+ // Paper start - Add fire-tick-delay option -+ private static int getFireTickDelay(Level world) { -+ return world.paperConfig().environment.fireTickDelay + world.random.nextInt(10); -+ // Paper end - Add fire-tick-delay option ++ private static int getFireTickDelay(Level world) { // Paper - Add fire-tick-delay option ++ return world.paperConfig().environment.fireTickDelay + world.random.nextInt(10); // Paper - Add fire-tick-delay option } @Override diff --git a/patches/server/Add-more-Witch-API.patch b/patches/server/Add-more-Witch-API.patch index cc523057a1..fc04dac012 100644 --- a/patches/server/Add-more-Witch-API.patch +++ b/patches/server/Add-more-Witch-API.patch @@ -15,12 +15,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (potionregistry != null) { - // Paper start - ItemStack potion = PotionUtils.setPotion(new ItemStack(Items.POTION), potionregistry); -- org.bukkit.inventory.ItemStack bukkitStack = com.destroystokyo.paper.event.entity.WitchReadyPotionEvent.process((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(potion)); -- this.setItemSlot(EquipmentSlot.MAINHAND, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(bukkitStack)); -+ // Paper start - logic moved into setDrinkingPotion, copy exact impl into the method and then comment out -+ this.setDrinkingPotion(potion); - // Paper end +- ItemStack potion = PotionUtils.setPotion(new ItemStack(Items.POTION), potionregistry); +- potion = org.bukkit.craftbukkit.event.CraftEventFactory.handleWitchReadyPotionEvent(this, potion); +- this.setItemSlot(EquipmentSlot.MAINHAND, potion); +- // Paper end - this.usingTime = this.getMainHandItem().getUseDuration(); - this.setUsingItem(true); - if (!this.isSilent()) { @@ -31,6 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - attributemodifiable.removeModifier(Witch.SPEED_MODIFIER_DRINKING.getId()); - attributemodifiable.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING); ++ this.setDrinkingPotion(PotionUtils.setPotion(new ItemStack(Items.POTION), potionregistry)); // Paper - logic moved into setDrinkingPotion, copy exact impl into the method and then comment out } } @@ -40,9 +39,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - moved to its own method + public void setDrinkingPotion(ItemStack potion) { -+ org.bukkit.inventory.ItemStack bukkitStack = com.destroystokyo.paper.event.entity.WitchReadyPotionEvent.process((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(potion)); -+ this.setItemSlot(EquipmentSlot.MAINHAND, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(bukkitStack)); -+ // Paper end ++ potion = org.bukkit.craftbukkit.event.CraftEventFactory.handleWitchReadyPotionEvent(this, potion); ++ this.setItemSlot(EquipmentSlot.MAINHAND, potion); + this.usingTime = this.getMainHandItem().getUseDuration(); + this.setUsingItem(true); + if (!this.isSilent()) { diff --git a/patches/server/Add-more-fields-to-AsyncPreLoginEvent.patch b/patches/server/Add-more-fields-to-AsyncPreLoginEvent.patch index 1ac6a195de..a57052ffb1 100644 --- a/patches/server/Add-more-fields-to-AsyncPreLoginEvent.patch +++ b/patches/server/Add-more-fields-to-AsyncPreLoginEvent.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); + // Paper start - Add more fields to AsyncPlayerPreLoginEvent -+ final java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); ++ final InetAddress rawAddress = ((InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); + com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, this.connection.hostname); server.getPluginManager().callEvent(asyncEvent); diff --git a/patches/server/Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch b/patches/server/Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch index 4f8f7d3d23..bd1b2ebb05 100644 --- a/patches/server/Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch +++ b/patches/server/Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); - ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1); -+ // Paper start, new EntityItem would throw if for whatever reason (mostly shitty datapacks) the itemstack1 turns out to be empty ++ // Paper start - new ItemEntity would throw if for whatever reason (mostly shitty datapacks) the itemstack1 turns out to be empty + // if the item stack is empty we instead just have our entityitem as null + ItemEntity entityitem = null; + if (!itemstack1.isEmpty()) { @@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); - this.level().addFreshEntity(entityitem); -+ // Paper start, entity item can be null, so we need to check against this ++ // Paper start - entity item can be null, so we need to check against this + if (entityitem != null) { + entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); + this.level().addFreshEntity(entityitem); diff --git a/patches/server/BlockDestroyEvent.patch b/patches/server/BlockDestroyEvent.patch index a05f87801e..25b5a13cef 100644 --- a/patches/server/BlockDestroyEvent.patch +++ b/patches/server/BlockDestroyEvent.patch @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + BlockState effectType = iblockdata; + int xp = iblockdata.getBlock().getExpDrop(iblockdata, (ServerLevel) this, pos, ItemStack.EMPTY, true); + if (com.destroystokyo.paper.event.block.BlockDestroyEvent.getHandlerList().getRegisteredListeners().length > 0) { -+ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(MCUtil.toBukkitBlock(this, pos), fluid.createLegacyBlock().createCraftBlockData(), effectType.createCraftBlockData(), xp, drop); ++ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos), fluid.createLegacyBlock().createCraftBlockData(), effectType.createCraftBlockData(), xp, drop); + if (!event.callEvent()) { + return false; + } diff --git a/patches/server/Call-BlockPhysicsEvent-more-often.patch b/patches/server/Call-BlockPhysicsEvent-more-often.patch index 10c630f87f..b6308b9cec 100644 --- a/patches/server/Call-BlockPhysicsEvent-more-often.patch +++ b/patches/server/Call-BlockPhysicsEvent-more-often.patch @@ -15,23 +15,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, this.sourcePos, false); + // Paper start - Call BlockPhysicsEvent + try { -+ boolean cancelled = false; -+ org.bukkit.craftbukkit.CraftWorld cworld = world.getWorld(); -+ if (cworld != null) { -+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( -+ org.bukkit.craftbukkit.block.CraftBlock.at(world, blockPos), -+ org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(blockState), -+ org.bukkit.craftbukkit.block.CraftBlock.at(world, sourcePos)); ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent( ++ org.bukkit.craftbukkit.block.CraftBlock.at(world, blockPos), ++ org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(blockState), ++ org.bukkit.craftbukkit.block.CraftBlock.at(world, this.sourcePos)); + -+ if (!event.callEvent()) { -+ cancelled = true; -+ } -+ } -+ if (!cancelled) { // continue to check for adjacent block (increase idx) ++ if (event.callEvent()) { // continue to check for adjacent block (increase idx) + NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, this.sourcePos, false); + } + } catch (StackOverflowError ex) { -+ world.lastPhysicsProblem = new BlockPos(blockPos); ++ world.lastPhysicsProblem = blockPos; + } + // Paper end - Call BlockPhysicsEvent if (this.idx < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.idx] == this.skipDirection) { diff --git a/patches/server/Call-missing-BlockDispenseEvent.patch b/patches/server/Call-missing-BlockDispenseEvent.patch index 49b15be6d2..177d9db68a 100644 --- a/patches/server/Call-missing-BlockDispenseEvent.patch +++ b/patches/server/Call-missing-BlockDispenseEvent.patch @@ -60,10 +60,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Call missing BlockDispenseEvent + @Nullable + public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack itemStack, net.minecraft.core.dispenser.DispenseItemBehavior instance) { -+ org.bukkit.block.Block bukkitBlock = pointer.level().getWorld().getBlockAt(pointer.pos().getX(), pointer.pos().getY(), pointer.pos().getZ()); ++ org.bukkit.block.Block bukkitBlock = CraftBlock.at(pointer.level(), pointer.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1)); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(to.getX(), to.getY(), to.getZ())); ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to)); + if (!net.minecraft.world.level.block.DispenserBlock.eventFired) { + if (!event.callEvent()) { + return itemStack; @@ -73,9 +73,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ net.minecraft.core.dispenser.DispenseItemBehavior idispensebehavior = net.minecraft.world.level.block.DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != net.minecraft.core.dispenser.DispenseItemBehavior.NOOP && idispensebehavior != instance) { -+ idispensebehavior.dispense(pointer, eventStack); ++ net.minecraft.core.dispenser.DispenseItemBehavior itemBehavior = net.minecraft.world.level.block.DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (itemBehavior != net.minecraft.core.dispenser.DispenseItemBehavior.NOOP && itemBehavior != instance) { ++ itemBehavior.dispense(pointer, eventStack); + return itemStack; + } + } @@ -85,4 +85,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - add EntityFertilizeEggEvent /** - * Calls the io.papermc.paper.event.entity.EntityFertilizeEggEvent. + * Calls the {@link io.papermc.paper.event.entity.EntityFertilizeEggEvent}. diff --git a/patches/server/Correctly-handle-interactions-with-items-on-cooldown.patch b/patches/server/Correctly-handle-interactions-with-items-on-cooldown.patch index 4836faddf8..3b44b40241 100644 --- a/patches/server/Correctly-handle-interactions-with-items-on-cooldown.patch +++ b/patches/server/Correctly-handle-interactions-with-items-on-cooldown.patch @@ -34,14 +34,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { - return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, false, hand, null); } -+ -+ // Paper start - cancelledItem param public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand, Vec3 targetPos) { ++ // Paper start - cancelledItem param + return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, cancelledBlock, false, hand, targetPos); + } ++ + public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, boolean cancelledItem, InteractionHand hand, Vec3 targetPos) { + // Paper end - cancelledItem param Player player = (who == null) ? null : (Player) who.getBukkitEntity(); diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 38962f72ee..4272a13c98 100644 --- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -596,7 +596,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } catch (Exception exception) { - exception.printStackTrace(); + io.papermc.paper.util.TraceUtil.printStackTrace(exception); // Paper - ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent } @@ -0,0 +0,0 @@ public class OldUsersConverter { @@ -605,7 +605,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } catch (Exception exception) { - exception.printStackTrace(); + io.papermc.paper.util.TraceUtil.printStackTrace(exception); // Paper - ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - ServerExceptionEvent } } diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java diff --git a/patches/server/Dont-resend-blocks-on-interactions.patch b/patches/server/Dont-resend-blocks-on-interactions.patch index 8058f13b59..c88f3274ca 100644 --- a/patches/server/Dont-resend-blocks-on-interactions.patch +++ b/patches/server/Dont-resend-blocks-on-interactions.patch @@ -124,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); + //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - Don't resync blocks // Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method - } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) { + } else if (iblockdata.is(Blocks.STRUCTURE_BLOCK) || iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) { player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server/Eigencraft-redstone-implementation.patch b/patches/server/Eigencraft-redstone-implementation.patch index 4dbbc3f89d..d5aa9977a1 100644 --- a/patches/server/Eigencraft-redstone-implementation.patch +++ b/patches/server/Eigencraft-redstone-implementation.patch @@ -41,6 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.level.block.state.BlockState; ++import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.block.BlockRedstoneEvent; + +import com.google.common.collect.Lists; @@ -925,7 +926,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // egg82's amendment + // Adding Bukkit's BlockRedstoneEvent - er.. event. + if (i != j) { -+ BlockRedstoneEvent event = new BlockRedstoneEvent(worldIn.getWorld().getBlockAt(upd.self.getX(), upd.self.getY(), upd.self.getZ()), i, j); ++ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(worldIn, upd.self), i, j); + worldIn.getCraftServer().getPluginManager().callEvent(event); + j = event.getNewCurrent(); + } @@ -1085,7 +1086,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + if (i != j) { -+ org.bukkit.event.block.BlockRedstoneEvent event = new org.bukkit.event.block.BlockRedstoneEvent(worldIn.getWorld().getBlockAt(pos1.getX(), pos1.getY(), pos1.getZ()), i, j); ++ org.bukkit.event.block.BlockRedstoneEvent event = new org.bukkit.event.block.BlockRedstoneEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldIn, pos1), i, j); + worldIn.getCraftServer().getPluginManager().callEvent(event); + + j = event.getNewCurrent(); diff --git a/patches/server/Extend-Player-Interact-cancellation.patch b/patches/server/Extend-Player-Interact-cancellation.patch index 0f65b957cd..d49552be56 100644 --- a/patches/server/Extend-Player-Interact-cancellation.patch +++ b/patches/server/Extend-Player-Interact-cancellation.patch @@ -9,9 +9,6 @@ However, it is possible to close these GUIs from the server. Flower pots are also not updated on the client when interaction is cancelled, this patch also resolves this. -Update adjacent blocks of doors, double plants, pistons and beds -when cancelling interaction. - diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -21,9 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc) player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); + // Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method -+ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) { -+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); -+ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) { ++ } else if (iblockdata.is(Blocks.STRUCTURE_BLOCK) || iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) { + player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); } + // Paper end - extend Player Interact cancellation diff --git a/patches/server/Fire-entity-death-event-for-ender-dragon.patch b/patches/server/Fire-entity-death-event-for-ender-dragon.patch index 18d2fe6365..90c3ad407d 100644 --- a/patches/server/Fire-entity-death-event-for-ender-dragon.patch +++ b/patches/server/Fire-entity-death-event-for-ender-dragon.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void kill() { + // Paper start - Fire entity death event + this.silentDeath = true; -+ org.bukkit.event.entity.EntityDeathEvent deathEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this); ++ org.bukkit.event.entity.EntityDeathEvent deathEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this); + if (deathEvent.isCancelled()) { + this.silentDeath = false; // Reset to default if event was cancelled + return; diff --git a/patches/server/Fire-event-on-GS4-query.patch b/patches/server/Fire-event-on-GS4-query.patch index 9db0e51ac3..7782f518b9 100644 --- a/patches/server/Fire-event-on-GS4-query.patch +++ b/patches/server/Fire-event-on-GS4-query.patch @@ -4,27 +4,6 @@ Date: Sun, 17 Mar 2019 21:46:56 +0200 Subject: [PATCH] Fire event on GS4 query -diff --git a/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java b/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java -+++ b/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java -@@ -0,0 +0,0 @@ public class NetworkDataOutputStream { - this.dataOutputStream.write(0); - } - -+ // Paper start - Fire event on GS4 query -+ public void writeStringUnchecked(String string) { -+ try { -+ writeString(string); -+ } catch (IOException e) { -+ com.destroystokyo.paper.util.SneakyThrow.sneaky(e); -+ } -+ } -+ // Paper end - Fire event on GS4 query -+ - public void write(int value) throws IOException { - this.dataOutputStream.write(value); - } diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java diff --git a/patches/server/Fix-commands-from-signs-not-firing-command-events.patch b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch index 393732d565..2bccb70e1e 100644 --- a/patches/server/Fix-commands-from-signs-not-firing-command-events.patch +++ b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch @@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (org.spigotmc.SpigotConfig.logCommands) { + LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command); + } -+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent((org.bukkit.entity.Player) player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) io.papermc.paper.util.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState(), front ? Side.FRONT : Side.BACK); ++ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent((org.bukkit.entity.Player) player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) CraftBlock.at(this.level, this.worldPosition).getState(), front ? Side.FRONT : Side.BACK); + if (!event.callEvent()) { + return false; + } diff --git a/patches/server/Implement-extended-PaperServerListPingEvent.patch b/patches/server/Implement-extended-PaperServerListPingEvent.patch index cbea780543..d516403348 100644 --- a/patches/server/Implement-extended-PaperServerListPingEvent.patch +++ b/patches/server/Implement-extended-PaperServerListPingEvent.patch @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final MinecraftServer server; + + PaperServerListPingEventImpl(MinecraftServer server, StatusClient client, int protocolVersion, @Nullable CachedServerIcon icon) { -+ super(client, server.server.motd(), server.getPlayerCount(), server.getMaxPlayers(), ++ super(client, server.motd(), server.getPlayerCount(), server.getMaxPlayers(), + server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon); + this.server = server; + } diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index b853c20f4f..ce4047452b 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -110,10 +110,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else if (flag1) { this.playHurtSound(source); @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity entityliving = this.getKillCredit(); -- + + /* // Paper - move down to make death event cancellable - this is the awardKillScore below if (this.deathScore >= 0 && entityliving != null) { entityliving.awardKillScore(this, this.deathScore, damageSource); @@ -132,7 +131,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (world instanceof ServerLevel) { ServerLevel worldserver = (ServerLevel) world; + // Paper - move below into if for onKill -+ + +- if (entity == null || entity.killedEntity(worldserver, this)) { + // Paper start + org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(damageSource); + if (deathEvent == null || !deathEvent.isCancelled()) { @@ -147,8 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.clearedEquipmentSlots.clear(); + } + // Paper end - -- if (entity == null || entity.killedEntity(worldserver, this)) { ++ + if (this.isSleeping()) { + this.stopSleeping(); + } diff --git a/patches/server/InventoryCloseEvent-Reason-API.patch b/patches/server/InventoryCloseEvent-Reason-API.patch index 4188cc5520..f2c7abd3e0 100644 --- a/patches/server/InventoryCloseEvent-Reason-API.patch +++ b/patches/server/InventoryCloseEvent-Reason-API.patch @@ -78,22 +78,14 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ import org.bukkit.event.inventory.ClickType; - import org.bukkit.event.inventory.CraftItemEvent; - import org.bukkit.event.inventory.InventoryAction; - import org.bukkit.event.inventory.InventoryClickEvent; -+import org.bukkit.event.inventory.InventoryCloseEvent; // Paper - import org.bukkit.event.inventory.InventoryCreativeEvent; - import org.bukkit.event.inventory.InventoryType.SlotType; - import org.bukkit.event.inventory.SmithItemEvent; @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { + // Paper start - Inventory close reason -+ this.handleContainerClose(packet, InventoryCloseEvent.Reason.PLAYER); ++ this.handleContainerClose(packet, org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLAYER); + } -+ public void handleContainerClose(ServerboundContainerClosePacket packet, InventoryCloseEvent.Reason reason) { ++ public void handleContainerClose(ServerboundContainerClosePacket packet, org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + // Paper end - Inventory close reason PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); diff --git a/patches/server/Lag-compensation-ticks.patch b/patches/server/Lag-compensation-ticks.patch index 8992290533..b0ef72bf8c 100644 --- a/patches/server/Lag-compensation-ticks.patch +++ b/patches/server/Lag-compensation-ticks.patch @@ -20,13 +20,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent - net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers + worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers ++ worldserver.updateLagCompensationTick(); // Paper - lag compensation + + this.profiler.push(() -> { + return worldserver + " " + worldserver.dimension().location(); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/patches/server/Limit-recipe-packets.patch b/patches/server/Limit-recipe-packets.patch index 54362def34..a5eee77eea 100644 --- a/patches/server/Limit-recipe-packets.patch +++ b/patches/server/Limit-recipe-packets.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - auto recipe limit + if (!org.bukkit.Bukkit.isPrimaryThread()) { + if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { -+ this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam", new Object[0]))); ++ this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"))); + return; + } + } diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 37e5c91ca1..85a8e3bbf8 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -3948,10 +3948,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return new Location(entity.getCommandSenderWorld().getWorld(), entity.getX(), entity.getY(), entity.getZ()); + } + -+ public static org.bukkit.block.Block toBukkitBlock(Level world, BlockPos pos) { -+ return world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); -+ } -+ + public static BlockPos toBlockPosition(Location loc) { + return new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } diff --git a/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch b/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch index 71510d239f..0ef5b849cb 100644 --- a/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch +++ b/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 while (iterator.hasNext()) { ServerLevel worldserver = (ServerLevel) iterator.next(); -+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent ++ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent this.profiler.push(() -> { return worldserver + " " + worldserver.dimension().location(); diff --git a/patches/server/Optimize-Hoppers.patch b/patches/server/Optimize-Hoppers.patch index 080813cd32..eda6ca466b 100644 --- a/patches/server/Optimize-Hoppers.patch +++ b/patches/server/Optimize-Hoppers.patch @@ -54,13 +54,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent -+ net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers + worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent ++ net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers this.profiler.push(() -> { + return worldserver + " " + worldserver.dimension().location(); diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index a84765187e..0d023c5d15 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, // Paper start - Add more fields to AsyncPlayerPreLoginEvent - final java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); + final InetAddress rawAddress = ((InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); - com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); + com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); // Paper - setPlayerProfileAPI AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, this.connection.hostname); diff --git a/patches/server/PlayerTeleportEndGatewayEvent.patch b/patches/server/PlayerTeleportEndGatewayEvent.patch index f418a5b171..44e9bcb8f3 100644 --- a/patches/server/PlayerTeleportEndGatewayEvent.patch +++ b/patches/server/PlayerTeleportEndGatewayEvent.patch @@ -24,12 +24,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Bukkit.getPluginManager().callEvent(teleEvent); if (teleEvent.isCancelled()) { return; -@@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { - - } - -- org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); -+ org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); // Paper - diff on change - if (teleEvent.isCancelled()) { - return; - } diff --git a/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch b/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch index 50141c3fa0..24783370fd 100644 --- a/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch +++ b/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch @@ -22,84 +22,58 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java @@ -0,0 +0,0 @@ public abstract class BaseFireBlock extends Block { - super.entityInside(state, world, pos, entity); - } -+ // Paper start - ItemActionContext param -+ @Override public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { this.onPlace(state, world, pos, oldState, notify, null); } @Override -- public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { -- if (!oldState.is(state.getBlock())) { -+ public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, net.minecraft.world.item.context.UseOnContext itemActionContext) { -+ // Paper end - ItemActionContext param -+ if (!iblockdata1.is(iblockdata.getBlock())) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { ++ // Paper start - UseOnContext param ++ this.onPlace(state, world, pos, oldState, notify, null); ++ } ++ ++ @Override ++ public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) { ++ // Paper end - UseOnContext param + if (!oldState.is(state.getBlock())) { if (BaseFireBlock.inPortalDimension(world)) { -- Optional optional = PortalShape.findEmptyPortalShape(world, pos, Direction.Axis.X); -+ Optional optional = PortalShape.findEmptyPortalShape(world, blockposition, Direction.Axis.X); + Optional optional = PortalShape.findEmptyPortalShape(world, pos, Direction.Axis.X); if (optional.isPresent()) { - ((PortalShape) optional.get()).createPortalBlocks(); -+ ((PortalShape) optional.get()).createPortalBlocks(itemActionContext); // Paper - pass ItemActionContext param ++ ((PortalShape) optional.get()).createPortalBlocks(context); // Paper - pass context param return; } } - -- if (!state.canSurvive(world, pos)) { -- this.fireExtinguished(world, pos); // CraftBukkit - fuel block broke -+ if (!iblockdata.canSurvive(world, blockposition)) { -+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke - } - - } diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/FireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java -@@ -0,0 +0,0 @@ import net.minecraft.server.level.ServerLevel; - import net.minecraft.tags.BiomeTags; - import net.minecraft.util.RandomSource; - import net.minecraft.world.item.context.BlockPlaceContext; -+import net.minecraft.world.item.context.UseOnContext; - import net.minecraft.world.level.BlockGetter; - import net.minecraft.world.level.GameRules; - import net.minecraft.world.level.Level; @@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock { } @Override - public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { - super.onPlace(state, world, pos, oldState, notify); -- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random)); -+ // Paper start - ItemActionContext param -+ public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) { -+ super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, itemActionContext); -+ // Paper end - ItemActionContext param -+ world.scheduleTick(blockposition, this, getFireTickDelay(world.random)); ++ // Paper start - UseOnContext param ++ public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) { ++ super.onPlace(state, world, pos, oldState, notify, context); ++ // Paper end - UseOnContext param + world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random)); } - private static int getFireTickDelay(RandomSource random) { diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -0,0 +0,0 @@ import net.minecraft.world.item.DyeColor; - import net.minecraft.world.item.Item; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.context.BlockPlaceContext; -+import net.minecraft.world.item.context.UseOnContext; - import net.minecraft.world.level.BlockGetter; - import net.minecraft.world.level.EmptyBlockGetter; - import net.minecraft.world.level.Explosion; @@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement { DebugPackets.sendNeighborsUpdatePacket(world, pos); } -+ // Paper start - add ItemActionContext param ++ // Paper start - UseOnContext param + @Deprecated -+ public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) { -+ this.onPlace(iblockdata, world, blockposition, iblockdata1, flag); ++ public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) { ++ this.onPlace(state, world, pos, oldState, notify); + } -+ // Paper end - ItemActionContext param ++ // Paper end - UseOnContext param ++ /** @deprecated */ @Deprecated public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { @@ -107,23 +81,18 @@ diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/s index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java +++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java -@@ -0,0 +0,0 @@ import net.minecraft.tags.BlockTags; - import net.minecraft.util.Mth; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityDimensions; -+import net.minecraft.world.item.context.UseOnContext; - import net.minecraft.world.level.LevelAccessor; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.NetherPortalBlock; @@ -0,0 +0,0 @@ public class PortalShape { } // CraftBukkit start - return boolean -- public boolean createPortalBlocks() { -+ // Paper start - ItemActionContext param -+ @Deprecated public boolean createPortalBlocks() { return this.createPortalBlocks(null); } -+ public boolean createPortalBlocks(UseOnContext itemActionContext) { -+ // Paper end - ItemActionContext param ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper + public boolean createPortalBlocks() { ++ // Paper start - UseOnContext param ++ return this.createPortalBlocks(null); ++ } ++ ++ public boolean createPortalBlocks(net.minecraft.world.item.context.UseOnContext useOnContext) { ++ // Paper end - UseOnContext param org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld(); // Copy below for loop @@ -132,7 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 }); - PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE); -+ PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, itemActionContext == null || itemActionContext.getPlayer() == null ? null : itemActionContext.getPlayer().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param ++ PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, useOnContext == null || useOnContext.getPlayer() == null ? null : useOnContext.getPlayer().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/patches/server/PreCreatureSpawnEvent.patch b/patches/server/PreCreatureSpawnEvent.patch index 1a4ddbcb99..63c2be0d2b 100644 --- a/patches/server/PreCreatureSpawnEvent.patch +++ b/patches/server/PreCreatureSpawnEvent.patch @@ -36,13 +36,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1); if (worldserver.getWorldBorder().isWithinBounds((BlockPos) blockposition_mutableblockposition) && SpawnUtil.moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a)) { + // Paper start - PreCreatureSpawnEvent -+ String key = EntityType.getKey(entitytypes).getPath(); -+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key); -+ -+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; -+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( ++ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( + io.papermc.paper.util.MCUtil.toLocation(worldserver, blockposition), -+ type, ++ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entitytypes), + reason + ); + if (!event.callEvent()) { @@ -67,17 +63,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public T spawn(ServerLevel worldserver, @Nullable CompoundTag nbttagcompound, @Nullable Consumer consumer, BlockPos blockposition, MobSpawnType enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { // CraftBukkit end + // Paper start - PreCreatureSpawnEvent -+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityType.getKey(this).getPath()); -+ if (type != null) { -+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; -+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(worldserver, blockposition), -+ type, -+ spawnReason -+ ); -+ if (!event.callEvent()) { -+ return null; -+ } ++ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( ++ io.papermc.paper.util.MCUtil.toLocation(worldserver, blockposition), ++ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(this), ++ spawnReason ++ ); ++ if (!event.callEvent()) { ++ return null; + } + // Paper end - PreCreatureSpawnEvent T t0 = this.create(worldserver, nbttagcompound, consumer, blockposition, enummobspawn, flag, flag1); @@ -105,24 +97,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 continue; } + // Paper start - PreCreatureSpawnEvent -+ EntityType entityType = optional.get(); -+ String key = EntityType.getKey(entityType).getPath(); -+ -+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key); -+ if (type != null) { -+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; -+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2), -+ type, -+ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER -+ ); -+ if (!event.callEvent()) { -+ flag = true; -+ if (event.shouldAbortSpawn()) { -+ break; -+ } -+ continue; ++ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( ++ io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2), ++ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(optional.get()), ++ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER ++ ); ++ if (!event.callEvent()) { ++ flag = true; ++ if (event.shouldAbortSpawn()) { ++ break; + } ++ continue; + } + // Paper end - PreCreatureSpawnEvent @@ -164,19 +149,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 EntityType entitytypes = spawnEntry.type; + // Paper start - PreCreatureSpawnEvent -+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; -+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityType.getKey(entitytypes).getPath()); -+ if (type != null) { -+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(world, pos), -+ type, SpawnReason.NATURAL -+ ); -+ if (!event.callEvent()) { -+ if (event.shouldAbortSpawn()) { -+ return PreSpawnStatus.ABORT; // Paper -+ } -+ return PreSpawnStatus.CANCELLED; // Paper ++ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( ++ io.papermc.paper.util.MCUtil.toLocation(world, pos), ++ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entitytypes), SpawnReason.NATURAL ++ ); ++ if (!event.callEvent()) { ++ if (event.shouldAbortSpawn()) { ++ return PreSpawnStatus.ABORT; + } ++ return PreSpawnStatus.CANCELLED; + } + // Paper end - PreCreatureSpawnEvent if (entitytypes.getCategory() == MobCategory.MISC) { diff --git a/patches/server/PreSpawnerSpawnEvent.patch b/patches/server/PreSpawnerSpawnEvent.patch index 60123ea19f..a8b0138bd3 100644 --- a/patches/server/PreSpawnerSpawnEvent.patch +++ b/patches/server/PreSpawnerSpawnEvent.patch @@ -13,17 +13,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java @@ -0,0 +0,0 @@ public abstract class BaseSpawner { - - org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key); - if (type != null) { -- com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; -- event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event; -+ event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent( - io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2), - type, -- org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER -+ io.papermc.paper.util.MCUtil.toLocation(world, pos) - ); - if (!event.callEvent()) { - flag = true; + continue; + } + // Paper start - PreCreatureSpawnEvent +- com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( ++ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent( + io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2), + org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(optional.get()), +- org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER ++ io.papermc.paper.util.MCUtil.toLocation(world, pos) + ); + if (!event.callEvent()) { + flag = true; diff --git a/patches/server/Profile-Lookup-Events.patch b/patches/server/Profile-Lookup-Events.patch index 0da9dc4404..3e8c71b290 100644 --- a/patches/server/Profile-Lookup-Events.patch +++ b/patches/server/Profile-Lookup-Events.patch @@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + PreLookupProfileEvent event = new PreLookupProfileEvent(name); + event.callEvent(); + if (event.getUUID() != null) { -+ // Plugin provided UUI, we can skip network call. ++ // Plugin provided UUID, we can skip network call. + GameProfile gameprofile = new GameProfile(event.getUUID(), name); + // We might even have properties! + Set profileProperties = event.getProfileProperties(); diff --git a/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch b/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch index ac025874f8..c2cb1a3f47 100644 --- a/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch +++ b/patches/server/Properly-handle-BlockBreakEvent-isDropItems.patch @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return this.defaultBlockState(); } -+ @io.papermc.paper.annotation.DoNotUse // Paper - fix drops not preventing stats/food exhaustion ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - fix drops not preventing stats/food exhaustion public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) { + // Paper start - fix drops not preventing stats/food exhaustion + this.playerDestroy(world, player, pos, state, blockEntity, tool, true, true); diff --git a/patches/server/Properly-handle-experience-dropping-on-block-break.patch b/patches/server/Properly-handle-experience-dropping-on-block-break.patch index 9539517d7c..4189cc813d 100644 --- a/patches/server/Properly-handle-experience-dropping-on-block-break.patch +++ b/patches/server/Properly-handle-experience-dropping-on-block-break.patch @@ -25,19 +25,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -0,0 +0,0 @@ public class Block extends BlockBehaviour implements ItemLike { - for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(state, world.getMinecraftWorld(), pos, blockEntity)) { + for (ItemStack drop : Block.getDrops(state, serverLevel, pos, blockEntity)) { items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop)); } + Block block = state.getBlock(); // Paper - Properly handle xp dropping - io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items); -+ event.setExpToDrop(block.getExpDrop(state, (ServerLevel) world, pos, net.minecraft.world.item.ItemStack.EMPTY, true)); // Paper - Properly handle xp dropping + io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, pos), org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, source), items); ++ event.setExpToDrop(block.getExpDrop(state, serverLevel, pos, net.minecraft.world.item.ItemStack.EMPTY, true)); // Paper - Properly handle xp dropping event.callEvent(); - for (var drop : event.getDrops()) { - popResource(world.getMinecraftWorld(), pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop)); + for (org.bukkit.inventory.ItemStack drop : event.getDrops()) { + popResource(serverLevel, pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop)); } -- state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, true); -+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping -+ block.popExperience((ServerLevel) world, pos, event.getExpToDrop()); // Paper - Properly handle xp dropping +- state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, true); ++ state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping ++ block.popExperience(serverLevel, pos, event.getExpToDrop()); // Paper - Properly handle xp dropping } return true; } diff --git a/patches/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch index 8f73abb642..8ef1e5e243 100644 --- a/patches/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public void runConsumer(final org.bukkit.World fallbackWorld, final Location fallbackLoc) { -+ if (this.dropConsumer == null || org.bukkit.craftbukkit.util.CraftMagicNumbers.getItem(this.stack.getType()) != this.item) { ++ if (this.dropConsumer == null || org.bukkit.craftbukkit.inventory.CraftItemType.bukkitToMinecraft(this.stack.getType()) != this.item) { + fallbackWorld.dropItem(fallbackLoc, this.stack); + } else { + this.dropConsumer.accept(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(this.stack)); @@ -182,10 +182,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return CraftEventFactory.callEntityDeathEvent(victim, drops, com.google.common.util.concurrent.Runnables.doNothing()); } - public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List drops, Runnable lootCheck) { -+ private static java.util.function.Function FROM_FUNCTION = stack -> { ++ ++ private static final java.util.function.Function FROM_FUNCTION = stack -> { + if (stack == null) return null; + return new Entity.DefaultDrop(CraftItemType.bukkitToMinecraft(stack.getType()), stack, null); + }; ++ + public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List drops, Runnable lootCheck) { // Paper // Paper end CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); @@ -201,7 +203,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { + // Paper start - Restore vanilla drops behavior + for (Entity.DefaultDrop drop : drops) { -+ if (drop == null) continue;; ++ if (drop == null) continue; + final org.bukkit.inventory.ItemStack stack = drop.stack(); + // Paper end - Restore vanilla drops behavior if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; diff --git a/patches/server/Throw-exception-on-world-create-while-being-ticked.patch b/patches/server/Throw-exception-on-world-create-while-being-ticked.patch index 9e9cca842b..56024bdebc 100644 --- a/patches/server/Throw-exception-on-world-create-while-being-ticked.patch +++ b/patches/server/Throw-exception-on-world-create-while-being-ticked.patch @@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; move down while (iterator.hasNext()) { ServerLevel worldserver = (ServerLevel) iterator.next(); - worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent + worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop