From ea4dd0356a413d2781b369b8f00f94266aaa15d9 Mon Sep 17 00:00:00 2001 From: chickeneer Date: Thu, 28 Nov 2019 20:36:54 -0600 Subject: [PATCH] EMC Add a PotionExtiguishFire Event Certain thrown potions will extinguish fire and campfires. This event adds the ability to cancel this --- .../entity/PotionExtinguishFireEvent.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main/java/com/destroystokyo/paper/event/entity/PotionExtinguishFireEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PotionExtinguishFireEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PotionExtinguishFireEvent.java new file mode 100644 index 00000000..2e27d7bb --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/PotionExtinguishFireEvent.java @@ -0,0 +1,70 @@ +package com.destroystokyo.paper.event.entity; + +import org.bukkit.block.Block; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; + +/** + * Lets you cancel a thrown potion from extinguishing a block such as fire or a campfire + * + * Note that a single potion may attempt to extinguish multiple blocks + */ +public class PotionExtinguishFireEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean canceled; + + private final Block block; + + public PotionExtinguishFireEvent(ThrownPotion entity, Block block) { + super(entity); + this.block = block; + } + + /** + * @return The Potion that is extinguishing the block + */ + public ThrownPotion getPotion() { + return (ThrownPotion) entity; + } + + /** + * @return The Potion that is extinguishing the block + */ + public ThrownPotion getEntity() { + return (ThrownPotion) entity; + } + + /** + * @return The block being extinguished + */ + public Block getBlock() { + return block; + } + + /** + * @return If the block being extinguished should be cancelled + */ + public boolean isCancelled() { + return canceled; + } + + /** + * Whether or not to cancel the extinguishing of the given block + * @param cancel true if you wish to cancel this event + */ + public void setCancelled(boolean cancel) { + canceled = cancel; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + +} -- 2.25.1.windows.1