Yatopia/patches/api/0010-EMC-ArrowHitBlockEvent.patch
2020-02-26 20:12:29 +01:00

114 lines
3.7 KiB
Diff

From 101589bec061173a7100c055cbeeec872542fbb9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 4 Dec 2016 01:03:19 -0500
Subject: [PATCH] EMC ArrowHitBlockEvent
---
.../event/entity/ArrowHitBlockEvent.java | 94 +++++++++++++++++++
1 file changed, 94 insertions(+)
create mode 100644 src/main/java/com/destroystokyo/paper/event/entity/ArrowHitBlockEvent.java
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ArrowHitBlockEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ArrowHitBlockEvent.java
new file mode 100644
index 00000000..cffeea86
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ArrowHitBlockEvent.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.AbstractArrow;
+import org.bukkit.entity.Arrow;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+
+/**
+ * Different from ProjectileHitEvent in that it will let you cancel if the projectile will
+ * "trigger" the block, such as TNT.
+ * This includes all variants of arrows including tridents
+ *
+ */
+public class ArrowHitBlockEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean canceled;
+
+ private final Block block;
+
+ public ArrowHitBlockEvent(AbstractArrow entity, Block block) {
+ super(entity);
+ this.block = block;
+ }
+
+ /**
+ * @return The Arrow that hit the block
+ */
+ public AbstractArrow getArrow() {
+ return (AbstractArrow) entity;
+ }
+
+ /**
+ * @return The Arrow that hit the block
+ */
+ public AbstractArrow getEntity() {
+ return (AbstractArrow) entity;
+ }
+
+ /**
+ * @return The block hit by the arrow that may trigger behavior
+ */
+ public Block getBlock() {
+ return block;
+ }
+
+ /**
+ * @return If the arrow activating a block should be cancelled
+ */
+ public boolean isCancelled() {
+ return canceled;
+ }
+
+ /**
+ * Whether or not to cancel any behavior that would occur from the arrow hitting the block
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ canceled = cancel;
+ }
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+}
--
2.25.1.windows.1