From 3475839dd7e1aacdf2c78edd0fd7d813d2f9e46c Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 25 Oct 2023 18:54:03 +1100 Subject: [PATCH] #925: Add hit entity/block to events extending ProjectileHitEvent By: Jishuna --- .../java/org/bukkit/event/entity/ExpBottleEvent.java | 11 ++++++++++- .../event/entity/LingeringPotionSplashEvent.java | 11 ++++++++++- .../org/bukkit/event/entity/PotionSplashEvent.java | 10 +++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java index 6417c2fd47..997c86b032 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java @@ -1,8 +1,12 @@ package org.bukkit.event.entity; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.ThrownExpBottle; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a ThrownExpBottle hits and releases experience. @@ -12,8 +16,13 @@ public class ExpBottleEvent extends ProjectileHitEvent { private int exp; private boolean showEffect = true; + @Deprecated public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, final int exp) { - super(bottle); + this(bottle, null, null, null, exp); + } + + public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, final int exp) { + super(bottle, hitEntity, hitBlock, hitFace); this.exp = exp; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java index a10dab1671..1584c6c41c 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java @@ -1,10 +1,14 @@ package org.bukkit.event.entity; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.Entity; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a splash potion hits an area @@ -14,8 +18,13 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca private boolean cancelled; private final AreaEffectCloud entity; + @Deprecated public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) { - super(potion); + this(potion, null, null, null, entity); + } + + public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, @NotNull final AreaEffectCloud entity) { + super(potion, hitEntity, hitBlock, hitFace); this.entity = entity; } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java index 80f31a267e..bc6ba6c4c0 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java @@ -4,11 +4,15 @@ import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a splash potion hits an area @@ -18,9 +22,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable private boolean cancelled; private final Map affectedEntities; + @Deprecated public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map affectedEntities) { - super(potion); + this(potion, null, null, null, affectedEntities); + } + public PotionSplashEvent(@NotNull final ThrownPotion potion, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, @NotNull final Map affectedEntities) { + super(potion, hitEntity, hitBlock, hitFace); this.affectedEntities = affectedEntities; }