From 1680f9985d508b73fa5f4406e9f655e78f19ce9b Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 9 May 2024 09:25:17 +0200 Subject: [PATCH] [ci skip] Use login/status packet enums in older protocols (#740) --- .../protocol1_12_2to1_13/packets/PlayerPacket1_13.java | 6 ++++-- .../protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index 8b0f0911..6bbc435d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -32,6 +32,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.gson.JsonElement; +import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; +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; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; @@ -57,13 +59,13 @@ public class PlayerPacket1_13 extends RewriterBase { @Override protected void registerPackets() { // Login Plugin Request - protocol.registerClientbound(State.LOGIN, 0x04, -1, new PacketHandlers() { + protocol.registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), -1, new PacketHandlers() { @Override public void register() { handler(packetWrapper -> { packetWrapper.cancel(); // Plugin response - packetWrapper.create(0x02, wrapper -> { + packetWrapper.create(ServerboundLoginPackets.CUSTOM_QUERY_ANSWER.getId(), wrapper -> { wrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id wrapper.write(Type.BOOLEAN, false); // Success }).sendToServer(Protocol1_12_2To1_13.class); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java index c282165a..aebc8519 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java @@ -36,6 +36,8 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; +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.ClientboundPackets1_16; @@ -70,7 +72,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol { + 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); JsonElement description = object.get("description"); @@ -113,7 +115,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol { + registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> { // Transform uuid to plain string UUID uuid = wrapper.read(Type.UUID); wrapper.write(Type.STRING, uuid.toString());