2020-05-02 00:03:47 +02:00
|
|
|
From 8c8906518963b84b507c5c2137db31a7b687de9f Mon Sep 17 00:00:00 2001
|
2018-06-06 04:48:27 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Tue, 5 Jun 2018 22:47:08 -0400
|
|
|
|
Subject: [PATCH] WitchReadyPotionEvent
|
|
|
|
|
|
|
|
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
|
2020-04-02 23:07:06 +02:00
|
|
|
index 000000000..5351b523d
|
2018-06-06 04:48:27 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,80 @@
|
2018-06-06 04:48:27 +02:00
|
|
|
+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;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
2018-06-06 04:48:27 +02:00
|
|
|
+
|
|
|
|
+public class WitchReadyPotionEvent extends EntityEvent implements Cancellable {
|
|
|
|
+ private ItemStack potion;
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public WitchReadyPotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) {
|
2018-06-06 04:48:27 +02:00
|
|
|
+ super(witch);
|
|
|
|
+ this.potion = potion;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Fires thee event, returning the desired potion, or air of cancelled
|
2018-08-16 13:20:58 +02:00
|
|
|
+ * @param witch the witch whom is readying to use a potion
|
|
|
|
+ * @param potion the potion to be used
|
|
|
|
+ * @return The ItemStack to be used
|
2018-06-06 04:48:27 +02:00
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
|
|
|
+ public static ItemStack process(@NotNull Witch witch, @Nullable ItemStack potion) {
|
2018-06-06 04:48:27 +02:00
|
|
|
+ WitchReadyPotionEvent event = new WitchReadyPotionEvent(witch, potion);
|
|
|
|
+ if (!event.callEvent() || event.getPotion() == null) {
|
|
|
|
+ return new ItemStack(Material.AIR);
|
|
|
|
+ }
|
|
|
|
+ return event.getPotion();
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-06 04:48:27 +02:00
|
|
|
+ @Override
|
|
|
|
+ public Witch getEntity() {
|
|
|
|
+ return (Witch) super.getEntity();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2018-08-16 13:20:58 +02:00
|
|
|
+ * @return the potion the witch is readying to use
|
2018-06-06 04:48:27 +02:00
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
2018-06-06 04:48:27 +02:00
|
|
|
+ public ItemStack getPotion() {
|
|
|
|
+ return potion;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the potion the which is going to hold and use
|
|
|
|
+ * @param potion The potion
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public void setPotion(@Nullable ItemStack potion) {
|
2018-06-06 04:48:27 +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-06-06 04:48:27 +02:00
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-06-06 04:48:27 +02:00
|
|
|
+ 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-05-02 00:03:47 +02:00
|
|
|
2.26.2
|
2018-06-06 04:48:27 +02:00
|
|
|
|