diff --git a/src/main/java/net/lenni0451/miniconnect/Main.java b/src/main/java/net/lenni0451/miniconnect/Main.java index 7c57d00..43537e8 100644 --- a/src/main/java/net/lenni0451/miniconnect/Main.java +++ b/src/main/java/net/lenni0451/miniconnect/Main.java @@ -1,10 +1,7 @@ package net.lenni0451.miniconnect; import net.lenni0451.miniconnect.proxy.StateRegistry; -import net.lenni0451.miniconnect.proxy.event.HAProxyEnableHandler; -import net.lenni0451.miniconnect.proxy.event.PacketHandlerRegistry; -import net.lenni0451.miniconnect.proxy.event.RedirectionHandler; -import net.lenni0451.miniconnect.proxy.event.ViaLoadHandler; +import net.lenni0451.miniconnect.proxy.event.*; import net.lenni0451.miniconnect.server.LobbyServerInitializer; import net.raphimc.netminecraft.netty.connection.NetServer; import net.raphimc.viaproxy.ViaProxy; @@ -46,6 +43,7 @@ public void onEnable() { ViaProxy.EVENT_MANAGER.register(new PacketHandlerRegistry()); ViaProxy.EVENT_MANAGER.register(new ViaLoadHandler()); ViaProxy.EVENT_MANAGER.register(new HAProxyEnableHandler()); + ViaProxy.EVENT_MANAGER.register(new OnlineModeHandler()); } } diff --git a/src/main/java/net/lenni0451/miniconnect/proxy/event/OnlineModeHandler.java b/src/main/java/net/lenni0451/miniconnect/proxy/event/OnlineModeHandler.java new file mode 100644 index 0000000..1aad5b2 --- /dev/null +++ b/src/main/java/net/lenni0451/miniconnect/proxy/event/OnlineModeHandler.java @@ -0,0 +1,14 @@ +package net.lenni0451.miniconnect.proxy.event; + +import net.lenni0451.lambdaevents.EventHandler; +import net.raphimc.viaproxy.plugins.events.JoinServerRequestEvent; + +public class OnlineModeHandler { + + @EventHandler(priority = Integer.MIN_VALUE) + public void onJoinServerRequest(final JoinServerRequestEvent event) { + if (event.isCancelled()) return; + event.getProxyConnection().kickClient("§cThe server is in online mode and requires authentication.\n§aPlease reconnect and authenticate by clicking on Login (key)."); + } + +}