3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-23 23:00:35 +01:00

Further cleanup.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-11-15 20:49:30 -05:00
Ursprung 480f87a760
Commit 866067bbed
5 geänderte Dateien mit 12 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -243,7 +243,7 @@ public class VelocityServer implements ProxyServer {
logger.info("Shutting down the proxy...");
for (ConnectedPlayer player : ImmutableList.copyOf(connectionsByUuid.values())) {
player.close(TextComponent.of("Proxy shutting down."));
player.disconnect(TextComponent.of("Proxy shutting down."));
}
this.cm.shutdown();

Datei anzeigen

@ -253,7 +253,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
@Override
public void exception(Throwable throwable) {
player.close(TextComponent.builder()
player.disconnect(TextComponent.builder()
.content("An exception occurred in your connection: ")
.color(TextColor.RED)
.append(TextComponent.of(ThrowableUtils.briefDescription(throwable), TextColor.WHITE))

Datei anzeigen

@ -411,10 +411,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
}
}
public void close(TextComponent reason) {
connection.closeWith(Disconnect.create(reason));
}
private MinecraftConnection ensureBackendConnection() {
VelocityServerConnection sc = this.connectedServer;
if (sc == null) {

Datei anzeigen

@ -19,8 +19,6 @@ import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.VelocityConstants;
import com.velocitypowered.proxy.protocol.ProtocolConstants;
import com.velocitypowered.proxy.protocol.StateRegistry;
import com.velocitypowered.proxy.protocol.packet.Disconnect;
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
@ -44,8 +42,6 @@ import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@ -195,7 +191,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode() || result
.isOnlineModeAllowed())) {
// Request encryption.
EncryptionRequest request = generateRequest();
EncryptionRequest request = generateEncryptionRequest();
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
inbound.write(request);
} else {
@ -204,7 +200,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
}, inbound.eventLoop());
}
private EncryptionRequest generateRequest() {
private EncryptionRequest generateEncryptionRequest() {
byte[] verify = new byte[4];
ThreadLocalRandom.current().nextBytes(verify);
@ -251,23 +247,22 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
if (reason.isPresent()) {
player.disconnect(reason.get());
} else {
handleProxyLogin(player);
finishLogin(player);
}
}, inbound.eventLoop());
});
}
private void handleProxyLogin(ConnectedPlayer player) {
private void finishLogin(ConnectedPlayer player) {
Optional<RegisteredServer> toTry = player.getNextServerToTry();
if (!toTry.isPresent()) {
player.close(TextComponent.of("No available servers", TextColor.RED));
player.disconnect(VelocityMessages.NO_AVAILABLE_SERVERS);
return;
}
if (!server.registerConnection(player)) {
inbound.closeWith(
Disconnect.create(TextComponent.of("You are already on this proxy!", TextColor.RED)));
player.disconnect(VelocityMessages.ALREADY_CONNECTED);
return;
}

Datei anzeigen

@ -10,6 +10,10 @@ public class VelocityMessages {
.of("This server only accepts connections from online-mode clients.", TextColor.RED);
public static final Component NO_PROXY_BEHIND_PROXY = TextComponent
.of("Running Velocity behind Velocity isn't supported.", TextColor.RED);
public static final Component NO_AVAILABLE_SERVERS = TextComponent
.of("No available servers", TextColor.RED);
public static final Component ALREADY_CONNECTED = TextComponent
.of("You are already connected to this proxy!", TextColor.RED);
private VelocityMessages() {
throw new AssertionError();