2019-06-14 04:27:40 +02:00
|
|
|
From 52e7ac31dedf5afa861d6a5cb99977fe77a8d279 Mon Sep 17 00:00:00 2001
|
2018-10-18 22:53:10 +02:00
|
|
|
From: Caleb Bassham <caleb.bassham@gmail.com>
|
|
|
|
Date: Fri, 28 Sep 2018 02:30:56 -0500
|
|
|
|
Subject: [PATCH] Add spectator target events
|
|
|
|
|
|
|
|
- PlayerStartSpectatingEntityEvent
|
|
|
|
- PlayerStopSpectatingEntityEvent
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java
|
|
|
|
new file mode 100644
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..b8ec7ef2d
|
2018-10-18 22:53:10 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,67 @@
|
2018-10-18 22:53:10 +02:00
|
|
|
+package com.destroystokyo.paper.event.player;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Entity;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.player.PlayerEvent;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-10-18 22:53:10 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Triggered when a player starts spectating an entity in spectator mode.
|
|
|
|
+ */
|
|
|
|
+public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable {
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ private boolean cancelled;
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull private final Entity currentSpectatorTarget;
|
|
|
|
+ @NotNull private final Entity newSpectatorTarget;
|
2018-10-18 22:53:10 +02:00
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public PlayerStartSpectatingEntityEvent(@NotNull Player player, @NotNull Entity currentSpectatorTarget, @NotNull Entity newSpectatorTarget) {
|
2018-10-18 22:53:10 +02:00
|
|
|
+ super(player);
|
|
|
|
+ this.currentSpectatorTarget = currentSpectatorTarget;
|
|
|
|
+ this.newSpectatorTarget = newSpectatorTarget;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the entity that the player is currently spectating or themselves if they weren't spectating anything
|
|
|
|
+ *
|
|
|
|
+ * @return The entity the player is currently spectating (before they start spectating the new target).
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ public Entity getCurrentSpectatorTarget() {
|
|
|
|
+ return currentSpectatorTarget;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the new entity that the player will now be spectating
|
|
|
|
+ *
|
|
|
|
+ * @return The entity the player is now going to be spectating.
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ public Entity getNewSpectatorTarget() {
|
|
|
|
+ return newSpectatorTarget;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ this.cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java
|
|
|
|
new file mode 100644
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..693d119ab
|
2018-10-18 22:53:10 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,54 @@
|
2018-10-18 22:53:10 +02:00
|
|
|
+package com.destroystokyo.paper.event.player;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Entity;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.player.PlayerEvent;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-10-18 22:53:10 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Triggered when a player stops spectating an entity in spectator mode.
|
|
|
|
+ */
|
|
|
|
+public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable {
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ private boolean cancelled;
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull private final Entity spectatorTarget;
|
2018-10-18 22:53:10 +02:00
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public PlayerStopSpectatingEntityEvent(@NotNull Player player, @NotNull Entity spectatorTarget) {
|
2018-10-18 22:53:10 +02:00
|
|
|
+ super(player);
|
|
|
|
+ this.spectatorTarget = spectatorTarget;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the entity that the player is spectating
|
|
|
|
+ *
|
|
|
|
+ * @return The entity the player is currently spectating (before they will stop).
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ public Entity getSpectatorTarget() {
|
|
|
|
+ return spectatorTarget;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ this.cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-10-18 22:53:10 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2019-04-23 06:47:07 +02:00
|
|
|
2.21.0
|
2018-10-18 22:53:10 +02:00
|
|
|
|