Skip to content

Commit

Permalink
Shutting down hooked EventManager
Browse files Browse the repository at this point in the history
  • Loading branch information
hevav committed Jul 22, 2022
1 parent 17d48bc commit 43af4ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public LimboAPI(Logger logger, ProxyServer server, Metrics.Factory metricsFactor
LimboProtocol.init();
} catch (ReflectiveOperationException e) {
throw new ReflectionException(e);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ public void reloadHandlers() throws IllegalAccessException {
}
}

public static void init(LimboAPI plugin) throws ReflectiveOperationException {
public static void init(LimboAPI plugin) throws ReflectiveOperationException, InterruptedException {
VelocityServer server = plugin.getServer();
EventManager newEventManager = new EventManagerHook(server.getPluginManager(), plugin);
EventManager oldEventManager = server.getEventManager();
VelocityEventManager oldEventManager = server.getEventManager();
HANDLERS_BY_TYPE_FIELD.set(newEventManager, HANDLERS_BY_TYPE_FIELD.get(oldEventManager));
HANDLERS_CACHE_FIELD.set(newEventManager, HANDLERS_CACHE_FIELD.get(oldEventManager));
UNTARGETED_METHOD_HANDLERS_FIELD.set(newEventManager, UNTARGETED_METHOD_HANDLERS_FIELD.get(oldEventManager));
Expand All @@ -221,5 +221,7 @@ public static void init(LimboAPI plugin) throws ReflectiveOperationException {

VELOCITY_SERVER_EVENT_MANAGER_FIELD.set(server, newEventManager);
VELOCITY_COMMAND_MANAGER_EVENT_MANAGER_FIELD.set(server.getCommandManager(), newEventManager);

oldEventManager.shutdown();
}
}

0 comments on commit 43af4ff

Please sign in to comment.