Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-16 04:50:10 +01:00
Clean up LOGIN/STATUS/CONFIGURATION handlers (#876)
Dieser Commit ist enthalten in:
Ursprung
6cc4990b6e
Commit
47b1508f66
@ -73,7 +73,7 @@ public class Protocol1_16To1_15_2 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
|
|
||||||
new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.COMMANDS);
|
new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.COMMANDS);
|
||||||
|
|
||||||
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);
|
String original = wrapper.passthrough(Types.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");
|
||||||
@ -116,7 +116,7 @@ public class Protocol1_16To1_15_2 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND);
|
soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND);
|
||||||
|
|
||||||
// Login success
|
// Login success
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
|
||||||
// Transform uuid to plain string
|
// Transform uuid to plain string
|
||||||
UUID uuid = wrapper.read(Types.UUID);
|
UUID uuid = wrapper.read(Types.UUID);
|
||||||
wrapper.write(Types.STRING, uuid.toString());
|
wrapper.write(Types.STRING, uuid.toString());
|
||||||
|
@ -297,7 +297,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Name
|
map(Types.STRING); // Name
|
||||||
@ -315,7 +315,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Server id
|
map(Types.STRING); // Server id
|
||||||
@ -331,7 +331,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.BYTE_ARRAY_PRIMITIVE); // Key
|
map(Types.BYTE_ARRAY_PRIMITIVE); // Key
|
||||||
@ -352,7 +352,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), ClientboundLoginPackets.CUSTOM_QUERY.getId(), new PacketHandlers() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.VAR_INT);
|
map(Types.VAR_INT);
|
||||||
|
@ -171,7 +171,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Remove the key once again
|
// Remove the key once again
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Name
|
map(Types.STRING); // Name
|
||||||
@ -183,7 +183,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Server id
|
map(Types.STRING); // Server id
|
||||||
@ -198,7 +198,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.BYTE_ARRAY_PRIMITIVE); // Keys
|
map(Types.BYTE_ARRAY_PRIMITIVE); // Keys
|
||||||
|
@ -291,7 +291,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Login changes
|
// Login changes
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketHandlers() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.UUID); // UUID
|
map(Types.UUID); // UUID
|
||||||
@ -307,7 +307,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Server id
|
map(Types.STRING); // Server id
|
||||||
@ -319,7 +319,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Name
|
map(Types.STRING); // Name
|
||||||
@ -330,7 +330,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.BYTE_ARRAY_PRIMITIVE); // Public key
|
map(Types.BYTE_ARRAY_PRIMITIVE); // Public key
|
||||||
|
@ -76,7 +76,7 @@ public final class Protocol1_20_2To1_20 extends BackwardsProtocol<ClientboundPac
|
|||||||
wrapper.write(Types.BYTE, (byte) slot);
|
wrapper.write(Types.BYTE, (byte) slot);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
|
||||||
// We can't set the internal state to configuration here as protocols down the line will expect the state to be play
|
// We can't set the internal state to configuration here as protocols down the line will expect the state to be play
|
||||||
// Add this *before* sending the ack since the server might immediately answer
|
// Add this *before* sending the ack since the server might immediately answer
|
||||||
wrapper.user().put(new ConfigurationPacketStorage());
|
wrapper.user().put(new ConfigurationPacketStorage());
|
||||||
@ -88,7 +88,7 @@ public final class Protocol1_20_2To1_20 extends BackwardsProtocol<ClientboundPac
|
|||||||
wrapper.create(ServerboundLoginPackets.LOGIN_ACKNOWLEDGED).scheduleSendToServer(Protocol1_20_2To1_20.class);
|
wrapper.create(ServerboundLoginPackets.LOGIN_ACKNOWLEDGED).scheduleSendToServer(Protocol1_20_2To1_20.class);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), wrapper -> {
|
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION, wrapper -> {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
wrapper.user().getProtocolInfo().setServerState(State.PLAY);
|
wrapper.user().getProtocolInfo().setServerState(State.PLAY);
|
||||||
wrapper.user().get(ConfigurationPacketStorage.class).setFinished(true);
|
wrapper.user().get(ConfigurationPacketStorage.class).setFinished(true);
|
||||||
@ -97,7 +97,7 @@ public final class Protocol1_20_2To1_20 extends BackwardsProtocol<ClientboundPac
|
|||||||
wrapper.user().getProtocolInfo().setClientState(State.PLAY);
|
wrapper.user().getProtocolInfo().setClientState(State.PLAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), wrapper -> {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO, wrapper -> {
|
||||||
wrapper.passthrough(Types.STRING); // Name
|
wrapper.passthrough(Types.STRING); // Name
|
||||||
|
|
||||||
// TODO Bad
|
// TODO Bad
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren