Archiviert
13
0

Don't attempt to add NULL keys to a ConcurrentHashMap. Fixes #21

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-12-06 23:07:56 +01:00
Ursprung 23ebcb47ab
Commit aa3600a337

Datei anzeigen

@ -6,6 +6,7 @@ import java.util.Set;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.injector.packet.PacketRegistry; import com.comphenix.protocol.injector.packet.PacketRegistry;
import com.google.common.base.Preconditions;
import net.minecraft.util.com.google.common.collect.Maps; import net.minecraft.util.com.google.common.collect.Maps;
@ -32,18 +33,26 @@ public class PacketTypeSet {
* @param type - the type to add. * @param type - the type to add.
*/ */
public synchronized void addType(PacketType type) { public synchronized void addType(PacketType type) {
types.add(type); Class<?> packetClass = getPacketClass(type);
types.add(Preconditions.checkNotNull(type, "type cannot be NULL."));
if (packetClass != null) {
classes.add(getPacketClass(type)); classes.add(getPacketClass(type));
} }
}
/** /**
* Remove a particular type to the set. * Remove a particular type to the set.
* @param type - the type to remove. * @param type - the type to remove.
*/ */
public synchronized void removeType(PacketType type) { public synchronized void removeType(PacketType type) {
types.remove(type); Class<?> packetClass = getPacketClass(type);
types.remove(Preconditions.checkNotNull(type, "type cannot be NULL."));
if (packetClass != null) {
classes.remove(getPacketClass(type)); classes.remove(getPacketClass(type));
} }
}
/** /**
* Retrieve the packet class associated with a particular type. * Retrieve the packet class associated with a particular type.