Fix Javadoc & Update version

This commit is contained in:
KingRainbow44 2022-04-26 14:08:48 -04:00
parent 82bca7a612
commit 35ff35039b
2 changed files with 7 additions and 7 deletions

View File

@ -18,7 +18,7 @@ plugins {
} }
group = 'tech.xigam' group = 'tech.xigam'
version = '1.0.0-dev' version = '1.0.1-dev'
sourceCompatibility = 17 sourceCompatibility = 17
targetCompatibility = 17 targetCompatibility = 17

View File

@ -17,11 +17,11 @@ import java.util.jar.JarFile;
import java.util.stream.Stream; 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 { public final class PluginManager {
private final Map<String, Plugin> plugins = new HashMap<>(); private final Map<String, Plugin> plugins = new HashMap<>();
private final List<EventHandler<?>> listeners = new LinkedList<>(); private final List<EventHandler> listeners = new LinkedList<>();
public PluginManager() { public PluginManager() {
this.loadPlugins(); // Load all plugins from the plugins directory. this.loadPlugins(); // Load all plugins from the plugins directory.
@ -131,7 +131,7 @@ public final class PluginManager {
* Registers a plugin's event listener. * Registers a plugin's event listener.
* @param listener The event listener. * @param listener The event listener.
*/ */
public void registerListener(EventHandler<?> listener) { public void registerListener(EventHandler listener) {
this.listeners.add(listener); this.listeners.add(listener);
} }
@ -140,8 +140,8 @@ public final class PluginManager {
* @param event The event to invoke. * @param event The event to invoke.
*/ */
public void invokeEvent(Event event) { public void invokeEvent(Event event) {
Stream<EventHandler<?>> handlers = this.listeners.stream() Stream<EventHandler> handlers = this.listeners.stream()
.filter(handler -> event.getClass().isInstance(event)); .filter(handler -> handler.handles().isInstance(event));
handlers.filter(handler -> handler.getPriority() == HandlerPriority.HIGH) handlers.filter(handler -> handler.getPriority() == HandlerPriority.HIGH)
.toList().forEach(handler -> this.invokeHandler(event, handler)); .toList().forEach(handler -> this.invokeHandler(event, handler));
handlers.filter(handler -> handler.getPriority() == HandlerPriority.NORMAL) 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 event The event passed through to the handler.
* @param handler The handler to invoke. * @param handler The handler to invoke.
*/ */
private void invokeHandler(Event event, EventHandler<?> handler) { private void invokeHandler(Event event, EventHandler handler) {
if(!event.isCanceled() || if(!event.isCanceled() ||
(event.isCanceled() && handler.ignoresCanceled()) (event.isCanceled() && handler.ignoresCanceled())
) handler.getCallback().accept(event); ) handler.getCallback().accept(event);