mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2025-01-02 18:28:57 +01:00
Updated VV API usage
This commit is contained in:
parent
a2eb352ae8
commit
11875755b4
@ -23,7 +23,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion-common:5.0.3-SNAPSHOT"
|
||||
compileOnly "com.viaversion:viaversion-common:5.0.4-SNAPSHOT"
|
||||
compileOnly "com.google.guava:guava:33.3.0-jre"
|
||||
compileOnly "io.netty:netty-handler:4.1.112.Final"
|
||||
}
|
||||
|
@ -17,17 +17,15 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.api.protocol;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundHandshakePackets;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.v1_7.ServerboundBaseProtocol1_7;
|
||||
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.HandshakeStorage;
|
||||
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
|
||||
|
||||
public class PreNettyBaseProtocol extends AbstractSimpleProtocol {
|
||||
public class PreNettyBaseProtocol extends ServerboundBaseProtocol1_7 {
|
||||
|
||||
public static final PreNettyBaseProtocol INSTANCE = new PreNettyBaseProtocol();
|
||||
|
||||
@ -37,6 +35,7 @@ public class PreNettyBaseProtocol extends AbstractSimpleProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
this.registerServerbound(State.HANDSHAKE, ServerboundHandshakePackets.CLIENT_INTENTION.getId(), ServerboundHandshakePackets.CLIENT_INTENTION.getId(), wrapper -> {
|
||||
wrapper.cancel();
|
||||
wrapper.read(Types.VAR_INT); // protocolVersion
|
||||
@ -44,22 +43,12 @@ public class PreNettyBaseProtocol extends AbstractSimpleProtocol {
|
||||
final int port = wrapper.read(Types.UNSIGNED_SHORT); // port
|
||||
wrapper.user().put(new HandshakeStorage(hostname, port));
|
||||
});
|
||||
|
||||
// Copied from BaseProtocol1_7
|
||||
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.LOGIN_ACKNOWLEDGED.getId(), ServerboundLoginPackets.LOGIN_ACKNOWLEDGED.getId(), wrapper -> {
|
||||
final ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||
info.setState(State.CONFIGURATION);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new ProtocolMetadataStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaseProtocol() {
|
||||
return true;
|
||||
public void init(final UserConnection user) {
|
||||
super.init(user);
|
||||
user.put(new ProtocolMetadataStorage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
@ -43,6 +42,7 @@ import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundStatusPackets;
|
||||
import com.viaversion.viaversion.protocols.base.v1_7.ClientboundBaseProtocol1_7;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -792,18 +792,7 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol<Client
|
||||
if (!protocolMetadata.skipEncryption) {
|
||||
Via.getManager().getProviders().get(EncryptionProvider.class).enableDecryption(wrapper.user());
|
||||
}
|
||||
|
||||
// Parts of BaseProtocol1_7 GAME_PROFILE handler
|
||||
if (info.protocolVersion().olderThan(ProtocolVersion.v1_20_2)) {
|
||||
info.setState(State.PLAY);
|
||||
}
|
||||
Via.getManager().getConnectionManager().onLoginSuccess(wrapper.user());
|
||||
if (!info.getPipeline().hasNonBaseProtocols()) {
|
||||
wrapper.user().setActive(false);
|
||||
}
|
||||
if (Via.getManager().isDebug()) {
|
||||
ViaLegacy.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}", new Object[]{info.getUsername(), info.protocolVersion().getName(), Joiner.on(", ").join(info.getPipeline().pipes(), ", ")});
|
||||
}
|
||||
ClientboundBaseProtocol1_7.onLoginSuccess(wrapper.user());
|
||||
|
||||
final PacketWrapper respawn = PacketWrapper.create(ServerboundPackets1_6_4.CLIENT_COMMAND, wrapper.user());
|
||||
respawn.write(Types.BYTE, (byte) 0); // force respawn
|
||||
|
@ -27,8 +27,8 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.base.BaseProtocol1_7;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.v1_7.ClientboundBaseProtocol1_7;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.util.UuidUtil;
|
||||
import net.raphimc.vialegacy.protocol.release.r1_7_2_5tor1_7_6_10.packet.ClientboundPackets1_7_2;
|
||||
@ -173,7 +173,7 @@ public class Protocolr1_7_2_5Tor1_7_6_10 extends AbstractProtocol<ClientboundPac
|
||||
if (uuid.matches(UUID_PATTERN)) {
|
||||
return uuid;
|
||||
} else if (uuid.length() == 32) {
|
||||
final String dashedUuid = BaseProtocol1_7.addDashes(uuid);
|
||||
final String dashedUuid = ClientboundBaseProtocol1_7.addDashes(uuid);
|
||||
if (dashedUuid.matches(UUID_PATTERN)) {
|
||||
return dashedUuid;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user