From 26db170a1eca88f1760b7eab61a507ac003ba1ba Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Tue, 26 Apr 2022 14:08:48 -0400 Subject: [PATCH] Fix Javadoc & Update version --- build.gradle | 2 +- .../java/emu/grasscutter/plugin/PluginManager.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 1be86626c..e5bab797d 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { } group = 'tech.xigam' -version = '1.0.0-dev' +version = '1.0.1-dev' sourceCompatibility = 17 targetCompatibility = 17 diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index f63e2381d..82d71ca6c 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -17,11 +17,11 @@ import java.util.jar.JarFile; import java.util.stream.Stream; /** - * Manages the server's plugins & the event system. + * Manages the server's plugins and the event system. */ public final class PluginManager { private final Map plugins = new HashMap<>(); - private final List> listeners = new LinkedList<>(); + private final List listeners = new LinkedList<>(); public PluginManager() { this.loadPlugins(); // Load all plugins from the plugins directory. @@ -131,7 +131,7 @@ public final class PluginManager { * Registers a plugin's event listener. * @param listener The event listener. */ - public void registerListener(EventHandler listener) { + public void registerListener(EventHandler listener) { this.listeners.add(listener); } @@ -140,8 +140,8 @@ public final class PluginManager { * @param event The event to invoke. */ public void invokeEvent(Event event) { - Stream> handlers = this.listeners.stream() - .filter(handler -> event.getClass().isInstance(event)); + Stream handlers = this.listeners.stream() + .filter(handler -> handler.handles().isInstance(event)); handlers.filter(handler -> handler.getPriority() == HandlerPriority.HIGH) .toList().forEach(handler -> this.invokeHandler(event, handler)); handlers.filter(handler -> handler.getPriority() == HandlerPriority.NORMAL) @@ -155,7 +155,7 @@ public final class PluginManager { * @param event The event passed through to the handler. * @param handler The handler to invoke. */ - private void invokeHandler(Event event, EventHandler handler) { + private void invokeHandler(Event event, EventHandler handler) { if(!event.isCanceled() || (event.isCanceled() && handler.ignoresCanceled()) ) handler.getCallback().accept(event);