diff --git a/patches/server/0004-Leaves-Server-Config-And-Command.patch b/patches/server/0004-Leaves-Server-Config-And-Command.patch index 18a0e36c..6299f70b 100644 --- a/patches/server/0004-Leaves-Server-Config-And-Command.patch +++ b/patches/server/0004-Leaves-Server-Config-And-Command.patch @@ -128,10 +128,10 @@ index a53514f2c510b29f596c361de7bc0b405c27e964..269c7ba0707db4fdc45a70000e0be892 .withRequiredArg() diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..11b51a22e3441d7118e29178db6ed3529be52d60 +index 0000000000000000000000000000000000000000..6bff943bc8c600a13d20d625fe3d49909f523cac --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -0,0 +1,787 @@ +@@ -0,0 +1,792 @@ +package top.leavesmc.leaves; + +import com.destroystokyo.paper.util.SneakyThrow; @@ -744,6 +744,11 @@ index 0000000000000000000000000000000000000000..11b51a22e3441d7118e29178db6ed352 + elytraAeronauticsNoChunkEndMes = getString("settings.modify.elytra-aeronautics.message-end", elytraAeronauticsNoChunkEndMes); + } + ++ public static boolean msptSyncProtocol = false; ++ private static void msptSyncProtocol() { ++ msptSyncProtocol = getBoolean("settings.protocol.bladeren.mspt-sync-protocol", msptSyncProtocol); ++ } ++ + public static final class WorldConfig { + + public final String worldName; diff --git a/patches/server/0078-Bladeren-mspt-sync-protocol.patch b/patches/server/0078-Bladeren-mspt-sync-protocol.patch new file mode 100644 index 00000000..7247f88d --- /dev/null +++ b/patches/server/0078-Bladeren-mspt-sync-protocol.patch @@ -0,0 +1,121 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Mon, 3 Jul 2023 22:12:16 +0800 +Subject: [PATCH] Bladeren mspt sync protocol + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index b8fd91fc1ebaafad28cfa08d5af71aa3b1c54da4..f393f9ae4465b8970122b2707290cac4350ac473 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -1610,6 +1610,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop players = new ArrayList<>(); ++ ++ @Contract("_ -> new") ++ public static @NotNull ResourceLocation id(String path) { ++ return new ResourceLocation(PROTOCOL_ID, path); ++ } ++ ++ public static void onPlayerJoin(@NotNull ServerPlayer player) { ++ if (LeavesConfig.msptSyncProtocol) { ++ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); ++ ProtocolUtils.sendPayloadPacket(player, MSPT_SYNC_ENABLE, buf); ++ } ++ } ++ ++ public static void handlePacket(ServerPlayer player, @NotNull ServerboundCustomPayloadPacket packet) { ++ if (packet.identifier.equals(MSPT_SYNC_ENABLE)) { ++ players.add(player); ++ } ++ } ++ ++ public static void onPlayerLoggedOut(@NotNull ServerPlayer player) { ++ if (LeavesConfig.msptSyncProtocol) { ++ players.remove(player); ++ } ++ } ++ ++ public static void tick(MinecraftServer server) { ++ if (LeavesConfig.msptSyncProtocol) { ++ if (server.getTickCount() % 20 == 0 && !players.isEmpty()) { ++ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); ++ double mspt = Arrays.stream(server.tickTimes).average().getAsDouble() * 1.0E-6D; ++ double tps = 1000.0D / Math.max(mspt, 50); ++ buf.writeDouble(mspt); ++ buf.writeDouble(tps); ++ players.forEach(player -> ProtocolUtils.sendPayloadPacket(player, MSPT_SYNC, buf)); ++ } ++ } ++ } ++}