2020-01-22 03:02:07 +01:00
|
|
|
From 7278c19fd5b1ecef74da0734e3905fd5cf3b9e82 Mon Sep 17 00:00:00 2001
|
2018-05-17 02:35:33 +02:00
|
|
|
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
|
2020-01-22 03:02:07 +01:00
|
|
|
index 00000000..fbbace36
|
2018-05-17 02:35:33 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,70 @@
|
2018-05-17 02:35:33 +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;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
2018-05-17 02:35:33 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Fired when a witch consumes the potion in their hand to buff themselves.
|
|
|
|
+ */
|
|
|
|
+public class WitchConsumePotionEvent extends EntityEvent implements Cancellable {
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable private ItemStack potion;
|
2018-05-17 02:35:33 +02:00
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public WitchConsumePotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) {
|
2018-05-17 02:35:33 +02:00
|
|
|
+ super(witch);
|
|
|
|
+ this.potion = potion;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-05-17 02:35:33 +02:00
|
|
|
+ @Override
|
|
|
|
+ public Witch getEntity() {
|
|
|
|
+ return (Witch) super.getEntity();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2018-08-16 13:20:58 +02:00
|
|
|
+ * @return the potion the witch will consume and have the effects applied.
|
2018-05-17 02:35:33 +02:00
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
2018-05-17 02:35:33 +02:00
|
|
|
+ public ItemStack getPotion() {
|
|
|
|
+ return potion;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the potion to be consumed and applied to the witch.
|
|
|
|
+ * @param potion The potion
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public void setPotion(@Nullable ItemStack potion) {
|
2018-05-17 02:35:33 +02:00
|
|
|
+ this.potion = potion != null ? potion.clone() : null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-05-17 02:35:33 +02:00
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-05-17 02:35:33 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean cancelled = false;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return Event was cancelled or potion was null
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled || 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
|
2020-01-22 03:02:07 +01:00
|
|
|
index 00000000..6ef6367b
|
2018-05-17 02:35:33 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java
|
|
|
|
@@ -0,0 +1,33 @@
|
|
|
|
+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() {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean cancelled = false;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2020-01-22 03:02:07 +01:00
|
|
|
2.25.0.windows.1
|
2018-05-17 02:35:33 +02:00
|
|
|
|