forked from PaperMC/Paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0044-Add-ProjectileCollideEvent.patch
87 lines (85 loc) · 2.63 KB
/
0044-Add-ProjectileCollideEvent.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
84
85
86
87
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Techcable <[email protected]>
Date: Fri, 16 Dec 2016 21:25:39 -0600
Subject: [PATCH] Add ProjectileCollideEvent
Now deprecated and replaced with ProjectileHitEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..b7df0e6ca024448784aaf4784930e565b8e5bdb3
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
@@ -0,0 +1,74 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Projectile;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a projectile collides with an entity
+ * <p>
+ * This event is called <b>before</b> {@link EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying
+ *
+ * @deprecated Deprecated, use {@link org.bukkit.event.entity.ProjectileHitEvent} and check if there is a hit entity
+ */
+@Deprecated(since = "1.19.3")
+public class ProjectileCollideEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Entity collidedWith;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public ProjectileCollideEvent(@NotNull Projectile projectile, @NotNull Entity collidedWith) {
+ super(projectile);
+ this.collidedWith = collidedWith;
+ }
+
+ /**
+ * Get the projectile that collided
+ *
+ * @return the projectile that collided
+ */
+ @NotNull
+ public Projectile getEntity() {
+ return (Projectile) super.getEntity();
+ }
+
+ /**
+ * Get the entity the projectile collided with
+ *
+ * @return the entity collided with
+ */
+ @NotNull
+ public Entity getCollidedWith() {
+ return this.collidedWith;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+}