forked from hpfxd/PandaSpigot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0022-Add-SpawnerPreSpawnEvent.patch
83 lines (81 loc) · 2.4 KB
/
0022-Add-SpawnerPreSpawnEvent.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mechoriet <kevinworm92@gmail.com>
Date: Mon, 19 Dec 2022 23:48:01 +0100
Subject: [PATCH] Add SpawnerPreSpawnEvent
diff --git a/src/main/java/net/techcable/tacospigot/event/entity/SpawnerPreSpawnEvent.java b/src/main/java/net/techcable/tacospigot/event/entity/SpawnerPreSpawnEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..efed50aedf83c7166709d32065e6333bd10c68d3
--- /dev/null
+++ b/src/main/java/net/techcable/tacospigot/event/entity/SpawnerPreSpawnEvent.java
@@ -0,0 +1,71 @@
+package net.techcable.tacospigot.event.entity;
+
+import com.google.common.base.Preconditions;
+
+import org.bukkit.Location;
+import org.bukkit.entity.EntityType;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+import static com.google.common.base.Preconditions.*;
+
+/**
+ * Fired before a mob spawns and entity data as calculated.
+ * <p>This is a more preformat alternative to {@link org.bukkit.event.entity.SpawnerSpawnEvent}</p>
+ */
+public class SpawnerPreSpawnEvent extends Event implements Cancellable {
+
+ private final Location location;
+ private final EntityType spawnedType;
+
+ public SpawnerPreSpawnEvent(Location location, EntityType spawnedType) {
+ this.location = checkNotNull(location, "Null location").clone(); // Defensive copy
+ this.spawnedType = checkNotNull(spawnedType, "Null spawned type");
+ }
+
+ /**
+ * Get the location of the spawner where the entity is being spawned
+ *
+ * @return the spawner's location
+ */
+ public Location getLocation() {
+ return location.clone(); // Defensive copy
+ }
+
+ /**
+ * Get the type of entity being spawned
+ *
+ * @return the type being spawned
+ */
+ public EntityType getSpawnedType() {
+ return spawnedType;
+ }
+
+ // Cancellable
+
+ private boolean cancelled;
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ // handlers
+
+ private static final HandlerList handlerList = new HandlerList();
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlerList;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlerList;
+ }
+}