From 72098bd870fd9abf89d701ff7f4e619292642f54 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 25 Aug 2018 19:56:42 -0500 Subject: [PATCH] Add PhantomPreSpawnEvent --- .../event/entity/PhantomPreSpawnEvent.java | 32 +++++++++++++++++++ .../main/java/org/bukkit/entity/Phantom.java | 13 ++++++++ 2 files changed, 45 insertions(+) create mode 100644 paper-api/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java new file mode 100644 index 0000000000..e465222aa8 --- /dev/null +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java @@ -0,0 +1,32 @@ +package com.destroystokyo.paper.event.entity; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +/** + * Called when a phantom is spawned for an exhausted player + */ +@NullMarked +public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent { + + private final Entity entity; + + @ApiStatus.Internal + public PhantomPreSpawnEvent(final Location location, final Entity entity, final CreatureSpawnEvent.SpawnReason reason) { + super(location, EntityType.PHANTOM, reason); + this.entity = entity; + } + + /** + * Get the entity this phantom is spawning for + * + * @return the Entity + */ + public Entity getSpawningEntity() { + return this.entity; + } +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Phantom.java b/paper-api/src/main/java/org/bukkit/entity/Phantom.java index 86cfdcf306..082601f349 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Phantom.java +++ b/paper-api/src/main/java/org/bukkit/entity/Phantom.java @@ -1,5 +1,8 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Represents a phantom. */ @@ -14,4 +17,14 @@ public interface Phantom extends Flying, Enemy { * @param sz The new size of the phantom. */ public void setSize(int sz); + + // Paper start + /** + * Get the UUID of the entity that caused this phantom to spawn + * + * @return UUID + */ + @Nullable + public java.util.UUID getSpawningEntity(); + // Paper end }