From 8985789d26a492efad92f39c5ee8d79198666ceb Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 16 Jun 2024 20:30:59 +0100 Subject: fix: retain buffer for scheduled packet handling --- src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java b/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java index 12ce3ef..9b8777c 100644 --- a/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java +++ b/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java @@ -87,11 +87,15 @@ public class ForgeModAPI { return; } + PacketBuffer buffer = packet.getBufferData(); + buffer.retain(); Minecraft.getMinecraft().addScheduledTask(() -> { try { - HypixelModAPI.getInstance().handle(identifier, new PacketSerializer(packet.getBufferData())); + HypixelModAPI.getInstance().handle(identifier, new PacketSerializer(buffer)); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to handle packet " + identifier, e); + } finally { + buffer.release(); } }); } -- cgit