geforkt von Mirrors/Velocity
Misc cleanup
Dieser Commit ist enthalten in:
Ursprung
eddf01fc32
Commit
2d2258d667
@ -19,7 +19,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
private final VelocityServerConnection serverConn;
|
||||
private final ClientPlaySessionHandler playerSessionHandler;
|
||||
|
||||
public BackendPlaySessionHandler(VelocityServer server, VelocityServerConnection serverConn) {
|
||||
BackendPlaySessionHandler(VelocityServer server, VelocityServerConnection serverConn) {
|
||||
this.server = server;
|
||||
this.serverConn = serverConn;
|
||||
this.playerSessionHandler = (ClientPlaySessionHandler) serverConn.getPlayer().getConnection().getSessionHandler();
|
||||
|
@ -30,8 +30,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
private final CompletableFuture<ConnectionRequestBuilder.Result> resultFuture;
|
||||
private boolean informationForwarded;
|
||||
|
||||
public LoginSessionHandler(VelocityServer server, VelocityServerConnection serverConn,
|
||||
CompletableFuture<ConnectionRequestBuilder.Result> resultFuture) {
|
||||
LoginSessionHandler(VelocityServer server, VelocityServerConnection serverConn,
|
||||
CompletableFuture<ConnectionRequestBuilder.Result> resultFuture) {
|
||||
this.server = server;
|
||||
this.serverConn = serverConn;
|
||||
this.resultFuture = resultFuture;
|
||||
|
@ -69,18 +69,15 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
}
|
||||
})
|
||||
.connect(registeredServer.getServerInfo().getAddress())
|
||||
.addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
if (future.isSuccess()) {
|
||||
connection = future.channel().pipeline().get(MinecraftConnection.class);
|
||||
.addListener((ChannelFutureListener) future -> {
|
||||
if (future.isSuccess()) {
|
||||
connection = future.channel().pipeline().get(MinecraftConnection.class);
|
||||
|
||||
// Kick off the connection process
|
||||
connection.setSessionHandler(new LoginSessionHandler(server, VelocityServerConnection.this, result));
|
||||
startHandshake();
|
||||
} else {
|
||||
result.completeExceptionally(future.cause());
|
||||
}
|
||||
// Kick off the connection process
|
||||
connection.setSessionHandler(new LoginSessionHandler(server, VelocityServerConnection.this, result));
|
||||
startHandshake();
|
||||
} else {
|
||||
result.completeExceptionally(future.cause());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@ -122,12 +119,6 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
connection.write(login);
|
||||
}
|
||||
|
||||
public void writeIfJoined(PluginMessage message) {
|
||||
if (hasCompletedJoin) {
|
||||
connection.write(message);
|
||||
}
|
||||
}
|
||||
|
||||
public MinecraftConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
private PlayerSettings settings;
|
||||
private final VelocityServer server;
|
||||
|
||||
public ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection, InetSocketAddress virtualHost) {
|
||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection, InetSocketAddress virtualHost) {
|
||||
this.server = server;
|
||||
this.profile = profile;
|
||||
this.connection = connection;
|
||||
@ -99,7 +99,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
return this.ping;
|
||||
}
|
||||
|
||||
public void setPing(long ping) {
|
||||
void setPing(long ping) {
|
||||
this.ping = ping;
|
||||
}
|
||||
|
||||
@ -386,7 +386,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
connection.closeWith(Disconnect.create(reason));
|
||||
}
|
||||
|
||||
public void teardown() {
|
||||
void teardown() {
|
||||
if (connectionInFlight != null) {
|
||||
connectionInFlight.disconnect();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.*;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.TranslatableComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
|
@ -6,7 +6,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
public class InitialConnectSessionHandler implements MinecraftSessionHandler {
|
||||
private final ConnectedPlayer player;
|
||||
|
||||
public InitialConnectSessionHandler(ConnectedPlayer player) {
|
||||
InitialConnectSessionHandler(ConnectedPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
@ -94,13 +94,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
public boolean handle(EncryptionResponse packet) {
|
||||
try {
|
||||
KeyPair serverKeyPair = server.getServerKeyPair();
|
||||
EncryptionResponse response = (EncryptionResponse) packet;
|
||||
byte[] decryptedVerifyToken = EncryptionUtils.decryptRsa(serverKeyPair, response.getVerifyToken());
|
||||
byte[] decryptedVerifyToken = EncryptionUtils.decryptRsa(serverKeyPair, packet.getVerifyToken());
|
||||
if (!Arrays.equals(verify, decryptedVerifyToken)) {
|
||||
throw new IllegalStateException("Unable to successfully decrypt the verification token.");
|
||||
}
|
||||
|
||||
byte[] decryptedSharedSecret = EncryptionUtils.decryptRsa(serverKeyPair, response.getSharedSecret());
|
||||
byte[] decryptedSharedSecret = EncryptionUtils.decryptRsa(serverKeyPair, packet.getSharedSecret());
|
||||
String serverId = EncryptionUtils.generateServerId(decryptedSharedSecret, serverKeyPair.getPublic());
|
||||
|
||||
String playerIp = ((InetSocketAddress) inbound.getChannel().remoteAddress()).getHostString();
|
||||
|
@ -19,7 +19,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
private final MinecraftConnection connection;
|
||||
private final InboundConnection inboundWrapper;
|
||||
|
||||
public StatusSessionHandler(VelocityServer server, MinecraftConnection connection, InboundConnection inboundWrapper) {
|
||||
StatusSessionHandler(VelocityServer server, MinecraftConnection connection, InboundConnection inboundWrapper) {
|
||||
this.server = server;
|
||||
this.connection = connection;
|
||||
this.inboundWrapper = inboundWrapper;
|
||||
|
@ -31,20 +31,10 @@ public class ConnectionRequestResults {
|
||||
|
||||
public static ConnectionRequestBuilder.Result forDisconnect(Disconnect disconnect) {
|
||||
Component deserialized = ComponentSerializers.JSON.deserialize(disconnect.getReason());
|
||||
return new ConnectionRequestBuilder.Result() {
|
||||
@Override
|
||||
public ConnectionRequestBuilder.Status getStatus() {
|
||||
return ConnectionRequestBuilder.Status.SERVER_DISCONNECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Component> getReason() {
|
||||
return Optional.of(deserialized);
|
||||
}
|
||||
};
|
||||
return forDisconnect(deserialized);
|
||||
}
|
||||
|
||||
public static ConnectionRequestBuilder.Result forDisconnect(TextComponent component) {
|
||||
public static ConnectionRequestBuilder.Result forDisconnect(Component component) {
|
||||
return new ConnectionRequestBuilder.Result() {
|
||||
@Override
|
||||
public ConnectionRequestBuilder.Status getStatus() {
|
||||
|
@ -13,12 +13,12 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class PluginMessageUtil {
|
||||
public static final String BRAND_CHANNEL = "MC|Brand";
|
||||
public static final String BRAND_CHANNEL_1_13 = "minecraft:brand";
|
||||
public static final String REGISTER_CHANNEL = "REGISTER";
|
||||
public static final String REGISTER_CHANNEL_1_13 = "minecraft:register";
|
||||
public static final String UNREGISTER_CHANNEL = "UNREGISTER";
|
||||
public static final String UNREGISTER_CHANNEL_1_13 = "minecraft:unregister";
|
||||
public static final String BRAND_CHANNEL_LEGACY = "MC|Brand";
|
||||
public static final String BRAND_CHANNEL = "minecraft:brand";
|
||||
public static final String REGISTER_CHANNEL_LEGACY = "REGISTER";
|
||||
public static final String REGISTER_CHANNEL = "minecraft:register";
|
||||
public static final String UNREGISTER_CHANNEL_LEGACY = "UNREGISTER";
|
||||
public static final String UNREGISTER_CHANNEL = "minecraft:unregister";
|
||||
|
||||
private PluginMessageUtil() {
|
||||
throw new AssertionError();
|
||||
@ -26,17 +26,17 @@ public class PluginMessageUtil {
|
||||
|
||||
public static boolean isMCBrand(PluginMessage message) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
return message.getChannel().equals(BRAND_CHANNEL) || message.getChannel().equals(BRAND_CHANNEL_1_13);
|
||||
return message.getChannel().equals(BRAND_CHANNEL_LEGACY) || message.getChannel().equals(BRAND_CHANNEL);
|
||||
}
|
||||
|
||||
public static boolean isMCRegister(PluginMessage message) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
return message.getChannel().equals(REGISTER_CHANNEL) || message.getChannel().equals(REGISTER_CHANNEL_1_13);
|
||||
return message.getChannel().equals(REGISTER_CHANNEL_LEGACY) || message.getChannel().equals(REGISTER_CHANNEL);
|
||||
}
|
||||
|
||||
public static boolean isMCUnregister(PluginMessage message) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
return message.getChannel().equals(UNREGISTER_CHANNEL) || message.getChannel().equals(UNREGISTER_CHANNEL_1_13);
|
||||
return message.getChannel().equals(UNREGISTER_CHANNEL_LEGACY) || message.getChannel().equals(UNREGISTER_CHANNEL);
|
||||
}
|
||||
|
||||
public static List<String> getChannels(PluginMessage message) {
|
||||
@ -49,7 +49,7 @@ public class PluginMessageUtil {
|
||||
|
||||
public static PluginMessage constructChannelsPacket(int protocolVersion, Collection<String> channels) {
|
||||
Preconditions.checkNotNull(channels, "channels");
|
||||
String channelName = protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ? REGISTER_CHANNEL_1_13 : REGISTER_CHANNEL;
|
||||
String channelName = protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ? REGISTER_CHANNEL : REGISTER_CHANNEL_LEGACY;
|
||||
PluginMessage message = new PluginMessage();
|
||||
message.setChannel(channelName);
|
||||
message.setData(String.join("\0", channels).getBytes(StandardCharsets.UTF_8));
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren