From c28c677309eb0fa337d94e69f694d2cf6b287ff2 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Mon, 2 Aug 2021 16:11:19 +0800 Subject: [PATCH] Use sync packet adapter, but it still fast enough --- .../org/maxgamer/quickshop/shop/ContainerShop.java | 1 + .../maxgamer/quickshop/shop/VirtualDisplayItem.java | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java index d2641a539..b9bdd12b6 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java @@ -1446,6 +1446,7 @@ public class ContainerShop implements Shop { setExtra(plugin, section); setDirty(); this.update(); + } @Override diff --git a/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java b/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java index c2220239b..239dba04a 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java +++ b/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java @@ -21,7 +21,6 @@ package org.maxgamer.quickshop.shop; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.async.AsyncListenerHandler; import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; @@ -85,7 +84,6 @@ public class VirtualDisplayItem extends DisplayItem { //cache chunk x and z private volatile ShopChunk chunkLocation; - private AsyncListenerHandler asyncListenerHandler; public VirtualDisplayItem(@NotNull Shop shop) throws RuntimeException { @@ -258,18 +256,13 @@ public class VirtualDisplayItem extends DisplayItem { } }; } - asyncListenerHandler = protocolManager.getAsynchronousManager().registerAsyncHandler(packetAdapter); - asyncListenerHandler.start(); + protocolManager.addPacketListener(packetAdapter); } private void unload() { packetSenders.clear(); if (packetAdapter != null) { - asyncListenerHandler.stop(); - protocolManager.getAsynchronousManager().unregisterAsyncHandler(asyncListenerHandler); - //protocolManager.removePacketListener(packetAdapter); - //Prevent memory leak - asyncListenerHandler = null; + protocolManager.removePacketListener(packetAdapter); packetAdapter = null; } }