From b4d1aa418afdd97bfdd5ce9b9d926862d3cf674d Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 18 Mar 2016 00:24:00 -0400 Subject: [PATCH] Add event call helper This simplifies new event calling by reducing the diff to actually fire the event and check for cancelled state. --- .../0024-Add-a-call-helper-to-Event.patch | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Spigot-API-Patches/0024-Add-a-call-helper-to-Event.patch diff --git a/Spigot-API-Patches/0024-Add-a-call-helper-to-Event.patch b/Spigot-API-Patches/0024-Add-a-call-helper-to-Event.patch new file mode 100644 index 0000000000..f6683f7025 --- /dev/null +++ b/Spigot-API-Patches/0024-Add-a-call-helper-to-Event.patch @@ -0,0 +1,44 @@ +From 82df1be4b32c98bc98852d11792b42808db38322 Mon Sep 17 00:00:00 2001 +From: Aikar +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 6677e1b..eaf6c49 100644 +--- a/src/main/java/org/bukkit/event/Event.java ++++ b/src/main/java/org/bukkit/event/Event.java +@@ -1,5 +1,6 @@ + package org.bukkit.event; + ++import org.bukkit.Bukkit; + import org.bukkit.plugin.PluginManager; + + /** +@@ -33,6 +34,22 @@ public abstract class Event { + this.async = isAsync; + } + ++ // Paper start ++ /** ++ * Calls the event and tests if cancelled. ++ * ++ * @return if event was cancelled, if cancellable. otherwise true. ++ */ ++ public boolean callEvent() { ++ 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.7.3 +