diff --git a/HEADER.txt b/HEADER.txt index 1fde5b4a..d543d1ed 100644 --- a/HEADER.txt +++ b/HEADER.txt @@ -1,4 +1,4 @@ -Copyright (C) 2021 - 2023 Elytrium +Copyright (C) 2021 - 2024 Elytrium This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by diff --git a/HEADER_MIXED.txt b/HEADER_MIXED.txt index 12a4a08e..b2bbad41 100644 --- a/HEADER_MIXED.txt +++ b/HEADER_MIXED.txt @@ -1,4 +1,4 @@ -Copyright (C) 2021 - 2023 Elytrium +Copyright (C) 2021 - 2024 Elytrium This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by diff --git a/VERSION b/VERSION index be5b4c7b..6f182425 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.20 +1.1.21 diff --git a/api/HEADER.txt b/api/HEADER.txt index 89af46b5..701d63bc 100644 --- a/api/HEADER.txt +++ b/api/HEADER.txt @@ -1,4 +1,4 @@ -Copyright (C) 2021 - 2023 Elytrium +Copyright (C) 2021 - 2024 Elytrium The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, reference the LICENSE file in the api top-level directory. \ No newline at end of file diff --git a/api/src/main/java/net/elytrium/limboapi/api/Limbo.java b/api/src/main/java/net/elytrium/limboapi/api/Limbo.java index c26d34f6..5760ab98 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/Limbo.java +++ b/api/src/main/java/net/elytrium/limboapi/api/Limbo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/LimboFactory.java b/api/src/main/java/net/elytrium/limboapi/api/LimboFactory.java index 09bdbd79..3f8576a0 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/LimboFactory.java +++ b/api/src/main/java/net/elytrium/limboapi/api/LimboFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/LimboSessionHandler.java b/api/src/main/java/net/elytrium/limboapi/api/LimboSessionHandler.java index bbc8f387..62be952e 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/LimboSessionHandler.java +++ b/api/src/main/java/net/elytrium/limboapi/api/LimboSessionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/BlockEntityVersion.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/BlockEntityVersion.java index 4d7619df..27c6351f 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/BlockEntityVersion.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/BlockEntityVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/BuiltInBiome.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/BuiltInBiome.java index 12ced0a4..2cc7a319 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/BuiltInBiome.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/BuiltInBiome.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/Dimension.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/Dimension.java index 9419fd49..ec541d3b 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/Dimension.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/Dimension.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBiome.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBiome.java index 3f80b25a..b5c37746 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBiome.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBiome.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlock.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlock.java index 9e89fa3f..77d5eb71 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlock.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlockEntity.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlockEntity.java index f71998c1..d7e74afe 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlockEntity.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualBlockEntity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualChunk.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualChunk.java index b2d072be..40713bf8 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualChunk.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualWorld.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualWorld.java index dd8c5ab1..ff44f392 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualWorld.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/VirtualWorld.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockSection.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockSection.java index 12911011..82569ca3 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockSection.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockSection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockStorage.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockStorage.java index 7ffbf38f..c395ba5f 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockStorage.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/BlockStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/ChunkSnapshot.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/ChunkSnapshot.java index 25b7f070..6e53acd7 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/ChunkSnapshot.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/ChunkSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/LightSection.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/LightSection.java index fea85754..73fd1798 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/data/LightSection.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/data/LightSection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/chunk/util/CompactStorage.java b/api/src/main/java/net/elytrium/limboapi/api/chunk/util/CompactStorage.java index e5cf6cd2..f45ed986 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/chunk/util/CompactStorage.java +++ b/api/src/main/java/net/elytrium/limboapi/api/chunk/util/CompactStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/command/LimboCommandMeta.java b/api/src/main/java/net/elytrium/limboapi/api/command/LimboCommandMeta.java index 5459439c..b5ca7ad1 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/command/LimboCommandMeta.java +++ b/api/src/main/java/net/elytrium/limboapi/api/command/LimboCommandMeta.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/event/LoginLimboRegisterEvent.java b/api/src/main/java/net/elytrium/limboapi/api/event/LoginLimboRegisterEvent.java index ff233bf6..20c46096 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/event/LoginLimboRegisterEvent.java +++ b/api/src/main/java/net/elytrium/limboapi/api/event/LoginLimboRegisterEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/file/BuiltInWorldFileType.java b/api/src/main/java/net/elytrium/limboapi/api/file/BuiltInWorldFileType.java index 49aa17de..5345202b 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/file/BuiltInWorldFileType.java +++ b/api/src/main/java/net/elytrium/limboapi/api/file/BuiltInWorldFileType.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/file/WorldFile.java b/api/src/main/java/net/elytrium/limboapi/api/file/WorldFile.java index 8ef485c8..c105aab5 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/file/WorldFile.java +++ b/api/src/main/java/net/elytrium/limboapi/api/file/WorldFile.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/material/Block.java b/api/src/main/java/net/elytrium/limboapi/api/material/Block.java index e4c46746..d478743b 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/material/Block.java +++ b/api/src/main/java/net/elytrium/limboapi/api/material/Block.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/material/Item.java b/api/src/main/java/net/elytrium/limboapi/api/material/Item.java index ee44290c..7ac214a1 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/material/Item.java +++ b/api/src/main/java/net/elytrium/limboapi/api/material/Item.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/material/VirtualItem.java b/api/src/main/java/net/elytrium/limboapi/api/material/VirtualItem.java index 1682f5d7..5b060b86 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/material/VirtualItem.java +++ b/api/src/main/java/net/elytrium/limboapi/api/material/VirtualItem.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/material/WorldVersion.java b/api/src/main/java/net/elytrium/limboapi/api/material/WorldVersion.java index e2a4df8d..bc0c3629 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/material/WorldVersion.java +++ b/api/src/main/java/net/elytrium/limboapi/api/material/WorldVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/player/GameMode.java b/api/src/main/java/net/elytrium/limboapi/api/player/GameMode.java index de307139..bda70f31 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/player/GameMode.java +++ b/api/src/main/java/net/elytrium/limboapi/api/player/GameMode.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/player/LimboPlayer.java b/api/src/main/java/net/elytrium/limboapi/api/player/LimboPlayer.java index ed1615e3..5306f164 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/player/LimboPlayer.java +++ b/api/src/main/java/net/elytrium/limboapi/api/player/LimboPlayer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/PacketDirection.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/PacketDirection.java index 7f4ac29e..20eb3f57 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/PacketDirection.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/PacketDirection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/PreparedPacket.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/PreparedPacket.java index 1ce209ce..8997c3c5 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/PreparedPacket.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/PreparedPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/map/MapPalette.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/map/MapPalette.java index ca13276b..ceaf8177 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/map/MapPalette.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/map/MapPalette.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketFactory.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketFactory.java index fc52092e..d62f9ebc 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketFactory.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketMapping.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketMapping.java index c1083bc2..14f6ad09 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketMapping.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/PacketMapping.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/AbilityFlags.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/AbilityFlags.java index dcac3ebb..665d0ae1 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/AbilityFlags.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/AbilityFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/BiomeData.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/BiomeData.java index e89313b0..f42e03d9 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/BiomeData.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/BiomeData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapData.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapData.java index 5b487b47..fbea44ed 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapData.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapPalette.java b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapPalette.java index d283465d..ef19822e 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapPalette.java +++ b/api/src/main/java/net/elytrium/limboapi/api/protocol/packets/data/MapPalette.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayMap.java b/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayMap.java index cf74d700..0dd78005 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayMap.java +++ b/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayMap.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayVanillaMap.java b/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayVanillaMap.java index a013c17a..3b1be74b 100644 --- a/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayVanillaMap.java +++ b/api/src/main/java/net/elytrium/limboapi/api/utils/OverlayVanillaMap.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/api/src/main/templates/net/elytrium/limboapi/BuildConstants.java b/api/src/main/templates/net/elytrium/limboapi/BuildConstants.java index 022733d7..f95103dc 100644 --- a/api/src/main/templates/net/elytrium/limboapi/BuildConstants.java +++ b/api/src/main/templates/net/elytrium/limboapi/BuildConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * The LimboAPI (excluding the LimboAPI plugin) is licensed under the terms of the MIT License. For more details, * reference the LICENSE file in the api top-level directory. diff --git a/build.gradle b/build.gradle index a357159a..f833aa20 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ allprojects() { apply(plugin: "org.cadixdev.licenser") setGroup("net.elytrium.limboapi") - setVersion("1.1.20") + setVersion("1.1.21") compileJava() { sourceCompatibility = JavaVersion.VERSION_17 diff --git a/plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java b/plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java index c2d8a594..b5114e75 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java +++ b/plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -82,7 +82,6 @@ import net.elytrium.limboapi.file.WorldFileTypeRegistry; import net.elytrium.limboapi.injection.disconnect.DisconnectListener; import net.elytrium.limboapi.injection.event.EventManagerHook; -import net.elytrium.limboapi.injection.kick.KickListener; import net.elytrium.limboapi.injection.login.LoginListener; import net.elytrium.limboapi.injection.login.LoginTasksQueue; import net.elytrium.limboapi.injection.packet.LegacyPlayerListItemHook; @@ -200,7 +199,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) { if (Settings.IMP.reload(this.configFile, Settings.IMP.PREFIX) == YamlConfig.LoadResult.CONFIG_NOT_EXISTS) { LOGGER.warn("************* FIRST LAUNCH *************"); LOGGER.warn("Thanks for installing LimboAPI!"); - LOGGER.warn("(C) 2021 - 2023 Elytrium"); + LOGGER.warn("(C) 2021 - 2024 Elytrium"); LOGGER.warn(""); LOGGER.warn("Check out our plugins here: https://ely.su/github <3"); LOGGER.warn("Discord: https://ely.su/discord"); @@ -283,7 +282,6 @@ public void reload() { VelocityEventManager eventManager = this.server.getEventManager(); eventManager.unregisterListeners(this); eventManager.register(this, this.loginListener); - eventManager.register(this, new KickListener(this)); eventManager.register(this, new DisconnectListener(this)); eventManager.register(this, new ReloadListener(this)); diff --git a/plugin/src/main/java/net/elytrium/limboapi/Settings.java b/plugin/src/main/java/net/elytrium/limboapi/Settings.java index 4eeb932a..2f2890df 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/Settings.java +++ b/plugin/src/main/java/net/elytrium/limboapi/Settings.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -49,6 +49,7 @@ public static class MAIN { public boolean CHECK_FOR_UPDATES = true; public int MAX_CHAT_MESSAGE_LENGTH = 256; + public int MAX_BRAND_NAME_LENGTH = 64; public int MAX_UNKNOWN_PACKET_LENGTH = 2048; public int MAX_SINGLE_GENERIC_PACKET_LENGTH = 4096; public int MAX_MULTI_GENERIC_PACKET_LENGTH = 131072; @@ -77,7 +78,8 @@ public static class MAIN { "Available versions:", "1_7_2, 1_7_6, 1_8, 1_9, 1_9_1, 1_9_2, 1_9_4, 1_10, 1_11, 1_11_1, 1_12, 1_12_1, 1_12_2,", "1_13, 1_13_1, 1_13_2, 1_14, 1_14_1, 1_14_2, 1_14_3, 1_14_4, 1_15, 1_15_1, 1_15_2,", - "1_16, 1_16_1, 1_16_2, 1_16_3, 1_16_4, 1_17, 1_17_1, 1_18, 1_18_2, 1_19, 1_19_1, 1_19_3, 1_20, 1_20_2, LATEST" + "1_16, 1_16_1, 1_16_2, 1_16_3, 1_16_4, 1_17, 1_17_1, 1_18, 1_18_2, 1_19, 1_19_1, 1_19_3,", + "1_20, 1_20_2, 1_20_3, LATEST" }) public String PREPARE_MIN_VERSION = "1_7_2"; public String PREPARE_MAX_VERSION = "LATEST"; @@ -108,6 +110,12 @@ public static class MAIN { @Comment("How many chunks we should send per tick") public int CHUNKS_PER_TICK = 16; + @Comment("Maximum delay for receiving ChatSession packet (for online-mode client-side race condition mitigation)") + public int CHAT_SESSION_PACKET_TIMEOUT = 5000; + + @Comment("Ability to force disable chat signing on 1.19.3+") + public boolean FORCE_DISABLE_MODERN_CHAT_SIGNING = true; + @Create public MESSAGES MESSAGES; diff --git a/plugin/src/main/java/net/elytrium/limboapi/file/MCEditSchematicFile.java b/plugin/src/main/java/net/elytrium/limboapi/file/MCEditSchematicFile.java index edd7451d..8f33215f 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/file/MCEditSchematicFile.java +++ b/plugin/src/main/java/net/elytrium/limboapi/file/MCEditSchematicFile.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/file/StructureNbtFile.java b/plugin/src/main/java/net/elytrium/limboapi/file/StructureNbtFile.java index 4a19f970..54d9f3f4 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/file/StructureNbtFile.java +++ b/plugin/src/main/java/net/elytrium/limboapi/file/StructureNbtFile.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/file/WorldEditSchemFile.java b/plugin/src/main/java/net/elytrium/limboapi/file/WorldEditSchemFile.java index e17d31ce..b5fed011 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/file/WorldEditSchemFile.java +++ b/plugin/src/main/java/net/elytrium/limboapi/file/WorldEditSchemFile.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/file/WorldFileTypeRegistry.java b/plugin/src/main/java/net/elytrium/limboapi/file/WorldFileTypeRegistry.java index 98b6a9ec..91665392 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/file/WorldFileTypeRegistry.java +++ b/plugin/src/main/java/net/elytrium/limboapi/file/WorldFileTypeRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/disconnect/DisconnectListener.java b/plugin/src/main/java/net/elytrium/limboapi/injection/disconnect/DisconnectListener.java index 2a8fcbe4..2d0deb4b 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/disconnect/DisconnectListener.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/disconnect/DisconnectListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedChannel.java b/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedChannel.java index 7d4ed1f1..e52e3bcd 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedChannel.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedMinecraftConnection.java b/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedMinecraftConnection.java index dcdf8748..cd7218a9 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedMinecraftConnection.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/ClosedMinecraftConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/DummyEventPool.java b/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/DummyEventPool.java index 9d68f203..d622fcae 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/DummyEventPool.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/dummy/DummyEventPool.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/event/EventManagerHook.java b/plugin/src/main/java/net/elytrium/limboapi/injection/event/EventManagerHook.java index d949f0ba..ef804459 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/event/EventManagerHook.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/event/EventManagerHook.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -20,11 +20,13 @@ import com.google.common.collect.ListMultimap; import com.velocitypowered.api.event.EventManager; import com.velocitypowered.api.event.player.GameProfileRequestEvent; +import com.velocitypowered.api.event.player.KickedFromServerEvent; import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.PluginManager; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.command.VelocityCommandManager; +import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.event.VelocityEventManager; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -38,6 +40,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; +import java.util.function.Function; import net.elytrium.commons.utils.reflection.ReflectionException; import net.elytrium.limboapi.LimboAPI; import net.elytrium.limboapi.Settings; @@ -130,6 +133,15 @@ private CompletableFuture proxyHook(E event) { return hookFuture; } + } else if (event instanceof KickedFromServerEvent kicked) { + CompletableFuture hookFuture = new CompletableFuture<>(); + super.fire(kicked).thenRunAsync(() -> { + Function callback = this.plugin.getKickCallback(kicked.getPlayer()); + if (callback == null || !callback.apply(kicked)) { + hookFuture.complete(event); + } + }, ((ConnectedPlayer) kicked.getPlayer()).getConnection().eventLoop()); + return hookFuture; } else { return null; } diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/kick/KickListener.java b/plugin/src/main/java/net/elytrium/limboapi/injection/kick/KickListener.java deleted file mode 100644 index b25c7375..00000000 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/kick/KickListener.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2021 - 2023 Elytrium - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * This file contains some parts of Velocity, licensed under the AGPLv3 License (AGPLv3). - * - * Copyright (C) 2018 Velocity 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 net.elytrium.limboapi.injection.kick; - -import com.velocitypowered.api.event.PostOrder; -import com.velocitypowered.api.event.Subscribe; -import com.velocitypowered.api.event.player.KickedFromServerEvent; -import com.velocitypowered.api.proxy.ConnectionRequestBuilder; -import com.velocitypowered.api.proxy.server.RegisteredServer; -import com.velocitypowered.proxy.connection.MinecraftConnection; -import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; -import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.connection.util.ConnectionMessages; -import com.velocitypowered.proxy.connection.util.ConnectionRequestResults; -import com.velocitypowered.proxy.protocol.packet.DisconnectPacket; -import io.netty.channel.EventLoop; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.reflect.Field; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import net.elytrium.commons.utils.reflection.ReflectionException; -import net.elytrium.limboapi.LimboAPI; -import net.elytrium.limboapi.injection.dummy.ClosedChannel; -import net.elytrium.limboapi.injection.dummy.ClosedMinecraftConnection; -import net.elytrium.limboapi.injection.dummy.DummyEventPool; -import net.kyori.adventure.identity.Identity; -import net.kyori.adventure.text.Component; - -public class KickListener { - - private static final MinecraftConnection DUMMY_CONNECTION = new ClosedMinecraftConnection(new ClosedChannel(new DummyEventPool()), null); - private static final Field CONNECTION_FIELD; - private static final MethodHandle BACKEND_CONNECTION_FIELD; - private static final MethodHandle CREATE_CONNECTION_REQUEST; - - private final LimboAPI plugin; - - public KickListener(LimboAPI plugin) { - this.plugin = plugin; - } - - @Subscribe(order = PostOrder.LAST) - public void onPlayerKicked(KickedFromServerEvent event) { - ConnectedPlayer player = (ConnectedPlayer) event.getPlayer(); - Function callback = this.plugin.getKickCallback(player); - if (callback != null) { - MinecraftConnection connection = player.getConnection(); - VelocityServerConnection backendConnection = player.getConnectedServer(); - - try { - CONNECTION_FIELD.set(player, DUMMY_CONNECTION); - - EventLoop eventLoop = connection.getChannel().eventLoop(); - eventLoop.schedule(() -> { - try { - BACKEND_CONNECTION_FIELD.invokeExact(player, (VelocityServerConnection) null); - if (connection.isClosed()) { - return; - } - - CONNECTION_FIELD.set(player, connection); - if (!callback.apply(event)) { - this.handleThen(event, player, backendConnection); - } - } catch (Throwable e) { - connection.close(); - throw new ReflectionException(e); - } - }, 250, TimeUnit.MILLISECONDS); - } catch (IllegalAccessException e) { - connection.close(); - throw new ReflectionException(e); - } - } - } - - // From Velocity. - private void handleThen(KickedFromServerEvent event, ConnectedPlayer player, VelocityServerConnection serverConnection) - throws Throwable { - if (event.getResult() instanceof KickedFromServerEvent.DisconnectPlayer res) { - player.disconnect(res.getReasonComponent()); - } else if (event.getResult() instanceof KickedFromServerEvent.RedirectPlayer res) { - ((ConnectionRequestBuilder) CREATE_CONNECTION_REQUEST.invokeExact(player, res.getServer(), serverConnection)) - .connect() - .whenCompleteAsync((status, throwable) -> { - if (throwable != null) { - player.handleConnectionException(status != null ? status.getAttemptedConnection() - : res.getServer(), throwable, true); - return; - } - - switch (status.getStatus()) { - // Impossible/nonsensical cases - case ALREADY_CONNECTED: - case CONNECTION_IN_PROGRESS: - // Fatal case - case CONNECTION_CANCELLED: - Component fallbackMsg = res.getMessageComponent(); - if (fallbackMsg == null) { - fallbackMsg = Component.empty(); - } - player.disconnect(status.getReasonComponent().orElse(fallbackMsg)); - break; - case SERVER_DISCONNECTED: - Component reason = status.getReasonComponent() - .orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR); - player.handleConnectionException(res.getServer(), DisconnectPacket.create(reason, - player.getProtocolVersion(), false), ((ConnectionRequestResults.Impl) status).isSafe()); - break; - case SUCCESS: - Component requestedMessage = res.getMessageComponent(); - if (requestedMessage == null) { - requestedMessage = Component.empty(); - } - if (requestedMessage != Component.empty()) { - player.sendMessage(requestedMessage); - } - break; - default: - // The only remaining value is successful (no need to do anything!) - break; - } - }, player.getConnection().eventLoop()); - } else if (event.getResult() instanceof KickedFromServerEvent.Notify res) { - if (event.kickedDuringServerConnect() && serverConnection != null) { - player.sendMessage(Identity.nil(), res.getMessageComponent()); - } else { - player.disconnect(res.getMessageComponent()); - } - } else { - // In case someone gets creative, assume we want to disconnect the player. - player.disconnect(Component.empty()); - } - } - - static { - try { - CONNECTION_FIELD = ConnectedPlayer.class.getDeclaredField("connection"); - CONNECTION_FIELD.setAccessible(true); - - BACKEND_CONNECTION_FIELD = MethodHandles.privateLookupIn(ConnectedPlayer.class, MethodHandles.lookup()) - .findSetter(ConnectedPlayer.class, "connectedServer", VelocityServerConnection.class); - - CREATE_CONNECTION_REQUEST = MethodHandles.privateLookupIn(ConnectedPlayer.class, MethodHandles.lookup()) - .findVirtual(ConnectedPlayer.class, "createConnectionRequest", - MethodType.methodType(ConnectionRequestBuilder.class, RegisteredServer.class, VelocityServerConnection.class)); - } catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException e) { - throw new ReflectionException(e); - } - } -} diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java b/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java index 4fd2548a..33d55b0e 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -54,6 +54,7 @@ import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.connection.client.InitialInboundConnection; import com.velocitypowered.proxy.connection.client.LoginInboundConnection; +import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl; import com.velocitypowered.proxy.network.Connections; import com.velocitypowered.proxy.protocol.StateRegistry; import com.velocitypowered.proxy.protocol.VelocityConnectionEvent; @@ -69,6 +70,7 @@ import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.UUID; import net.elytrium.commons.utils.reflection.ReflectionException; import net.elytrium.limboapi.LimboAPI; @@ -142,6 +144,20 @@ public void hookLoginSession(GameProfileRequestEvent event) throws Throwable { if (!connection.isClosed()) { connection.eventLoop().execute(() -> { try { + IdentifiedKey playerKey = inboundConnection.getIdentifiedKey(); + if (playerKey != null) { + if (playerKey.getSignatureHolder() == null) { + if (playerKey instanceof IdentifiedKeyImpl unlinkedKey) { + // Failsafe + if (!unlinkedKey.internalAddHolder(event.getGameProfile().getId())) { + playerKey = null; + } + } + } else if (!Objects.equals(playerKey.getSignatureHolder(), event.getGameProfile().getId())) { + playerKey = null; + } + } + // Initiate a regular connection and move over to it. ConnectedPlayer player = (ConnectedPlayer) CONNECTED_PLAYER_CONSTRUCTOR.invokeExact( this.server, @@ -149,7 +165,7 @@ public void hookLoginSession(GameProfileRequestEvent event) throws Throwable { connection, inboundConnection.getVirtualHost().orElse(null), this.onlineMode.contains(event.getUsername()), - inboundConnection.getIdentifiedKey() + playerKey ); if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { ((LoginConfirmHandler) connection.getActiveSessionHandler()).setPlayer(player); diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginTasksQueue.java b/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginTasksQueue.java index 3d04bc2a..7baa9720 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginTasksQueue.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginTasksQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -39,11 +39,11 @@ import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.permission.PermissionsSetupEvent; import com.velocitypowered.api.event.player.GameProfileRequestEvent; +import com.velocitypowered.api.event.player.PlayerClientBrandEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.permission.PermissionFunction; import com.velocitypowered.api.permission.PermissionProvider; import com.velocitypowered.api.proxy.InboundConnection; -import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; @@ -51,7 +51,6 @@ import com.velocitypowered.proxy.connection.client.ClientConfigSessionHandler; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.connection.client.InitialConnectSessionHandler; -import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl; import com.velocitypowered.proxy.network.Connections; import com.velocitypowered.proxy.protocol.StateRegistry; import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket; @@ -86,9 +85,10 @@ public class LoginTasksQueue { private static final MethodHandle INITIAL_CONNECT_SESSION_HANDLER_CONSTRUCTOR; private static final Field MC_CONNECTION_FIELD; private static final MethodHandle CONNECT_TO_INITIAL_SERVER_METHOD; - private static final MethodHandle PLAYER_KEY_FIELD; private static final Field LOGIN_STATE_FIELD; private static final Field CONNECTED_PLAYER_FIELD; + private static final MethodHandle SET_CLIENT_BRAND; + private static final Field BRAND_CHANNEL; private final LimboAPI plugin; private final Object handler; @@ -210,22 +210,6 @@ private void initialize(MinecraftConnection connection) throws Throwable { this.plugin.fixCompressor(pipeline, connection.getProtocolVersion()); } - if (this.player.getIdentifiedKey() != null) { - IdentifiedKey playerKey = this.player.getIdentifiedKey(); - if (playerKey.getSignatureHolder() == null) { - if (playerKey instanceof IdentifiedKeyImpl unlinkedKey) { - // Failsafe - if (!unlinkedKey.internalAddHolder(this.player.getUniqueId())) { - PLAYER_KEY_FIELD.invokeExact(this.player, (IdentifiedKey) null); - } - } - } else { - if (!Objects.equals(playerKey.getSignatureHolder(), this.player.getUniqueId())) { - PLAYER_KEY_FIELD.invokeExact(this.player, (IdentifiedKey) null); - } - } - } - Logger logger = LimboAPI.getLogger(); this.server.getEventManager().fire(new LoginEvent(this.player)).thenAcceptAsync(event -> { if (connection.isClosed()) { @@ -269,8 +253,28 @@ private void connectToServer(Logger logger, ConnectedPlayer player, MinecraftCon return; // Re-running this method due to synchronization with the client } else { - this.plugin.setActiveSessionHandler(connection, StateRegistry.CONFIG, - new ClientConfigSessionHandler(this.server, this.player)); + ClientConfigSessionHandler configHandler = new ClientConfigSessionHandler(this.server, this.player); + + // 1.20.2+ client doesn't send ClientSettings and brand while switching state, + // so we need to use packets that was sent during LOGIN completion. + if (connection.getActiveSessionHandler() instanceof LimboSessionHandlerImpl sessionHandler) { + if (sessionHandler.getSettings() != null) { + this.player.setClientSettings(sessionHandler.getSettings()); + } + + // TODO: also queue non-vanilla plugin messages? + if (sessionHandler.getBrand() != null) { + try { + this.server.getEventManager().fireAndForget(new PlayerClientBrandEvent(this.player, sessionHandler.getBrand())); + SET_CLIENT_BRAND.invokeExact(this.player, sessionHandler.getBrand()); + BRAND_CHANNEL.set(configHandler, "minecraft:brand"); + } catch (Throwable e) { + throw new ReflectionException(e); + } + } + } + + this.plugin.setActiveSessionHandler(connection, StateRegistry.CONFIG, configHandler); } this.server.getEventManager().fire(new PostLoginEvent(this.player)).thenAccept(postLoginEvent -> { @@ -309,8 +313,11 @@ private void connectToServer(Logger logger, ConnectedPlayer player, MinecraftCon MC_CONNECTION_FIELD = AuthSessionHandler.class.getDeclaredField("mcConnection"); MC_CONNECTION_FIELD.setAccessible(true); - PLAYER_KEY_FIELD = MethodHandles.privateLookupIn(ConnectedPlayer.class, MethodHandles.lookup()) - .findSetter(ConnectedPlayer.class, "playerKey", IdentifiedKey.class); + SET_CLIENT_BRAND = MethodHandles.privateLookupIn(ConnectedPlayer.class, MethodHandles.lookup()) + .findVirtual(ConnectedPlayer.class, "setClientBrand", MethodType.methodType(void.class, String.class)); + + BRAND_CHANNEL = ClientConfigSessionHandler.class.getDeclaredField("brandChannel"); + BRAND_CHANNEL.setAccessible(true); } catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException e) { throw new ReflectionException(e); } diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/login/confirmation/LoginConfirmHandler.java b/plugin/src/main/java/net/elytrium/limboapi/injection/login/confirmation/LoginConfirmHandler.java index 86904276..c8a1fc3a 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/login/confirmation/LoginConfirmHandler.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/login/confirmation/LoginConfirmHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LegacyPlayerListItemHook.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LegacyPlayerListItemHook.java index 4ede964f..2d29d0c6 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LegacyPlayerListItemHook.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LegacyPlayerListItemHook.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LimboCompressDecoder.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LimboCompressDecoder.java index c0d4a43b..26f6df37 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LimboCompressDecoder.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/LimboCompressDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftDiscardCompressDecoder.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftDiscardCompressDecoder.java index 12576733..c31252a3 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftDiscardCompressDecoder.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftDiscardCompressDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftLimitedCompressDecoder.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftLimitedCompressDecoder.java index ec1dc0a6..3800f5f5 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftLimitedCompressDecoder.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/MinecraftLimitedCompressDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/PreparedPacketImpl.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/PreparedPacketImpl.java index 4f8fbf22..0d4be8e0 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/PreparedPacketImpl.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/PreparedPacketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/ServerLoginSuccessHook.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/ServerLoginSuccessHook.java index a6aaf3c1..b7d72382 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/ServerLoginSuccessHook.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/ServerLoginSuccessHook.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/UpsertPlayerInfoHook.java b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/UpsertPlayerInfoHook.java index 2f74e802..04c1c414 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/packet/UpsertPlayerInfoHook.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/packet/UpsertPlayerInfoHook.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/material/Biome.java b/plugin/src/main/java/net/elytrium/limboapi/material/Biome.java index d22a884f..60d4b1f1 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/material/Biome.java +++ b/plugin/src/main/java/net/elytrium/limboapi/material/Biome.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/LimboProtocol.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/LimboProtocol.java index 9fea53b0..22ae0809 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/LimboProtocol.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/LimboProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BiomeStorage118.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BiomeStorage118.java index 5553d870..051dd8b2 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BiomeStorage118.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BiomeStorage118.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage17.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage17.java index 6394614e..9cf0facc 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage17.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage17.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage19.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage19.java index f400e87f..d47f88ad 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage19.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/BlockStorage19.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/StorageUtils.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/StorageUtils.java index 268a5548..e39defbb 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/data/StorageUtils.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/data/StorageUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/PacketFactoryImpl.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/PacketFactoryImpl.java index 42a9a91c..aff5b357 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/PacketFactoryImpl.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/PacketFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveOnGroundOnlyPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveOnGroundOnlyPacket.java index 7968c368..04de82f0 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveOnGroundOnlyPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveOnGroundOnlyPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePacket.java index 1a41614a..b4cc2fb6 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePositionOnlyPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePositionOnlyPacket.java index 719967bb..bd71a6a3 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePositionOnlyPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MovePositionOnlyPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveRotationOnlyPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveRotationOnlyPacket.java index b2467e65..a770851d 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveRotationOnlyPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/MoveRotationOnlyPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/PlayerChatSessionPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/PlayerChatSessionPacket.java index 54520b17..7fe2e1c0 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/PlayerChatSessionPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/PlayerChatSessionPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -21,20 +21,15 @@ import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; -import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; import java.util.UUID; -import net.elytrium.commons.utils.reflection.ReflectionException; +import net.elytrium.limboapi.Settings; @SuppressWarnings("unused") public class PlayerChatSessionPacket implements MinecraftPacket { - public static final MethodHandle PLAYER_FIELD; - private UUID holderId; private IdentifiedKey playerKey; @@ -52,14 +47,9 @@ public void encode(ByteBuf byteBuf, ProtocolUtils.Direction direction, ProtocolV @Override public boolean handle(MinecraftSessionHandler minecraftSessionHandler) { - // LimboAPI hook - discard if there is no identified key or unmatched UUID - if (minecraftSessionHandler instanceof ClientPlaySessionHandler playSessionHandler) { - try { - ConnectedPlayer player = (ConnectedPlayer) PLAYER_FIELD.invokeExact(playSessionHandler); - return player.getIdentifiedKey() == null || player.getUniqueId() != this.holderId; - } catch (Throwable e) { - throw new ReflectionException(e); - } + // LimboAPI hook - skip server-side signature verification if enabled + if (minecraftSessionHandler instanceof ClientPlaySessionHandler) { + return Settings.IMP.MAIN.FORCE_DISABLE_MODERN_CHAT_SIGNING; } return false; @@ -81,13 +71,4 @@ public void setPlayerKey(IdentifiedKey playerKey) { this.playerKey = playerKey; } - static { - try { - PLAYER_FIELD = MethodHandles.privateLookupIn(ClientPlaySessionHandler.class, MethodHandles.lookup()) - .findGetter(ClientPlaySessionHandler.class, "player", ConnectedPlayer.class); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new ReflectionException(e); - } - } - } diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/TeleportConfirmPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/TeleportConfirmPacket.java index ef28f3a9..6157c428 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/TeleportConfirmPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/c2s/TeleportConfirmPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChangeGameStatePacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChangeGameStatePacket.java index 2f0329e3..366342c5 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChangeGameStatePacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChangeGameStatePacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChunkDataPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChunkDataPacket.java index a94f7bf3..6b0345f1 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChunkDataPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/ChunkDataPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/DefaultSpawnPositionPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/DefaultSpawnPositionPacket.java index 09624c86..ff9fd778 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/DefaultSpawnPositionPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/DefaultSpawnPositionPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/MapDataPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/MapDataPacket.java index 37d93b73..295d4d0f 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/MapDataPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/MapDataPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PlayerAbilitiesPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PlayerAbilitiesPacket.java index 606e780e..8b51f053 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PlayerAbilitiesPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PlayerAbilitiesPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PositionRotationPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PositionRotationPacket.java index f9391db0..d775d8cf 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PositionRotationPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/PositionRotationPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetExperiencePacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetExperiencePacket.java index 04e40118..db9d0251 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetExperiencePacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetExperiencePacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetSlotPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetSlotPacket.java index 4394fe4b..a8886875 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetSlotPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/SetSlotPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/TimeUpdatePacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/TimeUpdatePacket.java index f512194e..e0dd09a5 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/TimeUpdatePacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/TimeUpdatePacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateTagsPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateTagsPacket.java index 179d778d..55658f21 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateTagsPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateTagsPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateViewPositionPacket.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateViewPositionPacket.java index 3252c626..ae087659 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateViewPositionPacket.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/packets/s2c/UpdateViewPositionPacket.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/protocol/util/NetworkSection.java b/plugin/src/main/java/net/elytrium/limboapi/protocol/util/NetworkSection.java index ba9afdc5..1a2c6d85 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/protocol/util/NetworkSection.java +++ b/plugin/src/main/java/net/elytrium/limboapi/protocol/util/NetworkSection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/CachedPackets.java b/plugin/src/main/java/net/elytrium/limboapi/server/CachedPackets.java index ceba8907..b4ebb43f 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/CachedPackets.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/CachedPackets.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/LimboImpl.java b/plugin/src/main/java/net/elytrium/limboapi/server/LimboImpl.java index b5822602..81188bbb 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/LimboImpl.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/LimboImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -34,6 +34,7 @@ import com.velocitypowered.proxy.connection.ConnectionTypes; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; +import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.connection.registry.DimensionInfo; import com.velocitypowered.proxy.network.Connections; @@ -42,6 +43,7 @@ import com.velocitypowered.proxy.protocol.StateRegistry; import com.velocitypowered.proxy.protocol.VelocityConnectionEvent; import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket; +import com.velocitypowered.proxy.protocol.packet.BossBarPacket; import com.velocitypowered.proxy.protocol.packet.JoinGamePacket; import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket; import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket; @@ -52,6 +54,7 @@ import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket; import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket; import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket; +import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; @@ -71,6 +74,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.LongAdder; @@ -179,7 +183,8 @@ protected void refresh() { JoinGamePacket legacyJoinGame = this.createLegacyJoinGamePacket(); JoinGamePacket joinGame = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_16); JoinGamePacket joinGame1162 = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_16_2); - JoinGamePacket joinGameModern = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_18_2); + JoinGamePacket joinGame1182 = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_18_2); + JoinGamePacket joinGame119 = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_19); JoinGamePacket joinGame1191 = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_19_1); JoinGamePacket joinGame1194 = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_19_4); JoinGamePacket joinGame120 = this.createJoinGamePacket(ProtocolVersion.MINECRAFT_1_20); @@ -188,7 +193,8 @@ protected void refresh() { .prepare(legacyJoinGame, ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MINECRAFT_1_15_2) .prepare(joinGame, ProtocolVersion.MINECRAFT_1_16, ProtocolVersion.MINECRAFT_1_16_1) .prepare(joinGame1162, ProtocolVersion.MINECRAFT_1_16_2, ProtocolVersion.MINECRAFT_1_18) - .prepare(joinGameModern, ProtocolVersion.MINECRAFT_1_18_2, ProtocolVersion.MINECRAFT_1_19) + .prepare(joinGame1182, ProtocolVersion.MINECRAFT_1_18_2, ProtocolVersion.MINECRAFT_1_18_2) + .prepare(joinGame119, ProtocolVersion.MINECRAFT_1_19, ProtocolVersion.MINECRAFT_1_19) .prepare(joinGame1191, ProtocolVersion.MINECRAFT_1_19_1, ProtocolVersion.MINECRAFT_1_19_3) .prepare(joinGame1194, ProtocolVersion.MINECRAFT_1_19_4, ProtocolVersion.MINECRAFT_1_19_4) .prepare(joinGame120, ProtocolVersion.MINECRAFT_1_20); @@ -200,8 +206,10 @@ protected void refresh() { .forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_16, ProtocolVersion.MINECRAFT_1_16_1)); this.createFastClientServerSwitch(joinGame1162, ProtocolVersion.MINECRAFT_1_16_2) .forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_16_2, ProtocolVersion.MINECRAFT_1_18)); - this.createFastClientServerSwitch(joinGameModern, ProtocolVersion.MINECRAFT_1_18_2) - .forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_18_2, ProtocolVersion.MINECRAFT_1_19)); + this.createFastClientServerSwitch(joinGame1182, ProtocolVersion.MINECRAFT_1_18_2) + .forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_18_2, ProtocolVersion.MINECRAFT_1_18_2)); + this.createFastClientServerSwitch(joinGame119, ProtocolVersion.MINECRAFT_1_19) + .forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_19, ProtocolVersion.MINECRAFT_1_19)); this.createFastClientServerSwitch(joinGame1191, ProtocolVersion.MINECRAFT_1_19_1) .forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_19_1, ProtocolVersion.MINECRAFT_1_19_3)); this.createFastClientServerSwitch(joinGame1194, ProtocolVersion.MINECRAFT_1_19_4) @@ -218,7 +226,7 @@ protected void refresh() { this.addPostJoin(this.postJoinPackets); this.configTransitionPackets = this.plugin.createPreparedPacket() - .prepare(new StartUpdatePacket(), ProtocolVersion.MINECRAFT_1_20_2) + .prepare(StartUpdatePacket.INSTANCE, ProtocolVersion.MINECRAFT_1_20_2) .build(); this.configPackets = this.plugin.createConfigPreparedPacket(); @@ -226,7 +234,7 @@ protected void refresh() { if (this.shouldUpdateTags) { this.configPackets.prepare(this::createTagsUpdate, ProtocolVersion.MINECRAFT_1_20_2); } - this.configPackets.prepare(new FinishedUpdatePacket(), ProtocolVersion.MINECRAFT_1_20_2); + this.configPackets.prepare(FinishedUpdatePacket.INSTANCE, ProtocolVersion.MINECRAFT_1_20_2); this.configPackets.build(); this.firstChunks = this.createFirstChunks(); @@ -289,6 +297,25 @@ public void spawnPlayer(Player apiPlayer, LimboSessionHandler handler) { boolean shouldSpawnPlayerImmediately = true; + // Discard information from previous server + if (player.getConnection().getActiveSessionHandler() instanceof ClientPlaySessionHandler sessionHandler) { + connection.eventLoop().execute(() -> { + player.getTabList().clearAll(); + for (UUID serverBossBar : sessionHandler.getServerBossBars()) { + player.getConnection().delayedWrite(BossBarPacket.createRemovePacket(serverBossBar, null)); + } + sessionHandler.getServerBossBars().clear(); + + if (player.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_8)) { + player.getConnection().delayedWrite(GenericTitlePacket.constructTitlePacket( + GenericTitlePacket.ActionType.RESET, player.getProtocolVersion())); + player.clearPlayerListHeaderAndFooter(); + } + + player.getConnection().flush(); + }); + } + if (connection.getState() != this.localStateRegistry) { if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) < 0) { connection.eventLoop().execute(() -> connection.setState(this.localStateRegistry)); @@ -324,7 +351,7 @@ protected void spawnPlayerLocal(Class handlerClas if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { if (connection.getState() != StateRegistry.CONFIG) { if (this.shouldRejoin) { - // Switch to PLAY state + // Switch to CONFIG state connection.write(this.configTransitionPackets); // Continue transition on the handler side @@ -435,6 +462,7 @@ protected void onSpawn(Class handlerClass, MinecraftConnection connection, ConnectedPlayer player, LimboSessionHandlerImpl sessionHandler) { if (this.plugin.isLimboJoined(player)) { if (this.shouldRejoin) { + sessionHandler.setMitigateChatSessionDesync(true); if (connection.getType() == ConnectionTypes.LEGACY_FORGE) { connection.delayedWrite(this.safeRejoinPackets); } else { @@ -444,6 +472,7 @@ protected void onSpawn(Class handlerClass, connection.delayedWrite(this.postJoinPackets); } } else { + sessionHandler.setMitigateChatSessionDesync(true); connection.delayedWrite(this.joinPackets); } @@ -544,10 +573,6 @@ public Limbo setGameMode(GameMode gameMode) { return this; } - protected boolean isShouldRejoin() { - return this.shouldRejoin; - } - @Override public Limbo setShouldRejoin(boolean shouldRejoin) { this.shouldRejoin = shouldRejoin; diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/LimboPlayerImpl.java b/plugin/src/main/java/net/elytrium/limboapi/server/LimboPlayerImpl.java index 88e7cd1b..59380185 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/LimboPlayerImpl.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/LimboPlayerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -236,8 +236,12 @@ public void disconnect() { if (this.connection.getActiveSessionHandler() == this.sessionHandler) { this.sessionHandler.disconnect(() -> { if (this.plugin.hasLoginQueue(this.player)) { - this.sessionHandler.disconnected(); - this.plugin.getLoginQueue(this.player).next(); + if (this.connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { + this.sessionHandler.disconnectToConfig(() -> this.plugin.getLoginQueue(this.player).next()); + } else { + this.sessionHandler.disconnected(); + this.plugin.getLoginQueue(this.player).next(); + } } else { RegisteredServer server = this.sessionHandler.getPreviousServer(); if (server != null) { @@ -257,9 +261,16 @@ public void disconnect(RegisteredServer server) { if (this.connection.getActiveSessionHandler() == this.sessionHandler) { this.sessionHandler.disconnect(() -> { if (this.plugin.hasLoginQueue(this.player)) { - this.sessionHandler.disconnected(); - this.plugin.setNextServer(this.player, server); - this.plugin.getLoginQueue(this.player).next(); + if (this.connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { + this.sessionHandler.disconnectToConfig(() -> { + this.plugin.setNextServer(this.player, server); + this.plugin.getLoginQueue(this.player).next(); + }); + } else { + this.sessionHandler.disconnected(); + this.plugin.setNextServer(this.player, server); + this.plugin.getLoginQueue(this.player).next(); + } } else { this.sendToRegisteredServer(server); } @@ -285,6 +296,13 @@ private void sendToRegisteredServer(RegisteredServer server) { this.player.createConnectionRequest(server).fireAndForget(); }); } else { + if (this.connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_1) <= 0) { + this.connection.delayedWrite(new LegacyPlayerListItemPacket( + LegacyPlayerListItemPacket.REMOVE_PLAYER, + List.of(new LegacyPlayerListItemPacket.Item(this.player.getUniqueId())) + )); + } + this.sessionHandler.disconnected(); this.player.createConnectionRequest(server).fireAndForget(); } diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/LimboSessionHandlerImpl.java b/plugin/src/main/java/net/elytrium/limboapi/server/LimboSessionHandlerImpl.java index 3bd65551..3e327080 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/LimboSessionHandlerImpl.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/LimboSessionHandlerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -26,7 +26,9 @@ import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.network.Connections; import com.velocitypowered.proxy.protocol.MinecraftPacket; +import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.StateRegistry; +import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket; import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket; import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket; import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket; @@ -36,6 +38,8 @@ import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket; import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket; import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket; +import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; +import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelPipeline; import io.netty.handler.timeout.ReadTimeoutHandler; @@ -78,7 +82,10 @@ public class LimboSessionHandlerImpl implements MinecraftSessionHandler { private final CompletableFuture chatSession = new CompletableFuture<>(); private LimboPlayer limboPlayer; + private ClientSettingsPacket settings; + private String brand; private ScheduledFuture keepAliveTask; + private ScheduledFuture chatSessionTimeoutTask; private long keepAliveKey; private boolean keepAlivePending; private long keepAliveSentTime; @@ -87,6 +94,7 @@ public class LimboSessionHandlerImpl implements MinecraftSessionHandler { private boolean loaded; private boolean switching; private boolean disconnecting; + private boolean mitigateChatSessionDesync; public LimboSessionHandlerImpl(LimboAPI plugin, LimboImpl limbo, ConnectedPlayer player, LimboSessionHandler callback, StateRegistry originalState, MinecraftSessionHandler originalHandler, @@ -100,6 +108,11 @@ public LimboSessionHandlerImpl(LimboAPI plugin, LimboImpl limbo, ConnectedPlayer this.previousServer = previousServer; this.limboName = limboName; this.loaded = player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_18_2) < 0; + + if (originalHandler instanceof LimboSessionHandlerImpl sessionHandler) { + this.settings = sessionHandler.getSettings(); + this.brand = sessionHandler.getBrand(); + } } public void onConfig(LimboPlayer player) { @@ -153,16 +166,20 @@ public void disconnectToConfig(Runnable runnable) { this.switching = true; this.loaded = false; - if (this.player.isOnlineMode() && this.limbo.isShouldRejoin()) { + if (this.player.isOnlineMode() && this.mitigateChatSessionDesync) { // As a client sends PlayerChatSessionPacket asynchronously, // we should wait for it to ensure that it will not be sent // while switching CONFIG to PLAY state, and so didn't break the connection + if (!this.chatSession.isDone() && this.chatSessionTimeoutTask == null) { + this.chatSessionTimeoutTask = this.player.getConnection().eventLoop() + .schedule(() -> this.chatSession.complete(this), Settings.IMP.MAIN.CHAT_SESSION_PACKET_TIMEOUT, TimeUnit.MILLISECONDS); + } this.chatSession.thenRunAsync(() -> { - this.player.getConnection().write(new StartUpdatePacket()); + this.player.getConnection().write(StartUpdatePacket.INSTANCE); this.configTransition.thenRun(this::disconnected).thenRun(runnable); }, this.player.getConnection().eventLoop()); } else { - this.player.getConnection().write(new StartUpdatePacket()); + this.player.getConnection().write(StartUpdatePacket.INSTANCE); this.configTransition.thenRun(this::disconnected).thenRun(runnable); } } @@ -320,11 +337,14 @@ public void handleUnknown(ByteBuf packet) { @Override public void handleGeneric(MinecraftPacket packet) { - if (packet instanceof PlayerChatSessionPacket) { + if (packet instanceof ClientSettingsPacket clientSettings) { + this.settings = clientSettings; + } else if (packet instanceof PlayerChatSessionPacket) { + if (this.chatSessionTimeoutTask != null) { + this.chatSessionTimeoutTask.cancel(true); + } this.chatSession.complete(this); - } - - if (packet instanceof PluginMessagePacket pluginMessage) { + } else if (packet instanceof PluginMessagePacket pluginMessage) { int singleLength = pluginMessage.content().readableBytes() + pluginMessage.getChannel().length() * 4; this.genericBytes += singleLength; if (singleLength > Settings.IMP.MAIN.MAX_SINGLE_GENERIC_PACKET_LENGTH) { @@ -334,6 +354,16 @@ public void handleGeneric(MinecraftPacket packet) { this.kickTooBigPacket("generic (PluginMessage packet (custom payload)), multi", this.genericBytes); return; } + + if (this.player.getConnection().getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0 + && PluginMessageUtil.isMcBrand(pluginMessage)) { + try { + this.brand = ProtocolUtils.readString(pluginMessage.content().slice(), Settings.IMP.MAIN.MAX_BRAND_NAME_LENGTH); + } catch (QuietDecoderException ignored) { + this.kickTooBigPacket("brand name", pluginMessage.content().readableBytes()); + return; + } + } } this.callback.onGeneric(packet); @@ -422,6 +452,18 @@ public int getPing() { return this.ping; } + public void setMitigateChatSessionDesync(boolean mitigateChatSessionDesync) { + this.mitigateChatSessionDesync = mitigateChatSessionDesync; + } + + public ClientSettingsPacket getSettings() { + return this.settings; + } + + public String getBrand() { + return this.brand; + } + static { try { TEARDOWN_METHOD = MethodHandles.privateLookupIn(ConnectedPlayer.class, MethodHandles.lookup()) diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlock.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlock.java index a77d121c..6df957e2 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlock.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlockEntity.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlockEntity.java index 1915bf29..8e6919c6 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlockEntity.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleBlockEntity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleItem.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleItem.java index 96e20937..28c5da2f 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleItem.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleItem.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleTagManager.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleTagManager.java index 93ccff7d..c8f881d6 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleTagManager.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleTagManager.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleWorld.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleWorld.java index 19a7086e..d80fd54e 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleWorld.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/SimpleWorld.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunk.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunk.java index 3d0827ba..77895e70 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunk.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunkSnapshot.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunkSnapshot.java index f679cae5..2de6bb2c 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunkSnapshot.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleChunkSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleLightSection.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleLightSection.java index 27b28ea8..6799c21d 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleLightSection.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleLightSection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleSection.java b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleSection.java index d76b6b96..92525881 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleSection.java +++ b/plugin/src/main/java/net/elytrium/limboapi/server/world/chunk/SimpleSection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayIntObjectMap.java b/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayIntObjectMap.java index 92b23daa..680746f4 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayIntObjectMap.java +++ b/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayIntObjectMap.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayObject2IntMap.java b/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayObject2IntMap.java index 9d9f43db..4c41e04d 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayObject2IntMap.java +++ b/plugin/src/main/java/net/elytrium/limboapi/utils/OverlayObject2IntMap.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/utils/ReloadListener.java b/plugin/src/main/java/net/elytrium/limboapi/utils/ReloadListener.java index 3af8ec2e..69557f5e 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/utils/ReloadListener.java +++ b/plugin/src/main/java/net/elytrium/limboapi/utils/ReloadListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/plugin/src/main/java/net/elytrium/limboapi/utils/SetIsObjectSet.java b/plugin/src/main/java/net/elytrium/limboapi/utils/SetIsObjectSet.java index 50e2a235..587688c3 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/utils/SetIsObjectSet.java +++ b/plugin/src/main/java/net/elytrium/limboapi/utils/SetIsObjectSet.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 - 2023 Elytrium + * Copyright (C) 2021 - 2024 Elytrium * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by