From 00a9dc0ce8823e83b332b6d4c8893c44366ee69f Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Fri, 26 Apr 2024 15:13:09 -0400 Subject: [PATCH] Prevent logins --- .../src/main/java/cc/restfulmc/demo/DemoPlugin.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DemoPlugin/src/main/java/cc/restfulmc/demo/DemoPlugin.java b/DemoPlugin/src/main/java/cc/restfulmc/demo/DemoPlugin.java index f1c9a01..4f72947 100644 --- a/DemoPlugin/src/main/java/cc/restfulmc/demo/DemoPlugin.java +++ b/DemoPlugin/src/main/java/cc/restfulmc/demo/DemoPlugin.java @@ -2,10 +2,13 @@ package cc.restfulmc.demo; import cc.restfulmc.demo.listener.ServerPingListener; import com.google.inject.Inject; +import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.connection.PreLoginEvent; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.proxy.ProxyServer; +import net.kyori.adventure.text.Component; /** * @author Braydon @@ -23,4 +26,9 @@ public final class DemoPlugin { public void onProxyInitialize(ProxyInitializeEvent event) { server.getEventManager().register(this, new ServerPingListener()); } + + @Subscribe(order = PostOrder.FIRST) + public void onLogin(PreLoginEvent event) { + event.setResult(PreLoginEvent.PreLoginComponentResult.denied(Component.text("§cYou can't join a demo server :("))); + } } \ No newline at end of file