From 2cfdf9021cfd3f9fce29a3db2f30ab0cb77ba3b5 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sun, 14 Aug 2022 16:01:27 +0800 Subject: Bugfix: wrong initialization sequence crashes velocity server startup. --- .../java/com/keuin/crosslink/plugin/velocity/VelocityEventBus.java | 3 +-- .../com/keuin/crosslink/plugin/velocity/VelocityMainWrapper.java | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityEventBus.java b/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityEventBus.java index 2b6ddf8..4a2afdd 100644 --- a/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityEventBus.java +++ b/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityEventBus.java @@ -1,7 +1,6 @@ package com.keuin.crosslink.plugin.velocity; import com.google.inject.Inject; -import com.keuin.crosslink.plugin.bungee.BungeeEventBus; import com.keuin.crosslink.plugin.common.IEventBus; import com.keuin.crosslink.plugin.common.event.EventHandler; import com.keuin.crosslink.plugin.common.event.PlayerConnectEvent; @@ -22,7 +21,7 @@ import java.util.logging.Logger; public class VelocityEventBus implements IEventBus { private final Object plugin; private final ProxyServer velocity; - private final Logger logger = Logger.getLogger(BungeeEventBus.class.getName()); + private final Logger logger = Logger.getLogger(VelocityEventBus.class.getName()); private final Set connectedPlayers = Collections.newSetFromMap(new ConcurrentHashMap<>()); // all players connected to the proxy private final Map serverPlayerLastJoined = new HashMap<>(); // the server players last connected to diff --git a/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityMainWrapper.java b/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityMainWrapper.java index b1f5881..dbebfc9 100644 --- a/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityMainWrapper.java +++ b/src/main/java/com/keuin/crosslink/plugin/velocity/VelocityMainWrapper.java @@ -32,6 +32,7 @@ import java.nio.file.Path; public final class VelocityMainWrapper { private final ProxyServer proxy; private final PluginMain plugin; + private final VelocityEventBus eventBus; @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { @@ -41,13 +42,15 @@ public final class VelocityMainWrapper { // shutdown event proxy.getEventManager().register( this, ProxyShutdownEvent.class, (ev) -> plugin.disable()); + // register event bus + proxy.getEventManager().register(this, eventBus); + // main initialization plugin.enable(); } @Inject public VelocityMainWrapper(ProxyServer proxy, Logger logger, @DataDirectory Path pluginDataPath) { - var eventBus = new VelocityEventBus(this, proxy); - proxy.getEventManager().register(this, eventBus); + this.eventBus = new VelocityEventBus(this, proxy); this.proxy = proxy; var injector = Guice.createInjector( new VelocityAccessorModule(this), -- cgit v1.2.3