mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-25 12:25:22 +01:00
Delete Upstreamed fixes from VV
Upstream has merged some of the existing VFP merges into itself, so we can delete them here
This commit is contained in:
parent
06f538ec7c
commit
4a512e43bd
@ -1,5 +1,5 @@
|
|||||||
# gradle
|
# gradle
|
||||||
org.gradle.jvmargs=-Xmx8G -XX:+UseG1GC
|
org.gradle.jvmargs=-Xmx8G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|
||||||
# minecraft and fabric
|
# minecraft and fabric
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
|
||||||
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
|
|
||||||
public abstract class AbstractChatSession extends StoredObject {
|
|
||||||
private final ProfileKey profileKey;
|
|
||||||
|
|
||||||
private final MessageSigner signer;
|
|
||||||
|
|
||||||
public AbstractChatSession(UserConnection user, final ProfileKey profileKey, final PrivateKey privateKey) {
|
|
||||||
super(user);
|
|
||||||
this.profileKey = profileKey;
|
|
||||||
|
|
||||||
this.signer = MessageSigner.create(privateKey, "SHA256withRSA");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileKey getProfileKey() {
|
|
||||||
return profileKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageSigner getSigner() {
|
|
||||||
return signer;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures;
|
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.SignatureUpdatableModel;
|
|
||||||
|
|
||||||
import java.security.*;
|
|
||||||
|
|
||||||
public interface MessageSigner {
|
|
||||||
|
|
||||||
byte[] sign(final SignatureUpdatableModel signer);
|
|
||||||
|
|
||||||
static MessageSigner create(final PrivateKey privateKey, final String algorithm) {
|
|
||||||
return signer -> {
|
|
||||||
try {
|
|
||||||
final Signature signature = Signature.getInstance(algorithm);
|
|
||||||
signature.initSign(privateKey);
|
|
||||||
|
|
||||||
signer.update(data -> {
|
|
||||||
try {
|
|
||||||
signature.update(data);
|
|
||||||
} catch (SignatureException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return signature.sign();
|
|
||||||
} catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
|
|
||||||
throw new IllegalStateException("Failed to sign message", e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_0;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.util.JsonHelper;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.MessageMetadataModel;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.AbstractChatSession;
|
|
||||||
import net.lenni0451.mcstructs.text.components.StringComponent;
|
|
||||||
import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ChatSession1_19_0 extends AbstractChatSession {
|
|
||||||
|
|
||||||
public ChatSession1_19_0(UserConnection user, ProfileKey profileKey, PrivateKey privateKey) {
|
|
||||||
super(user, profileKey, privateKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] sign(final UUID sender, final MessageMetadataModel messageMetadata) {
|
|
||||||
return getSigner().sign(updater -> {
|
|
||||||
final byte[] data = new byte[32];
|
|
||||||
final ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN);
|
|
||||||
|
|
||||||
buffer.putLong(messageMetadata.salt());
|
|
||||||
buffer.putLong(sender.getMostSignificantBits()).putLong(sender.getLeastSignificantBits());
|
|
||||||
buffer.putLong(Instant.ofEpochMilli(messageMetadata.timestamp()).getEpochSecond());
|
|
||||||
|
|
||||||
updater.update(data);
|
|
||||||
updater.update(JsonHelper.toSortedString(TextComponentSerializer.V1_18.serializeJson(new StringComponent(messageMetadata.plain()))).getBytes(StandardCharsets.UTF_8));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_0.provider;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
|
||||||
import com.viaversion.viaversion.util.Pair;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CommandArgumentsProvider implements Provider {
|
|
||||||
|
|
||||||
public List<Pair<String, String>> getSignedArguments(final String command) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_0.util;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonPrimitive;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class JsonHelper {
|
|
||||||
|
|
||||||
public static String toSortedString(JsonElement json) {
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
JsonWriter jsonWriter = new JsonWriter(stringWriter);
|
|
||||||
|
|
||||||
try {
|
|
||||||
writeSorted(jsonWriter, json, Comparator.naturalOrder());
|
|
||||||
} catch (IOException var4) {
|
|
||||||
throw new AssertionError(var4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringWriter.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeSorted(JsonWriter writer, @Nullable JsonElement json, @Nullable Comparator<String> comparator) throws IOException {
|
|
||||||
if (json != null && !json.isJsonNull()) {
|
|
||||||
if (json.isJsonPrimitive()) {
|
|
||||||
JsonPrimitive jsonPrimitive = json.getAsJsonPrimitive();
|
|
||||||
if (jsonPrimitive.isNumber()) {
|
|
||||||
writer.value(jsonPrimitive.getAsNumber());
|
|
||||||
} else if (jsonPrimitive.isBoolean()) {
|
|
||||||
writer.value(jsonPrimitive.getAsBoolean());
|
|
||||||
} else {
|
|
||||||
writer.value(jsonPrimitive.getAsString());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Iterator var5;
|
|
||||||
if (json.isJsonArray()) {
|
|
||||||
writer.beginArray();
|
|
||||||
var5 = json.getAsJsonArray().iterator();
|
|
||||||
|
|
||||||
while(var5.hasNext()) {
|
|
||||||
JsonElement jsonElement = (JsonElement)var5.next();
|
|
||||||
writeSorted(writer, jsonElement, comparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.endArray();
|
|
||||||
} else {
|
|
||||||
if (!json.isJsonObject()) {
|
|
||||||
throw new IllegalArgumentException("Couldn't write " + json.getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.beginObject();
|
|
||||||
var5 = sort(json.getAsJsonObject().entrySet(), comparator).iterator();
|
|
||||||
|
|
||||||
while(var5.hasNext()) {
|
|
||||||
Map.Entry<String, JsonElement> entry = (Map.Entry)var5.next();
|
|
||||||
writer.name((String)entry.getKey());
|
|
||||||
writeSorted(writer, (JsonElement)entry.getValue(), comparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.endObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
writer.nullValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Collection<Map.Entry<String, JsonElement>> sort(Collection<Map.Entry<String, JsonElement>> entries, @Nullable Comparator<String> comparator) {
|
|
||||||
if (comparator == null) {
|
|
||||||
return entries;
|
|
||||||
} else {
|
|
||||||
List<Map.Entry<String, JsonElement>> list = new ArrayList(entries);
|
|
||||||
list.sort(Map.Entry.comparingByKey(comparator));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_2;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.AbstractChatSession;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.MessageMetadataModel;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.MessageBodyModel;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.MessageHeaderModel;
|
|
||||||
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ChatSession1_19_2 extends AbstractChatSession {
|
|
||||||
public final static SecureRandom SECURE_RANDOM = new SecureRandom();
|
|
||||||
|
|
||||||
private byte[] precedingSignature = null;
|
|
||||||
|
|
||||||
public ChatSession1_19_2(UserConnection user, ProfileKey profileKey, PrivateKey privateKey) {
|
|
||||||
super(user, profileKey, privateKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] sign(final UUID sender, final MessageMetadataModel messageMetadata, final PlayerMessageSignature[] lastSeenMessages) {
|
|
||||||
final MessageHeaderModel header = new MessageHeaderModel(sender, precedingSignature);
|
|
||||||
final MessageBodyModel body = new MessageBodyModel(messageMetadata, lastSeenMessages);
|
|
||||||
|
|
||||||
precedingSignature = getSigner().sign(updater -> header.updater(body.digestBytes(), updater));
|
|
||||||
|
|
||||||
return precedingSignature;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model;
|
|
||||||
|
|
||||||
import com.google.common.hash.Hashing;
|
|
||||||
import com.google.common.hash.HashingOutputStream;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
|
||||||
public class MessageBodyModel {
|
|
||||||
private final MessageMetadataModel messageMetadata;
|
|
||||||
private final PlayerMessageSignature[] lastSeenMessages;
|
|
||||||
|
|
||||||
public MessageBodyModel(MessageMetadataModel messageMetadata, PlayerMessageSignature[] lastSeenMessages) {
|
|
||||||
this.messageMetadata = messageMetadata;
|
|
||||||
this.lastSeenMessages = lastSeenMessages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeLastSeenMessage(final DataOutput dataOutput) {
|
|
||||||
for (PlayerMessageSignature seenMessage : lastSeenMessages) {
|
|
||||||
try {
|
|
||||||
dataOutput.writeByte(70);
|
|
||||||
dataOutput.writeLong(seenMessage.uuid().getMostSignificantBits());
|
|
||||||
dataOutput.writeLong(seenMessage.uuid().getLeastSignificantBits());
|
|
||||||
dataOutput.write(seenMessage.signatureBytes());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] digestBytes() {
|
|
||||||
final HashingOutputStream hashingOutputStream = new HashingOutputStream(Hashing.sha256(), OutputStream.nullOutputStream());
|
|
||||||
final DataOutputStream dataOutputStream = new DataOutputStream(hashingOutputStream);
|
|
||||||
|
|
||||||
try {
|
|
||||||
dataOutputStream.writeLong(messageMetadata.salt());
|
|
||||||
dataOutputStream.writeLong(Instant.ofEpochMilli(messageMetadata.timestamp()).getEpochSecond());
|
|
||||||
|
|
||||||
final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(dataOutputStream, StandardCharsets.UTF_8);
|
|
||||||
outputStreamWriter.write(messageMetadata.plain());
|
|
||||||
outputStreamWriter.flush();
|
|
||||||
|
|
||||||
dataOutputStream.write(70);
|
|
||||||
writeLastSeenMessage(dataOutputStream);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashingOutputStream.hash().asBytes();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public record MessageHeaderModel(UUID sender, byte[] precedingSignature) {
|
|
||||||
|
|
||||||
public byte[] toByteArray(final UUID uuid) {
|
|
||||||
final byte[] data = new byte[16];
|
|
||||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN);
|
|
||||||
|
|
||||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
|
||||||
byteBuffer.putLong(uuid.getLeastSignificantBits());
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updater(final byte[] bodyDigest, final SignatureUpdaterModel updater) {
|
|
||||||
if (precedingSignature != null) {
|
|
||||||
updater.update(precedingSignature);
|
|
||||||
}
|
|
||||||
|
|
||||||
updater.update(toByteArray(sender()));
|
|
||||||
updater.update(bodyDigest);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model;
|
|
||||||
|
|
||||||
public record MessageMetadataModel(String plain, long timestamp, long salt) {
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model;
|
|
||||||
|
|
||||||
public interface SignatureUpdatableModel {
|
|
||||||
|
|
||||||
void update(final SignatureUpdaterModel updater);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model;
|
|
||||||
|
|
||||||
public interface SignatureUpdaterModel {
|
|
||||||
|
|
||||||
void update(final byte[] data);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
|
||||||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.network.packet.c2s.login.EnterConfigurationC2SPacket;
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(ClientLoginNetworkHandler.class)
|
|
||||||
public class MixinClientLoginNetworkHandler {
|
|
||||||
|
|
||||||
@Shadow @Final private ClientConnection connection;
|
|
||||||
|
|
||||||
@Redirect(method = "onSuccess", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V"))
|
|
||||||
public void sendPackets(ClientConnection instance, Packet<?> packet) {
|
|
||||||
// Minecraft used to send these packets when the join game packet by the server is received
|
|
||||||
if (ProtocolHack.getTargetVersion(connection.channel).isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && !(packet instanceof EnterConfigurationC2SPacket)) return;
|
|
||||||
|
|
||||||
instance.send(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,17 +72,6 @@ public abstract class MixinClientPlayNetworkHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;setServerViewDistance(I)V", shift = At.Shift.AFTER))
|
|
||||||
public void sendBrandAndOptionPackets(GameJoinS2CPacket packet, CallbackInfo ci) {
|
|
||||||
// Counterpart from MixinClientLoginNetworkHandler
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
|
||||||
final var connection = this.getConnection();
|
|
||||||
|
|
||||||
connection.send(new ClientOptionsC2SPacket(MinecraftClient.getInstance().options.getSyncedOptions()));
|
|
||||||
connection.send(new CustomPayloadC2SPacket(new BrandCustomPayload(ClientBrandRetriever.getClientModName())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onChunkLoadDistance", at = @At("RETURN"))
|
@Inject(method = "onChunkLoadDistance", at = @At("RETURN"))
|
||||||
public void emulateSimulationDistance(ChunkLoadDistanceS2CPacket packet, CallbackInfo ci) {
|
public void emulateSimulationDistance(ChunkLoadDistanceS2CPacket packet, CallbackInfo ci) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
|
||||||
|
@ -19,14 +19,14 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_0;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_1;
|
||||||
import net.raphimc.mcauth.util.MicrosoftConstants;
|
import net.raphimc.mcauth.util.MicrosoftConstants;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||||
import de.florianmichael.viafabricplus.definition.account.BedrockAccountHandler;
|
import de.florianmichael.viafabricplus.definition.account.BedrockAccountHandler;
|
||||||
import de.florianmichael.viafabricplus.definition.account.ClassiCubeAccountHandler;
|
import de.florianmichael.viafabricplus.definition.account.ClassiCubeAccountHandler;
|
||||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.ChatSession1_19_0;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.ChatSession1_19_2;
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||||
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
|
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
|
||||||
@ -49,7 +49,6 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||||
@ -120,20 +119,24 @@ public class MixinConnectScreen_1 {
|
|||||||
return; // This disables the chat session emulation for all versions <= 1.18.2
|
return; // This disables the chat session emulation for all versions <= 1.18.2
|
||||||
}
|
}
|
||||||
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||||
MinecraftClient.getInstance().getProfileKeys().fetchKeyPair().thenAcceptAsync(optional -> optional.ifPresentOrElse(playerKeyPair -> {
|
final var profile = MinecraftClient.getInstance().getProfileKeys().fetchKeyPair().join().orElse(null);
|
||||||
final PlayerPublicKey.PublicKeyData publicKeyData = playerKeyPair.publicKey().data();
|
if (profile != null) {
|
||||||
|
final PlayerPublicKey.PublicKeyData publicKeyData = profile.publicKey().data();
|
||||||
|
|
||||||
userConnection.put(new ChatSession1_19_2(userConnection, new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), publicKeyData.keySignature()), playerKeyPair.privateKey()));
|
final UUID playerUuid = MinecraftClient.getInstance().getSession().getUuidOrNull();
|
||||||
|
|
||||||
|
userConnection.put(new ChatSession1_19_1(playerUuid, profile.privateKey(), new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), publicKeyData.keySignature())));
|
||||||
if (targetVersion == VersionEnum.r1_19) {
|
if (targetVersion == VersionEnum.r1_19) {
|
||||||
final var legacyKey = ((IPublicKeyData) (Object) publicKeyData).viafabricplus_getV1Key();
|
final var legacyKey = ((IPublicKeyData) (Object) publicKeyData).viafabricplus_getV1Key();
|
||||||
if (legacyKey != null) {
|
if (legacyKey != null) {
|
||||||
userConnection.put(new ChatSession1_19_0(userConnection, new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), legacyKey.array()), playerKeyPair.privateKey()));
|
userConnection.put(new ChatSession1_19_0(playerUuid, profile.privateKey(), new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), legacyKey.array())));
|
||||||
} else {
|
} else {
|
||||||
ViaFabricPlus.LOGGER.error("Failed to get v1 key, can't setup ChatSession_0");
|
ViaFabricPlus.LOGGER.error("Failed to fetch legacy key, can't setup ChatSession");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, () -> ViaFabricPlus.LOGGER.error("Failed to fetch keyPair, can't setup ChatSession")));
|
} else {
|
||||||
|
ViaFabricPlus.LOGGER.error("Failed to fetch keyPair, can't setup ChatSession");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_14to1_13_2;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(targets = "com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.InventoryPackets$2", remap = false)
|
|
||||||
public class MixinInventoryPackets_2 {
|
|
||||||
|
|
||||||
@Inject(method = "lambda$register$0", at = @At(value = "FIELD", target = "Lcom/viaversion/viaversion/api/type/Type;BOOLEAN:Lcom/viaversion/viaversion/api/type/types/BooleanType;", ordinal = 2, shift = At.Shift.BEFORE))
|
|
||||||
public void removeWrongData(PacketWrapper wrapper, CallbackInfo ci) {
|
|
||||||
wrapper.clearInputBuffer();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_19_1to1_19;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
|
||||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.Protocol1_19_1To1_19;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
|
|
||||||
import com.viaversion.viaversion.util.Pair;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.MessageMetadataModel;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.provider.CommandArgumentsProvider;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.ChatSession1_19_0;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Mixin(Protocol1_19_1To1_19.class)
|
|
||||||
public class MixinProtocol1_19_1To1_19 extends AbstractProtocol<ClientboundPackets1_19, ClientboundPackets1_19_1, ServerboundPackets1_19, ServerboundPackets1_19_1> {
|
|
||||||
|
|
||||||
@Inject(method = "registerPackets", at = @At("RETURN"), remap = false)
|
|
||||||
public void injectRegisterPackets(CallbackInfo ci) {
|
|
||||||
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING);
|
|
||||||
read(Type.OPTIONAL_PROFILE_KEY);
|
|
||||||
handler(wrapper -> {
|
|
||||||
final ChatSession1_19_0 chatSession1190 = wrapper.user().get(ChatSession1_19_0.class);
|
|
||||||
|
|
||||||
wrapper.write(Type.OPTIONAL_PROFILE_KEY, chatSession1190 == null ? null : chatSession1190.getProfileKey());
|
|
||||||
});
|
|
||||||
read(Type.OPTIONAL_UUID);
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
|
||||||
public void register() {
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
|
||||||
public void register() {
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
this.registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, ServerboundPackets1_19.CHAT_MESSAGE, new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING); // Message
|
|
||||||
map(Type.LONG); // Timestamp
|
|
||||||
map(Type.LONG); // Salt
|
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Signature
|
|
||||||
handler(wrapper -> {
|
|
||||||
final UUID sender = wrapper.user().getProtocolInfo().getUuid();
|
|
||||||
final String message = wrapper.get(Type.STRING, 0);
|
|
||||||
final long timestamp = wrapper.get(Type.LONG, 0);
|
|
||||||
final long salt = wrapper.get(Type.LONG, 1);
|
|
||||||
|
|
||||||
final ChatSession1_19_0 chatSession1190 = wrapper.user().get(ChatSession1_19_0.class);
|
|
||||||
if (chatSession1190 != null) {
|
|
||||||
wrapper.set(Type.BYTE_ARRAY_PRIMITIVE, 0, chatSession1190.sign(sender, new MessageMetadataModel(message, timestamp, salt)));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
map(Type.BOOLEAN); // Signed preview
|
|
||||||
read(Type.PLAYER_MESSAGE_SIGNATURE_ARRAY); // Last seen messages
|
|
||||||
read(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE); // Last received message
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
this.registerServerbound(ServerboundPackets1_19_1.CHAT_COMMAND, ServerboundPackets1_19.CHAT_COMMAND, new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING); // Command
|
|
||||||
map(Type.LONG); // Timestamp
|
|
||||||
map(Type.LONG); // Salt
|
|
||||||
map(Type.VAR_INT); // Signatures
|
|
||||||
|
|
||||||
// Emulating old signatures
|
|
||||||
handler(wrapper -> {
|
|
||||||
final UUID sender = wrapper.user().getProtocolInfo().getUuid();
|
|
||||||
final String command = wrapper.get(Type.STRING, 0);
|
|
||||||
final long timestamp = wrapper.get(Type.LONG, 0);
|
|
||||||
final long salt = wrapper.get(Type.LONG, 1);
|
|
||||||
|
|
||||||
final ChatSession1_19_0 chatSession1190 = wrapper.user().get(ChatSession1_19_0.class);
|
|
||||||
final CommandArgumentsProvider commandArgumentsProvider = Via.getManager().getProviders().get(CommandArgumentsProvider.class);
|
|
||||||
|
|
||||||
if (chatSession1190 != null) {
|
|
||||||
if (commandArgumentsProvider != null) {
|
|
||||||
final int signatures = wrapper.get(Type.VAR_INT, 0);
|
|
||||||
for (int i = 0; i < signatures; i++) {
|
|
||||||
wrapper.read(Type.STRING); // Argument name
|
|
||||||
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Pair<String, String> argument : commandArgumentsProvider.getSignedArguments(command)) {
|
|
||||||
final byte[] signature = chatSession1190.sign(sender, new MessageMetadataModel(argument.value(), timestamp, salt));
|
|
||||||
|
|
||||||
wrapper.write(Type.STRING, argument.key());
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
map(Type.BOOLEAN); // Signed preview
|
|
||||||
read(Type.PLAYER_MESSAGE_SIGNATURE_ARRAY); // Last seen messages
|
|
||||||
read(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE); // Last received message
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,196 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_19_3to1_19_1;
|
|
||||||
|
|
||||||
import com.google.common.primitives.Longs;
|
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.storage.NonceStorage;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
|
||||||
import com.viaversion.viaversion.api.type.types.ByteArrayType;
|
|
||||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
|
||||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.storage.ReceivedMessagesStorage;
|
|
||||||
import com.viaversion.viaversion.util.Pair;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.model.MessageMetadataModel;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.provider.CommandArgumentsProvider;
|
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_2.ChatSession1_19_2;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Mixin(value = Protocol1_19_3To1_19_1.class, remap = false)
|
|
||||||
public class MixinProtocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPackets1_19_1, ClientboundPackets1_19_3, ServerboundPackets1_19_1, ServerboundPackets1_19_3> {
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
private final static BitSetType ACKNOWLEDGED_BIT_SET_TYPE = new BitSetType(20);
|
|
||||||
|
|
||||||
@Inject(method = "registerPackets", at = @At("RETURN"))
|
|
||||||
public void fixKeys(CallbackInfo ci) {
|
|
||||||
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING); // Server-ID
|
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Public Key
|
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Nonce
|
|
||||||
handler(wrapper -> wrapper.user().put(new NonceStorage(wrapper.get(Type.BYTE_ARRAY_PRIMITIVE, 1))));
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING); // Name
|
|
||||||
handler(wrapper -> {
|
|
||||||
final ChatSession1_19_2 chatSession1192 = wrapper.user().get(ChatSession1_19_2.class);
|
|
||||||
wrapper.write(Type.OPTIONAL_PROFILE_KEY, chatSession1192 != null ? chatSession1192.getProfileKey() : null); // Profile Key
|
|
||||||
});
|
|
||||||
map(Type.OPTIONAL_UUID); // UUID
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
|
||||||
|
|
||||||
handler(wrapper -> {
|
|
||||||
final ChatSession1_19_2 chatSession1192 = wrapper.user().get(ChatSession1_19_2.class);
|
|
||||||
final byte[] encryptedNonce = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
|
|
||||||
|
|
||||||
wrapper.write(Type.BOOLEAN, chatSession1192 == null);
|
|
||||||
if (chatSession1192 != null) {
|
|
||||||
final long salt = ChatSession1_19_2.SECURE_RANDOM.nextLong();
|
|
||||||
final byte[] signedNonce = chatSession1192.getSigner().sign(updater -> {
|
|
||||||
updater.update(wrapper.user().get(NonceStorage.class).nonce());
|
|
||||||
updater.update(Longs.toByteArray(salt));
|
|
||||||
});
|
|
||||||
|
|
||||||
wrapper.write(Type.LONG, salt);
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signedNonce);
|
|
||||||
} else {
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, encryptedNonce);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_19_3.CHAT_COMMAND, ServerboundPackets1_19_1.CHAT_COMMAND, new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING); // Command
|
|
||||||
map(Type.LONG); // Timestamp
|
|
||||||
map(Type.LONG); // Salt
|
|
||||||
map(Type.VAR_INT); // Signatures
|
|
||||||
handler(wrapper -> {
|
|
||||||
final int signatures = wrapper.get(Type.VAR_INT, 0);
|
|
||||||
|
|
||||||
final ChatSession1_19_2 chatSession1192 = wrapper.user().get(ChatSession1_19_2.class);
|
|
||||||
final CommandArgumentsProvider commandArgumentsProvider = Via.getManager().getProviders().get(CommandArgumentsProvider.class);
|
|
||||||
|
|
||||||
final boolean signingEnabled = chatSession1192 != null && commandArgumentsProvider != null;
|
|
||||||
|
|
||||||
for (int i = 0; i < signatures; i++) {
|
|
||||||
if (signingEnabled) {
|
|
||||||
wrapper.read(Type.STRING); // Argument name
|
|
||||||
wrapper.read(Type.SIGNATURE_BYTES); // Signature
|
|
||||||
} else {
|
|
||||||
wrapper.passthrough(Type.STRING); // Argument name
|
|
||||||
|
|
||||||
// Signature
|
|
||||||
wrapper.read(Type.SIGNATURE_BYTES);
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, new byte[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chatSession1192 != null) {
|
|
||||||
final UUID sender = wrapper.user().getProtocolInfo().getUuid();
|
|
||||||
final String command = wrapper.get(Type.STRING, 0);
|
|
||||||
final long timestamp = wrapper.get(Type.LONG, 0);
|
|
||||||
final long salt = wrapper.get(Type.LONG, 1);
|
|
||||||
|
|
||||||
final ReceivedMessagesStorage messagesStorage = wrapper.user().get(ReceivedMessagesStorage.class);
|
|
||||||
|
|
||||||
for (Pair<String, String> argument : commandArgumentsProvider.getSignedArguments(command)) {
|
|
||||||
final byte[] signature = chatSession1192.sign(sender, new MessageMetadataModel(argument.value(), timestamp, salt), messagesStorage.lastSignatures());
|
|
||||||
|
|
||||||
wrapper.write(Type.STRING, argument.key());
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapper.write(Type.BOOLEAN, false); // No signed preview
|
|
||||||
|
|
||||||
final ReceivedMessagesStorage messagesStorage = wrapper.user().get(ReceivedMessagesStorage.class);
|
|
||||||
messagesStorage.resetUnacknowledgedCount();
|
|
||||||
wrapper.write(Type.PLAYER_MESSAGE_SIGNATURE_ARRAY, messagesStorage.lastSignatures());
|
|
||||||
wrapper.write(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE, null);
|
|
||||||
});
|
|
||||||
|
|
||||||
read(Type.VAR_INT); // Offset
|
|
||||||
read(ACKNOWLEDGED_BIT_SET_TYPE); // Acknowledged
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
registerServerbound(ServerboundPackets1_19_3.CHAT_MESSAGE, ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketHandlers() {
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
map(Type.STRING); // Command
|
|
||||||
map(Type.LONG); // Timestamp
|
|
||||||
map(Type.LONG); // Salt
|
|
||||||
read(Type.OPTIONAL_SIGNATURE_BYTES); // Signature
|
|
||||||
handler(wrapper -> {
|
|
||||||
final ChatSession1_19_2 chatSession1192 = wrapper.user().get(ChatSession1_19_2.class);
|
|
||||||
final ReceivedMessagesStorage messagesStorage = wrapper.user().get(ReceivedMessagesStorage.class);
|
|
||||||
|
|
||||||
if (chatSession1192 != null) {
|
|
||||||
final UUID sender = wrapper.user().getProtocolInfo().getUuid();
|
|
||||||
final String message = wrapper.get(Type.STRING, 0);
|
|
||||||
final long timestamp = wrapper.get(Type.LONG, 0);
|
|
||||||
final long salt = wrapper.get(Type.LONG, 1);
|
|
||||||
|
|
||||||
final byte[] signature = chatSession1192.sign(sender, new MessageMetadataModel(message, timestamp, salt), messagesStorage.lastSignatures());
|
|
||||||
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, signature);
|
|
||||||
wrapper.write(Type.BOOLEAN, false); // Signed Preview - not implemented yet, but I could do it
|
|
||||||
} else {
|
|
||||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, new byte[0]); // Signature
|
|
||||||
wrapper.write(Type.BOOLEAN, false); // No signed preview
|
|
||||||
}
|
|
||||||
|
|
||||||
messagesStorage.resetUnacknowledgedCount();
|
|
||||||
wrapper.write(Type.PLAYER_MESSAGE_SIGNATURE_ARRAY, messagesStorage.lastSignatures());
|
|
||||||
wrapper.write(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE, null);
|
|
||||||
});
|
|
||||||
|
|
||||||
read(Type.VAR_INT); // Offset
|
|
||||||
read(ACKNOWLEDGED_BIT_SET_TYPE); // Acknowledged
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_9_1to1_9;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(value = Protocol1_9_1To1_9.class, remap = false)
|
|
||||||
public class MixinProtocol1_9_1To1_9 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
|
|
||||||
|
|
||||||
@Inject(method = "registerPackets", at = @At("RETURN"))
|
|
||||||
public void clearInputBuffer(CallbackInfo ci) {
|
|
||||||
registerClientbound(ClientboundPackets1_9.CHUNK_DATA, wrapper -> {
|
|
||||||
wrapper.passthrough(ChunkType1_9_1.forEnvironment(wrapper.user().get(ClientWorld.class).getEnvironment()));
|
|
||||||
wrapper.clearInputBuffer();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,23 +18,18 @@
|
|||||||
package de.florianmichael.viafabricplus.protocolhack.impl;
|
package de.florianmichael.viafabricplus.protocolhack.impl;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.signature.SignableCommandArgumentsProvider;
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PlayerLookTargetProvider;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PlayerLookTargetProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.provider.PlayerAbilitiesProvider;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.provider.PlayerAbilitiesProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.provider.CommandArgumentsProvider;
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.ViaFabricPlusCommandArgumentsProvider;
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusBlobCacheProvider;
|
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusBlobCacheProvider;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusNettyPipelineProvider;
|
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusNettyPipelineProvider;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusTransferProvider;
|
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusTransferProvider;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.*;
|
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.*;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusBaseVersionProvider;
|
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.*;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusHandItemProvider;
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusMovementTransmitterProvider;
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusPlayerAbilitiesProvider;
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusPlayerLookTargetProvider;
|
|
||||||
import net.raphimc.viabedrock.protocol.providers.BlobCacheProvider;
|
import net.raphimc.viabedrock.protocol.providers.BlobCacheProvider;
|
||||||
import net.raphimc.viabedrock.protocol.providers.NettyPipelineProvider;
|
import net.raphimc.viabedrock.protocol.providers.NettyPipelineProvider;
|
||||||
import net.raphimc.viabedrock.protocol.providers.TransferProvider;
|
import net.raphimc.viabedrock.protocol.providers.TransferProvider;
|
||||||
@ -60,8 +55,7 @@ public class ViaFabricPlusVLLoader extends VLLoader {
|
|||||||
providers.use(HandItemProvider.class, new ViaFabricPlusHandItemProvider());
|
providers.use(HandItemProvider.class, new ViaFabricPlusHandItemProvider());
|
||||||
providers.use(PlayerLookTargetProvider.class, new ViaFabricPlusPlayerLookTargetProvider());
|
providers.use(PlayerLookTargetProvider.class, new ViaFabricPlusPlayerLookTargetProvider());
|
||||||
providers.use(PlayerAbilitiesProvider.class, new ViaFabricPlusPlayerAbilitiesProvider());
|
providers.use(PlayerAbilitiesProvider.class, new ViaFabricPlusPlayerAbilitiesProvider());
|
||||||
|
providers.use(SignableCommandArgumentsProvider.class, new ViaFabricPlusCommandArgumentsProvider());
|
||||||
providers.use(CommandArgumentsProvider.class, new ViaFabricPlusCommandArgumentsProvider());
|
|
||||||
|
|
||||||
providers.use(OldAuthProvider.class, new ViaFabricPlusOldAuthProvider());
|
providers.use(OldAuthProvider.class, new ViaFabricPlusOldAuthProvider());
|
||||||
providers.use(ClassicWorldHeightProvider.class, new ViaFabricPlusClassicWorldHeightProvider());
|
providers.use(ClassicWorldHeightProvider.class, new ViaFabricPlusClassicWorldHeightProvider());
|
||||||
|
@ -15,25 +15,29 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.florianmichael.viafabricplus.protocolhack.provider;
|
package de.florianmichael.viafabricplus.protocolhack.provider.viaversion;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.minecraft.signature.SignableCommandArgumentsProvider;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
import de.florianmichael.viafabricplus.definition.signatures.v1_19_0.provider.CommandArgumentsProvider;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
|
||||||
import net.minecraft.command.argument.SignedArgumentList;
|
import net.minecraft.command.argument.SignedArgumentList;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ViaFabricPlusCommandArgumentsProvider extends CommandArgumentsProvider {
|
public class ViaFabricPlusCommandArgumentsProvider extends SignableCommandArgumentsProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Pair<String, String>> getSignedArguments(String command) {
|
public List<Pair<String, String>> getSignableArguments(String command) {
|
||||||
final ClientPlayNetworkHandler clientPlayNetworkHandler = MinecraftClient.getInstance().getNetworkHandler();
|
final var network = MinecraftClient.getInstance().getNetworkHandler();
|
||||||
|
if (network != null) {
|
||||||
|
return SignedArgumentList.of(
|
||||||
|
network.getCommandDispatcher().parse(command, network.getCommandSource())).
|
||||||
|
arguments().stream().
|
||||||
|
map(function -> new Pair<>(function.getNodeName(), function.value())).
|
||||||
|
toList();
|
||||||
|
|
||||||
if (clientPlayNetworkHandler != null) {
|
|
||||||
return SignedArgumentList.of(clientPlayNetworkHandler.getCommandDispatcher().parse(command, clientPlayNetworkHandler.getCommandSource())).arguments().stream().map(function -> new Pair<>(function.getNodeName(), function.value())).toList();
|
|
||||||
}
|
}
|
||||||
return super.getSignedArguments(command);
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -115,7 +115,6 @@
|
|||||||
"fixes.minecraft.item.MixinShovelItem",
|
"fixes.minecraft.item.MixinShovelItem",
|
||||||
"fixes.minecraft.item.MixinSwordItem",
|
"fixes.minecraft.item.MixinSwordItem",
|
||||||
"fixes.minecraft.network.MixinClientCommonNetworkHandler",
|
"fixes.minecraft.network.MixinClientCommonNetworkHandler",
|
||||||
"fixes.minecraft.network.MixinClientLoginNetworkHandler",
|
|
||||||
"fixes.minecraft.network.MixinClientPlayNetworkHandler",
|
"fixes.minecraft.network.MixinClientPlayNetworkHandler",
|
||||||
"fixes.minecraft.packet.MixinChatMessageC2SPacket",
|
"fixes.minecraft.packet.MixinChatMessageC2SPacket",
|
||||||
"fixes.minecraft.packet.MixinPacketByteBuf",
|
"fixes.minecraft.packet.MixinPacketByteBuf",
|
||||||
@ -157,16 +156,12 @@
|
|||||||
"fixes.viaversion.protocol1_13to1_12_2.MixinSkullHandler",
|
"fixes.viaversion.protocol1_13to1_12_2.MixinSkullHandler",
|
||||||
"fixes.viaversion.protocol1_13to1_12_2.MixinWorldPackets1_13",
|
"fixes.viaversion.protocol1_13to1_12_2.MixinWorldPackets1_13",
|
||||||
"fixes.viaversion.protocol1_14to1_13_2.MixinInventoryPackets",
|
"fixes.viaversion.protocol1_14to1_13_2.MixinInventoryPackets",
|
||||||
"fixes.viaversion.protocol1_14to1_13_2.MixinInventoryPackets_2",
|
|
||||||
"fixes.viaversion.protocol1_15to1_14_4.MixinMetadataRewriter1_15To1_14_4",
|
"fixes.viaversion.protocol1_15to1_14_4.MixinMetadataRewriter1_15To1_14_4",
|
||||||
"fixes.viaversion.protocol1_16_2to1_16_1.MixinWorldPackets_2",
|
"fixes.viaversion.protocol1_16_2to1_16_1.MixinWorldPackets_2",
|
||||||
"fixes.viaversion.protocol1_17to1_16_4.MixinEntityPackets1_17",
|
"fixes.viaversion.protocol1_17to1_16_4.MixinEntityPackets1_17",
|
||||||
"fixes.viaversion.protocol1_17to1_16_4.MixinInventoryAcknowledgements",
|
"fixes.viaversion.protocol1_17to1_16_4.MixinInventoryAcknowledgements",
|
||||||
"fixes.viaversion.protocol1_17to1_16_4.MixinWorldPackets1_17",
|
"fixes.viaversion.protocol1_17to1_16_4.MixinWorldPackets1_17",
|
||||||
"fixes.viaversion.protocol1_19_1to1_19.MixinProtocol1_19_1To1_19",
|
|
||||||
"fixes.viaversion.protocol1_19_3to1_19_1.MixinProtocol1_19_3To1_19_1",
|
|
||||||
"fixes.viaversion.protocol1_19to1_18_2.MixinWorldPackets",
|
"fixes.viaversion.protocol1_19to1_18_2.MixinWorldPackets",
|
||||||
"fixes.viaversion.protocol1_9_1to1_9.MixinProtocol1_9_1To1_9",
|
|
||||||
"fixes.viaversion.protocol1_9to1_8.MixinChunkType1_8",
|
"fixes.viaversion.protocol1_9to1_8.MixinChunkType1_8",
|
||||||
"fixes.viaversion.protocol1_9to1_8.MixinCommandBlockProvider",
|
"fixes.viaversion.protocol1_9to1_8.MixinCommandBlockProvider",
|
||||||
"fixes.viaversion.protocol1_9to1_8.MixinEntityPackets_6_1",
|
"fixes.viaversion.protocol1_9to1_8.MixinEntityPackets_6_1",
|
||||||
|
Loading…
Reference in New Issue
Block a user