geforkt von Mirrors/Velocity
fix disconnect decoding
Dieser Commit ist enthalten in:
Ursprung
8a6c20ee32
Commit
32228e85ab
@ -28,7 +28,6 @@ import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
|||||||
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
|
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerResourcePackSendEvent;
|
import com.velocitypowered.api.event.player.ServerResourcePackSendEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
|
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
@ -367,7 +366,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) {
|
if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) {
|
||||||
serverConn.getPlayer().handleConnectionException(serverConn.getServer(),
|
serverConn.getPlayer().handleConnectionException(serverConn.getServer(),
|
||||||
Disconnect.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
|
Disconnect.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
|
||||||
ProtocolVersion.MINECRAFT_1_16), true);
|
serverConn.getPlayer().getProtocolVersion(), false), true);
|
||||||
} else {
|
} else {
|
||||||
serverConn.getPlayer().disconnect(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
serverConn.getPlayer().disconnect(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
logger.info("{} has disconnected: {}", this,
|
logger.info("{} has disconnected: {}", this,
|
||||||
LegacyComponentSerializer.legacySection().serialize(translated));
|
LegacyComponentSerializer.legacySection().serialize(translated));
|
||||||
}
|
}
|
||||||
connection.closeWith(Disconnect.create(translated, this.getProtocolVersion()));
|
connection.closeWith(Disconnect.create(translated, this.getProtocolVersion(), duringLogin));
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable VelocityServerConnection getConnectedServer() {
|
public @Nullable VelocityServerConnection getConnectedServer() {
|
||||||
@ -750,7 +750,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
Component reason = status.getReasonComponent()
|
Component reason = status.getReasonComponent()
|
||||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
handleConnectionException(res.getServer(),
|
handleConnectionException(res.getServer(),
|
||||||
Disconnect.create(reason, getProtocolVersion()), ((Impl) status).isSafe());
|
Disconnect.create(reason, getProtocolVersion(), false),
|
||||||
|
((Impl) status).isSafe());
|
||||||
break;
|
break;
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
Component requestedMessage = res.getMessageComponent();
|
Component requestedMessage = res.getMessageComponent();
|
||||||
@ -1274,8 +1275,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
case SERVER_DISCONNECTED:
|
case SERVER_DISCONNECTED:
|
||||||
Component reason = status.getReasonComponent()
|
Component reason = status.getReasonComponent()
|
||||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
handleConnectionException(toConnect, Disconnect.create(reason, getProtocolVersion()),
|
handleConnectionException(toConnect,
|
||||||
status.isSafe());
|
Disconnect.create(reason, getProtocolVersion(), false), status.isSafe());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// The only remaining value is successful (no need to do anything!)
|
// The only remaining value is successful (no need to do anything!)
|
||||||
|
@ -95,9 +95,7 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
logger.info("{} has disconnected: {}", this,
|
logger.info("{} has disconnected: {}", this,
|
||||||
LegacyComponentSerializer.legacySection().serialize(translated));
|
LegacyComponentSerializer.legacySection().serialize(translated));
|
||||||
}
|
}
|
||||||
connection.closeWith(Disconnect.create(translated,
|
connection.closeWith(Disconnect.create(translated, getProtocolVersion(), true));
|
||||||
getProtocolVersion() == ProtocolVersion.MINECRAFT_1_20_3 // Login disconnects are string
|
|
||||||
? ProtocolVersion.MINECRAFT_1_20_2 : getProtocolVersion()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,8 +106,6 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
public void disconnectQuietly(Component reason) {
|
public void disconnectQuietly(Component reason) {
|
||||||
Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE
|
Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE
|
||||||
.lookupClosest(Locale.getDefault()));
|
.lookupClosest(Locale.getDefault()));
|
||||||
connection.closeWith(Disconnect.create(translated,
|
connection.closeWith(Disconnect.create(translated, getProtocolVersion(), true));
|
||||||
getProtocolVersion() == ProtocolVersion.MINECRAFT_1_20_3 // Login disconnects are string
|
|
||||||
? ProtocolVersion.MINECRAFT_1_20_2 : getProtocolVersion()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -149,7 +149,8 @@ public enum StateRegistry {
|
|||||||
|
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
PluginMessage.class, PluginMessage::new, map(0x00, MINECRAFT_1_20_2, false));
|
PluginMessage.class, PluginMessage::new, map(0x00, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(Disconnect.class, Disconnect::new, map(0x01, MINECRAFT_1_20_2, false));
|
clientbound.register(
|
||||||
|
Disconnect.class, () -> new Disconnect(false), map(0x01, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
FinishedUpdate.class, FinishedUpdate::new, map(0x02, MINECRAFT_1_20_2, false));
|
FinishedUpdate.class, FinishedUpdate::new, map(0x02, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(KeepAlive.class, KeepAlive::new, map(0x03, MINECRAFT_1_20_2, false));
|
clientbound.register(KeepAlive.class, KeepAlive::new, map(0x03, MINECRAFT_1_20_2, false));
|
||||||
@ -335,7 +336,7 @@ public enum StateRegistry {
|
|||||||
map(0x18, MINECRAFT_1_20_2, false));
|
map(0x18, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
Disconnect.class,
|
Disconnect.class,
|
||||||
Disconnect::new,
|
() -> new Disconnect(false),
|
||||||
map(0x40, MINECRAFT_1_7_2, false),
|
map(0x40, MINECRAFT_1_7_2, false),
|
||||||
map(0x1A, MINECRAFT_1_9, false),
|
map(0x1A, MINECRAFT_1_9, false),
|
||||||
map(0x1B, MINECRAFT_1_13, false),
|
map(0x1B, MINECRAFT_1_13, false),
|
||||||
@ -566,7 +567,8 @@ public enum StateRegistry {
|
|||||||
serverbound.register(
|
serverbound.register(
|
||||||
LoginAcknowledged.class, LoginAcknowledged::new, map(0x03, MINECRAFT_1_20_2, false));
|
LoginAcknowledged.class, LoginAcknowledged::new, map(0x03, MINECRAFT_1_20_2, false));
|
||||||
|
|
||||||
clientbound.register(Disconnect.class, Disconnect::new, map(0x00, MINECRAFT_1_7_2, false));
|
clientbound.register(
|
||||||
|
Disconnect.class, () -> new Disconnect(true), map(0x00, MINECRAFT_1_7_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
EncryptionRequest.class, EncryptionRequest::new, map(0x01, MINECRAFT_1_7_2, false));
|
EncryptionRequest.class, EncryptionRequest::new, map(0x01, MINECRAFT_1_7_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
|
@ -30,11 +30,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public class Disconnect implements MinecraftPacket {
|
public class Disconnect implements MinecraftPacket {
|
||||||
|
|
||||||
private @Nullable ComponentHolder reason;
|
private @Nullable ComponentHolder reason;
|
||||||
|
private final boolean login;
|
||||||
|
|
||||||
public Disconnect() {
|
public Disconnect(boolean login) {
|
||||||
|
this.login = login;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Disconnect(ComponentHolder reason) {
|
private Disconnect(boolean login, ComponentHolder reason) {
|
||||||
|
this.login = login;
|
||||||
this.reason = Preconditions.checkNotNull(reason, "reason");
|
this.reason = Preconditions.checkNotNull(reason, "reason");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +61,7 @@ public class Disconnect implements MinecraftPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
||||||
reason = ComponentHolder.read(buf, version);
|
reason = ComponentHolder.read(buf, login ? ProtocolVersion.MINECRAFT_1_20_2 : version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,8 +74,8 @@ public class Disconnect implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Disconnect create(Component component, ProtocolVersion version) {
|
public static Disconnect create(Component component, ProtocolVersion version, boolean login) {
|
||||||
Preconditions.checkNotNull(component, "component");
|
Preconditions.checkNotNull(component, "component");
|
||||||
return new Disconnect(new ComponentHolder(version, component));
|
return new Disconnect(login, new ComponentHolder(login ? ProtocolVersion.MINECRAFT_1_20_2 : version, component));
|
||||||
}
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren