From 921784f41e92132623dc812263841ad575dc7753 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:42:28 +0800 Subject: [PATCH] Updated Upstream (Leaves) Upstream has released updates that appear to apply and compile correctly Leaves Changes: LeavesMC/Leaves@3992c79 Update Paper (#261) LeavesMC/Leaves@df31300 Fix loop initialization (#263) LeavesMC/Leaves@103beaa Disable crystal-portal proximity check (#260) LeavesMC/Leaves@6ed6771 Fix fast resume (#258) LeavesMC/Leaves@2ac9175 Fix Jade Protocol (#264) LeavesMC/Leaves@fd5e8be Fix Empty ShulkerBox stack (#257) LeavesMC/Leaves@d490f0d Update Syncmatica Protocol (#249) LeavesMC/Leaves@072c07f Fix Empty ShulkerBox stack, again (#257) LeavesMC/Leaves@752a60d Can disable LivingEntity aiStep alive check (#219) LeavesMC/Leaves@1ad3ede Fix Replay not save mode, and issue #209 done LeavesMC/Leaves@658cb0e Update alternative block placement protocol LeavesMC/Leaves@d2a4562 Update Paper LeavesMC/Leaves@bc4cd4f Update Servux Protocol LeavesMC/Leaves@632f5c3 Leaves Plugin (#271) LeavesMC/Leaves@6a3a5cd [release-skip] Enable Gradle parallel & cache LeavesMC/Leaves@347e621 update leavesclip LeavesMC/Leaves@21be64a Add scheduled bot remove (#274) LeavesMC/Leaves@36813ac Update Paper LeavesMC/Leaves@7d09a3a Fix #276 and #277 LeavesMC/Leaves@86d8553 Update PCA, fix #280 --- patches/server/0029-Leaves-Server-Utils.patch | 2 +- .../server/0030-Leaves-Protocol-Core.patch | 64 +++++++++++++++++-- .../server/0031-Leaves-Jade-Protocol.patch | 11 ++-- .../0034-Leaves-Syncmatica-Protocol.patch | 63 +++++++++++++----- ...aves-Disable-moved-wrongly-threshold.patch | 2 - ...-LeavesProtocolManager-init-protocol.patch | 53 +++++++-------- 6 files changed, 136 insertions(+), 59 deletions(-) diff --git a/patches/server/0029-Leaves-Server-Utils.patch b/patches/server/0029-Leaves-Server-Utils.patch index 476408630..eddfada66 100644 --- a/patches/server/0029-Leaves-Server-Utils.patch +++ b/patches/server/0029-Leaves-Server-Utils.patch @@ -9,7 +9,7 @@ and change store way to sql maybe? Original license: GPLv3 Original project: https://github.com/LeavesMC/Leaves -Commit: a872cd0de5ea02a7abf6174842b7ba4b530bb025 +Commit: 86d85530bc3cc448aea134690ae415fabec8e891 diff --git a/src/main/java/org/leavesmc/leaves/LeavesLogger.java b/src/main/java/org/leavesmc/leaves/LeavesLogger.java new file mode 100644 diff --git a/patches/server/0030-Leaves-Protocol-Core.patch b/patches/server/0030-Leaves-Protocol-Core.patch index d4246ea50..061453deb 100644 --- a/patches/server/0030-Leaves-Protocol-Core.patch +++ b/patches/server/0030-Leaves-Protocol-Core.patch @@ -204,12 +204,13 @@ index 0000000000000000000000000000000000000000..986d2a6641ff8017dddf3e5f2655adfc +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd731294025d2833b +index 0000000000000000000000000000000000000000..b76eb38942171d22dcd767ea353f012e5920f1f5 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java -@@ -0,0 +1,384 @@ +@@ -0,0 +1,436 @@ +package org.leavesmc.leaves.protocol.core; + ++import com.google.common.collect.ImmutableSet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; @@ -236,6 +237,7 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940 +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; ++import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; @@ -251,6 +253,7 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940 + + private static final Map> KNOWN_TYPES = new HashMap<>(); + private static final Map> KNOW_RECEIVERS = new HashMap<>(); ++ private static Set ALL_KNOWN_ID = new HashSet<>(); + + private static final List TICKERS = new ArrayList<>(); + private static final List PLAYER_JOIN = new ArrayList<>(); @@ -310,8 +313,10 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940 + if (!found) { + Constructor> constructor = receiver.payload().getConstructor(PAYLOAD_PARAMETER_TYPES); + if (constructor.isAnnotationPresent(LeavesCustomPayload.New.class)) { -+ map.put(receiver, constructor); + constructor.setAccessible(true); ++ map.put(receiver, constructor); ++ } else { ++ throw new NoSuchMethodException(); + } + } + } catch (NoSuchMethodException exception) { @@ -363,6 +368,20 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940 + KNOWN_TYPES.put(protocol, map); + } + } ++ ++ for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) { ++ Map map = KNOWN_TYPES.get(protocol); ++ for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) { ++ if (receiver.sendFabricRegister() && !receiver.ignoreId()) { ++ for (String payloadId : receiver.payloadId()) { ++ for (String namespace : protocol.namespace()) { ++ ALL_KNOWN_ID.add(new ResourceLocation(namespace, payloadId)); ++ } ++ } ++ } ++ } ++ } ++ ALL_KNOWN_ID = ImmutableSet.copyOf(ALL_KNOWN_ID); + } + + public static LeavesCustomPayload decode(ResourceLocation id, FriendlyByteBuf buf) { @@ -439,6 +458,8 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940 + LOGGER.warning("Failed to handle player join, " + exception.getCause() + ": " + exception.getMessage()); + } + } ++ ++ ProtocolUtils.sendPayloadPacket(player, new FabricRegisterPayload(ALL_KNOWN_ID)); + } + + public static void handlePlayerLeave(ServerPlayer player) { @@ -591,13 +612,44 @@ index 0000000000000000000000000000000000000000..e7ce2e7a1686f1775c0a2e0cd7312940 + buf.writeBytes(data); + } + } ++ ++ public record FabricRegisterPayload( ++ Set channels) implements LeavesCustomPayload { ++ ++ public static final ResourceLocation CHANNEL = ResourceLocation.withDefaultNamespace("register"); ++ ++ @New ++ public FabricRegisterPayload(ResourceLocation location, FriendlyByteBuf buf) { ++ this(buf.readCollection(HashSet::new, FriendlyByteBuf::readResourceLocation)); ++ } ++ ++ @Override ++ public void write(FriendlyByteBuf buf) { ++ boolean first = true; ++ ++ ResourceLocation channel; ++ for (Iterator var3 = this.channels.iterator(); var3.hasNext(); buf.writeBytes(channel.toString().getBytes(StandardCharsets.US_ASCII))) { ++ channel = var3.next(); ++ if (first) { ++ first = false; ++ } else { ++ buf.writeByte(0); ++ } ++ } ++ } ++ ++ @Override ++ public ResourceLocation id() { ++ return CHANNEL; ++ } ++ } +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java new file mode 100644 -index 0000000000000000000000000000000000000000..f941f095184cf4b7af284d1357ea1a85815e8a66 +index 0000000000000000000000000000000000000000..9d71f8e6af24301bedf60f5c87e0bb3c1697d5e3 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java -@@ -0,0 +1,61 @@ +@@ -0,0 +1,63 @@ +package org.leavesmc.leaves.protocol.core; + +import java.lang.annotation.ElementType; @@ -622,6 +674,8 @@ index 0000000000000000000000000000000000000000..f941f095184cf4b7af284d1357ea1a85 + String[] payloadId() default ""; + + boolean ignoreId() default false; ++ ++ boolean sendFabricRegister() default true; + } + + @Target(ElementType.METHOD) diff --git a/patches/server/0031-Leaves-Jade-Protocol.patch b/patches/server/0031-Leaves-Jade-Protocol.patch index 33e755cf5..dda8f10a2 100644 --- a/patches/server/0031-Leaves-Jade-Protocol.patch +++ b/patches/server/0031-Leaves-Jade-Protocol.patch @@ -142,10 +142,10 @@ index c63bdbd72ecd45b8d5862a996636c0ce1e87166e..4e91895387b214cadc658b150ed6b88e } diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..43ad624bbe334384de4e79d0075e67389648c014 +index 0000000000000000000000000000000000000000..cc9f71e2bc8261f07fdb4d296cc8d13cfa2753ad --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java -@@ -0,0 +1,396 @@ +@@ -0,0 +1,397 @@ +package org.leavesmc.leaves.protocol.jade; + +import io.netty.buffer.ByteBuf; @@ -242,7 +242,7 @@ index 0000000000000000000000000000000000000000..43ad624bbe334384de4e79d0075e6738 +public class JadeProtocol { + + public static PriorityStore priorities; -+ private static List shearableBlocks = List.of(); ++ private static List shearableBlocks = null; + + public static final String PROTOCOL_ID = "jade"; + @@ -325,9 +325,10 @@ index 0000000000000000000000000000000000000000..43ad624bbe334384de4e79d0075e6738 + + try { + shearableBlocks = Collections.unmodifiableList(LootTableMineableCollector.execute( -+ MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.LOOT_TABLE), -+ Items.SHEARS.getDefaultInstance())); ++ MinecraftServer.getServer().reloadableRegistries().get().registryOrThrow(Registries.LOOT_TABLE), ++ Items.SHEARS.getDefaultInstance())); + } catch (Throwable ignore) { ++ shearableBlocks = List.of(); + LeavesLogger.LOGGER.severe("Failed to collect shearable blocks"); + } + } diff --git a/patches/server/0034-Leaves-Syncmatica-Protocol.patch b/patches/server/0034-Leaves-Syncmatica-Protocol.patch index 480e2fd80..c7c6e1613 100644 --- a/patches/server/0034-Leaves-Syncmatica-Protocol.patch +++ b/patches/server/0034-Leaves-Syncmatica-Protocol.patch @@ -58,7 +58,7 @@ index c159340c3d7d90601bb69a4e1b997e372d48841a..9bff9c7fce4fec7687940f4212ac05d4 } diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..3f06c2006877bd35dedca02ffba9e30b0391e022 +index 0000000000000000000000000000000000000000..0704ac7825c69e69097b3e7c77763044f9fa9e1e --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -0,0 +1,396 @@ @@ -158,12 +158,12 @@ index 0000000000000000000000000000000000000000..3f06c2006877bd35dedca02ffba9e30b + playerMap.remove(oldPlayer); + } + -+ @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true) -+ public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) { ++ @ProtocolHandler.PayloadReceiver(payload = SyncmaticaPayload.class, payloadId = "main") ++ public static void onPacketGet(ServerPlayer player, SyncmaticaPayload payload) { + if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.syncmaticaProtocol) { + return; + } -+ onPacket(player.connection.exchangeTarget, payload.id(), payload.data()); ++ onPacket(player.connection.exchangeTarget, payload.packetType(), payload.data()); + } + + public static void onPacket(final @NotNull ExchangeTarget source, final ResourceLocation id, final FriendlyByteBuf packetBuf) { @@ -1331,9 +1331,42 @@ index 0000000000000000000000000000000000000000..27a056b306daa91400946a30e68ce01d + } + } +} +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java +new file mode 100644 +index 0000000000000000000000000000000000000000..cb5dffe81c4f0becad0ae2fbf7e9143f4fa577ef +--- /dev/null ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java +@@ -0,0 +1,27 @@ ++package org.leavesmc.leaves.protocol.syncmatica; ++ ++import net.minecraft.network.FriendlyByteBuf; ++import net.minecraft.resources.ResourceLocation; ++import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; ++ ++public record SyncmaticaPayload(ResourceLocation packetType, ++ FriendlyByteBuf data) implements LeavesCustomPayload { ++ ++ private static final ResourceLocation NETWORK_ID = new ResourceLocation(SyncmaticaProtocol.PROTOCOL_ID, "main"); ++ ++ @New ++ public static SyncmaticaPayload decode(ResourceLocation location, FriendlyByteBuf buf) { ++ return new SyncmaticaPayload(buf.readResourceLocation(), new FriendlyByteBuf(buf.readBytes(buf.readableBytes()))); ++ } ++ ++ @Override ++ public void write(FriendlyByteBuf buf) { ++ buf.writeResourceLocation(this.packetType); ++ buf.writeBytes(this.data.readBytes(this.data.readableBytes())); ++ } ++ ++ @Override ++ public ResourceLocation id() { ++ return NETWORK_ID; ++ } ++} diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..4efe181c5fd6e0251b6beb148bd3fa07ed509c78 +index 0000000000000000000000000000000000000000..d2625b1ca6fc207dfb8c282d3dc0baa2701479c9 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java @@ -0,0 +1,122 @@ @@ -1354,7 +1387,7 @@ index 0000000000000000000000000000000000000000..4efe181c5fd6e0251b6beb148bd3fa07 +public class SyncmaticaProtocol { + + public static final String PROTOCOL_ID = "syncmatica"; -+ public static final String PROTOCOL_VERSION = "leaves-syncmatica-1.0.0"; ++ public static final String PROTOCOL_VERSION = "leaves-syncmatica-1.1.0"; + + private static final File litematicFolder = new File("." + File.separator + "syncmatics"); + private static final PlayerIdentifierProvider playerIdentifierProvider = new PlayerIdentifierProvider(); @@ -1690,10 +1723,10 @@ index 0000000000000000000000000000000000000000..0f45ef7f4abcd7cff627e5a3df2a9fca +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java new file mode 100644 -index 0000000000000000000000000000000000000000..1ce637d91f12f8fdd54fce38534861836b6a93ca +index 0000000000000000000000000000000000000000..b0da7abf0748d4bdb3141c28f201906157a0eaad --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java -@@ -0,0 +1,40 @@ +@@ -0,0 +1,39 @@ +package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import net.minecraft.network.FriendlyByteBuf; @@ -1701,6 +1734,7 @@ index 0000000000000000000000000000000000000000..1ce637d91f12f8fdd54fce3853486183 +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import org.leavesmc.leaves.protocol.core.ProtocolUtils; +import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; ++import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaPayload; + +import java.util.ArrayList; +import java.util.Collection; @@ -1717,9 +1751,7 @@ index 0000000000000000000000000000000000000000..1ce637d91f12f8fdd54fce3853486183 + } + + public void sendPacket(final ResourceLocation id, final FriendlyByteBuf packetBuf) { -+ ProtocolUtils.sendPayloadPacket(client.player, id, buf -> { -+ buf.writeBytes(packetBuf); -+ }); ++ ProtocolUtils.sendPayloadPacket(client.player, new SyncmaticaPayload(id, packetBuf)); + } + + public FeatureSet getFeatureSet() { @@ -1984,16 +2016,17 @@ index 0000000000000000000000000000000000000000..065a39942603f7b884cca40d8d7b4b47 +} diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java new file mode 100644 -index 0000000000000000000000000000000000000000..9614fce87e2522690aac0af4c04d9fbcb72167af +index 0000000000000000000000000000000000000000..cb7aed6c0aa31cd46c071da7b483c63e755a6bff --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java -@@ -0,0 +1,65 @@ +@@ -0,0 +1,66 @@ +package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import io.netty.buffer.Unpooled; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; ++import org.leavesmc.leaves.protocol.syncmatica.CommunicationManager; +import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; +import org.leavesmc.leaves.protocol.syncmatica.PacketType; +import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; @@ -2016,7 +2049,7 @@ index 0000000000000000000000000000000000000000..9614fce87e2522690aac0af4c04d9fbc + @Override + public void handle(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + if (id.equals(PacketType.REGISTER_VERSION.identifier)) { -+ String partnerVersion = packetBuf.readUtf(32767); ++ String partnerVersion = packetBuf.readUtf(); + if (partnerVersion.equals("0.0.1")) { + close(false); + return; @@ -2040,7 +2073,7 @@ index 0000000000000000000000000000000000000000..9614fce87e2522690aac0af4c04d9fbc + final Collection l = SyncmaticaProtocol.getSyncmaticManager().getAll(); + newBuf.writeInt(l.size()); + for (final ServerPlacement p : l) { -+ getManager().putMetaData(p, newBuf, getPartner()); ++ CommunicationManager.putMetaData(p, newBuf, getPartner()); + } + getPartner().sendPacket(PacketType.CONFIRM_USER.identifier, newBuf); + succeed(); diff --git a/patches/server/0037-Leaves-Disable-moved-wrongly-threshold.patch b/patches/server/0037-Leaves-Disable-moved-wrongly-threshold.patch index 76f081456..41a9242cd 100644 --- a/patches/server/0037-Leaves-Disable-moved-wrongly-threshold.patch +++ b/patches/server/0037-Leaves-Disable-moved-wrongly-threshold.patch @@ -6,8 +6,6 @@ Subject: [PATCH] Leaves: Disable moved wrongly threshold Original license: GPLv3 Original project: https://github.com/LeavesMC/Leaves -Commit: e234432bd99e1c4b07c24d1dd247977226a7516a - diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index f0105e01f94352dee85f91ca2ae951311f4c052f..c9cf3499de2809c9983881c88029b39264030f94 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/patches/server/0087-Optimize-LeavesProtocolManager-init-protocol.patch b/patches/server/0087-Optimize-LeavesProtocolManager-init-protocol.patch index 419d60709..7ff6e4326 100644 --- a/patches/server/0087-Optimize-LeavesProtocolManager-init-protocol.patch +++ b/patches/server/0087-Optimize-LeavesProtocolManager-init-protocol.patch @@ -276,10 +276,10 @@ index 9e35dfaf8bb5511b4cd0a71175d7ecb6d835042f..5ef19098512ae8a070dea270a68c2769 buf.writeByte(0); buf.writeInt(org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapServerID); diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java -index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8fc6b791ec 100644 +index b76eb38942171d22dcd767ea353f012e5920f1f5..d79d69bc630b3bb73ca32bc1e80509df06954dad 100644 --- a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java -@@ -6,33 +6,23 @@ import net.minecraft.resources.ResourceLocation; +@@ -7,24 +7,18 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import org.apache.commons.lang.ArrayUtils; import org.bukkit.event.player.PlayerKickEvent; @@ -304,7 +304,8 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; --import java.util.LinkedHashSet; + import java.util.Iterator; +@@ -32,9 +26,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -314,7 +315,7 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f public class LeavesProtocolManager { private static final Class[] PAYLOAD_PARAMETER_TYPES = {ResourceLocation.class, FriendlyByteBuf.class}; -@@ -48,8 +38,16 @@ public class LeavesProtocolManager { +@@ -51,8 +42,16 @@ public class LeavesProtocolManager { private static final List RELOAD_SERVER = new ArrayList<>(); private static final Map> MINECRAFT_REGISTER = new HashMap<>(); @@ -332,7 +333,7 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f final LeavesProtocol protocol = clazz.getAnnotation(LeavesProtocol.class); if (protocol != null) { Set methods; -@@ -59,7 +57,12 @@ public class LeavesProtocolManager { +@@ -62,7 +61,12 @@ public class LeavesProtocolManager { methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f); Collections.addAll(methods, publicMethods); Collections.addAll(methods, privateMethods); @@ -346,7 +347,7 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f LOGGER.severe("Failed to load class " + clazz.getName() + " due to missing dependencies, " + error.getCause() + ": " + error.getMessage()); return; } -@@ -72,6 +75,16 @@ public class LeavesProtocolManager { +@@ -75,6 +79,16 @@ public class LeavesProtocolManager { method.setAccessible(true); @@ -363,7 +364,7 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f final ProtocolHandler.Init init = method.getAnnotation(ProtocolHandler.Init.class); if (init != null) { try { -@@ -135,12 +148,6 @@ public class LeavesProtocolManager { +@@ -140,12 +154,6 @@ public class LeavesProtocolManager { continue; } @@ -376,13 +377,14 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f final ProtocolHandler.MinecraftRegister minecraftRegister = method.getAnnotation(ProtocolHandler.MinecraftRegister.class); if (minecraftRegister != null) { if (!MINECRAFT_REGISTER.containsKey(protocol)) { -@@ -155,6 +162,16 @@ public class LeavesProtocolManager { - } +@@ -174,6 +182,17 @@ public class LeavesProtocolManager { + ALL_KNOWN_ID = ImmutableSet.copyOf(ALL_KNOWN_ID); } + private static void cleanProtocols() { + KNOWN_TYPES.clear(); + KNOW_RECEIVERS.clear(); ++ //ALL_KNOWN_ID.clear(); // No need + TICKERS.clear(); + PLAYER_JOIN.clear(); + PLAYER_LEAVE.clear(); @@ -393,7 +395,7 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f public static LeavesCustomPayload decode(ResourceLocation id, FriendlyByteBuf buf) { for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) { if (!ArrayUtils.contains(protocol.namespace(), id.getNamespace())) { -@@ -276,81 +293,6 @@ public class LeavesProtocolManager { +@@ -297,81 +316,6 @@ public class LeavesProtocolManager { } } @@ -476,7 +478,7 @@ index e7ce2e7a1686f1775c0a2e0cd731294025d2833b..871971a82b36b8e106bab040030f8a8f @Override public void write(@NotNull FriendlyByteBuf buf) { diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java -index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd045753e9d 100644 +index cc9f71e2bc8261f07fdb4d296cc8d13cfa2753ad..a687c38577919bbb20a0f1b15255aec3c07fa3be 100644 --- a/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java +++ b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java @@ -103,6 +103,10 @@ public class JadeProtocol { @@ -503,18 +505,7 @@ index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd0 allKeys.stream().filter(Predicate.not(JadeProtocol::isPrimaryKey)).forEach($ -> { int index = keys.indexOf(JadeProtocol.getPrimaryKey($)); keys.add(index + 1, $); -@@ -177,8 +181,8 @@ public class JadeProtocol { - - try { - shearableBlocks = Collections.unmodifiableList(LootTableMineableCollector.execute( -- MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.LOOT_TABLE), -- Items.SHEARS.getDefaultInstance())); -+ MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.LOOT_TABLE), -+ Items.SHEARS.getDefaultInstance())); - } catch (Throwable ignore) { - LeavesLogger.LOGGER.severe("Failed to collect shearable blocks"); - } -@@ -186,17 +190,11 @@ public class JadeProtocol { +@@ -187,17 +191,11 @@ public class JadeProtocol { @ProtocolHandler.PlayerJoin public static void onPlayerJoin(ServerPlayer player) { @@ -533,7 +524,7 @@ index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd0 MinecraftServer server = MinecraftServer.getServer(); server.execute(() -> { Level world = player.level(); -@@ -237,10 +235,6 @@ public class JadeProtocol { +@@ -238,10 +236,6 @@ public class JadeProtocol { @ProtocolHandler.PayloadReceiver(payload = RequestBlockPayload.class, payloadId = "request_block") public static void requestBlockData(ServerPlayer player, RequestBlockPayload payload) { @@ -544,7 +535,7 @@ index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd0 MinecraftServer server = MinecraftServer.getServer(); server.execute(() -> { Level world = player.level(); -@@ -302,7 +296,8 @@ public class JadeProtocol { +@@ -303,7 +297,8 @@ public class JadeProtocol { } } @@ -554,7 +545,7 @@ index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd0 private static final ResourceLocation PACKET_REQUEST_ENTITY = JadeProtocol.id("request_entity"); -@@ -326,7 +321,8 @@ public class JadeProtocol { +@@ -327,7 +322,8 @@ public class JadeProtocol { } } @@ -564,7 +555,7 @@ index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd0 private static final ResourceLocation PACKET_REQUEST_BLOCK = JadeProtocol.id("request_block"); private static final StreamCodec ITEM_STACK_CODEC = ItemStack.OPTIONAL_STREAM_CODEC; -@@ -352,7 +348,8 @@ public class JadeProtocol { +@@ -353,7 +349,8 @@ public class JadeProtocol { } } @@ -575,7 +566,7 @@ index 43ad624bbe334384de4e79d0075e67389648c014..a03a6e558179a1b1c81ee57143e00cd0 private static final ResourceLocation PACKET_SERVER_PING = JadeProtocol.id("server_ping_v1"); private static final StreamCodec> SHEARABLE_BLOCKS_CODEC = ByteBufCodecs.registry(Registries.BLOCK).apply(ByteBufCodecs.list()); diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java -index 3f06c2006877bd35dedca02ffba9e30b0391e022..91e88f0325e48f8c2523028acbacf04e22262c67 100644 +index 0704ac7825c69e69097b3e7c77763044f9fa9e1e..c039765237d56def91a1e630a0510062305fd585 100644 --- a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java +++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -48,6 +48,10 @@ public class CommunicationManager { @@ -611,11 +602,11 @@ index 3f06c2006877bd35dedca02ffba9e30b0391e022..91e88f0325e48f8c2523028acbacf04e if (potentialMessageTarget != null) { @@ -96,9 +94,6 @@ public class CommunicationManager { - @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true) - public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) { + @ProtocolHandler.PayloadReceiver(payload = SyncmaticaPayload.class, payloadId = "main") + public static void onPacketGet(ServerPlayer player, SyncmaticaPayload payload) { - if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.syncmaticaProtocol) { - return; - } - onPacket(player.connection.exchangeTarget, payload.id(), payload.data()); + onPacket(player.connection.exchangeTarget, payload.packetType(), payload.data()); }