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.client.ClientPlaySessionHandler;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.*;
|
||||
@ -28,11 +27,14 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
private final VelocityServer server;
|
||||
private final VelocityServerConnection serverConn;
|
||||
private final CompletableFuture<ConnectionRequestBuilder.Result> resultFuture;
|
||||
private boolean informationForwarded;
|
||||
|
||||
public LoginSessionHandler(VelocityServer server, VelocityServerConnection serverConn) {
|
||||
public LoginSessionHandler(VelocityServer server, VelocityServerConnection serverConn,
|
||||
CompletableFuture<ConnectionRequestBuilder.Result> resultFuture) {
|
||||
this.server = server;
|
||||
this.serverConn = serverConn;
|
||||
this.resultFuture = resultFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,9 +68,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
@Override
|
||||
public boolean handle(Disconnect packet) {
|
||||
Disconnect disconnect = (Disconnect) packet;
|
||||
// Do we have an outstanding notification? If so, fulfill it.
|
||||
doNotify(ConnectionRequestResults.forDisconnect(disconnect));
|
||||
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet));
|
||||
serverConn.disconnect();
|
||||
return true;
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
@Override
|
||||
public boolean handle(ServerLoginSuccess packet) {
|
||||
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?")));
|
||||
serverConn.disconnect();
|
||||
return true;
|
||||
@ -103,7 +103,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
existingConnection.disconnect();
|
||||
}
|
||||
|
||||
doNotify(ConnectionRequestResults.SUCCESSFUL);
|
||||
resultFuture.complete(ConnectionRequestResults.SUCCESSFUL);
|
||||
serverConn.getConnection().setSessionHandler(new BackendPlaySessionHandler(server, serverConn));
|
||||
serverConn.getPlayer().setConnectedServer(serverConn);
|
||||
return true;
|
||||
@ -111,28 +111,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
@Override
|
||||
public void exception(Throwable throwable) {
|
||||
CompletableFuture<ConnectionRequestBuilder.Result> future = serverConn.getConnection().getChannel()
|
||||
.attr(VelocityServerConnection.CONNECTION_NOTIFIER).getAndSet(null);
|
||||
if (future != null) {
|
||||
future.completeExceptionally(throwable);
|
||||
}
|
||||
resultFuture.completeExceptionally(throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected() {
|
||||
CompletableFuture<ConnectionRequestBuilder.Result> future = serverConn.getConnection().getChannel()
|
||||
.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);
|
||||
}
|
||||
resultFuture.completeExceptionally(new IOException("Unexpectedly disconnected from remote server"));
|
||||
}
|
||||
|
||||
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.ChannelInitializer;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -34,9 +33,6 @@ import static com.velocitypowered.proxy.VelocityServer.GSON;
|
||||
import static com.velocitypowered.proxy.network.Connections.*;
|
||||
|
||||
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 ConnectedPlayer proxyPlayer;
|
||||
private final VelocityServer server;
|
||||
@ -66,7 +62,6 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolConstants.Direction.CLIENTBOUND))
|
||||
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolConstants.Direction.SERVERBOUND));
|
||||
|
||||
ch.attr(CONNECTION_NOTIFIER).set(result);
|
||||
MinecraftConnection connection = new MinecraftConnection(ch, server);
|
||||
connection.setState(StateRegistry.HANDSHAKE);
|
||||
connection.setAssociation(VelocityServerConnection.this);
|
||||
@ -81,7 +76,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
connection = future.channel().pipeline().get(MinecraftConnection.class);
|
||||
|
||||
// Kick off the connection process
|
||||
connection.setSessionHandler(new LoginSessionHandler(server, VelocityServerConnection.this));
|
||||
connection.setSessionHandler(new LoginSessionHandler(server, VelocityServerConnection.this, result));
|
||||
startHandshake();
|
||||
} else {
|
||||
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 (serverConnection.hasCompletedJoin()) {
|
||||
logger.info("Will write {}", packet);
|
||||
serverConnection.getConnection().write(packet);
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren