2019-02-23 18:17:41 +01:00
|
|
|
From 39a9d269c567db7d72040f7bd62befb4c4a09482 Mon Sep 17 00:00:00 2001
|
2016-03-18 05:24:00 +01:00
|
|
|
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
|
2018-07-19 06:42:43 +02:00
|
|
|
index 6677e1bd..e7061112 100644
|
2016-03-18 05:24:00 +01:00
|
|
|
--- 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.
|
|
|
|
+ *
|
2018-06-18 22:42:39 +02:00
|
|
|
+ * @return false if event was cancelled, if cancellable. otherwise true.
|
2016-03-18 05:24:00 +01:00
|
|
|
+ */
|
|
|
|
+ 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()
|
|
|
|
--
|
2019-02-23 18:17:41 +01:00
|
|
|
2.20.1
|
2016-03-18 05:24:00 +01:00
|
|
|
|