3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

Cleanup LOGIN/STATUS packet handlers (#4113)

Dieser Commit ist enthalten in:
EnZaXD 2024-08-28 15:52:28 +02:00 committet von GitHub
Ursprung 4f66fd793b
Commit 32e51b52aa
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
7 geänderte Dateien mit 22 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -173,11 +173,11 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol<ClientboundPackets1_1
WorldPacketRewriter1_13.register(this);
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT, wrapper -> {
componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT));
});
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), new PacketHandlers() {
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING);

Datei anzeigen

@ -81,14 +81,14 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol<ClientboundPackets1_1
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.AWARD_STATS);
// Login Success
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
// Transform string to a uuid
UUID uuid = UUID.fromString(wrapper.read(Types.STRING));
wrapper.write(Types.UUID, uuid);
});
// Motd Status - line breaks are no longer allowed for player samples
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), wrapper -> {
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE, wrapper -> {
String original = wrapper.passthrough(Types.STRING);
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
JsonObject players = object.getAsJsonObject("players");

Datei anzeigen

@ -232,7 +232,7 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol<ClientboundPack
cancelServerbound(ServerboundPackets1_19.CHAT_PREVIEW);
// Login changes
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketHandlers() {
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, new PacketHandlers() {
@Override
public void register() {
map(Types.UUID); // UUID
@ -241,7 +241,7 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol<ClientboundPack
}
});
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Server id
@ -253,7 +253,7 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol<ClientboundPack
}
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Name
@ -261,7 +261,7 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol<ClientboundPack
}
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY, new PacketHandlers() {
@Override
public void register() {
map(Types.BYTE_ARRAY_PRIMITIVE); // Keys

Datei anzeigen

@ -279,7 +279,7 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol<ClientboundPa
}
});
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Server id
@ -291,7 +291,7 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol<ClientboundPa
});
}
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Name
@ -302,7 +302,7 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol<ClientboundPa
map(Types.OPTIONAL_UUID); // Profile uuid
}
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY, new PacketHandlers() {
@Override
public void register() {
map(Types.BYTE_ARRAY_PRIMITIVE); // Public key

Datei anzeigen

@ -228,7 +228,7 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol<ClientboundPack
}
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Name
@ -246,7 +246,7 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol<ClientboundPack
read(Types.OPTIONAL_UUID); // Profile uuid
}
});
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Server id
@ -261,7 +261,7 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol<ClientboundPack
});
}
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY, new PacketHandlers() {
@Override
public void register() {
map(Types.BYTE_ARRAY_PRIMITIVE); // Keys
@ -281,7 +281,7 @@ public final class Protocol1_19To1_19_1 extends AbstractProtocol<ClientboundPack
});
}
});
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), ClientboundLoginPackets.CUSTOM_QUERY.getId(), new PacketHandlers() {
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT);

Datei anzeigen

@ -120,7 +120,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
wrapper.resetReader();
wrapper.user().put(new LastTags(wrapper));
});
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), wrapper -> {
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.UPDATE_TAGS, wrapper -> {
tagRewriter.handleGeneric(wrapper);
wrapper.resetReader();
wrapper.user().put(new LastTags(wrapper));
@ -131,7 +131,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
wrapper.write(Types.VAR_INT, (int) slot);
});
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), wrapper -> {
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, wrapper -> {
wrapper.passthrough(Types.STRING); // Name
final UUID uuid = wrapper.read(Types.UUID);
@ -144,7 +144,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
// We need to wait for it send the login ack before actually sending the play login,
// hence packets are added to a queue. With the data from the login packet, we sent what is needed
// during the configuration phase before finally transitioning to the play state with the client as well.
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
wrapper.user().get(ConfigurationState.class).setBridgePhase(BridgePhase.PROFILE_SENT);
wrapper.user().getProtocolInfo().setServerState(State.PLAY);
});

Datei anzeigen

@ -83,7 +83,7 @@ public class Protocol1_8To1_9 extends AbstractProtocol<ClientboundPackets1_8, Cl
protected void registerPackets() {
super.registerPackets();
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT, wrapper -> {
if (wrapper.isReadable(Types.COMPONENT, 0)) {
// Already written as component in the base protocol
return;