From 7c404db56b76e933d5e9a66ad510541ebe68c1f5 Mon Sep 17 00:00:00 2001 From: Jacob Bordas Date: Mon, 31 Aug 2020 13:32:11 +0200 Subject: [PATCH 1/2] Added event when all expansions are loaded for developers. --- .../events/ExpansionsLoadedEvent.java | 28 +++++++++++++++++++ .../manager/LocalExpansionManager.java | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java diff --git a/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java b/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java new file mode 100644 index 0000000..8a97567 --- /dev/null +++ b/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java @@ -0,0 +1,28 @@ +package me.clip.placeholderapi.events; + + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * This event is ran when all expansions are loaded. + * This is done when reloading config, on plugin start and on server load. + * @author jacobbordas (@ignissak) + */ +public class ExpansionsLoadedEvent extends Event { + + @NotNull + private static final HandlerList HANDLERS = new HandlerList(); + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLERS; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLERS; + } +} diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index 79f3509..ac3527f 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -36,6 +36,7 @@ import java.util.logging.Level; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.events.ExpansionRegisterEvent; import me.clip.placeholderapi.events.ExpansionUnregisterEvent; +import me.clip.placeholderapi.events.ExpansionsLoadedEvent; import me.clip.placeholderapi.expansion.Cacheable; import me.clip.placeholderapi.expansion.Cleanable; import me.clip.placeholderapi.expansion.Configurable; @@ -320,6 +321,9 @@ public final class LocalExpansionManager implements Listener { Msg.msg(sender, registered == 0 ? "&6No expansions were registered!" : registered + "&a placeholder hooks successfully registered!"); + + final ExpansionsLoadedEvent event = new ExpansionsLoadedEvent(); + Bukkit.getPluginManager().callEvent(event); }); } From 2c13acfd307bd1b86e59e987ee5ace89d510a18e Mon Sep 17 00:00:00 2001 From: Jacob Bordas Date: Tue, 1 Sep 2020 01:31:52 +0200 Subject: [PATCH 2/2] Changes regarding review by Andre Signed-off-by: Jacob Bordas --- .../me/clip/placeholderapi/events/ExpansionsLoadedEvent.java | 4 +--- .../expansion/manager/LocalExpansionManager.java | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java b/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java index 8a97567..d949b8a 100644 --- a/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java +++ b/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java @@ -6,9 +6,7 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** - * This event is ran when all expansions are loaded. - * This is done when reloading config, on plugin start and on server load. - * @author jacobbordas (@ignissak) + * This event is called when all expansions are loaded (when reloading config, on plugin start and on server load). */ public class ExpansionsLoadedEvent extends Event { diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index ac3527f..f0add00 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -322,8 +322,7 @@ public final class LocalExpansionManager implements Listener { registered == 0 ? "&6No expansions were registered!" : registered + "&a placeholder hooks successfully registered!"); - final ExpansionsLoadedEvent event = new ExpansionsLoadedEvent(); - Bukkit.getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent()); }); }