mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-28 03:19:21 +00:00
Cleanup ChatImage protocol support & Further reduce worldgen allocation (#131)
* Cleanup protocol comment & Reduce worldgen allocations * Cleanup protocol
This commit is contained in:
@@ -190,18 +190,10 @@ index ed8d9888a24d3ae6cf8fe2f8b269554102e451df..1bdd77078c7345db1a675fbdc26b37e9
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/protocol/ChatImageProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/ChatImageProtocol.java
|
||||
index 87ffe8a81a8bab7d20ff9551b105487d47616ee1..b026b9fefd85d16b0294738034bfae1220d47eac 100644
|
||||
index 25f893aad5c7fa289f484355635f528cb2e17459..1cc499393256e4eaaf2333076201fb702606462d 100644
|
||||
--- a/src/main/java/org/leavesmc/leaves/protocol/ChatImageProtocol.java
|
||||
+++ b/src/main/java/org/leavesmc/leaves/protocol/ChatImageProtocol.java
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
-import org.dreeam.leaf.config.modules.network.ProtocolSupport;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.protocol.chatimage.ChatImageIndex;
|
||||
@@ -30,7 +29,12 @@ public class ChatImageProtocol {
|
||||
@@ -30,7 +30,12 @@ public class ChatImageProtocol {
|
||||
public static int MAX_STRING = 532767;
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
@@ -215,42 +207,6 @@ index 87ffe8a81a8bab7d20ff9551b105487d47616ee1..b026b9fefd85d16b0294738034bfae12
|
||||
private static final ResourceLocation FILE_INFO = ChatImageProtocol.id("file_info");
|
||||
|
||||
@New
|
||||
@@ -49,7 +53,8 @@ public class ChatImageProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
- public record DownloadFileChannelPacket(String message) implements LeavesCustomPayload<LeavesProtocolManager.LeavesPayload> {
|
||||
+ public record DownloadFileChannelPacket(
|
||||
+ String message) implements LeavesCustomPayload<LeavesProtocolManager.LeavesPayload> {
|
||||
/**
|
||||
* 发送文件分块到客户端通道(Map)
|
||||
*/
|
||||
@@ -72,7 +77,8 @@ public class ChatImageProtocol {
|
||||
|
||||
}
|
||||
|
||||
- public record FileChannelPacket(String message) implements LeavesCustomPayload<LeavesProtocolManager.LeavesPayload> {
|
||||
+ public record FileChannelPacket(
|
||||
+ String message) implements LeavesCustomPayload<LeavesProtocolManager.LeavesPayload> {
|
||||
/**
|
||||
* 客户端发送文件分块到服务器通道(Map)
|
||||
*/
|
||||
@@ -97,7 +103,6 @@ public class ChatImageProtocol {
|
||||
|
||||
@ProtocolHandler.PayloadReceiver(payload = FileChannelPacket.class, payloadId = "file_channel")
|
||||
public static void serverFileChannelReceived(ServerPlayer player, String res) {
|
||||
- if (!ProtocolSupport.chatImageProtocol) return;
|
||||
ChatImageIndex title = gson.fromJson(res, ChatImageIndex.class);
|
||||
HashMap<Integer, String> blocks = SERVER_BLOCK_CACHE.containsKey(title.url) ? SERVER_BLOCK_CACHE.get(title.url) : new HashMap<>();
|
||||
blocks.put(title.index, res);
|
||||
@@ -123,7 +128,6 @@ public class ChatImageProtocol {
|
||||
|
||||
@ProtocolHandler.PayloadReceiver(payload = FileInfoChannelPacket.class, payloadId = "file_info")
|
||||
public static void serverFileInfoChannelReceived(ServerPlayer player, String url) {
|
||||
- if (!ProtocolSupport.chatImageProtocol) return;
|
||||
if (SERVER_BLOCK_CACHE.containsKey(url) && FILE_COUNT_MAP.containsKey(url)) {
|
||||
HashMap<Integer, String> list = SERVER_BLOCK_CACHE.get(url);
|
||||
Integer total = FILE_COUNT_MAP.get(url);
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java
|
||||
index 9e35dfaf8bb5511b4cd0a71175d7ecb6d835042f..5ef19098512ae8a070dea270a68c27695c34624b 100644
|
||||
--- a/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java
|
||||
|
||||
Reference in New Issue
Block a user