From f583d70d1aa6a50eee79080834266bc342e51913 Mon Sep 17 00:00:00 2001 From: 4drian3d Date: Fri, 22 Oct 2021 15:02:53 -0500 Subject: [PATCH] Added FastLogin Velocity support --- proxy/pom.xml | 10 +++++++ .../proxy/AuthMeVelocityPlugin.java | 2 ++ .../proxy/listener/FastLoginListener.java | 29 +++++++++++++++++++ .../proxy/listener/ProxyListener.java | 9 ++++-- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/FastLoginListener.java diff --git a/proxy/pom.xml b/proxy/pom.xml index 0f00409..8817c1f 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -20,6 +20,10 @@ jitpack.io https://jitpack.io + + codemc-snapshots + https://repo.codemc.io/repository/maven-snapshots/ + @@ -35,6 +39,12 @@ 3.2.3 compile + + com.github.games647 + fastlogin.velocity + 1.11-SNAPSHOT + provided + diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java index d73df8f..9cdf4eb 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java @@ -1,6 +1,7 @@ package com.glyart.authmevelocity.proxy; import com.glyart.authmevelocity.proxy.config.AuthMeConfig; +import com.glyart.authmevelocity.proxy.listener.FastLoginListener; import com.glyart.authmevelocity.proxy.listener.ProxyListener; import com.google.inject.Inject; import com.velocitypowered.api.event.Subscribe; @@ -34,6 +35,7 @@ public class AuthMeVelocityPlugin { public void onProxyInitialize(ProxyInitializeEvent event) { server.getChannelRegistrar().register(new LegacyChannelIdentifier("authmevelocity:main"), MinecraftChannelIdentifier.create("authmevelocity", "main")); server.getEventManager().register(this, new ProxyListener(this, server)); + server.getEventManager().register(this, new FastLoginListener(this, server)); AuthMeConfig.defaultConfig(); logger.info("AuthMeVelocity enabled"); logger.info("AuthServers: " + config.getList("authservers")); diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/FastLoginListener.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/FastLoginListener.java new file mode 100644 index 0000000..1a733f2 --- /dev/null +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/FastLoginListener.java @@ -0,0 +1,29 @@ +package com.glyart.authmevelocity.proxy.listener; + +import java.util.Optional; +import java.util.UUID; + +import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEvent; +import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin; +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ProxyServer; + +public class FastLoginListener { + private final AuthMeVelocityPlugin plugin; + private final ProxyServer server; + public FastLoginListener(AuthMeVelocityPlugin plugin, ProxyServer server){ + this.plugin = plugin; + this.server = server; + } + @Subscribe + public void onAutoLogin(VelocityFastLoginAutoLoginEvent event){ + Optional autoLoginPlayer = server.getPlayer(event.getProfile().getName()); + if(autoLoginPlayer.isPresent()){ + UUID playerUUID = autoLoginPlayer.get().getUniqueId(); + if(!plugin.loggedPlayers.contains(playerUUID)){ + plugin.loggedPlayers.add(playerUUID); + } + } + } +} diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java index 943dad0..cd0eb7d 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java @@ -41,10 +41,13 @@ public class ProxyListener { if (!player.isPresent()) return; Player loggedPlayer = player.get(); - plugin.loggedPlayers.add(loggedPlayer.getUniqueId()); + UUID playerUUID = loggedPlayer.getUniqueId(); + if (!plugin.loggedPlayers.contains(playerUUID)){ + plugin.loggedPlayers.add(playerUUID); - RegisteredServer loginServer = player.get().getCurrentServer().get().getServer(); - server.getEventManager().fireAndForget(new ProxyLoginEvent(loggedPlayer, loginServer)); + RegisteredServer loginServer = player.get().getCurrentServer().get().getServer(); + server.getEventManager().fireAndForget(new ProxyLoginEvent(loggedPlayer, loginServer)); + } } @Subscribe