diff options
Diffstat (limited to 'patches/api/0107-WitchReadyPotionEvent.patch')
-rw-r--r-- | patches/api/0107-WitchReadyPotionEvent.patch | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/patches/api/0107-WitchReadyPotionEvent.patch b/patches/api/0107-WitchReadyPotionEvent.patch index 2231308ed2..e33270f804 100644 --- a/patches/api/0107-WitchReadyPotionEvent.patch +++ b/patches/api/0107-WitchReadyPotionEvent.patch @@ -7,44 +7,34 @@ Control what potion the witch readies to use diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..57f93af14acc6346c5a343e05fe8f5d44d6adbc6 +index 0000000000000000000000000000000000000000..7feca06e72bd585bbfa219df38a2161b77e8d4c4 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java -@@ -0,0 +1,80 @@ +@@ -0,0 +1,68 @@ +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 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..57f93af14acc6346c5a343e05fe8f5d4 + */ + @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; ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; + } + -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; + } + -+ private boolean cancelled = false; -+ ++ @NotNull + @Override -+ public boolean isCancelled() { -+ return cancelled; ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; + } + -+ @Override -+ public void setCancelled(boolean cancel) { -+ cancelled = cancel; ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; + } +} |