From 53c54485ebac6c13f790f155de10d57fdb94b7ff Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 21 Jul 2022 19:56:42 +0200 Subject: [PATCH] Cleanup optional types --- .../viaversion/viaversion/api/type/Type.java | 25 ++++++------- .../api/type/types/ComponentType.java | 8 +++++ .../viaversion/api/type/types/UUIDType.java | 9 +++++ ...itionType.java => GlobalPositionType.java} | 24 +++++++------ .../types/minecraft/OptPosition1_14Type.java | 34 ------------------ .../type/types/minecraft/OptPositionType.java | 34 ------------------ .../api/type/types/minecraft/OptUUIDType.java | 35 ------------------- .../minecraft/OptionalComponentType.java | 34 ------------------ .../OptionalPlayerMessageSignatureType.java | 34 ------------------ .../minecraft/OptionalProfileKeyType.java | 34 ------------------ .../minecraft/PlayerMessageSignatureType.java | 8 +++++ .../types/minecraft/Position1_14Type.java | 8 +++++ .../type/types/minecraft/PositionType.java | 8 +++++ .../type/types/minecraft/ProfileKeyType.java | 8 +++++ 14 files changed, 72 insertions(+), 231 deletions(-) rename api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/{OptionalGlobalPositionType.java => GlobalPositionType.java} (74%) delete mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPosition1_14Type.java delete mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPositionType.java delete mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptUUIDType.java delete mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalComponentType.java delete mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalPlayerMessageSignatureType.java delete mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalProfileKeyType.java 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 e2ea0ed68..47df659a2 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 @@ -62,16 +62,10 @@ import com.viaversion.viaversion.api.type.types.minecraft.FlatItemArrayType; import com.viaversion.viaversion.api.type.types.minecraft.FlatItemType; import com.viaversion.viaversion.api.type.types.minecraft.FlatVarIntItemArrayType; import com.viaversion.viaversion.api.type.types.minecraft.FlatVarIntItemType; +import com.viaversion.viaversion.api.type.types.minecraft.GlobalPositionType; import com.viaversion.viaversion.api.type.types.minecraft.ItemArrayType; import com.viaversion.viaversion.api.type.types.minecraft.ItemType; import com.viaversion.viaversion.api.type.types.minecraft.NBTType; -import com.viaversion.viaversion.api.type.types.minecraft.OptPosition1_14Type; -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; @@ -110,17 +104,17 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { /* Other Types */ public static final Type COMPONENT = new ComponentType(); - public static final Type OPTIONAL_COMPONENT = new OptionalComponentType(); + public static final Type OPTIONAL_COMPONENT = new ComponentType.OptionalComponentType(); public static final Type STRING = new StringType(); public static final Type OPTIONAL_STRING = new StringType.OptionalStringType(); public static final Type STRING_ARRAY = new ArrayType<>(Type.STRING); public static final Type UUID = new UUIDType(); - public static final Type OPTIONAL_UUID = new OptUUIDType(); + public static final Type OPTIONAL_UUID = new UUIDType.OptionalUUIDType(); + public static final Type UUID_ARRAY = new ArrayType<>(Type.UUID); @Deprecated/*(forRemoval = true)*/ public static final Type UUID_INT_ARRAY = new UUIDIntArrayType(); - public static final Type UUID_ARRAY = new ArrayType<>(Type.UUID); public static final VarIntType VAR_INT = new VarIntType(); public static final OptionalVarIntType OPTIONAL_VAR_INT = new OptionalVarIntType(); @@ -156,15 +150,16 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { /* MC Types */ public static final Type POSITION = new PositionType(); - public static final Type OPTIONAL_POSITION = new OptPositionType(); + public static final Type OPTIONAL_POSITION = new PositionType.OptionalPositionType(); public static final Type POSITION1_14 = new Position1_14Type(); - public static final Type OPTIONAL_POSITION_1_14 = new OptPosition1_14Type(); + public static final Type OPTIONAL_POSITION_1_14 = new Position1_14Type.OptionalPosition1_14Type(); public static final Type ROTATION = new EulerAngleType(); public static final Type VECTOR = new VectorType(); public static final Type NBT = new NBTType(); public static final Type NBT_ARRAY = new ArrayType<>(Type.NBT); - public static final Type OPTIONAL_GLOBAL_POSITION = new OptionalGlobalPositionType(); + public static final Type GLOBAL_POSITION = new GlobalPositionType(); + public static final Type OPTIONAL_GLOBAL_POSITION = new GlobalPositionType.OptionalGlobalPositionType(); public static final Type BLOCK_CHANGE_RECORD = new BlockChangeRecordType(); public static final Type BLOCK_CHANGE_RECORD_ARRAY = new ArrayType<>(Type.BLOCK_CHANGE_RECORD); @@ -178,10 +173,10 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { public static final Type ITEM_ARRAY = new ItemArrayType(); public static final Type PROFILE_KEY = new ProfileKeyType(); - public static final Type OPTIONAL_PROFILE_KEY = new OptionalProfileKeyType(); + public static final Type OPTIONAL_PROFILE_KEY = new ProfileKeyType.OptionalProfileKeyType(); public static final Type PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType(); - public static final Type OPTIONAL_PLAYER_MESSAGE_SIGNATURE = new OptionalPlayerMessageSignatureType(); + public static final Type OPTIONAL_PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType.OptionalPlayerMessageSignatureType(); public static final Type PLAYER_MESSAGE_SIGNATURE_ARRAY = new ArrayType<>(PLAYER_MESSAGE_SIGNATURE); /* 1.13 Flat Item (no data) */ diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java index 2ad8bad58..1d793b197 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/ComponentType.java @@ -26,6 +26,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; @@ -51,4 +52,11 @@ public class ComponentType extends Type { public void write(ByteBuf buffer, JsonElement object) throws Exception { STRING_TAG.write(buffer, object.toString()); } + + public static final class OptionalComponentType extends OptionalType { + + public OptionalComponentType() { + super(Type.COMPONENT); + } + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java index 52f848b04..a98a6b13b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/UUIDType.java @@ -22,12 +22,14 @@ */ package com.viaversion.viaversion.api.type.types; +import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; import java.util.UUID; public class UUIDType extends Type { + public UUIDType() { super(UUID.class); } @@ -42,4 +44,11 @@ public class UUIDType extends Type { buffer.writeLong(object.getMostSignificantBits()); buffer.writeLong(object.getLeastSignificantBits()); } + + public static final class OptionalUUIDType extends OptionalType { + + public OptionalUUIDType() { + super(Type.UUID); + } + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalGlobalPositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/GlobalPositionType.java similarity index 74% rename from api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalGlobalPositionType.java rename to api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/GlobalPositionType.java index 2c0f9c8f0..19745eb1c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalGlobalPositionType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/GlobalPositionType.java @@ -23,30 +23,32 @@ package com.viaversion.viaversion.api.type.types.minecraft; import com.viaversion.viaversion.api.minecraft.GlobalPosition; +import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; -public class OptionalGlobalPositionType extends Type { +public class GlobalPositionType extends Type { - public OptionalGlobalPositionType() { + public GlobalPositionType() { super(GlobalPosition.class); } @Override public GlobalPosition read(ByteBuf buffer) throws Exception { - if (buffer.readBoolean()) { - final String dimension = Type.STRING.read(buffer); - return Type.POSITION1_14.read(buffer).withDimension(dimension); - } - return null; + final String dimension = Type.STRING.read(buffer); + return Type.POSITION1_14.read(buffer).withDimension(dimension); } @Override public void write(ByteBuf buffer, GlobalPosition object) throws Exception { - buffer.writeBoolean(object != null); - if (object != null) { - Type.STRING.write(buffer, object.dimension()); - Type.POSITION1_14.write(buffer, object); + Type.STRING.write(buffer, object.dimension()); + Type.POSITION1_14.write(buffer, object); + } + + public static final class OptionalGlobalPositionType extends OptionalType { + + public OptionalGlobalPositionType() { + super(Type.GLOBAL_POSITION); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPosition1_14Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPosition1_14Type.java deleted file mode 100644 index ca43da989..000000000 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPosition1_14Type.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.Position; -import com.viaversion.viaversion.api.type.OptionalType; -import com.viaversion.viaversion.api.type.Type; - -public class OptPosition1_14Type extends OptionalType { - - public OptPosition1_14Type() { - super(Type.POSITION1_14); - } -} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPositionType.java deleted file mode 100644 index c2fe4cf11..000000000 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptPositionType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.Position; -import com.viaversion.viaversion.api.type.OptionalType; -import com.viaversion.viaversion.api.type.Type; - -public class OptPositionType extends OptionalType { - - public OptPositionType() { - super(Type.POSITION); - } -} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptUUIDType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptUUIDType.java deleted file mode 100644 index 10e8c71e1..000000000 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptUUIDType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.type.OptionalType; -import com.viaversion.viaversion.api.type.Type; - -import java.util.UUID; - -public class OptUUIDType extends OptionalType { - - public OptUUIDType() { - super(Type.UUID); - } -} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalComponentType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalComponentType.java deleted file mode 100644 index 3ad255586..000000000 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalComponentType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.google.gson.JsonElement; -import com.viaversion.viaversion.api.type.OptionalType; -import com.viaversion.viaversion.api.type.Type; - -public class OptionalComponentType extends OptionalType { - - public OptionalComponentType() { - super(Type.COMPONENT); - } -} \ No newline at end of file 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 deleted file mode 100644 index a2ad9d490..000000000 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalPlayerMessageSignatureType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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/OptionalProfileKeyType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalProfileKeyType.java deleted file mode 100644 index 3ddac9eab..000000000 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/OptionalProfileKeyType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.ProfileKey; -import com.viaversion.viaversion.api.type.OptionalType; -import com.viaversion.viaversion.api.type.Type; - -public class OptionalProfileKeyType extends OptionalType { - - public OptionalProfileKeyType() { - super(Type.PROFILE_KEY); - } -} 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 index af1e17189..8fa5aedd3 100644 --- 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 @@ -23,6 +23,7 @@ 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; import io.netty.buffer.ByteBuf; @@ -42,4 +43,11 @@ public class PlayerMessageSignatureType extends Type { Type.UUID.write(buffer, value.uuid()); Type.BYTE_ARRAY_PRIMITIVE.write(buffer, value.signatureBytes()); } + + public static final 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/Position1_14Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java index c4b2bb84a..b529f2de2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Position1_14Type.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types.minecraft; import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; @@ -48,4 +49,11 @@ public class Position1_14Type extends Type { | (object.y() & 0xfff) | ((((long) object.z()) & 0x3ffffff) << 12)); } + + public static final class OptionalPosition1_14Type extends OptionalType { + + public OptionalPosition1_14Type() { + super(Type.POSITION1_14); + } + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java index 98f149e4c..c9cf5ac02 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/PositionType.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types.minecraft; import com.viaversion.viaversion.api.minecraft.Position; +import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; @@ -48,4 +49,11 @@ public class PositionType extends Type { | ((((long) object.y()) & 0xfff) << 26) | (object.z() & 0x3ffffff)); } + + public static final class OptionalPositionType extends OptionalType { + + public OptionalPositionType() { + super(Type.POSITION); + } + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ProfileKeyType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ProfileKeyType.java index 09b89ebc4..17e8e285c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ProfileKeyType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ProfileKeyType.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types.minecraft; import com.viaversion.viaversion.api.minecraft.ProfileKey; +import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; @@ -43,4 +44,11 @@ public class ProfileKeyType extends Type { Type.BYTE_ARRAY_PRIMITIVE.write(buffer, object.publicKey()); Type.BYTE_ARRAY_PRIMITIVE.write(buffer, object.keySignature()); } + + public static final class OptionalProfileKeyType extends OptionalType { + + public OptionalProfileKeyType() { + super(Type.PROFILE_KEY); + } + } }