From 7bcd1d10f2e974c9767e8d8c36cc87e681b5cd90 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 1 Feb 2022 18:01:00 +1100 Subject: [PATCH] #717: Add PlayerHideEntityEvent and PlayerShowEntityEvent By: Gero --- .../event/player/PlayerHideEntityEvent.java | 52 ++++++++++++++++++ .../event/player/PlayerShowEntityEvent.java | 53 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java create mode 100644 paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java new file mode 100644 index 0000000000..d8a73cd222 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java @@ -0,0 +1,52 @@ +package org.bukkit.event.player; + +import org.bukkit.Warning; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a visible entity is hidden from a player. + * + * This event is only called when the entity's visibility status is actually + * changed. + * + * This event is called regardless of if the entity was within tracking range. + * + * @see Player#hideEntity(org.bukkit.plugin.Plugin, org.bukkit.entity.Entity) + * @deprecated draft API + */ +@Deprecated +@Warning(false) +public class PlayerHideEntityEvent extends PlayerEvent { + + private static final HandlerList handlers = new HandlerList(); + private final Entity entity; + + public PlayerHideEntityEvent(@NotNull Player who, @NotNull Entity entity) { + super(who); + this.entity = entity; + } + + /** + * Gets the entity which has been hidden from the player. + * + * @return the hidden entity + */ + @NotNull + public Entity getEntity() { + return entity; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java new file mode 100644 index 0000000000..5408a8c123 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java @@ -0,0 +1,53 @@ +package org.bukkit.event.player; + +import org.bukkit.Warning; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a hidden entity is shown to a player. + * + * This event is only called when the entity's visibility status is actually + * changed. + * + * This event is called regardless of whether the entity was within tracking + * range. + * + * @see Player#showEntity(org.bukkit.plugin.Plugin, org.bukkit.entity.Entity) + * @deprecated draft API + */ +@Deprecated +@Warning(false) +public class PlayerShowEntityEvent extends PlayerEvent { + + private static final HandlerList handlers = new HandlerList(); + private final Entity entity; + + public PlayerShowEntityEvent(@NotNull Player who, @NotNull Entity entity) { + super(who); + this.entity = entity; + } + + /** + * Gets the entity which has been shown to the player. + * + * @return the shown entity + */ + @NotNull + public Entity getEntity() { + return entity; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +}