mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
126 lines
7.5 KiB
Diff
126 lines
7.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Thu, 10 Jul 2025 22:11:47 +0300
|
|
Subject: [PATCH] Leaves: Protocol Core
|
|
|
|
Original project: https://github.com/LeavesMC/Leaves
|
|
Original license: GPLv3
|
|
|
|
diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..c3be4c2fd4a544967322a45d3b8c0fe78a0684a5 100644
|
|
--- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
|
@@ -40,13 +40,22 @@ public interface CustomPacketPayload {
|
|
|
|
@Override
|
|
public void encode(B buffer, CustomPacketPayload value) {
|
|
+ // DivineMC start - Leaves Protocol Core
|
|
+ if (value instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload payload) {
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.encode(buffer, payload);
|
|
+ return;
|
|
+ }
|
|
+ // DivineMC end - Leaves Protocol Core
|
|
this.writeCap(buffer, value.type(), value);
|
|
}
|
|
|
|
@Override
|
|
public CustomPacketPayload decode(B buffer) {
|
|
ResourceLocation resourceLocation = buffer.readResourceLocation();
|
|
- return (CustomPacketPayload)this.findCodec(resourceLocation).decode(buffer);
|
|
+ // DivineMC start - Leaves Protocol Core
|
|
+ var payload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(resourceLocation, buffer);
|
|
+ return java.util.Objects.requireNonNullElseGet(payload, () -> this.findCodec(resourceLocation).decode(buffer));
|
|
+ // DivineMC end - Leaves Protocol Core
|
|
}
|
|
};
|
|
}
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 83ccf00e3cff9dced3cc97abffd7881b0be5420e..60e77f74124027cc73fd4366b77fdb54c68273e5 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1824,6 +1824,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
GameTestTicker.SINGLETON.tick();
|
|
}
|
|
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(tickCount); // DivineMC - Leaves Protocol Core
|
|
+
|
|
for (int i = 0; i < this.tickables.size(); i++) {
|
|
this.tickables.get(i).run();
|
|
}
|
|
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
index e5569978a23c5bde673146421963a2ff0905d514..65d74d0021b48e92f8d06ad19a255023abc1a6d4 100644
|
|
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -62,6 +62,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
public @Nullable String playerBrand;
|
|
public final java.util.Set<String> pluginMessagerChannels;
|
|
// Paper end - retain certain values
|
|
+ public final GameProfile profile; // DivineMC - Leaves Protocol Core
|
|
|
|
public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) {
|
|
this.server = server;
|
|
@@ -75,6 +76,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
this.pluginMessagerChannels = cookie.channels();
|
|
this.keepAlive = cookie.keepAlive();
|
|
// Paper end
|
|
+ this.profile = cookie.gameProfile(); // DivineMC - Leaves Protocol Core
|
|
}
|
|
|
|
// Paper start - configuration phase API
|
|
@@ -166,6 +168,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
|
|
@Override
|
|
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
|
+ // DivineMC start - Leaves Protocol Core
|
|
+ if (packet.payload() instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload leavesPayload) {
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this), leavesPayload);
|
|
+ return;
|
|
+ }
|
|
+ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.DiscardedPayload(net.minecraft.resources.ResourceLocation id, byte[] data)) {
|
|
+ if (org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleBytebuf(org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this), id, io.netty.buffer.Unpooled.wrappedBuffer(data))) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // DivineMC end - Leaves Protocol Core
|
|
+
|
|
// Paper start
|
|
if (!(packet.payload() instanceof final net.minecraft.network.protocol.common.custom.DiscardedPayload discardedPayload)) {
|
|
return;
|
|
@@ -231,6 +245,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
final String channel = new String(data, from, length, java.nio.charset.StandardCharsets.US_ASCII);
|
|
if (register) {
|
|
bridge.addChannel(channel);
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this)); // DivineMC - Leaves Protocol Core
|
|
} else {
|
|
bridge.removeChannel(channel);
|
|
}
|
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
|
index 5106bfb8b48d963dca4784db1787123e9475ada0..eab5505b10c1044f864a7327b18f1389fd09765f 100644
|
|
--- a/net/minecraft/server/players/PlayerList.java
|
|
+++ b/net/minecraft/server/players/PlayerList.java
|
|
@@ -251,6 +251,8 @@ public abstract class PlayerList {
|
|
return;
|
|
}
|
|
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // DivineMC - Leaves Protocol Core
|
|
+
|
|
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
|
|
|
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
|
@@ -441,6 +443,7 @@ public abstract class PlayerList {
|
|
return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName())));
|
|
}
|
|
public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) {
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // DivineMC - Leaves Protocol Core
|
|
// Paper end - Fix kick event leave message not being sent
|
|
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
|
|
ServerLevel serverLevel = player.level();
|
|
@@ -1403,6 +1406,7 @@ public abstract class PlayerList {
|
|
serverPlayer.connection.send(clientboundUpdateRecipesPacket);
|
|
serverPlayer.getRecipeBook().sendInitialRecipeBook(serverPlayer);
|
|
}
|
|
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleDataPackReload(); // DivineMC - Leaves Protocol Core
|
|
}
|
|
|
|
public boolean isAllowCommandsForAllPlayers() {
|