fix: fixed legacy minecraft version plugin message sending
This commit is contained in:
parent
a500090723
commit
afda8ecbc3
@ -28,6 +28,7 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
|
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import io.github._4drian3d.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
import io.github._4drian3d.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
@ -74,8 +75,10 @@ import java.util.function.Predicate;
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
||||||
public static final ChannelIdentifier AUTHMEVELOCITY_CHANNEL
|
public static final ChannelIdentifier MODERN_CHANNEL
|
||||||
= MinecraftChannelIdentifier.create("authmevelocity", "main");
|
= MinecraftChannelIdentifier.create("authmevelocity", "main");
|
||||||
|
public static final ChannelIdentifier LEGACY_CHANNEL
|
||||||
|
= new LegacyChannelIdentifier("authmevelocity:main");
|
||||||
@Inject
|
@Inject
|
||||||
private ProxyServer proxy;
|
private ProxyServer proxy;
|
||||||
@Inject
|
@Inject
|
||||||
@ -109,7 +112,7 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
final int pluginId = 16128;
|
final int pluginId = 16128;
|
||||||
final Metrics metrics = metricsFactory.make(this, pluginId);
|
final Metrics metrics = metricsFactory.make(this, pluginId);
|
||||||
|
|
||||||
proxy.getChannelRegistrar().register(AUTHMEVELOCITY_CHANNEL);
|
proxy.getChannelRegistrar().register(MODERN_CHANNEL, LEGACY_CHANNEL);
|
||||||
|
|
||||||
List.of(
|
List.of(
|
||||||
new ProxyListener(this),
|
new ProxyListener(this),
|
||||||
|
@ -106,8 +106,14 @@ public final class ConnectListener {
|
|||||||
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
|
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
|
||||||
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||||
buf.writeUTF("LOGIN");
|
buf.writeUTF("LOGIN");
|
||||||
player.getCurrentServer().ifPresent(sv ->
|
player.getCurrentServer().ifPresent(sv -> {
|
||||||
sv.sendPluginMessage(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL, buf.toByteArray()));
|
var byteArray = buf.toByteArray();
|
||||||
|
if (!sv.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) {
|
||||||
|
plugin.logDebug("ServerPostConnectEvent | Failed to send on Modern Channel");
|
||||||
|
var legacyResult = sv.sendPluginMessage(AuthMeVelocityPlugin.LEGACY_CHANNEL, byteArray);
|
||||||
|
if(!legacyResult) plugin.logDebug("ServerPostConnectEvent | Failed to send on Legacy Channel");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ public class PluginMessageListener {
|
|||||||
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
|
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
|
||||||
final boolean cancelled = !event.getResult().isAllowed()
|
final boolean cancelled = !event.getResult().isAllowed()
|
||||||
|| !(event.getSource() instanceof ServerConnection)
|
|| !(event.getSource() instanceof ServerConnection)
|
||||||
|| !event.getIdentifier().equals(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL);
|
|| !(event.getIdentifier().equals(AuthMeVelocityPlugin.MODERN_CHANNEL)
|
||||||
|
|| event.getIdentifier().equals(AuthMeVelocityPlugin.LEGACY_CHANNEL));
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
plugin.logDebug("PluginMessageEvent | Not allowed");
|
plugin.logDebug("PluginMessageEvent | Not allowed");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user