mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Add event call helper
This simplifies new event calling by reducing the diff to actually fire the event and check for cancelled state.
This commit is contained in:
parent
d61ce9271e
commit
d35aeb50ee
42
Spigot-API-Patches/Add-a-call-helper-to-Event.patch
Normal file
42
Spigot-API-Patches/Add-a-call-helper-to-Event.patch
Normal file
@ -0,0 +1,42 @@
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/Event.java
|
||||
+++ b/src/main/java/org/bukkit/event/Event.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package org.bukkit.event;
|
||||
|
||||
+import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
/**
|
||||
@@ -0,0 +0,0 @@ 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()
|
||||
--
|
Loading…
Reference in New Issue
Block a user