geforkt von Mirrors/Velocity
Finalize integrated BungeeQuack
Dieser Commit ist enthalten in:
Ursprung
b08f27b5c4
Commit
87ad188f92
@ -1,5 +1,8 @@
|
|||||||
package com.velocitypowered.proxy.connection.backend;
|
package com.velocitypowered.proxy.connection.backend;
|
||||||
|
|
||||||
|
import static com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder.getBungeeCordChannel;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||||
@ -53,6 +56,10 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void activated() {
|
public void activated() {
|
||||||
serverConn.getServer().addPlayer(serverConn.getPlayer());
|
serverConn.getServer().addPlayer(serverConn.getPlayer());
|
||||||
|
MinecraftConnection serverMc = serverConn.ensureConnected();
|
||||||
|
serverMc.write(PluginMessageUtil.constructChannelsPacket(serverMc.getProtocolVersion(),
|
||||||
|
ImmutableList.of(getBungeeCordChannel(serverMc.getProtocolVersion()))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,6 @@ package com.velocitypowered.proxy.connection.backend;
|
|||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
|
||||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
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;
|
||||||
@ -15,10 +14,8 @@ import com.velocitypowered.proxy.protocol.util.ByteBufDataInput;
|
|||||||
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
|
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
|
||||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
||||||
class BungeeCordMessageResponder {
|
class BungeeCordMessageResponder {
|
||||||
@ -46,10 +43,8 @@ class BungeeCordMessageResponder {
|
|||||||
String playerName = in.readUTF();
|
String playerName = in.readUTF();
|
||||||
String serverName = in.readUTF();
|
String serverName = in.readUTF();
|
||||||
|
|
||||||
proxy.getPlayer(playerName).ifPresent(player -> {
|
proxy.getPlayer(playerName).flatMap(player -> proxy.getServer(serverName))
|
||||||
proxy.getServer(serverName).ifPresent(server -> player.createConnectionRequest(server)
|
.ifPresent(server -> player.createConnectionRequest(server).fireAndForget());
|
||||||
.fireAndForget());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processIp(ByteBufDataInput in) {
|
private void processIp(ByteBufDataInput in) {
|
||||||
@ -120,7 +115,7 @@ class BungeeCordMessageResponder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processGetServers(ByteBufDataInput in) {
|
private void processGetServers() {
|
||||||
StringJoiner joiner = new StringJoiner(", ");
|
StringJoiner joiner = new StringJoiner(", ");
|
||||||
for (RegisteredServer server : proxy.getAllServers()) {
|
for (RegisteredServer server : proxy.getAllServers()) {
|
||||||
joiner.add(server.getServerInfo().getName());
|
joiner.add(server.getServerInfo().getName());
|
||||||
@ -148,7 +143,7 @@ class BungeeCordMessageResponder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processGetServer(ByteBufDataInput in) {
|
private void processGetServer() {
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
ByteBufDataOutput out = new ByteBufDataOutput(buf);
|
ByteBufDataOutput out = new ByteBufDataOutput(buf);
|
||||||
|
|
||||||
@ -158,7 +153,7 @@ class BungeeCordMessageResponder {
|
|||||||
sendResponse(buf);
|
sendResponse(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processUuid(ByteBufDataInput in) {
|
private void processUuid() {
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
ByteBufDataOutput out = new ByteBufDataOutput(buf);
|
ByteBufDataOutput out = new ByteBufDataOutput(buf);
|
||||||
|
|
||||||
@ -243,11 +238,15 @@ class BungeeCordMessageResponder {
|
|||||||
sendResponse(this.player, buf);
|
sendResponse(this.player, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String getBungeeCordChannel(ProtocolVersion version) {
|
||||||
|
return version.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0 ? MODERN_CHANNEL.getId()
|
||||||
|
: LEGACY_CHANNEL.getId();
|
||||||
|
}
|
||||||
|
|
||||||
// Note: this method will always release the buffer!
|
// Note: this method will always release the buffer!
|
||||||
private static void sendResponse(ConnectedPlayer player, ByteBuf buf) {
|
private static void sendResponse(ConnectedPlayer player, ByteBuf buf) {
|
||||||
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
|
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
|
||||||
String chan = serverConnection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13)
|
String chan = getBungeeCordChannel(serverConnection.getProtocolVersion());
|
||||||
>= 0 ? MODERN_CHANNEL.getId() : LEGACY_CHANNEL.getId();
|
|
||||||
|
|
||||||
PluginMessage msg = null;
|
PluginMessage msg = null;
|
||||||
boolean released = false;
|
boolean released = false;
|
||||||
@ -269,7 +268,7 @@ class BungeeCordMessageResponder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean process(PluginMessage message) {
|
boolean process(PluginMessage message) {
|
||||||
if (!MODERN_CHANNEL.getId().equals(message.getChannel()) && !LEGACY_CHANNEL.getId()
|
if (!MODERN_CHANNEL.getId().equals(message.getChannel()) && !LEGACY_CHANNEL.getId()
|
||||||
.equals(message.getChannel())) {
|
.equals(message.getChannel())) {
|
||||||
return false;
|
return false;
|
||||||
@ -277,47 +276,52 @@ class BungeeCordMessageResponder {
|
|||||||
|
|
||||||
ByteBufDataInput in = new ByteBufDataInput(message.content());
|
ByteBufDataInput in = new ByteBufDataInput(message.content());
|
||||||
String subChannel = in.readUTF();
|
String subChannel = in.readUTF();
|
||||||
if (subChannel.equals("ForwardToPlayer")) {
|
switch (subChannel) {
|
||||||
this.processForwardToPlayer(in);
|
case "ForwardToPlayer":
|
||||||
}
|
this.processForwardToPlayer(in);
|
||||||
if (subChannel.equals("Forward")) {
|
break;
|
||||||
this.processForwardToServer(in);
|
case "Forward":
|
||||||
}
|
this.processForwardToServer(in);
|
||||||
if (subChannel.equals("Connect")) {
|
break;
|
||||||
this.processConnect(in);
|
case "Connect":
|
||||||
}
|
this.processConnect(in);
|
||||||
if (subChannel.equals("ConnectOther")) {
|
break;
|
||||||
this.processConnectOther(in);
|
case "ConnectOther":
|
||||||
}
|
this.processConnectOther(in);
|
||||||
if (subChannel.equals("IP")) {
|
break;
|
||||||
this.processIp(in);
|
case "IP":
|
||||||
}
|
this.processIp(in);
|
||||||
if (subChannel.equals("PlayerCount")) {
|
break;
|
||||||
this.processPlayerCount(in);
|
case "PlayerCount":
|
||||||
}
|
this.processPlayerCount(in);
|
||||||
if (subChannel.equals("PlayerList")) {
|
break;
|
||||||
this.processPlayerList(in);
|
case "PlayerList":
|
||||||
}
|
this.processPlayerList(in);
|
||||||
if (subChannel.equals("GetServers")) {
|
break;
|
||||||
this.processGetServers(in);
|
case "GetServers":
|
||||||
}
|
this.processGetServers();
|
||||||
if (subChannel.equals("Message")) {
|
break;
|
||||||
this.processMessage(in);
|
case "Message":
|
||||||
}
|
this.processMessage(in);
|
||||||
if (subChannel.equals("GetServer")) {
|
break;
|
||||||
this.processGetServer(in);
|
case "GetServer":
|
||||||
}
|
this.processGetServer();
|
||||||
if (subChannel.equals("UUID")) {
|
break;
|
||||||
this.processUuid(in);
|
case "UUID":
|
||||||
}
|
this.processUuid();
|
||||||
if (subChannel.equals("UUIDOther")) {
|
break;
|
||||||
this.processUuidOther(in);
|
case "UUIDOther":
|
||||||
}
|
this.processUuidOther(in);
|
||||||
if (subChannel.equals("ServerIP")) {
|
break;
|
||||||
this.processServerIp(in);
|
case "ServerIP":
|
||||||
}
|
this.processServerIp(in);
|
||||||
if (subChannel.equals("KickPlayer")) {
|
break;
|
||||||
this.processKick(in);
|
case "KickPlayer":
|
||||||
|
this.processKick(in);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Do nothing, unknown command
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren