PaperMC/patches/api/0120-EnderDragon-Events.patch

221 lines
6.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: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 21 Jul 2018 01:51:05 -0500
Subject: [PATCH] EnderDragon Events
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..242eb9c07866365568c036819be2b4f882319aa1
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java
@@ -0,0 +1,74 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import java.util.Collection;
2021-06-11 14:02:28 +02:00
+import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.DragonFireball;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
2023-09-14 12:44:12 +02:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud
+ */
+@NullMarked
2021-06-11 14:02:28 +02:00
+public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
2023-09-14 12:44:12 +02:00
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Collection<LivingEntity> targets;
+ private final AreaEffectCloud areaEffectCloud;
2024-02-01 10:15:57 +01:00
+ private boolean cancelled;
2021-06-11 14:02:28 +02:00
+
2023-09-14 12:44:12 +02:00
+ @ApiStatus.Internal
+ public EnderDragonFireballHitEvent(final DragonFireball fireball, final Collection<LivingEntity> targets, final AreaEffectCloud areaEffectCloud) {
2021-06-11 14:02:28 +02:00
+ super(fireball);
+ this.targets = targets;
+ this.areaEffectCloud = areaEffectCloud;
+ }
+
+ /**
+ * The fireball involved in this event
+ */
+ @Override
+ public DragonFireball getEntity() {
+ return (DragonFireball) super.getEntity();
+ }
+
+ /**
+ * The living entities hit by fireball
+ *
+ * @return the targets
+ */
+ public Collection<LivingEntity> getTargets() {
2024-02-01 10:15:57 +01:00
+ return this.targets;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * @return The area effect cloud spawned in this collision
+ */
+ public AreaEffectCloud getAreaEffectCloud() {
2024-02-01 10:15:57 +01:00
+ return this.areaEffectCloud;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
+ public boolean isCancelled() {
2024-02-01 10:15:57 +01:00
+ return this.cancelled;
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
+ }
2023-09-14 12:44:12 +02:00
+
2024-02-01 10:15:57 +01:00
+ @Override
2023-09-14 12:44:12 +02:00
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
2021-06-11 14:02:28 +02:00
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..47cf33ef97ce1b92bc13c4d3a6c49d050e344eb1
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
@@ -0,0 +1,61 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.EnderDragon;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames
+ */
+@NullMarked
2021-06-11 14:02:28 +02:00
+public class EnderDragonFlameEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final AreaEffectCloud areaEffectCloud;
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 EnderDragonFlameEvent(final EnderDragon enderDragon, final AreaEffectCloud areaEffectCloud) {
2021-06-11 14:02:28 +02:00
+ super(enderDragon);
+ this.areaEffectCloud = areaEffectCloud;
+ }
+
+ /**
+ * The enderdragon involved in this event
+ */
+ @Override
+ public EnderDragon getEntity() {
+ return (EnderDragon) super.getEntity();
+ }
+
+ /**
+ * @return The area effect cloud spawned in this collision
+ */
+ public AreaEffectCloud getAreaEffectCloud() {
2024-02-01 10:15:57 +01:00
+ return this.areaEffectCloud;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @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
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7dd6e17b648868cf5d549f1e779e5d92439751dd
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java
@@ -0,0 +1,61 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.DragonFireball;
+import org.bukkit.entity.EnderDragon;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Fired when an EnderDragon shoots a fireball
+ */
+@NullMarked
2021-06-11 14:02:28 +02:00
+public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final DragonFireball fireball;
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 EnderDragonShootFireballEvent(final EnderDragon entity, final DragonFireball fireball) {
2021-06-11 14:02:28 +02:00
+ super(entity);
+ this.fireball = fireball;
+ }
+
+ /**
+ * The enderdragon shooting the fireball
+ */
+ @Override
+ public EnderDragon getEntity() {
+ return (EnderDragon) super.getEntity();
+ }
+
+ /**
+ * @return The fireball being shot
+ */
+ public DragonFireball getFireball() {
2024-02-01 10:15:57 +01:00
+ return this.fireball;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01: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
2024-02-01 10:15:57 +01:00
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+}