aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0029-Add-a-call-helper-to-Event.patch
blob: 4b287bfa560f4cb941d9bab8098a3a62c02541f9 (plain)
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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 19 May 2013 20:36:58 -0400
Subject: [PATCH] Add a call helper to Event

Reduces diff in Server patches

diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index 18d0636b749913bfdcea8eebc7d0840d192fb071..8ec56cd6b8e0f5c5dd8c7c88b4671e18dcf109d0 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -35,6 +35,22 @@ public abstract class Event {
         this.async = isAsync;
     }
 
+    // Paper start
+    /**
+     * Calls the event and tests if cancelled.
+     *
+     * @return false if event was cancelled, if cancellable. otherwise true.
+     */
+    public boolean callEvent() {
+        org.bukkit.Bukkit.getPluginManager().callEvent(this);
+        if (this instanceof Cancellable) {
+            return !((Cancellable) this).isCancelled();
+        } else {
+            return true;
+        }
+    }
+    // Paper end
+
     /**
      * Convenience method for providing a user-friendly identifier. By
      * default, it is the event's class's {@linkplain Class#getSimpleName()