From 7e35f49e54f8399bee810f7775144f5c29d0a6f4 Mon Sep 17 00:00:00 2001 From: CarmJos Date: Tue, 7 Jun 2022 07:40:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(main):=20=E6=B7=BB=E5=8A=A0=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E3=80=81=E5=BC=82=E6=AD=A5=E4=B8=8E=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=94=A4=E8=B5=B7=E4=BA=8B=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/command/pom.xml | 2 +- base/gui/pom.xml | 2 +- base/main/pom.xml | 2 +- .../java/cc/carm/lib/easyplugin/EasyPlugin.java | 17 +++++++++++++++++ collection/all/pom.xml | 2 +- collection/bom/pom.xml | 2 +- collection/common/pom.xml | 2 +- extension/papi/pom.xml | 2 +- extension/vault/pom.xml | 2 +- pom.xml | 2 +- 10 files changed, 26 insertions(+), 9 deletions(-) diff --git a/base/command/pom.xml b/base/command/pom.xml index a5cdfbf..6e5504c 100644 --- a/base/command/pom.xml +++ b/base/command/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/base/gui/pom.xml b/base/gui/pom.xml index 7796c63..efae80b 100644 --- a/base/gui/pom.xml +++ b/base/gui/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/base/main/pom.xml b/base/main/pom.xml index 0b52d1e..3cd489c 100644 --- a/base/main/pom.xml +++ b/base/main/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/base/main/src/main/java/cc/carm/lib/easyplugin/EasyPlugin.java b/base/main/src/main/java/cc/carm/lib/easyplugin/EasyPlugin.java index 5c8e929..9980a59 100644 --- a/base/main/src/main/java/cc/carm/lib/easyplugin/EasyPlugin.java +++ b/base/main/src/main/java/cc/carm/lib/easyplugin/EasyPlugin.java @@ -7,6 +7,7 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandExecutor; import org.bukkit.command.PluginCommand; import org.bukkit.command.TabCompleter; +import org.bukkit.event.Event; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; @@ -17,6 +18,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.concurrent.CompletableFuture; public abstract class EasyPlugin extends JavaPlugin { @@ -134,6 +136,21 @@ public abstract class EasyPlugin extends JavaPlugin { if (isDebugging()) print("&8[DEBUG] &r", messages); } + public void callEventSync(Event event) { + getScheduler().run(() -> Bukkit.getPluginManager().callEvent(event)); + } + + public void callEventAsync(Event event) { + getScheduler().runAsync(() -> Bukkit.getPluginManager().callEvent(event)); + } + + public @NotNull CompletableFuture callEventFuture(T event) { + return CompletableFuture.supplyAsync(() -> { + Bukkit.getPluginManager().callEvent(event); + return event; + }); + } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean hasOverride(String methodName) { Map methodMap = new HashMap<>(); diff --git a/collection/all/pom.xml b/collection/all/pom.xml index 421b851..84d93fb 100644 --- a/collection/all/pom.xml +++ b/collection/all/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/collection/bom/pom.xml b/collection/bom/pom.xml index 01c1210..601fb7b 100644 --- a/collection/bom/pom.xml +++ b/collection/bom/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/collection/common/pom.xml b/collection/common/pom.xml index 83b1ebf..03de656 100644 --- a/collection/common/pom.xml +++ b/collection/common/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/extension/papi/pom.xml b/extension/papi/pom.xml index a95ed75..68c0a17 100644 --- a/extension/papi/pom.xml +++ b/extension/papi/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/extension/vault/pom.xml b/extension/vault/pom.xml index 4865e72..b8ce812 100644 --- a/extension/vault/pom.xml +++ b/extension/vault/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.5 + 1.4.6 ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 8b4407e..01f74db 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ cc.carm.lib easyplugin-parent pom - 1.4.5 + 1.4.6 base/main