Add PhantomPreSpawnEvent

This commit is contained in:
BillyGalbreath 2018-08-25 19:56:42 -05:00
parent b589db2d90
commit 72098bd870
2 changed files with 45 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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
}