Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Fix login packet reading on 1.16 servers
Dieser Commit ist enthalten in:
Ursprung
f245bb8263
Commit
6eaeb5a201
@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -109,22 +110,29 @@ public class BaseProtocol1_7 extends Protocol {
|
|||||||
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.STRING); // 0 - UUID as String
|
|
||||||
map(Type.STRING); // 1 - Player Username
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
||||||
info.setState(State.PLAY);
|
info.setState(State.PLAY);
|
||||||
// Save other info
|
|
||||||
String stringUUID = wrapper.get(Type.STRING, 0);
|
if (info.getServerProtocolVersion() >= ProtocolVersion.v1_16.getId()) {
|
||||||
if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters
|
// 1.16+ uses int arrays
|
||||||
// Trimmed
|
UUID uuid = wrapper.passthrough(Type.UUID_INT_ARRAY);
|
||||||
stringUUID = addDashes(stringUUID);
|
info.setUuid(uuid);
|
||||||
|
} else {
|
||||||
|
// Save other info
|
||||||
|
String stringUUID = wrapper.passthrough(Type.STRING);
|
||||||
|
if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters
|
||||||
|
// Trimmed
|
||||||
|
stringUUID = addDashes(stringUUID);
|
||||||
|
}
|
||||||
|
UUID uuid = UUID.fromString(stringUUID);
|
||||||
|
info.setUuid(uuid);
|
||||||
}
|
}
|
||||||
UUID uuid = UUID.fromString(stringUUID);
|
|
||||||
info.setUuid(uuid);
|
String username = wrapper.passthrough(Type.STRING);
|
||||||
info.setUsername(wrapper.get(Type.STRING, 1));
|
info.setUsername(username);
|
||||||
// Add to ported clients
|
// Add to ported clients
|
||||||
Via.getManager().addPortedClient(wrapper.user());
|
Via.getManager().addPortedClient(wrapper.user());
|
||||||
|
|
||||||
@ -137,7 +145,7 @@ public class BaseProtocol1_7 extends Protocol {
|
|||||||
// Print out the route to console
|
// Print out the route to console
|
||||||
Via.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
|
Via.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
|
||||||
new Object[]{
|
new Object[]{
|
||||||
wrapper.get(Type.STRING, 1),
|
username,
|
||||||
info.getProtocolVersion(),
|
info.getProtocolVersion(),
|
||||||
Joiner.on(", ").join(info.getPipeline().pipes(), ", ")
|
Joiner.on(", ").join(info.getPipeline().pipes(), ", ")
|
||||||
});
|
});
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren