diff --git a/ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java b/ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java index 87c09e26..0859738c 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java +++ b/ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java @@ -9,9 +9,11 @@ import java.util.logging.Level; import org.bukkit.plugin.Plugin; +import com.comphenix.protocol.events.ListeningWhitelist; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketListener; +import com.google.common.base.Joiner; /** * Represents a handler for an asynchronous event. @@ -206,7 +208,47 @@ public class AsyncListenerHandler { if (cancelled) throw new IllegalStateException("Cannot start a worker when the listener is closing."); - filterManager.scheduleAsyncTask(listener.getPlugin(), getListenerLoop()); + final AsyncRunnable listenerLoop = getListenerLoop(); + + filterManager.scheduleAsyncTask(listener.getPlugin(), new Runnable() { + @Override + public void run() { + String workerName = getFriendlyWorkerName(listenerLoop.getID()); + + // Add the friendly worker name + Thread.currentThread().setName(workerName); + listenerLoop.run(); + } + }); + } + + /** + * Create a friendly thread name using the following convention: + *
+ * Protocol Worker {id} - {plugin} - [recv: {packets}, send: {packets}]
+ *