aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorConnor Linfoot <connorlinfoot@me.com>2024-06-16 20:30:59 +0100
committerConnor Linfoot <connorlinfoot@me.com>2024-06-16 20:30:59 +0100
commit8985789d26a492efad92f39c5ee8d79198666ceb (patch)
tree9cfc906ef32cc85d78ff057c688c5eed63fd2229 /src/main/java
parent2a9e941ca938a9704c77ed63cd1a01de3ae5f657 (diff)
downloadHyPixelForgeModAPI-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.java6
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();
}
});
}