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

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

Dieser Commit ist enthalten in:
EnZaXD 2024-05-09 09:25:17 +02:00 committet von GitHub
Ursprung e8602adf5b
Commit 1680f9985d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -32,6 +32,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.rewriter.RewriterBase; import com.viaversion.viaversion.api.rewriter.RewriterBase;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.gson.JsonElement; 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.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_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; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
@ -57,13 +59,13 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Login Plugin Request // Login Plugin Request
protocol.registerClientbound(State.LOGIN, 0x04, -1, new PacketHandlers() { protocol.registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), -1, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
handler(packetWrapper -> { handler(packetWrapper -> {
packetWrapper.cancel(); packetWrapper.cancel();
// Plugin response // 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.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
wrapper.write(Type.BOOLEAN, false); // Success wrapper.write(Type.BOOLEAN, false); // Success
}).sendToServer(Protocol1_12_2To1_13.class); }).sendToServer(Protocol1_12_2To1_13.class);

Datei anzeigen

@ -36,6 +36,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject; 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_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
@ -70,7 +72,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.DECLARE_COMMANDS); new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.DECLARE_COMMANDS);
registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> { registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), wrapper -> {
String original = wrapper.passthrough(Type.STRING); String original = wrapper.passthrough(Type.STRING);
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class); JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
JsonElement description = object.get("description"); JsonElement description = object.get("description");
@ -113,7 +115,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND);
// Login success // Login success
registerClientbound(State.LOGIN, 0x02, 0x02, wrapper -> { registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
// Transform uuid to plain string // Transform uuid to plain string
UUID uuid = wrapper.read(Type.UUID); UUID uuid = wrapper.read(Type.UUID);
wrapper.write(Type.STRING, uuid.toString()); wrapper.write(Type.STRING, uuid.toString());