mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 21:26:17 +01:00
Renamed the ListenerToken in the code as well.
This commit is contained in:
parent
880520cd94
commit
025e97ca95
@ -44,15 +44,15 @@ public class AsyncFilterManager {
|
||||
}
|
||||
|
||||
public AsyncListenerHandler registerAsyncHandler(Plugin plugin, PacketListener listener) {
|
||||
AsyncListenerHandler token = new AsyncListenerHandler(plugin, mainThread, this, listener);
|
||||
AsyncListenerHandler handler = new AsyncListenerHandler(plugin, mainThread, this, listener);
|
||||
|
||||
// Add listener to either or both processing queue
|
||||
if (hasValidWhitelist(listener.getSendingWhitelist()))
|
||||
serverProcessingQueue.addListener(token, listener.getSendingWhitelist());
|
||||
serverProcessingQueue.addListener(handler, listener.getSendingWhitelist());
|
||||
if (hasValidWhitelist(listener.getReceivingWhitelist()))
|
||||
clientProcessingQueue.addListener(token, listener.getReceivingWhitelist());
|
||||
clientProcessingQueue.addListener(handler, listener.getReceivingWhitelist());
|
||||
|
||||
return token;
|
||||
return handler;
|
||||
}
|
||||
|
||||
private boolean hasValidWhitelist(ListeningWhitelist whitelist) {
|
||||
@ -61,25 +61,25 @@ public class AsyncFilterManager {
|
||||
|
||||
/**
|
||||
* Unregisters and closes the given asynchronous handler.
|
||||
* @param listenerToken - asynchronous handler.
|
||||
* @param handler - asynchronous handler.
|
||||
*/
|
||||
public void unregisterAsyncHandler(AsyncListenerHandler listenerToken) {
|
||||
if (listenerToken == null)
|
||||
public void unregisterAsyncHandler(AsyncListenerHandler handler) {
|
||||
if (handler == null)
|
||||
throw new IllegalArgumentException("listenerToken cannot be NULL");
|
||||
|
||||
listenerToken.cancel();
|
||||
handler.cancel();
|
||||
}
|
||||
|
||||
// Called by ListenerToken
|
||||
void unregisterAsyncHandlerInternal(AsyncListenerHandler listenerToken) {
|
||||
// Called by AsyncListenerHandler
|
||||
void unregisterAsyncHandlerInternal(AsyncListenerHandler handler) {
|
||||
|
||||
PacketListener listener = listenerToken.getAsyncListener();
|
||||
PacketListener listener = handler.getAsyncListener();
|
||||
|
||||
// Just remove it from the queue(s)
|
||||
if (hasValidWhitelist(listener.getSendingWhitelist()))
|
||||
serverProcessingQueue.removeListener(listenerToken, listener.getSendingWhitelist());
|
||||
serverProcessingQueue.removeListener(handler, listener.getSendingWhitelist());
|
||||
if (hasValidWhitelist(listener.getReceivingWhitelist()))
|
||||
clientProcessingQueue.removeListener(listenerToken, listener.getReceivingWhitelist());
|
||||
clientProcessingQueue.removeListener(handler, listener.getReceivingWhitelist());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,10 +122,10 @@ public class AsyncListenerHandler {
|
||||
|
||||
// Now, get the next non-cancelled listener
|
||||
for (; marker.getListenerTraversal().hasNext(); ) {
|
||||
AsyncListenerHandler token = marker.getListenerTraversal().next().getListener();
|
||||
AsyncListenerHandler handler = marker.getListenerTraversal().next().getListener();
|
||||
|
||||
if (!token.isCancelled()) {
|
||||
token.enqueuePacket(packet);
|
||||
if (!handler.isCancelled()) {
|
||||
handler.enqueuePacket(packet);
|
||||
continue mainLoop;
|
||||
}
|
||||
}
|
||||
|
@ -117,9 +117,9 @@ class PacketProcessingQueue extends AbstractConcurrentListenerMultimap<AsyncList
|
||||
|
||||
public void cleanupAll() {
|
||||
// Cancel all the threads and every listener
|
||||
for (PrioritizedListener<AsyncListenerHandler> token : values()) {
|
||||
if (token != null) {
|
||||
token.getListener().cancel();
|
||||
for (PrioritizedListener<AsyncListenerHandler> handler : values()) {
|
||||
if (handler != null) {
|
||||
handler.getListener().cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user