Archiviert
13
0

Add the ability to see registered asynchronous listeners.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2014-03-13 23:55:33 +01:00
Ursprung f4f8817fd5
Commit 75a5efcaa1
4 geänderte Dateien mit 29 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -136,8 +136,14 @@ public interface AsynchronousManager {
public abstract void unregisterTimeoutHandler(PacketListener listener);
/**
* Get a immutable list of every registered timeout handler.
* @return List of every registered timeout handler.
* Get a immutable set of every registered timeout handler.
* @return Set of every registered timeout handler.
*/
public abstract Set<PacketListener> getTimeoutHandlers();
/**
* Get an immutable set of every registered asynchronous packet listener.
* @return Set of every asynchronous packet listener.
*/
public abstract Set<PacketListener> getAsyncHandlers();
}

Datei anzeigen

@ -82,10 +82,17 @@ class CommandProtocol extends CommandBase {
// Display every listener on the server
private void printListeners(final CommandSender sender, String[] args) {
for (PacketListener listener : ProtocolLibrary.getProtocolManager().getPacketListeners()) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
for (PacketListener listener : manager.getPacketListeners()) {
sender.sendMessage(ChatColor.GOLD + "Packet listeners:");
sender.sendMessage(ChatColor.GOLD + " " + listener);
}
// Along with every asynchronous listener
for (PacketListener listener : manager.getAsynchronousManager().getAsyncHandlers()) {
sender.sendMessage(ChatColor.GOLD + "Asynchronous listeners:");
sender.sendMessage(ChatColor.GOLD + " " + listener);
}
}
private void performUpdate(final CommandSender sender, UpdateType type) {

Datei anzeigen

@ -7,8 +7,6 @@ import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.PacketType.Sender;
import com.comphenix.protocol.collections.IntegerMap;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

Datei anzeigen

@ -41,6 +41,7 @@ import com.comphenix.protocol.injector.SortedPacketListenerList;
import com.comphenix.protocol.injector.packet.PacketRegistry;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
/**
@ -142,6 +143,18 @@ public class AsyncFilterManager implements AsynchronousManager {
return ImmutableSet.copyOf(timeoutListeners);
}
@Override
public Set<PacketListener> getAsyncHandlers() {
ImmutableSet.Builder<PacketListener> builder = ImmutableSet.builder();
// Add every asynchronous packet listener
for (PrioritizedListener<AsyncListenerHandler> handler :
Iterables.concat(serverProcessingQueue.values(), clientProcessingQueue.values())) {
builder.add(handler.getListener().getAsyncListener());
}
return builder.build();
}
/**
* Registers an asynchronous packet handler.
* <p>