mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 20:16:02 +01:00
Fix 1.16 Bungee compat
Moved the version hack outside of the BaseProtocol class into separate impls with properly checking the sent version
This commit is contained in:
parent
7ec9eb08d9
commit
70e142e4c4
@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.Pair;
|
|||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||||
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
||||||
|
import us.myles.ViaVersion.protocols.base.BaseProtocol1_16;
|
||||||
import us.myles.ViaVersion.protocols.base.BaseProtocol1_7;
|
import us.myles.ViaVersion.protocols.base.BaseProtocol1_7;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
|
import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
|
||||||
@ -72,7 +73,8 @@ public class ProtocolRegistry {
|
|||||||
|
|
||||||
// Base Protocol
|
// Base Protocol
|
||||||
registerBaseProtocol(BASE_PROTOCOL, Range.lessThan(Integer.MIN_VALUE));
|
registerBaseProtocol(BASE_PROTOCOL, Range.lessThan(Integer.MIN_VALUE));
|
||||||
registerBaseProtocol(new BaseProtocol1_7(), Range.all());
|
registerBaseProtocol(new BaseProtocol1_7(), Range.lessThan(ProtocolVersion.v1_16.getId()));
|
||||||
|
registerBaseProtocol(new BaseProtocol1_16(), Range.atLeast(ProtocolVersion.v1_16.getId()));
|
||||||
|
|
||||||
registerProtocol(new Protocol1_9To1_8(), ProtocolVersion.v1_9, ProtocolVersion.v1_8);
|
registerProtocol(new Protocol1_9To1_8(), ProtocolVersion.v1_9, ProtocolVersion.v1_8);
|
||||||
registerProtocol(new Protocol1_9_1To1_9(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9.getId());
|
registerProtocol(new Protocol1_9_1To1_9(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9.getId());
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package us.myles.ViaVersion.protocols.base;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BaseProtocol1_16 extends BaseProtocol1_7 {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected UUID passthroughLoginUUID(final PacketWrapper wrapper) throws Exception {
|
||||||
|
return wrapper.passthrough(Type.UUID_INT_ARRAY);
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,6 @@ import us.myles.ViaVersion.api.Pair;
|
|||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
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.protocol.SimpleProtocol;
|
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
||||||
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;
|
||||||
@ -116,20 +115,8 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
ProtocolInfo info = wrapper.user().getProtocolInfo();
|
ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||||
info.setState(State.PLAY);
|
info.setState(State.PLAY);
|
||||||
|
|
||||||
if (info.getServerProtocolVersion() >= ProtocolVersion.v1_16.getId()) {
|
UUID uuid = passthroughLoginUUID(wrapper);
|
||||||
// 1.16+ uses int arrays
|
|
||||||
UUID uuid = wrapper.passthrough(Type.UUID_INT_ARRAY);
|
|
||||||
info.setUuid(uuid);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
String username = wrapper.passthrough(Type.STRING);
|
String username = wrapper.passthrough(Type.STRING);
|
||||||
info.setUsername(username);
|
info.setUsername(username);
|
||||||
@ -137,7 +124,7 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
Via.getManager().handleLoginSuccess(wrapper.user());
|
Via.getManager().handleLoginSuccess(wrapper.user());
|
||||||
|
|
||||||
if (info.getPipeline().pipes().size() == 2
|
if (info.getPipeline().pipes().size() == 2
|
||||||
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_7.class
|
&& info.getPipeline().pipes().get(1).getClass().isAssignableFrom(BaseProtocol1_7.class)
|
||||||
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
|
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
|
||||||
wrapper.user().setActive(false);
|
wrapper.user().setActive(false);
|
||||||
|
|
||||||
@ -198,4 +185,13 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
idBuff.insert(8, '-');
|
idBuff.insert(8, '-');
|
||||||
return idBuff.toString();
|
return idBuff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected UUID passthroughLoginUUID(PacketWrapper wrapper) throws Exception {
|
||||||
|
String uuidString = wrapper.passthrough(Type.STRING);
|
||||||
|
if (uuidString.length() == 32) { // Trimmed UUIDs are 32 characters
|
||||||
|
// Trimmed
|
||||||
|
uuidString = addDashes(uuidString);
|
||||||
|
}
|
||||||
|
return UUID.fromString(uuidString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user