mirror of
https://github.com/LeavesMC/Leaves.git
synced 2026-01-04 15:41:31 +00:00
Apply Jade Protocol
This commit is contained in:
@@ -172,7 +172,7 @@ 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..eb9e9d3a0dbb17eb68940685d4a6dea5b33a61f1
|
||||
index 0000000000000000000000000000000000000000..3a33982b92bfb12ce1284fb9429672a698a7ce4b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
@@ -0,0 +1,365 @@
|
||||
@@ -234,7 +234,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ Collections.addAll(methods, publicMethods);
|
||||
+ Collections.addAll(methods, privateMethods);
|
||||
+ } catch (NoClassDefFoundError error) {
|
||||
+ LOGGER.severe("Failed to load class " + clazz.getName() + " due to missing dependencies, " + error.getMessage());
|
||||
+ LOGGER.severe("Failed to load class " + clazz.getName() + " due to missing dependencies, " + error.getCause() + ": " + error.getMessage());
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -251,7 +251,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ try {
|
||||
+ method.invoke(null);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.severe("Failed to invoke init method " + method.getName() + " in " + clazz.getName() + ", " + exception.getMessage());
|
||||
+ LOGGER.severe("Failed to invoke init method " + method.getName() + " in " + clazz.getName() + ", " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
@@ -268,7 +268,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+
|
||||
+ map.put(receiver, constructor);
|
||||
+ } catch (NoSuchMethodException exception) {
|
||||
+ LOGGER.severe("Failed to find constructor for " + receiver.payload().getName() + ", " + exception.getMessage());
|
||||
+ LOGGER.severe("Failed to find constructor for " + receiver.payload().getName() + ", " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
@@ -330,7 +330,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ try {
|
||||
+ return map.get(receiver).newInstance(id, buf);
|
||||
+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to create payload for " + id + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to create payload for " + id + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ buf.readBytes(buf.readableBytes());
|
||||
+ return new ErrorPayload(id, protocol.namespace(), receiver.payloadId());
|
||||
+ }
|
||||
@@ -358,7 +358,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ try {
|
||||
+ map.get(receiver).invoke(null, player, payload);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to handle payload " + payload.type().id() + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to handle payload " + payload.type().id() + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -373,7 +373,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ method.invoke(null);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to tick, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to tick, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -385,7 +385,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ method.invoke(null, player);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to handle player join, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to handle player join, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -397,7 +397,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ method.invoke(null, player);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to handle player leave, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to handle player leave, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -409,7 +409,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ method.invoke(null);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to handle server reload, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to handle server reload, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -428,7 +428,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ try {
|
||||
+ map.get(register).invoke(null, player);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
+ LOGGER.warning("Failed to handle minecraft register, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to handle minecraft register, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -454,12 +454,12 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ Enumeration<JarEntry> entries = jar.entries();
|
||||
+ findClassesInPackageByJar(pack, entries, packageDirName, classes);
|
||||
+ } catch (IOException exception) {
|
||||
+ LOGGER.warning("Failed to load jar file, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to load jar file, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (IOException exception) {
|
||||
+ LOGGER.warning("Failed to load classes, " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to load classes, " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ return classes;
|
||||
+ }
|
||||
@@ -479,7 +479,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ try {
|
||||
+ classes.add(Class.forName(packageName + '.' + className));
|
||||
+ } catch (ClassNotFoundException exception) {
|
||||
+ LOGGER.warning("Failed to load class " + className + ", " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to load class " + className + ", " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -503,7 +503,7 @@ index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5
|
||||
+ try {
|
||||
+ classes.add(Class.forName(packageName + '.' + className));
|
||||
+ } catch (ClassNotFoundException exception) {
|
||||
+ LOGGER.warning("Failed to load class " + className + ", " + exception.getMessage());
|
||||
+ LOGGER.warning("Failed to load class " + className + ", " + exception.getCause() + ": " + exception.getMessage());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -610,23 +610,29 @@ index 0000000000000000000000000000000000000000..f9dc0a60ca4287e5ec91dd3fc1ae315e
|
||||
+}
|
||||
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..562f3d515679965571597945e8682712e1e1f0b9
|
||||
index 0000000000000000000000000000000000000000..f54381eec7ec0ffde39e87b39b16e02d3ed1b419
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java
|
||||
@@ -0,0 +1,37 @@
|
||||
@@ -0,0 +1,47 @@
|
||||
+package org.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import io.netty.buffer.ByteBuf;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Function;
|
||||
+
|
||||
+public class ProtocolUtils {
|
||||
+
|
||||
+ private static final Function<ByteBuf, RegistryFriendlyByteBuf> bufDecorator = RegistryFriendlyByteBuf.decorator(MinecraftServer.getServer().registryAccess());
|
||||
+
|
||||
+ public static void sendEmptyPayloadPacket(ServerPlayer player, ResourceLocation id) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(new LeavesProtocolManager.EmptyPayload(id)));
|
||||
+ }
|
||||
@@ -650,4 +656,8 @@ index 0000000000000000000000000000000000000000..562f3d515679965571597945e8682712
|
||||
+ public static void sendPayloadPacket(ServerPlayer player, CustomPacketPayload payload) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(payload));
|
||||
+ }
|
||||
+
|
||||
+ public static RegistryFriendlyByteBuf decorate(ByteBuf buf) {
|
||||
+ return bufDecorator.apply(buf);
|
||||
+ }
|
||||
+}
|
||||
|
||||
2332
patches/server/0042-Jade-Protocol.patch
Normal file
2332
patches/server/0042-Jade-Protocol.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
|
||||
Date: Tue, 7 May 2024 23:52:04 +0800
|
||||
Subject: [PATCH] Placeholder of Jade-Protocol
|
||||
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -46,3 +46,4 @@ dependency-reduced-pom.xml
|
||||
# vs code
|
||||
/.vscode
|
||||
/.factorypath
|
||||
+
|
||||
Reference in New Issue
Block a user