From 9c28ceb8bf10de4f1feb5c623a19cc6a96dc9dbc Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Tue, 26 Apr 2022 19:57:32 -0400 Subject: [PATCH] Fix handler creation --- .../server/event/EventHandler.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/event/EventHandler.java b/src/main/java/emu/grasscutter/server/event/EventHandler.java index 4522cc2c6..f24bc2dee 100644 --- a/src/main/java/emu/grasscutter/server/event/EventHandler.java +++ b/src/main/java/emu/grasscutter/server/event/EventHandler.java @@ -5,9 +5,22 @@ import emu.grasscutter.Grasscutter; import java.util.function.Consumer; public final class EventHandler { - private final Class event; + private final Class event; + + /** + * Creates an instance of {@link EventHandler} for the specified event. + * @param event The event to handle. + * @return An instance of {@link EventHandler}. + */ + public static EventHandler forEvent(Class event) { + return new EventHandler(event); + } - public EventHandler(Class event) { + /** + * @deprecated Will be replaced with a private constructor instead. Use {@link #forEvent(Class)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.1") + public EventHandler(Class event) { this.event = event; } @@ -19,7 +32,7 @@ public final class EventHandler { * Gets which event this handler is handling. * @return An event class. */ - public Class handles() { + public Class handles() { return this.event; }