Skip to content

Commit

Permalink
[release-skip] Move protocol config
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jul 27, 2024
1 parent 86d8553 commit bb803a9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
18 changes: 12 additions & 6 deletions patches/server/0006-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions patches/server/0007-Leaves-Protocol-Core.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -712,6 +713,10 @@ index 0000000000000000000000000000000000000000..f54381eec7ec0ffde39e87b39b16e02d
+
+ private static final Function<ByteBuf, RegistryFriendlyByteBuf> 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)));
+ }
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0059-Leaves-carpet-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand All @@ -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");
+
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0074-Bladeren-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand All @@ -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");
Expand Down
28 changes: 14 additions & 14 deletions patches/server/0114-Servux-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand Down Expand Up @@ -200,7 +200,7 @@ index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4
+
+ @ProtocolHandler.PlayerJoin
+ public static void onPlayerLoggedIn(ServerPlayer player) {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxEntityProtocol) {
+ return;
+ }
+
Expand All @@ -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;
+ }
+
Expand Down Expand Up @@ -275,7 +275,7 @@ index 0000000000000000000000000000000000000000..8fb61870622738290167b5fa81f157f4
+ }
+
+ public static void sendPacket(ServerPlayer player, EntityDataPayload payload) {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxEntityProtocol) {
+ return;
+ }
+
Expand Down Expand Up @@ -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) {
Expand All @@ -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 @@
Expand Down Expand Up @@ -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;
+ }
+
Expand All @@ -560,7 +560,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c
+
+ @ProtocolHandler.PlayerJoin
+ public static void onPlayerLoggedIn(ServerPlayer player) {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxStructureProtocol) {
+ return;
+ }
+
Expand All @@ -569,7 +569,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c
+
+ @ProtocolHandler.PlayerLeave
+ public static void onPlayerLoggedOut(@NotNull ServerPlayer player) {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxStructureProtocol) {
+ return;
+ }
+
Expand All @@ -578,7 +578,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c
+
+ @ProtocolHandler.Ticker
+ public static void tick() {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxStructureProtocol) {
+ return;
+ }
+
Expand All @@ -602,7 +602,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c
+ }
+
+ public static void onStartedWatchingChunk(ServerPlayer player, LevelChunk chunk) {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxStructureProtocol) {
+ return;
+ }
+
Expand Down Expand Up @@ -934,7 +934,7 @@ index 0000000000000000000000000000000000000000..028e9f00bb6422f0df40c6d6d286fd0c
+ }
+
+ public static void sendPacket(ServerPlayer player, StructuresPayload payload) {
+ if (!LeavesConfig.servuxProtocol) {
+ if (!LeavesConfig.servuxStructureProtocol) {
+ return;
+ }
+
Expand Down

0 comments on commit bb803a9

Please sign in to comment.