Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Further cleanup.
Dieser Commit ist enthalten in:
Ursprung
480f87a760
Commit
866067bbed
@ -243,7 +243,7 @@ public class VelocityServer implements ProxyServer {
|
|||||||
logger.info("Shutting down the proxy...");
|
logger.info("Shutting down the proxy...");
|
||||||
|
|
||||||
for (ConnectedPlayer player : ImmutableList.copyOf(connectionsByUuid.values())) {
|
for (ConnectedPlayer player : ImmutableList.copyOf(connectionsByUuid.values())) {
|
||||||
player.close(TextComponent.of("Proxy shutting down."));
|
player.disconnect(TextComponent.of("Proxy shutting down."));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cm.shutdown();
|
this.cm.shutdown();
|
||||||
|
@ -253,7 +253,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exception(Throwable throwable) {
|
public void exception(Throwable throwable) {
|
||||||
player.close(TextComponent.builder()
|
player.disconnect(TextComponent.builder()
|
||||||
.content("An exception occurred in your connection: ")
|
.content("An exception occurred in your connection: ")
|
||||||
.color(TextColor.RED)
|
.color(TextColor.RED)
|
||||||
.append(TextComponent.of(ThrowableUtils.briefDescription(throwable), TextColor.WHITE))
|
.append(TextComponent.of(ThrowableUtils.briefDescription(throwable), TextColor.WHITE))
|
||||||
|
@ -411,10 +411,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close(TextComponent reason) {
|
|
||||||
connection.closeWith(Disconnect.create(reason));
|
|
||||||
}
|
|
||||||
|
|
||||||
private MinecraftConnection ensureBackendConnection() {
|
private MinecraftConnection ensureBackendConnection() {
|
||||||
VelocityServerConnection sc = this.connectedServer;
|
VelocityServerConnection sc = this.connectedServer;
|
||||||
if (sc == null) {
|
if (sc == null) {
|
||||||
|
@ -19,8 +19,6 @@ import com.velocitypowered.proxy.VelocityServer;
|
|||||||
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
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.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
|
||||||
@ -44,8 +42,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import net.kyori.text.Component;
|
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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
@ -195,7 +191,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode() || result
|
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode() || result
|
||||||
.isOnlineModeAllowed())) {
|
.isOnlineModeAllowed())) {
|
||||||
// Request encryption.
|
// Request encryption.
|
||||||
EncryptionRequest request = generateRequest();
|
EncryptionRequest request = generateEncryptionRequest();
|
||||||
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
||||||
inbound.write(request);
|
inbound.write(request);
|
||||||
} else {
|
} else {
|
||||||
@ -204,7 +200,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}, inbound.eventLoop());
|
}, inbound.eventLoop());
|
||||||
}
|
}
|
||||||
|
|
||||||
private EncryptionRequest generateRequest() {
|
private EncryptionRequest generateEncryptionRequest() {
|
||||||
byte[] verify = new byte[4];
|
byte[] verify = new byte[4];
|
||||||
ThreadLocalRandom.current().nextBytes(verify);
|
ThreadLocalRandom.current().nextBytes(verify);
|
||||||
|
|
||||||
@ -251,23 +247,22 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
if (reason.isPresent()) {
|
if (reason.isPresent()) {
|
||||||
player.disconnect(reason.get());
|
player.disconnect(reason.get());
|
||||||
} else {
|
} else {
|
||||||
handleProxyLogin(player);
|
finishLogin(player);
|
||||||
}
|
}
|
||||||
}, inbound.eventLoop());
|
}, inbound.eventLoop());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleProxyLogin(ConnectedPlayer player) {
|
private void finishLogin(ConnectedPlayer player) {
|
||||||
Optional<RegisteredServer> toTry = player.getNextServerToTry();
|
Optional<RegisteredServer> toTry = player.getNextServerToTry();
|
||||||
if (!toTry.isPresent()) {
|
if (!toTry.isPresent()) {
|
||||||
player.close(TextComponent.of("No available servers", TextColor.RED));
|
player.disconnect(VelocityMessages.NO_AVAILABLE_SERVERS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!server.registerConnection(player)) {
|
if (!server.registerConnection(player)) {
|
||||||
inbound.closeWith(
|
player.disconnect(VelocityMessages.ALREADY_CONNECTED);
|
||||||
Disconnect.create(TextComponent.of("You are already on this proxy!", TextColor.RED)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ public class VelocityMessages {
|
|||||||
.of("This server only accepts connections from online-mode clients.", TextColor.RED);
|
.of("This server only accepts connections from online-mode clients.", TextColor.RED);
|
||||||
public static final Component NO_PROXY_BEHIND_PROXY = TextComponent
|
public static final Component NO_PROXY_BEHIND_PROXY = TextComponent
|
||||||
.of("Running Velocity behind Velocity isn't supported.", TextColor.RED);
|
.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() {
|
private VelocityMessages() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren