3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 11:30:06 +01:00
Paper/Spigot-API-Patches/0143-Add-PhantomPreSpawnEvent.patch

64 Zeilen
1.9 KiB
Diff

2018-08-27 09:01:09 +02:00
From aad5790f10fafc46c204416df8cb615935d6a978 Mon Sep 17 00:00:00 2001
2018-08-27 08:51:20 +02:00
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 25 Aug 2018 19:56:42 -0500
Subject: [PATCH] Add PhantomPreSpawnEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java
new file mode 100644
2018-08-27 09:01:09 +02:00
index 000000000..303a1ec9b
2018-08-27 08:51:20 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java
@@ -0,0 +1,30 @@
+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 javax.annotation.Nullable;
+
+/**
+ * Called when a phantom is spawned for an exhausted player
+ */
+public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent {
+ private final Entity entity;
+
+ public PhantomPreSpawnEvent(Location location, Entity entity, CreatureSpawnEvent.SpawnReason reason) {
+ super(location, EntityType.PHANTOM, reason);
+ this.entity = entity;
+ }
+
+ /**
+ * Get the entity this phantom is spawning for
+ *
+ * @return Entity
+ */
+ @Nullable
+ public Entity getSpawningEntity() {
+ return entity;
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/Phantom.java b/src/main/java/org/bukkit/entity/Phantom.java
2018-08-27 09:01:09 +02:00
index 1a1044edc..65b703a2d 100644
2018-08-27 08:51:20 +02:00
--- a/src/main/java/org/bukkit/entity/Phantom.java
+++ b/src/main/java/org/bukkit/entity/Phantom.java
@@ -14,4 +14,13 @@ public interface Phantom extends Flying {
* @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
+ */
+ public java.util.UUID getSpawningEntity();
+ // Paper end
}
--
2.18.0