mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-22 00:19:20 +00:00
Updated Upstream (Gale/Purpur/Leaves/Dependencies)
This commit is contained in:
@@ -58,10 +58,10 @@ index 61cd58a5bb3d228b29b9cc4db11be03d4c833223..1610f21bbfbca0d12ca12373e56d90a5
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 8fd80d1167edea751fec1c14deabc427c221e98b..80db3fcf338846770e8c8ee6aa7635a68f2b6753 100644
|
||||
index 42e6754ae5432a41f54064961bd5d66891a30612..9a3dbd337728374e3adb1071769f7824c2698fe3 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -361,6 +361,7 @@ public abstract class PlayerList {
|
||||
@@ -362,6 +362,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined
|
||||
@@ -69,7 +69,7 @@ index 8fd80d1167edea751fec1c14deabc427c221e98b..80db3fcf338846770e8c8ee6aa7635a6
|
||||
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
@@ -619,6 +620,7 @@ public abstract class PlayerList {
|
||||
@@ -620,6 +621,7 @@ public abstract class PlayerList {
|
||||
return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())));
|
||||
}
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
|
||||
@@ -78,7 +78,7 @@ index 8fd80d1167edea751fec1c14deabc427c221e98b..80db3fcf338846770e8c8ee6aa7635a6
|
||||
org.purpurmc.purpur.task.BossBarTask.removeFromAll(entityplayer.getBukkitEntity()); // Purpur
|
||||
ServerLevel worldserver = entityplayer.serverLevel();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 443e227ee762163fa19eefb3c554fa871ad07323..a1317e374066d2abe20064bc47e20f4b19db9705 100644
|
||||
index 3c3b98d13587ce21bffa14a79aed963a7ce1f176..db96be7e6f30ecab1349c1fe68fcdd2f4e27167d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -482,6 +482,7 @@ public final class CraftServer implements Server {
|
||||
@@ -117,19 +117,22 @@ index 0000000000000000000000000000000000000000..f884f54f5a1f0665c290e014f088aae8
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..26544936005d167f764a823faebc200f59b2e008
|
||||
index 0000000000000000000000000000000000000000..740039a14fe915e7edd30273de628efd92512e4a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
@@ -0,0 +1,339 @@
|
||||
@@ -0,0 +1,361 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.apache.commons.lang.ArrayUtils;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import org.bukkit.event.player.PlayerKickEvent;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Constructor;
|
||||
@@ -141,6 +144,7 @@ index 0000000000000000000000000000000000000000..26544936005d167f764a823faebc200f
|
||||
+import java.net.URLDecoder;
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collections;
|
||||
+import java.util.Enumeration;
|
||||
+import java.util.HashMap;
|
||||
@@ -265,6 +269,8 @@ index 0000000000000000000000000000000000000000..26544936005d167f764a823faebc200f
|
||||
+ return map.get(receiver).newInstance(id, buf);
|
||||
+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ buf.readBytes(buf.readableBytes());
|
||||
+ return new ErrorPayload(id, protocol.namespace(), receiver.payloadId());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -273,6 +279,15 @@ index 0000000000000000000000000000000000000000..26544936005d167f764a823faebc200f
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePayload(ServerPlayer player, CustomPacketPayload payload) {
|
||||
+ if (payload instanceof ServerboundCustomPayloadPacket.UnknownPayload) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (payload instanceof ErrorPayload errorPayload) {
|
||||
+ player.connection.disconnect("Payload " + Arrays.toString(errorPayload.packetID) + " from " + Arrays.toString(errorPayload.protocolID) + " error", PlayerKickEvent.Cause.INVALID_PAYLOAD);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), payload.id().getNamespace())) {
|
||||
+ continue;
|
||||
@@ -437,6 +452,13 @@ index 0000000000000000000000000000000000000000..26544936005d167f764a823faebc200f
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record ErrorPayload(ResourceLocation id, String[] protocolID,
|
||||
+ String[] packetID) implements CustomPacketPayload {
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record EmptyPayload(ResourceLocation id) implements CustomPacketPayload {
|
||||
+
|
||||
+ public EmptyPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
|
||||
Reference in New Issue
Block a user