From bb803a90f1505b0cef3c388c46bba8af0725b110 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Sun, 28 Jul 2024 01:56:56 +0800 Subject: [PATCH] [release-skip] Move protocol config --- ...006-Leaves-Server-Config-And-Command.patch | 18 ++++++++---- .../server/0007-Leaves-Protocol-Core.patch | 9 ++++-- .../server/0059-Leaves-carpet-support.patch | 4 +-- patches/server/0074-Bladeren-Protocol.patch | 4 +-- patches/server/0114-Servux-Protocol.patch | 28 +++++++++---------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/patches/server/0006-Leaves-Server-Config-And-Command.patch b/patches/server/0006-Leaves-Server-Config-And-Command.patch index fe19a511..07a9b9c0 100644 --- a/patches/server/0006-Leaves-Server-Config-And-Command.patch +++ b/patches/server/0006-Leaves-Server-Config-And-Command.patch @@ -85,10 +85,10 @@ index c2c421b1caf76b40542fdc436801accbe97a38cb..29f139fb4d70a9a362ac0a30579eb0b4 .withRequiredArg() diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..403c5f4f374a7e7525f9a81c9e70b6b2791db248 +index 0000000000000000000000000000000000000000..c97284e726b707699af98c999423d8383c7a5c87 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java -@@ -0,0 +1,930 @@ +@@ -0,0 +1,936 @@ +package org.leavesmc.leaves; + +import com.destroystokyo.paper.util.SneakyThrow; @@ -789,7 +789,8 @@ index 0000000000000000000000000000000000000000..403c5f4f374a7e7525f9a81c9e70b6b2 + + // Leaves end - protocol - syncmatica + -+ @GlobalConfig(name = "pca-sync-protocol", category = "protocol", verify = PcaVerify.class) ++ @RemovedConfig(name = "pca-sync-protocol", category = "protocol", transform = true) ++ @GlobalConfig(name = "pca-sync-protocol", category = {"protocol", "pca"}, verify = PcaVerify.class) + public static boolean pcaSyncProtocol = false; + + public static class PcaVerify extends ConfigVerify.BooleanConfigVerify { @@ -802,7 +803,8 @@ index 0000000000000000000000000000000000000000..403c5f4f374a7e7525f9a81c9e70b6b2 + } + } + -+ @GlobalConfig(name = "pca-sync-player-entity", category = "protocol", verify = PcaPlayerEntityVerify.class) ++ @RemovedConfig(name = "pca-sync-player-entity", category = "protocol", convert = PcaPlayerEntityVerify.class, transform = true) ++ @GlobalConfig(name = "pca-sync-player-entity", category = {"protocol", "pca"}, verify = PcaPlayerEntityVerify.class) + public static PcaPlayerEntityType pcaSyncPlayerEntity = PcaPlayerEntityType.OPS; + + public enum PcaPlayerEntityType { @@ -843,8 +845,12 @@ index 0000000000000000000000000000000000000000..403c5f4f374a7e7525f9a81c9e70b6b2 + @GlobalConfig(name = "xaero-map-server-id", category = "protocol", verify = ConfigVerify.IntConfigVerify.class) + public static int xaeroMapServerID = new Random().nextInt(); + -+ @GlobalConfig(name = "servux-protocol", category = "protocol") -+ public static boolean servuxProtocol = false; ++ @RemovedConfig(name = "servux-protocol", category = "protocol", transform = true) ++ @GlobalConfig(name = "structure-protocol", category = {"protocol", "servux"}) ++ public static boolean servuxStructureProtocol = false; ++ ++ @GlobalConfig(name = "entity-protocol", category = {"protocol", "servux"}) ++ public static boolean servuxEntityProtocol = false; + + @GlobalConfig(name = "leaves-carpet-support", category = "protocol") + public static boolean leavesCarpetSupport = false; diff --git a/patches/server/0007-Leaves-Protocol-Core.patch b/patches/server/0007-Leaves-Protocol-Core.patch index 0addcb21..665b22d1 100644 --- a/patches/server/0007-Leaves-Protocol-Core.patch +++ b/patches/server/0007-Leaves-Protocol-Core.patch @@ -689,13 +689,14 @@ index 0000000000000000000000000000000000000000..9d71f8e6af24301bedf60f5c87e0bb3c +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java new file mode 100644 -index 0000000000000000000000000000000000000000..f54381eec7ec0ffde39e87b39b16e02d3ed1b419 +index 0000000000000000000000000000000000000000..72fb1e6517e266146cb1828875e7b7e6ae9b140d --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java -@@ -0,0 +1,47 @@ +@@ -0,0 +1,52 @@ +package org.leavesmc.leaves.protocol.core; + +import io.netty.buffer.ByteBuf; ++import io.papermc.paper.ServerBuildInfo; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; @@ -712,6 +713,10 @@ index 0000000000000000000000000000000000000000..f54381eec7ec0ffde39e87b39b16e02d + + private static final Function bufDecorator = RegistryFriendlyByteBuf.decorator(MinecraftServer.getServer().registryAccess()); + ++ public static String buildProtocolVersion(String protocol) { ++ return protocol + "-leaves-" + ServerBuildInfo.buildInfo().asString(ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); ++ } ++ + public static void sendEmptyPayloadPacket(ServerPlayer player, ResourceLocation id) { + player.connection.send(new ClientboundCustomPayloadPacket(new LeavesProtocolManager.EmptyPayload(id))); + } diff --git a/patches/server/0059-Leaves-carpet-support.patch b/patches/server/0059-Leaves-carpet-support.patch index 96f0f4d7..da35798c 100644 --- a/patches/server/0059-Leaves-carpet-support.patch +++ b/patches/server/0059-Leaves-carpet-support.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Leaves carpet support diff --git a/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..00f6fe8b6bcb5f0b3246ea9264f5e5993271d251 +index 0000000000000000000000000000000000000000..3b6801435790fd892ece3ba7d89499eec29626ff --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java @@ -0,0 +1,120 @@ @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00f6fe8b6bcb5f0b3246ea9264f5e599 +public class CarpetServerProtocol { + + public static final String PROTOCOL_ID = "carpet"; -+ public static final String VERSION = "leaves-carpet-1.0.0"; ++ public static final String VERSION = ProtocolUtils.buildProtocolVersion(PROTOCOL_ID); + + private static final ResourceLocation HELLO_ID = CarpetServerProtocol.id("hello"); + diff --git a/patches/server/0074-Bladeren-Protocol.patch b/patches/server/0074-Bladeren-Protocol.patch index fd8af844..35d88956 100644 --- a/patches/server/0074-Bladeren-Protocol.patch +++ b/patches/server/0074-Bladeren-Protocol.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Bladeren Protocol diff --git a/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..4d9285d69724e8600fd7a3f9a6c31ecd579de6ad +index 0000000000000000000000000000000000000000..318a1a42c43688cc2711c3b902e7302e26c9a83e --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java @@ -0,0 +1,150 @@ @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..4d9285d69724e8600fd7a3f9a6c31ecd +public class BladerenProtocol { + + public static final String PROTOCOL_ID = "bladeren"; -+ public static final String PROTOCOL_VERSION = "1.0.0"; ++ public static final String PROTOCOL_VERSION = ProtocolUtils.buildProtocolVersion(PROTOCOL_ID); + + private static final ResourceLocation HELLO_ID = id("hello"); + private static final ResourceLocation FEATURE_MODIFY_ID = id("feature_modify"); diff --git a/patches/server/0114-Servux-Protocol.patch b/patches/server/0114-Servux-Protocol.patch index 3e0e7012..a5274b4e 100644 --- a/patches/server/0114-Servux-Protocol.patch +++ b/patches/server/0114-Servux-Protocol.patch @@ -158,7 +158,7 @@ index 0000000000000000000000000000000000000000..3a0e790f0d8e6866950601f9936984a8 +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4eb6189a9 +index 0000000000000000000000000000000000000000..ffa483d369760faeb73555f9a93dac5f38c24530 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java @@ -0,0 +1,295 @@ @@ -200,7 +200,7 @@ index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4 + + @ProtocolHandler.PlayerJoin + public static void onPlayerLoggedIn(ServerPlayer player) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxEntityProtocol) { + return; + } + @@ -209,7 +209,7 @@ index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4 + + @ProtocolHandler.PayloadReceiver(payload = EntityDataPayload.class, payloadId = "entity_data") + public static void onPacketReceive(ServerPlayer player, EntityDataPayload payload) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxEntityProtocol) { + return; + } + @@ -275,7 +275,7 @@ index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4 + } + + public static void sendPacket(ServerPlayer player, EntityDataPayload payload) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxEntityProtocol) { + return; + } + @@ -459,21 +459,21 @@ index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4 +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..f80678c0abc38c72b63a32450bd726268d208d6a +index 0000000000000000000000000000000000000000..ea83d25b76f2e4814c82c1010ba4c0bca0758840 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java @@ -0,0 +1,17 @@ +package org.leavesmc.leaves.protocol.servux; + -+import io.papermc.paper.ServerBuildInfo; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +public class ServuxProtocol { + + public static final String PROTOCOL_ID = "servux"; -+ public static final String SERVUX_STRING = "servux-leaves-" + ServerBuildInfo.buildInfo().asString(ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); ++ public static final String SERVUX_STRING = ProtocolUtils.buildProtocolVersion(PROTOCOL_ID); + + @Contract("_ -> new") + public static @NotNull ResourceLocation id(String path) { @@ -482,7 +482,7 @@ index 0000000000000000000000000000000000000000..f80678c0abc38c72b63a32450bd72626 +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c7e1c290c +index 0000000000000000000000000000000000000000..306eabf5ce384c863fc986a3a446c101b4494b47 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java @@ -0,0 +1,465 @@ @@ -544,7 +544,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c + + @ProtocolHandler.PayloadReceiver(payload = StructuresPayload.class, payloadId = "structures") + public static void onPacketReceive(ServerPlayer player, StructuresPayload payload) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxStructureProtocol) { + return; + } + @@ -560,7 +560,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c + + @ProtocolHandler.PlayerJoin + public static void onPlayerLoggedIn(ServerPlayer player) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxStructureProtocol) { + return; + } + @@ -569,7 +569,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c + + @ProtocolHandler.PlayerLeave + public static void onPlayerLoggedOut(@NotNull ServerPlayer player) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxStructureProtocol) { + return; + } + @@ -578,7 +578,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c + + @ProtocolHandler.Ticker + public static void tick() { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxStructureProtocol) { + return; + } + @@ -602,7 +602,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c + } + + public static void onStartedWatchingChunk(ServerPlayer player, LevelChunk chunk) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxStructureProtocol) { + return; + } + @@ -934,7 +934,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c + } + + public static void sendPacket(ServerPlayer player, StructuresPayload payload) { -+ if (!LeavesConfig.servuxProtocol) { ++ if (!LeavesConfig.servuxStructureProtocol) { + return; + } +