Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

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;
import com.velocitypowered.api.event.connection.DisconnectEvent;
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.
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
Loading