From 37d57af6ecd1dedae3b3efac42c3ce97b08b1a4f Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 6 Feb 2021 15:26:21 +0000 Subject: [PATCH 1/3] Change ResourceLeakDetector to PARANOID for displayleaks --- .../ViaVersion/commands/defaultsubs/DisplayLeaksSubCmd.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DisplayLeaksSubCmd.java b/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DisplayLeaksSubCmd.java index 5710105db..244697ee3 100644 --- a/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DisplayLeaksSubCmd.java +++ b/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DisplayLeaksSubCmd.java @@ -17,12 +17,12 @@ public class DisplayLeaksSubCmd extends ViaSubCommand { @Override public boolean execute(ViaCommandSender sender, String[] args) { - if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED) - ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED); + if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.PARANOID) + ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID); else ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); - sendMessage(sender, "&6Leak detector is now %s", (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled")); + sendMessage(sender, "&6Leak detector is now %s", (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.PARANOID ? "&aenabled" : "&cdisabled")); return true; } } From ac877d0b1a1541c8447789ab237f616d1bcd8abf Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 6 Feb 2021 15:29:36 +0000 Subject: [PATCH 2/3] The bytebuf doesn't need to be rewritten --- .../bukkit/handlers/BukkitDecodeHandler.java | 28 +++++++------------ .../sponge/handlers/SpongeDecodeHandler.java | 28 +++++++------------ 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java index 3930581f9..2650e5f77 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java @@ -31,25 +31,17 @@ public class BukkitDecodeHandler extends ByteToMessageDecoder { throw CancelDecoderException.generate(null); } - ByteBuf transformedBuf = null; - try { - if (info.shouldTransformPacket()) { - transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - info.transformIncoming(transformedBuf, CancelDecoderException::generate); - } + if (info.shouldTransformPacket()) { + info.transformIncoming(bytebuf, CancelDecoderException::generate); + } - try { - list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, transformedBuf == null ? bytebuf : transformedBuf)); - } catch (InvocationTargetException e) { - if (e.getCause() instanceof Exception) { - throw (Exception) e.getCause(); - } else if (e.getCause() instanceof Error) { - throw (Error) e.getCause(); - } - } - } finally { - if (transformedBuf != null) { - transformedBuf.release(); + try { + list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, bytebuf)); + } catch (InvocationTargetException e) { + if (e.getCause() instanceof Exception) { + throw (Exception) e.getCause(); + } else if (e.getCause() instanceof Error) { + throw (Error) e.getCause(); } } } diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java index 975a62896..387954b46 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java @@ -28,25 +28,17 @@ public class SpongeDecodeHandler extends ByteToMessageDecoder { throw CancelDecoderException.generate(null); } - ByteBuf transformedBuf = null; - try { - if (info.shouldTransformPacket()) { - transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - info.transformIncoming(transformedBuf, CancelDecoderException::generate); - } + if (info.shouldTransformPacket()) { + info.transformIncoming(bytebuf, CancelDecoderException::generate); + } - try { - list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, transformedBuf == null ? bytebuf : transformedBuf)); - } catch (InvocationTargetException e) { - if (e.getCause() instanceof Exception) { - throw (Exception) e.getCause(); - } else if (e.getCause() instanceof Error) { - throw (Error) e.getCause(); - } - } - } finally { - if (transformedBuf != null) { - transformedBuf.release(); + try { + list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, bytebuf)); + } catch (InvocationTargetException e) { + if (e.getCause() instanceof Exception) { + throw (Exception) e.getCause(); + } else if (e.getCause() instanceof Error) { + throw (Error) e.getCause(); } } } From 727c575a1cc27013b80813b49ca801d9ad282fd6 Mon Sep 17 00:00:00 2001 From: Myles Date: Tue, 9 Feb 2021 10:35:13 +0000 Subject: [PATCH 3/3] Run QuickMove on next tick to improve likeliness of success (fixes #2044) Since it is 5 ticks later, the inventory may be closed --- .../bukkit/providers/BukkitInventoryQuickMoveProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java index 9422aca8a..f1f0adc7a 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java @@ -74,7 +74,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider // http://wiki.vg/index.php?title=Protocol&oldid=13223#Click_Window updateTask.addItem(windowId, slotId, actionId); if (!registered) { - Via.getPlatform().runSync(updateTask, 5L); + Via.getPlatform().runSync(updateTask); } return true; }