Paper/patches/api/0046-Add-ProjectileCollideEvent.patch

88 lines
2.6 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@outlook.com>
Date: Fri, 16 Dec 2016 21:25:39 -0600
Subject: [PATCH] Add ProjectileCollideEvent
Now deprecated and replaced with ProjectileHitEvent
2021-06-11 14:02:28 +02:00
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
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..3caff9cbb990e03d4331bd601272aec5090affcf
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,74 @@
2021-06-11 14:02:28 +02:00
+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;
2024-02-01 10:15:57 +01:00
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
2021-06-11 14:02:28 +02:00
+import org.bukkit.event.entity.EntityEvent;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a projectile collides with an entity
2021-06-11 14:02:28 +02:00
+ * <p>
2024-02-01 10:15:57 +01:00
+ * 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
2021-06-11 14:02:28 +02:00
+ */
+@Deprecated
2021-06-11 14:02:28 +02:00
+public class ProjectileCollideEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2021-06-11 14:02:28 +02:00
+ @NotNull private final Entity collidedWith;
+
2024-02-01 10:15:57 +01:00
+ private boolean cancelled;
2021-06-11 14:02:28 +02:00
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
+ public ProjectileCollideEvent(@NotNull Projectile projectile, @NotNull Entity collidedWith) {
+ super(projectile);
2021-06-11 14:02:28 +02:00
+ this.collidedWith = collidedWith;
+ }
+
+ /**
+ * Get the projectile that collided
+ *
+ * @return the projectile that collided
+ */
+ @NotNull
+ public Projectile getEntity() {
+ return (Projectile) super.getEntity();
+ }
+
2024-02-01 10:15:57 +01:00
+ /**
+ * Get the entity the projectile collided with
+ *
+ * @return the entity collided with
+ */
2021-06-11 14:02:28 +02:00
+ @NotNull
2024-02-01 10:15:57 +01:00
+ public Entity getCollidedWith() {
+ return this.collidedWith;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
+ public boolean isCancelled() {
2024-02-01 10:15:57 +01:00
+ return this.cancelled;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
2024-02-01 10:15:57 +01:00
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
2021-06-11 14:02:28 +02:00
+}