Paper/Spigot-API-Patches/0023-Add-a-call-helper-to-Event.patch

38 lines
1.1 KiB
Diff
Raw Normal View History

2019-04-23 06:47:07 +02:00
From eca2d156a9ab87ab92228e8ae93fa65cc65cab02 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 18d0636b..8ec56cd6 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()
--
2.21.0