Handle multiple connection sides properly.
Dieser Commit ist enthalten in:
Ursprung
79786b8192
Commit
addc62457a
@ -30,8 +30,10 @@ import com.comphenix.protocol.reflect.FieldAccessException;
|
|||||||
import com.comphenix.protocol.reflect.PrettyPrinter;
|
import com.comphenix.protocol.reflect.PrettyPrinter;
|
||||||
import com.comphenix.protocol.utility.ChatExtensions;
|
import com.comphenix.protocol.utility.ChatExtensions;
|
||||||
import com.google.common.collect.DiscreteDomains;
|
import com.google.common.collect.DiscreteDomains;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Range;
|
import com.google.common.collect.Range;
|
||||||
import com.google.common.collect.Ranges;
|
import com.google.common.collect.Ranges;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the "packet" debug command.
|
* Handles the "packet" debug command.
|
||||||
@ -313,18 +315,19 @@ class CommandPacket extends CommandBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<Integer> getValidPackets(ConnectionSide side) throws FieldAccessException {
|
private Set<Integer> getValidPackets(ConnectionSide side) throws FieldAccessException {
|
||||||
|
HashSet<Integer> supported = Sets.newHashSet();
|
||||||
|
|
||||||
if (side.isForClient())
|
if (side.isForClient())
|
||||||
return Packets.Client.getSupported();
|
supported.addAll(Packets.Client.getSupported());
|
||||||
else if (side.isForServer())
|
else if (side.isForServer())
|
||||||
return Packets.Server.getSupported();
|
supported.addAll(Packets.Server.getSupported());
|
||||||
else
|
return supported;
|
||||||
throw new IllegalArgumentException("Illegal side: " + side);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Integer> getNamedPackets(ConnectionSide side) {
|
private Set<Integer> getNamedPackets(ConnectionSide side) {
|
||||||
|
|
||||||
Set<Integer> valids = null;
|
Set<Integer> valids = null;
|
||||||
Set<Integer> result = null;
|
Set<Integer> result = Sets.newHashSet();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
valids = getValidPackets(side);
|
valids = getValidPackets(side);
|
||||||
@ -334,11 +337,9 @@ class CommandPacket extends CommandBase {
|
|||||||
|
|
||||||
// Check connection side
|
// Check connection side
|
||||||
if (side.isForClient())
|
if (side.isForClient())
|
||||||
result = Packets.Client.getRegistry().values();
|
result.addAll(Packets.Client.getRegistry().values());
|
||||||
else if (side.isForServer())
|
if (side.isForServer())
|
||||||
result = Packets.Server.getRegistry().values();
|
result.addAll(Packets.Server.getRegistry().values());
|
||||||
else
|
|
||||||
throw new IllegalArgumentException("Illegal side: " + side);
|
|
||||||
|
|
||||||
// Remove invalid packets
|
// Remove invalid packets
|
||||||
result.retainAll(valids);
|
result.retainAll(valids);
|
||||||
@ -445,11 +446,8 @@ class CommandPacket extends CommandBase {
|
|||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
if (side.isForClient())
|
if (side.isForClient())
|
||||||
clientListeners.put(idStart, idStop, listener);
|
clientListeners.put(idStart, idStop, listener);
|
||||||
else if (side.isForServer())
|
if (side.isForServer())
|
||||||
serverListeners.put(idStart, idStop, listener);
|
serverListeners.put(idStart, idStop, listener);
|
||||||
else
|
|
||||||
throw new IllegalArgumentException("Not a legal connection side.");
|
|
||||||
|
|
||||||
return listener;
|
return listener;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("No packets found in the range " + idStart + " - " + idStop + ".");
|
throw new IllegalArgumentException("No packets found in the range " + idStart + " - " + idStop + ".");
|
||||||
@ -459,13 +457,14 @@ class CommandPacket extends CommandBase {
|
|||||||
public Set<AbstractIntervalTree<Integer, DetailedPacketListener>.Entry> removePacketListeners(
|
public Set<AbstractIntervalTree<Integer, DetailedPacketListener>.Entry> removePacketListeners(
|
||||||
ConnectionSide side, int idStart, int idStop, boolean detailed) {
|
ConnectionSide side, int idStart, int idStop, boolean detailed) {
|
||||||
|
|
||||||
|
HashSet<AbstractIntervalTree<Integer, DetailedPacketListener>.Entry> result = Sets.newHashSet();
|
||||||
|
|
||||||
// The interval tree will automatically remove the listeners for us
|
// The interval tree will automatically remove the listeners for us
|
||||||
if (side.isForClient())
|
if (side.isForClient())
|
||||||
return clientListeners.remove(idStart, idStop);
|
result.addAll(clientListeners.remove(idStart, idStop));
|
||||||
else if (side.isForServer())
|
if (side.isForServer())
|
||||||
return serverListeners.remove(idStart, idStop);
|
result.addAll(serverListeners.remove(idStart, idStop));
|
||||||
else
|
return result;
|
||||||
throw new IllegalArgumentException("Not a legal connection side.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SubCommand parseCommand(String[] args, int index) {
|
private SubCommand parseCommand(String[] args, int index) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren