Paper/patches/api/0100-WitchConsumePotionEvent.patch

85 lines
2.5 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 16 May 2018 20:26:16 -0400
Subject: [PATCH] WitchConsumePotionEvent
Fires when a witch consumes the potion in their hand
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..43ee765dedf5001fadf1af317b6ab323fde34851
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java
@@ -0,0 +1,71 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+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;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Fired when a witch consumes the potion in their hand to buff themselves.
+ */
+@NullMarked
2021-06-11 14:02:28 +02:00
+public class WitchConsumePotionEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private @Nullable ItemStack potion;
2024-02-01 10:15:57 +01:00
+ private boolean cancelled;
2021-06-11 14:02:28 +02:00
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
+ public WitchConsumePotionEvent(final Witch witch, final @Nullable ItemStack potion) {
2021-06-11 14:02:28 +02:00
+ super(witch);
+ this.potion = potion;
+ }
+
+ @Override
+ public Witch getEntity() {
+ return (Witch) super.getEntity();
+ }
+
+ /**
+ * @return the potion the witch will consume and have the effects applied.
+ */
+ public @Nullable ItemStack getPotion() {
2024-02-01 10:15:57 +01:00
+ return this.potion;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Sets the potion to be consumed and applied to the witch.
2024-02-01 10:15:57 +01:00
+ *
2021-06-11 14:02:28 +02:00
+ * @param potion The potion
+ */
+ public void setPotion(final @Nullable ItemStack potion) {
2021-06-11 14:02:28 +02:00
+ this.potion = potion != null ? potion.clone() : null;
+ }
+
+ /**
2024-02-01 10:15:57 +01:00
+ * @return Event was cancelled or potion was {@code null}
2021-06-11 14:02:28 +02:00
+ */
+ @Override
+ public boolean isCancelled() {
2024-02-01 10:15:57 +01:00
+ return this.cancelled || this.potion == null;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
+ public void setCancelled(final boolean cancel) {
2024-02-01 10:15:57 +01:00
+ this.cancelled = cancel;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
2021-06-11 14:02:28 +02:00
+ public HandlerList getHandlers() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
+ public static HandlerList getHandlerList() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+}