From 3f2d80d0706a030c1a1d93008bbaa6b14cc7b038 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:35:09 +0800 Subject: [PATCH] perf: Appleskin protocol --- patches/server/0053-Appleskin-Protocol.patch | 26 ++++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/patches/server/0053-Appleskin-Protocol.patch b/patches/server/0053-Appleskin-Protocol.patch index 65e51437..dab3484c 100644 --- a/patches/server/0053-Appleskin-Protocol.patch +++ b/patches/server/0053-Appleskin-Protocol.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Appleskin Protocol diff --git a/src/main/java/top/leavesmc/leaves/protocol/AppleSkinProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/AppleSkinProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..a4ed856d458a231a758d58fc62227a1130410d05 +index 0000000000000000000000000000000000000000..6fd6a1c9ef54c95e452e08a69f9ddb1d6600e651 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/protocol/AppleSkinProtocol.java -@@ -0,0 +1,112 @@ +@@ -0,0 +1,106 @@ +package top.leavesmc.leaves.protocol; + +import net.minecraft.resources.ResourceLocation; @@ -52,7 +52,6 @@ index 0000000000000000000000000000000000000000..a4ed856d458a231a758d58fc62227a11 + @ProtocolHandler.PlayerJoin + public static void onPlayerLoggedIn(@NotNull ServerPlayer player) { + if (LeavesConfig.appleskinProtocol) { -+ players.add(player); + resetPlayerData(player); + } + } @@ -65,14 +64,17 @@ index 0000000000000000000000000000000000000000..a4ed856d458a231a758d58fc62227a11 + } + } + ++ @ProtocolHandler.MinecraftRegister(ignoreId = true) ++ public static void onPlayerSubscribed(@NotNull ServerPlayer player) { ++ if (LeavesConfig.appleskinProtocol) { ++ players.add(player); ++ } ++ } ++ + @ProtocolHandler.Ticker + public static void tick() { + if (LeavesConfig.appleskinProtocol) { + for (ServerPlayer player : players) { -+ if (!player.getBukkitEntity().getListeningPluginChannels().contains(SATURATION_KEY.toString())) { -+ continue; -+ } -+ + FoodData data = player.getFoodData(); + + float saturation = data.getSaturationLevel(); @@ -98,19 +100,11 @@ index 0000000000000000000000000000000000000000..a4ed856d458a231a758d58fc62227a11 + + @ProtocolHandler.ReloadServer + public static void onServerReload() { -+ if (LeavesConfig.appleskinProtocol) { -+ enableAllPlayer(); -+ } else { ++ if (!LeavesConfig.appleskinProtocol) { + disableAllPlayer(); + } + } + -+ public static void enableAllPlayer() { -+ for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) { -+ onPlayerLoggedIn(player); -+ } -+ } -+ + public static void disableAllPlayer() { + for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) { + onPlayerLoggedOut(player);