diff options
author | Connor Linfoot <connorlinfoot@me.com> | 2024-06-16 20:30:59 +0100 |
---|---|---|
committer | Connor Linfoot <connorlinfoot@me.com> | 2024-06-16 20:30:59 +0100 |
commit | 8985789d26a492efad92f39c5ee8d79198666ceb (patch) | |
tree | 9cfc906ef32cc85d78ff057c688c5eed63fd2229 /src/main/java | |
parent | 2a9e941ca938a9704c77ed63cd1a01de3ae5f657 (diff) | |
download | HyPixelForgeModAPI-8985789d26a492efad92f39c5ee8d79198666ceb.tar.gz HyPixelForgeModAPI-8985789d26a492efad92f39c5ee8d79198666ceb.tar.bz2 HyPixelForgeModAPI-8985789d26a492efad92f39c5ee8d79198666ceb.zip |
fix: retain buffer for scheduled packet handling
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java | 6 |
1 files changed, 5 insertions, 1 deletions
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(); } }); } |