geforkt von Mirrors/Velocity
Remove more junk
Dieser Commit ist enthalten in:
Ursprung
dc594e692d
Commit
a44bb3b048
@ -9,7 +9,6 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|||||||
import com.velocitypowered.proxy.connection.VelocityConstants;
|
import com.velocitypowered.proxy.connection.VelocityConstants;
|
||||||
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
|
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
|
||||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.*;
|
import com.velocitypowered.proxy.protocol.packet.*;
|
||||||
@ -28,11 +27,14 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class LoginSessionHandler implements MinecraftSessionHandler {
|
public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private final VelocityServerConnection serverConn;
|
private final VelocityServerConnection serverConn;
|
||||||
|
private final CompletableFuture<ConnectionRequestBuilder.Result> resultFuture;
|
||||||
private boolean informationForwarded;
|
private boolean informationForwarded;
|
||||||
|
|
||||||
public LoginSessionHandler(VelocityServer server, VelocityServerConnection serverConn) {
|
public LoginSessionHandler(VelocityServer server, VelocityServerConnection serverConn,
|
||||||
|
CompletableFuture<ConnectionRequestBuilder.Result> resultFuture) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.serverConn = serverConn;
|
this.serverConn = serverConn;
|
||||||
|
this.resultFuture = resultFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,9 +68,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Disconnect packet) {
|
public boolean handle(Disconnect packet) {
|
||||||
Disconnect disconnect = (Disconnect) packet;
|
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet));
|
||||||
// Do we have an outstanding notification? If so, fulfill it.
|
|
||||||
doNotify(ConnectionRequestResults.forDisconnect(disconnect));
|
|
||||||
serverConn.disconnect();
|
serverConn.disconnect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(ServerLoginSuccess packet) {
|
public boolean handle(ServerLoginSuccess packet) {
|
||||||
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && !informationForwarded) {
|
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && !informationForwarded) {
|
||||||
doNotify(ConnectionRequestResults.forDisconnect(
|
resultFuture.complete(ConnectionRequestResults.forDisconnect(
|
||||||
TextComponent.of("Your server did not send a forwarding request to the proxy. Is it set up correctly?")));
|
TextComponent.of("Your server did not send a forwarding request to the proxy. Is it set up correctly?")));
|
||||||
serverConn.disconnect();
|
serverConn.disconnect();
|
||||||
return true;
|
return true;
|
||||||
@ -103,7 +103,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
existingConnection.disconnect();
|
existingConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
doNotify(ConnectionRequestResults.SUCCESSFUL);
|
resultFuture.complete(ConnectionRequestResults.SUCCESSFUL);
|
||||||
serverConn.getConnection().setSessionHandler(new BackendPlaySessionHandler(server, serverConn));
|
serverConn.getConnection().setSessionHandler(new BackendPlaySessionHandler(server, serverConn));
|
||||||
serverConn.getPlayer().setConnectedServer(serverConn);
|
serverConn.getPlayer().setConnectedServer(serverConn);
|
||||||
return true;
|
return true;
|
||||||
@ -111,28 +111,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exception(Throwable throwable) {
|
public void exception(Throwable throwable) {
|
||||||
CompletableFuture<ConnectionRequestBuilder.Result> future = serverConn.getConnection().getChannel()
|
resultFuture.completeExceptionally(throwable);
|
||||||
.attr(VelocityServerConnection.CONNECTION_NOTIFIER).getAndSet(null);
|
|
||||||
if (future != null) {
|
|
||||||
future.completeExceptionally(throwable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected() {
|
||||||
CompletableFuture<ConnectionRequestBuilder.Result> future = serverConn.getConnection().getChannel()
|
resultFuture.completeExceptionally(new IOException("Unexpectedly disconnected from remote server"));
|
||||||
.attr(VelocityServerConnection.CONNECTION_NOTIFIER).getAndSet(null);
|
|
||||||
if (future != null) {
|
|
||||||
future.completeExceptionally(new IOException("Unexpectedly disconnected from remote server"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doNotify(ConnectionRequestBuilder.Result result) {
|
|
||||||
CompletableFuture<ConnectionRequestBuilder.Result> future = serverConn.getConnection().getChannel()
|
|
||||||
.attr(VelocityServerConnection.CONNECTION_NOTIFIER).getAndSet(null);
|
|
||||||
if (future != null) {
|
|
||||||
future.complete(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ByteBuf createForwardingData(byte[] hmacSecret, String address, GameProfile profile) {
|
private static ByteBuf createForwardingData(byte[] hmacSecret, String address, GameProfile profile) {
|
||||||
|
@ -25,7 +25,6 @@ import io.netty.channel.ChannelFuture;
|
|||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||||
import io.netty.util.AttributeKey;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -34,9 +33,6 @@ import static com.velocitypowered.proxy.VelocityServer.GSON;
|
|||||||
import static com.velocitypowered.proxy.network.Connections.*;
|
import static com.velocitypowered.proxy.network.Connections.*;
|
||||||
|
|
||||||
public class VelocityServerConnection implements MinecraftConnectionAssociation, ServerConnection {
|
public class VelocityServerConnection implements MinecraftConnectionAssociation, ServerConnection {
|
||||||
static final AttributeKey<CompletableFuture<ConnectionRequestBuilder.Result>> CONNECTION_NOTIFIER =
|
|
||||||
AttributeKey.newInstance("connection-notification-result");
|
|
||||||
|
|
||||||
private final VelocityRegisteredServer registeredServer;
|
private final VelocityRegisteredServer registeredServer;
|
||||||
private final ConnectedPlayer proxyPlayer;
|
private final ConnectedPlayer proxyPlayer;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
@ -66,7 +62,6 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolConstants.Direction.CLIENTBOUND))
|
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolConstants.Direction.CLIENTBOUND))
|
||||||
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolConstants.Direction.SERVERBOUND));
|
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolConstants.Direction.SERVERBOUND));
|
||||||
|
|
||||||
ch.attr(CONNECTION_NOTIFIER).set(result);
|
|
||||||
MinecraftConnection connection = new MinecraftConnection(ch, server);
|
MinecraftConnection connection = new MinecraftConnection(ch, server);
|
||||||
connection.setState(StateRegistry.HANDSHAKE);
|
connection.setState(StateRegistry.HANDSHAKE);
|
||||||
connection.setAssociation(VelocityServerConnection.this);
|
connection.setAssociation(VelocityServerConnection.this);
|
||||||
@ -81,7 +76,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
connection = future.channel().pipeline().get(MinecraftConnection.class);
|
connection = future.channel().pipeline().get(MinecraftConnection.class);
|
||||||
|
|
||||||
// Kick off the connection process
|
// Kick off the connection process
|
||||||
connection.setSessionHandler(new LoginSessionHandler(server, VelocityServerConnection.this));
|
connection.setSessionHandler(new LoginSessionHandler(server, VelocityServerConnection.this, result));
|
||||||
startHandshake();
|
startHandshake();
|
||||||
} else {
|
} else {
|
||||||
result.completeExceptionally(future.cause());
|
result.completeExceptionally(future.cause());
|
||||||
|
@ -180,7 +180,6 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
// If we don't want to handle this packet, just forward it on.
|
// If we don't want to handle this packet, just forward it on.
|
||||||
if (serverConnection.hasCompletedJoin()) {
|
if (serverConnection.hasCompletedJoin()) {
|
||||||
logger.info("Will write {}", packet);
|
|
||||||
serverConnection.getConnection().write(packet);
|
serverConnection.getConnection().write(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren