Waterfall/BungeeCord-Patches/0026-Add-callEvent-shortcut-to-Event.patch

33 lines
1.1 KiB
Diff
Raw Normal View History

From e86cf467adab61a44534cc9ece28770989a5e1c4 Mon Sep 17 00:00:00 2001
2019-12-02 12:55:27 +01:00
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Date: Sun, 14 Apr 2019 19:15:00 +0300
Subject: [PATCH] Add callEvent() shortcut to Event
diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/Event.java b/api/src/main/java/net/md_5/bungee/api/plugin/Event.java
index e2e01ecb..25ec1bd8 100644
--- a/api/src/main/java/net/md_5/bungee/api/plugin/Event.java
+++ b/api/src/main/java/net/md_5/bungee/api/plugin/Event.java
@@ -12,4 +12,18 @@ public abstract class Event
public void postCall()
{
}
+ // Waterfall start - Add callEvent() shortcut, borrowed from PaperMC/Paper
+ /**
+ * Calls the event and tests if cancelled.
+ *
+ * @return false if event was cancelled, if cancellable. otherwise true.
+ */
+ public final boolean callEvent() {
+ net.md_5.bungee.api.ProxyServer.getInstance().getPluginManager().callEvent(this);
+ if (this instanceof Cancellable) {
+ return !((Cancellable) this).isCancelled();
+ }
+ return true;
+ }
+ // Waterfall end
}
--
2.26.1
2019-12-02 12:55:27 +01:00