From 57ef90e851b5815435b7089b9cdcca98276c1d3d Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 15 Jul 2022 16:26:58 +0200 Subject: [PATCH] 1.19.1-pre5 --- .../api/minecraft/PlayerMessageSignature.java | 43 ++++++++++ .../api/protocol/version/ProtocolVersion.java | 2 +- .../viaversion/viaversion/api/type/Type.java | 7 ++ .../OptionalPlayerMessageSignatureType.java | 34 ++++++++ .../minecraft/PlayerMessageSignatureType.java | 45 ++++++++++ .../ClientboundPackets1_19_1.java | 4 +- .../Protocol1_19_1To1_19.java | 56 +++++++++--- .../ServerboundPackets1_19_1.java | 85 +++++++++++++++++++ gradle.properties | 2 +- 9 files changed, 263 insertions(+), 15 deletions(-) create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/PlayerMessageSignature.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalPlayerMessageSignatureType.java create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PlayerMessageSignatureType.java create mode 100644 common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ServerboundPackets1_19_1.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/PlayerMessageSignature.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/PlayerMessageSignature.java new file mode 100644 index 000000000..52fe505b1 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/PlayerMessageSignature.java @@ -0,0 +1,43 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2022 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.viaversion.viaversion.api.minecraft; + +import java.util.UUID; + +public final class PlayerMessageSignature { + private final UUID uuid; + private final byte[] signatureBytes; + + public PlayerMessageSignature(final UUID uuid, final byte[] signatureBytes) { + this.uuid = uuid; + this.signatureBytes = signatureBytes; + } + + public UUID uuid() { + return uuid; + } + + public byte[] signatureBytes() { + return signatureBytes; + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index cd7accc59..23e2b9ec6 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -81,7 +81,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1)); public static final ProtocolVersion v1_18_2 = register(758, "1.18.2"); public static final ProtocolVersion v1_19 = register(759, "1.19"); - public static final ProtocolVersion v1_19_1 = register(760, 97, "1.19.1"); + public static final ProtocolVersion v1_19_1 = register(760, 98, "1.19.1"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static ProtocolVersion register(int version, String name) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java index f4a08a6f5..adaf14cb2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java @@ -28,6 +28,7 @@ import com.google.gson.JsonElement; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.EulerAngle; import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.Vector; @@ -69,8 +70,10 @@ import com.viaversion.viaversion.api.type.types.minecraft.OptPositionType; import com.viaversion.viaversion.api.type.types.minecraft.OptUUIDType; import com.viaversion.viaversion.api.type.types.minecraft.OptionalComponentType; import com.viaversion.viaversion.api.type.types.minecraft.OptionalGlobalPositionType; +import com.viaversion.viaversion.api.type.types.minecraft.OptionalPlayerMessageSignatureType; import com.viaversion.viaversion.api.type.types.minecraft.OptionalProfileKeyType; import com.viaversion.viaversion.api.type.types.minecraft.OptionalVarIntType; +import com.viaversion.viaversion.api.type.types.minecraft.PlayerMessageSignatureType; import com.viaversion.viaversion.api.type.types.minecraft.Position1_14Type; import com.viaversion.viaversion.api.type.types.minecraft.PositionType; import com.viaversion.viaversion.api.type.types.minecraft.ProfileKeyType; @@ -176,6 +179,10 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { public static final Type PROFILE_KEY = new ProfileKeyType(); public static final Type OPTIONAL_PROFILE_KEY = new OptionalProfileKeyType(); + public static final Type PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType(); + public static final Type OPTIONAL_PLAYER_MESSAGE_SIGNATURE = new OptionalPlayerMessageSignatureType(); + public static final Type PLAYER_MESSAGE_SIGNATURE_ARRAY = new ArrayType<>(PLAYER_MESSAGE_SIGNATURE); + /* 1.13 Flat Item (no data) */ public static final Type FLAT_ITEM = new FlatItemType(); public static final Type FLAT_VAR_INT_ITEM = new FlatVarIntItemType(); diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalPlayerMessageSignatureType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalPlayerMessageSignatureType.java new file mode 100644 index 000000000..a2ad9d490 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalPlayerMessageSignatureType.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2022 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.viaversion.viaversion.api.type.types.minecraft; + +import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; +import com.viaversion.viaversion.api.type.OptionalType; +import com.viaversion.viaversion.api.type.Type; + +public class OptionalPlayerMessageSignatureType extends OptionalType { + + public OptionalPlayerMessageSignatureType() { + super(Type.PLAYER_MESSAGE_SIGNATURE); + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PlayerMessageSignatureType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PlayerMessageSignatureType.java new file mode 100644 index 000000000..af1e17189 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PlayerMessageSignatureType.java @@ -0,0 +1,45 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2022 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.viaversion.viaversion.api.type.types.minecraft; + +import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; + +public class PlayerMessageSignatureType extends Type { + + public PlayerMessageSignatureType() { + super(PlayerMessageSignature.class); + } + + @Override + public PlayerMessageSignature read(final ByteBuf buffer) throws Exception { + return new PlayerMessageSignature(Type.UUID.read(buffer), Type.BYTE_ARRAY_PRIMITIVE.read(buffer)); + } + + @Override + public void write(final ByteBuf buffer, final PlayerMessageSignature value) throws Exception { + Type.UUID.write(buffer, value.uuid()); + Type.BYTE_ARRAY_PRIMITIVE.write(buffer, value.signatureBytes()); + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ClientboundPackets1_19_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ClientboundPackets1_19_1.java index f746aaa83..590453a25 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ClientboundPackets1_19_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ClientboundPackets1_19_1.java @@ -71,8 +71,8 @@ public enum ClientboundPackets1_19_1 implements ClientboundPacketType { PING, // 0x2F CRAFT_RECIPE_RESPONSE, // 0x30 PLAYER_ABILITIES, // 0x31 - PLAYER_CHAT, // 0x32 - PLAYER_CHAT_HEADER, // 0x33 + PLAYER_CHAT_HEADER, // 0x32 + PLAYER_CHAT, // 0x33 COMBAT_END, // 0x34 COMBAT_ENTER, // 0x35 COMBAT_KILL, // 0x36 diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java index b4340cf5e..3a7a97a8e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java @@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPacke import java.io.IOException; -public final class Protocol1_19_1To1_19 extends AbstractProtocol { +public final class Protocol1_19_1To1_19 extends AbstractProtocol { private static final String CHAT_REGISTRY_SNBT = "{\n" + " \"minecraft:chat_type\": {\n" + @@ -70,7 +70,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { + final int signatures = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < signatures; i++) { + wrapper.passthrough(Type.STRING); // Argument name + wrapper.passthrough(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 + } + }); + + cancelServerbound(ServerboundPackets1_19_1.CHAT_ACK); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ServerboundPackets1_19_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ServerboundPackets1_19_1.java new file mode 100644 index 000000000..ff6e037f4 --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/ServerboundPackets1_19_1.java @@ -0,0 +1,85 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2022 ViaVersion 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 . + */ +package com.viaversion.viaversion.protocols.protocol1_19_1to1_19; + +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; + +public enum ServerboundPackets1_19_1 implements ServerboundPacketType { + + TELEPORT_CONFIRM, // 0x00 + QUERY_BLOCK_NBT, // 0x01 + SET_DIFFICULTY, // 0x02 + CHAT_ACK, + CHAT_COMMAND, // 0x03 + CHAT_MESSAGE, // 0x04 + CHAT_PREVIEW, // 0x05 + CLIENT_STATUS, // 0x06 + CLIENT_SETTINGS, // 0x07 + TAB_COMPLETE, // 0x08 + CLICK_WINDOW_BUTTON, // 0x09 + CLICK_WINDOW, // 0x0A + CLOSE_WINDOW, // 0x0B + PLUGIN_MESSAGE, // 0x0C + EDIT_BOOK, // 0x0D + ENTITY_NBT_REQUEST, // 0x0E + INTERACT_ENTITY, // 0x0F + GENERATE_JIGSAW, // 0x10 + KEEP_ALIVE, // 0x11 + LOCK_DIFFICULTY, // 0x12 + PLAYER_POSITION, // 0x13 + PLAYER_POSITION_AND_ROTATION, // 0x14 + PLAYER_ROTATION, // 0x15 + PLAYER_MOVEMENT, // 0x16 + VEHICLE_MOVE, // 0x17 + STEER_BOAT, // 0x18 + PICK_ITEM, // 0x19 + CRAFT_RECIPE_REQUEST, // 0x1A + PLAYER_ABILITIES, // 0x1B + PLAYER_DIGGING, // 0x1C + ENTITY_ACTION, // 0x1D + STEER_VEHICLE, // 0x1E + PONG, // 0x1F + RECIPE_BOOK_DATA, // 0x20 + SEEN_RECIPE, // 0x21 + RENAME_ITEM, // 0x22 + RESOURCE_PACK_STATUS, // 0x23 + ADVANCEMENT_TAB, // 0x24 + SELECT_TRADE, // 0x25 + SET_BEACON_EFFECT, // 0x26 + HELD_ITEM_CHANGE, // 0x27 + UPDATE_COMMAND_BLOCK, // 0x28 + UPDATE_COMMAND_BLOCK_MINECART, // 0x29 + CREATIVE_INVENTORY_ACTION, // 0x2A + UPDATE_JIGSAW_BLOCK, // 0x2B + UPDATE_STRUCTURE_BLOCK, // 0x2C + UPDATE_SIGN, // 0x2D + ANIMATION, // 0x2E + SPECTATE, // 0x2F + PLAYER_BLOCK_PLACEMENT, // 0x30 + USE_ITEM; // 0x31 + + @Override + public int getId() { + return ordinal(); + } + + @Override + public String getName() { + return name(); + } +} diff --git a/gradle.properties b/gradle.properties index fcbcec0fb..d31ddf90c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.4.0-1.19.1-pre4-SNAPSHOT +projectVersion=4.4.0-1.19.1-pre5-SNAPSHOT # Gradle properties org.gradle.daemon=true