mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Don't release buffer after single use.
This commit is contained in:
parent
0d1036693c
commit
544e47c9e7
1 changed files with 3 additions and 7 deletions
|
@ -21,12 +21,10 @@ public class ByteBufHelper {
|
|||
public static final ByteBufNetInput in = new ByteBufNetInput(buffer);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T writeAndRead(Packet writable){
|
||||
if(buffer.isReadable()) {
|
||||
buffer.release();
|
||||
}
|
||||
|
||||
public static <T> T writeAndRead(Packet writable) {
|
||||
try {
|
||||
buffer.clear();
|
||||
|
||||
writable.write(out);
|
||||
|
||||
// Creating new fresh packet to reset fields.
|
||||
|
@ -41,8 +39,6 @@ public class ByteBufHelper {
|
|||
return (T) readable;
|
||||
} catch(Exception e) {
|
||||
throw new IllegalStateException("Failed parse packet", e);
|
||||
} finally {
|
||||
buffer.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue