From f6d715a67d4a5ef4ec88d01eb74c486fb62cea05 Mon Sep 17 00:00:00 2001 From: ItsNature Date: Thu, 21 May 2026 00:16:02 +0200 Subject: [PATCH] fix(velocity): legacy player detection --- .../lunarclient/apollo/ApolloVelocityPlatform.java | 4 ++++ .../apollo/listener/ApolloPlayerListener.java | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java b/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java index 2825214a..f074ff32 100644 --- a/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java +++ b/platform/velocity/src/main/java/com/lunarclient/apollo/ApolloVelocityPlatform.java @@ -94,6 +94,7 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.messages.ChannelRegistrar; +import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import java.nio.file.Path; import java.util.ArrayList; @@ -118,6 +119,7 @@ public final class ApolloVelocityPlatform implements ApolloPlatform { public static MinecraftChannelIdentifier PLUGIN_CHANNEL; + public static LegacyChannelIdentifier LEGACY_PLUGIN_CHANNEL; @Getter private static ApolloVelocityPlatform instance; @@ -227,6 +229,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { ChannelRegistrar channelRegistrar = this.server.getChannelRegistrar(); channelRegistrar.register(ApolloVelocityPlatform.PLUGIN_CHANNEL); + channelRegistrar.register(ApolloVelocityPlatform.LEGACY_PLUGIN_CHANNEL); channelRegistrar.register(ApolloMetadataListener.FML_HANDSHAKE_CHANNEL); CommandManager commandManager = this.server.getCommandManager(); @@ -250,6 +253,7 @@ public void onProxyShutdown(ProxyShutdownEvent event) { static { PLUGIN_CHANNEL = MinecraftChannelIdentifier.create("lunar", "apollo"); + LEGACY_PLUGIN_CHANNEL = new LegacyChannelIdentifier(ApolloManager.PLUGIN_MESSAGE_CHANNEL); } } diff --git a/platform/velocity/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.java b/platform/velocity/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.java index d5a4906f..f7870a65 100644 --- a/platform/velocity/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.java +++ b/platform/velocity/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.java @@ -25,7 +25,6 @@ import com.lunarclient.apollo.Apollo; import com.lunarclient.apollo.ApolloManager; -import com.lunarclient.apollo.ApolloVelocityPlatform; import com.lunarclient.apollo.player.ApolloPlayerManagerImpl; import com.lunarclient.apollo.wrapper.VelocityApolloPlayer; import com.velocitypowered.api.event.Subscribe; @@ -33,6 +32,7 @@ import com.velocitypowered.api.event.connection.PluginMessageEvent; import com.velocitypowered.api.event.player.PlayerChannelRegisterEvent; import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.messages.ChannelIdentifier; /** * Handles registration and un-registration of Apollo players. @@ -49,7 +49,15 @@ public final class ApolloPlayerListener { */ @Subscribe public void onPlayerRegisterChannel(PlayerChannelRegisterEvent event) { - if (!event.getChannels().contains(ApolloVelocityPlatform.PLUGIN_CHANNEL)) { + boolean registered = false; + for (ChannelIdentifier channel : event.getChannels()) { + if (channel.getId().equals(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) { + registered = true; + break; + } + } + + if (!registered) { return; } @@ -65,7 +73,7 @@ public void onPlayerRegisterChannel(PlayerChannelRegisterEvent event) { */ @Subscribe public void onPluginMessage(PluginMessageEvent event) { - if (!event.getIdentifier().equals(ApolloVelocityPlatform.PLUGIN_CHANNEL)) { + if (!event.getIdentifier().getId().equals(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) { return; }