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

[ci skip] Use login/status packet enums in older protocols (#3835)

Dieser Commit ist enthalten in:
EnZaXD 2024-05-09 09:25:54 +02:00 committet von GitHub
Ursprung 31211c2214
Commit c24169c410
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
3 geänderte Dateien mit 12 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -39,6 +39,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
@ -170,9 +172,11 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
EntityPackets.register(this);
WorldPackets.register(this);
registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)));
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT));
});
registerClientbound(State.STATUS, 0x00, 0x00, new PacketHandlers() {
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), new PacketHandlers() {
@Override
public void register() {
map(Type.STRING);

Datei anzeigen

@ -35,6 +35,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.TranslationMappings;
@ -79,14 +81,14 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
// Login Success
registerClientbound(State.LOGIN, 0x02, 0x02, wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
// Transform string to a uuid
UUID uuid = UUID.fromString(wrapper.read(Type.STRING));
wrapper.write(Type.UUID, uuid);
});
// Motd Status - line breaks are no longer allowed for player samples
registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> {
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), wrapper -> {
String original = wrapper.passthrough(Type.STRING);
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
JsonObject players = object.getAsJsonObject("players");

Datei anzeigen

@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
@ -86,7 +87,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
protected void registerPackets() {
super.registerPackets();
registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
if (wrapper.isReadable(Type.COMPONENT, 0)) {
// Already written as component in the base protocol
return;