Updated Via* API usage

This commit is contained in:
RaphiMC 2023-10-20 16:39:35 +02:00
parent 7496180e0f
commit 598626c610
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
6 changed files with 14 additions and 20 deletions

View File

@ -36,7 +36,7 @@ public abstract class MixinChunkType1_8 {
return null;
}
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;Lcom/viaversion/viaversion/api/minecraft/ClientWorld;)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/type/types/chunk/ChunkType1_8;deserialize(IIZZI[B)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;"))
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/type/types/chunk/ChunkType1_8;deserialize(IIZZI[B)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;"))
private Chunk fixAegis(int chunkX, int chunkZ, boolean fullChunk, boolean skyLight, int bitmask, byte[] data) {
try {
return deserialize(chunkX, chunkZ, fullChunk, skyLight, bitmask, data);

View File

@ -17,8 +17,7 @@
*/
package net.raphimc.viaproxy.protocolhack.viaproxy.signature.storage;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.ProfileKey;
import net.raphimc.viaproxy.protocolhack.viaproxy.signature.util.DataConsumer;
@ -28,16 +27,14 @@ import java.security.SignatureException;
import java.util.UUID;
import java.util.function.Consumer;
public class ChatSession extends StoredObject {
public class ChatSession implements StorableObject {
private final UUID uuid;
private final PrivateKey privateKey;
private final ProfileKey profileKey;
private final Signature signer;
public ChatSession(final UserConnection user, final UUID uuid, final PrivateKey privateKey, final ProfileKey profileKey) {
super(user);
public ChatSession(final UUID uuid, final PrivateKey privateKey, final ProfileKey profileKey) {
this.uuid = uuid;
this.privateKey = privateKey;
this.profileKey = profileKey;

View File

@ -17,7 +17,6 @@
*/
package net.raphimc.viaproxy.protocolhack.viaproxy.signature.storage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ProfileKey;
import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer;
import net.lenni0451.mcstructs.text.utils.JsonUtils;
@ -33,8 +32,8 @@ import java.util.UUID;
public class ChatSession1_19_0 extends ChatSession {
public ChatSession1_19_0(UserConnection user, UUID uuid, PrivateKey privateKey, ProfileKey profileKey) {
super(user, uuid, privateKey, profileKey);
public ChatSession1_19_0(UUID uuid, PrivateKey privateKey, ProfileKey profileKey) {
super(uuid, privateKey, profileKey);
}
public byte[] signChatMessage(final MessageMetadata metadata, final DecoratableMessage content) throws SignatureException {

View File

@ -17,7 +17,6 @@
*/
package net.raphimc.viaproxy.protocolhack.viaproxy.signature.storage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
import com.viaversion.viaversion.api.minecraft.ProfileKey;
import net.raphimc.viaproxy.protocolhack.viaproxy.signature.model.DecoratableMessage;
@ -33,8 +32,8 @@ public class ChatSession1_19_1 extends ChatSession {
private byte[] precedingSignature;
public ChatSession1_19_1(UserConnection user, UUID uuid, PrivateKey privateKey, ProfileKey profileKey) {
super(user, uuid, privateKey, profileKey);
public ChatSession1_19_1(UUID uuid, PrivateKey privateKey, ProfileKey profileKey) {
super(uuid, privateKey, profileKey);
}
public byte[] signChatMessage(final MessageMetadata metadata, final DecoratableMessage content, final PlayerMessageSignature[] lastSeenMessages) throws SignatureException {

View File

@ -18,7 +18,6 @@
package net.raphimc.viaproxy.protocolhack.viaproxy.signature.storage;
import com.google.common.primitives.Ints;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
import com.viaversion.viaversion.api.minecraft.ProfileKey;
import net.raphimc.viaproxy.protocolhack.viaproxy.signature.model.MessageMetadata;
@ -34,8 +33,8 @@ public class ChatSession1_19_3 extends ChatSession {
private final UUID sessionId = UUID.randomUUID();
private MessageLink link;
public ChatSession1_19_3(UserConnection user, UUID uuid, PrivateKey privateKey, ProfileKey profileKey) {
super(user, uuid, privateKey, profileKey);
public ChatSession1_19_3(UUID uuid, PrivateKey privateKey, ProfileKey profileKey) {
super(uuid, privateKey, profileKey);
this.link = new MessageLink(uuid, this.sessionId);
}

View File

@ -81,15 +81,15 @@ public class ExternalInterface {
}
proxyConnection.setLoginHelloPacket(new C2SLoginHelloPacket1_20_2(proxyConnection.getGameProfile().getName(), expiresAt, publicKey, loginHelloKeySignature, proxyConnection.getGameProfile().getId()));
user.put(new ChatSession1_19_0(user, uuid, privateKey, new ProfileKey(expiresAtMillis, publicKeyBytes, playerCertificates.legacyPublicKeySignature())));
user.put(new ChatSession1_19_1(user, uuid, privateKey, new ProfileKey(expiresAtMillis, publicKeyBytes, keySignature)));
user.put(new ChatSession1_19_3(user, uuid, privateKey, new ProfileKey(expiresAtMillis, publicKeyBytes, keySignature)));
user.put(new ChatSession1_19_0(uuid, privateKey, new ProfileKey(expiresAtMillis, publicKeyBytes, playerCertificates.legacyPublicKeySignature())));
user.put(new ChatSession1_19_1(uuid, privateKey, new ProfileKey(expiresAtMillis, publicKeyBytes, keySignature)));
user.put(new ChatSession1_19_3(uuid, privateKey, new ProfileKey(expiresAtMillis, publicKeyBytes, keySignature)));
} else if (proxyConnection.getServerVersion().equals(VersionEnum.bedrockLatest) && account instanceof BedrockAccount bedrockAccount) {
final StepMCChain.MCChain mcChain = bedrockAccount.getMcChain();
final UUID deviceId = mcChain.prevResult().initialXblSession().prevResult2().id();
final String playFabId = bedrockAccount.getPlayFabToken().playFabId();
user.put(new AuthChainData(user, mcChain.mojangJwt(), mcChain.identityJwt(), mcChain.publicKey(), mcChain.privateKey(), deviceId, playFabId));
user.put(new AuthChainData(mcChain.mojangJwt(), mcChain.identityJwt(), mcChain.publicKey(), mcChain.privateKey(), deviceId, playFabId));
}
}