forked from hpfxd/PandaSpigot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0016-Backport-ProjectileHitEvent-API-improvements.patch
91 lines (85 loc) · 2.86 KB
/
0016-Backport-ProjectileHitEvent-API-improvements.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
88
89
90
91
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hpfxd <[email protected]>
Date: Mon, 23 May 2022 20:18:09 -0400
Subject: [PATCH] Backport ProjectileHitEvent API improvements
- Added getHitBlock
- Added getHitBlockFace
- Added getHitEntity
diff --git a/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java
index 25ae8323a24b35105f780e85276a7a7a47ed7c61..2b274a93470f03af8bc3250dc897d1a1cc4c8021 100644
--- a/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java
+++ b/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java
@@ -2,22 +2,76 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.HandlerList;
+// PandaSpigot start
+import org.bukkit.entity.Entity;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+// PandaSpigot end
/**
* Called when a projectile hits an object
*/
public class ProjectileHitEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
-
+ // PandaSpigot start
+ private final Entity hitEntity;
+ private final Block hitBlock;
+ private final BlockFace hitFace;
public ProjectileHitEvent(final Projectile projectile) {
+ this(projectile, null, null);
+ }
+ public ProjectileHitEvent(final Projectile projectile, Entity hitEntity) {
+ this(projectile, hitEntity, null);
+ }
+ public ProjectileHitEvent(final Projectile projectile, Block hitBlock) {
+ this(projectile, null, hitBlock);
+ }
+ public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock) {
+ this(projectile, hitEntity, hitBlock, null);
+ }
+ public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock, BlockFace hitFace) {
super(projectile);
+ this.hitEntity = hitEntity;
+ this.hitBlock = hitBlock;
+ this.hitFace = hitFace;
}
+ // PandaSpigot end
@Override
public Projectile getEntity() {
return (Projectile) entity;
}
+ // PandaSpigot start
+ /**
+ * Gets the block that was hit, if it was a block that was hit.
+ *
+ * @return hit block or else null
+ */
+ public Block getHitBlock() {
+ return hitBlock;
+ }
+
+ /**
+ * Gets the block face that was hit, if it was a block that was hit and the
+ * face was provided in the vent.
+ *
+ * @return hit face or else null
+ */
+ public BlockFace getHitBlockFace() {
+ return hitFace;
+ }
+
+ /**
+ * Gets the entity that was hit, if it was an entity that was hit.
+ *
+ * @return hit entity or else null
+ */
+ public Entity getHitEntity() {
+ return hitEntity;
+ }
+ // PandaSpigot end
+
@Override
public HandlerList getHandlers() {
return handlers;