13
0
geforkt von Mirrors/Velocity

Merge branch 'dev/1.1.0' of github.com:VelocityPowered/Velocity

Dieser Commit ist enthalten in:
Gabik21 2019-07-06 01:08:21 +02:00
Commit 3a1b5099c9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A95DB353715365DF
2 geänderte Dateien mit 22 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,5 @@
package com.velocitypowered.proxy.connection.backend;
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
@ -56,23 +55,16 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
MinecraftConnection mc = serverConn.ensureConnected();
VelocityConfiguration configuration = server.getConfiguration();
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && packet
.getChannel()
.equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) {
LoginPluginResponse response = new LoginPluginResponse();
response.setSuccess(true);
response.setId(packet.getId());
response.setData(createForwardingData(configuration.getForwardingSecret(),
.getChannel().equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) {
ByteBuf forwardingData = createForwardingData(configuration.getForwardingSecret(),
serverConn.getPlayer().getRemoteAddress().getHostString(),
serverConn.getPlayer().getGameProfile()));
serverConn.getPlayer().getGameProfile());
LoginPluginResponse response = new LoginPluginResponse(packet.getId(), true, forwardingData);
mc.write(response);
informationForwarded = true;
} else {
// Don't understand
LoginPluginResponse response = new LoginPluginResponse();
response.setSuccess(false);
response.setId(packet.getId());
response.setData(Unpooled.EMPTY_BUFFER);
mc.write(response);
mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER));
}
return true;
}

Datei anzeigen

@ -4,14 +4,25 @@ import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
public class LoginPluginResponse implements MinecraftPacket {
public class LoginPluginResponse extends DeferredByteBufHolder implements MinecraftPacket {
private int id;
private boolean success;
private ByteBuf data = Unpooled.EMPTY_BUFFER;
public LoginPluginResponse() {
super(Unpooled.EMPTY_BUFFER);
}
public LoginPluginResponse(int id, boolean success, @MonotonicNonNull ByteBuf buf) {
super(buf);
this.id = id;
this.success = success;
}
public int getId() {
return id;
@ -29,20 +40,12 @@ public class LoginPluginResponse implements MinecraftPacket {
this.success = success;
}
public ByteBuf getData() {
return data;
}
public void setData(ByteBuf data) {
this.data = data;
}
@Override
public String toString() {
return "LoginPluginResponse{"
+ "id=" + id
+ ", success=" + success
+ ", data=" + data
+ ", data=" + super.toString()
+ '}';
}
@ -51,9 +54,9 @@ public class LoginPluginResponse implements MinecraftPacket {
this.id = ProtocolUtils.readVarInt(buf);
this.success = buf.readBoolean();
if (buf.isReadable()) {
this.data = buf.readSlice(buf.readableBytes());
this.replace(buf.readSlice(buf.readableBytes()));
} else {
this.data = Unpooled.EMPTY_BUFFER;
this.replace(Unpooled.EMPTY_BUFFER);
}
}
@ -61,7 +64,7 @@ public class LoginPluginResponse implements MinecraftPacket {
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
ProtocolUtils.writeVarInt(buf, id);
buf.writeBoolean(success);
buf.writeBytes(data);
buf.writeBytes(content());
}
@Override